Merge remote-tracking branch 'origin/master' into SmartSpell

This commit is contained in:
hondacrx
2017-07-24 14:06:50 -04:00
18 changed files with 56 additions and 77 deletions
+1 -3
View File
@@ -285,9 +285,7 @@ namespace System
public static string ConvertFormatSyntax(this string str)
{
// @"%(\d+(\.\d+)?)?(d|f|s|u|i|llX|X|ll)"; old working
//@"%(\d+(\.\d+)?)?(-\d+[a-z]|[[a-z])"; working somewhat
string pattern = @"(%\W*\d*[a-zA-Z]*)"; //Working fully????
string pattern = @"(%\W*\d*[a-zA-Z]*)";
int count = 0;
string result = Regex.Replace(str, pattern, m =>
+5 -2
View File
@@ -95,7 +95,7 @@ namespace Game.AI
mDespawnState++;
}
else
me.DespawnOrUnsummon();
me.DespawnOrUnsummon(0, TimeSpan.FromSeconds(mRespawnTime));
}
else
mDespawnTime -= diff;
@@ -549,6 +549,7 @@ namespace Game.AI
public override void JustRespawned()
{
mDespawnTime = 0;
mRespawnTime = 0;
mDespawnState = 0;
mEscortState = SmartEscortState.None;
me.SetVisible(true);
@@ -907,9 +908,10 @@ namespace Game.AI
public void SetInvincibilityHpLevel(uint level) { mInvincibilityHpLevel = level; }
public void SetDespawnTime(uint t)
public void SetDespawnTime(uint t, uint r = 0)
{
mDespawnTime = t;
mRespawnTime = r;
mDespawnState = (uint)(t != 0 ? 1 : 0);
}
@@ -945,6 +947,7 @@ namespace Game.AI
uint mInvincibilityHpLevel;
uint mDespawnTime;
uint mRespawnTime;
uint mDespawnState;
public uint mEscortQuestID;
+1
View File
@@ -2373,6 +2373,7 @@ namespace Game.AI
public struct ForceDespawn
{
public uint delay;
public uint respawn;
}
public struct InvincHP
{
+2 -2
View File
@@ -1073,11 +1073,11 @@ namespace Game.AI
Creature target = obj.ToCreature();
if (target.IsAlive() && IsSmart(target))
{
((SmartAI)target.GetAI()).SetDespawnTime(e.Action.forceDespawn.delay + 1); // Next tick
((SmartAI)target.GetAI()).SetDespawnTime(e.Action.forceDespawn.delay + 1, e.Action.forceDespawn.respawn); // Next tick
((SmartAI)target.GetAI()).StartDespawn();
}
else
target.DespawnOrUnsummon(e.Action.forceDespawn.delay);
target.DespawnOrUnsummon(e.Action.forceDespawn.delay, TimeSpan.FromSeconds(e.Action.forceDespawn.respawn));
}
else if (obj.IsTypeId(TypeId.GameObject))
{
+2 -2
View File
@@ -494,8 +494,8 @@ namespace Game.Chat
handler.HasLowerSecurityAccount(null, accountId, true))
return false;
int expansion = int.Parse(exp); //get int anyway (0 if error)
if (expansion < 0 || expansion > WorldConfig.GetIntValue(WorldCfg.Expansion))
byte expansion = byte.Parse(exp); //get int anyway (0 if error)
if (expansion > WorldConfig.GetIntValue(WorldCfg.Expansion))
return false;
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_EXPANSION);
+3 -1
View File
@@ -55,9 +55,11 @@ namespace Game.Chat
string activeStr = target.GetUInt32Value(PlayerFields.ChosenTitle) == titleInfo.MaskID
? handler.GetCypherString(CypherStrings.Active) : "";
string titleNameStr = string.Format(name.ConvertFormatSyntax(), targetName);
// send title in "id (idx:idx) - [namedlink locale]" format
if (handler.GetSession() != null)
handler.SendSysMessage(CypherStrings.TitleListChat, titleInfo.Id, titleInfo.MaskID, titleInfo.Id, name, loc, knownStr, activeStr);
handler.SendSysMessage(CypherStrings.TitleListChat, titleInfo.Id, titleInfo.MaskID, titleInfo.Id, titleNameStr, loc, knownStr, activeStr);
else
handler.SendSysMessage(CypherStrings.TitleListConsole, titleInfo.Id, titleInfo.MaskID, name, loc, knownStr, activeStr);
}
+3 -3
View File
@@ -607,10 +607,10 @@ namespace Game.Chat
return false;
}
int currentValue = (int)handler.GetSession().GetPlayer().GetUInt32Value(opcode);
uint currentValue = handler.GetSession().GetPlayer().GetUInt32Value(opcode);
currentValue += value;
handler.GetSession().GetPlayer().SetUInt32Value(opcode, (uint)currentValue);
currentValue += (uint)value;
handler.GetSession().GetPlayer().SetUInt32Value(opcode, currentValue);
handler.SendSysMessage(CypherStrings.Change32bitField, opcode, currentValue);
+1 -1
View File
@@ -829,7 +829,7 @@ namespace Game.Chat
string activeStr = target && target.GetUInt32Value(PlayerFields.ChosenTitle) == titleInfo.MaskID
? handler.GetCypherString(CypherStrings.Active) : "";
string titleNameStr = name + targetName;
string titleNameStr = string.Format(name.ConvertFormatSyntax(), targetName);
// send title in "id (idx:idx) - [namedlink locale]" format
if (handler.GetSession() != null)
+1 -4
View File
@@ -110,11 +110,8 @@ namespace Game.Chat
}
[Command("faction", RBACPermissions.CommandModifyFaction)]
static bool Faction(StringArguments args, CommandHandler handler)
static bool HandleModifyFactionCommand(StringArguments args, CommandHandler handler)
{
if (args.Empty())
return false;
string pfactionid = handler.extractKeyFromLink(args, "Hfaction");
Creature target = handler.getSelectedCreature();
+10 -19
View File
@@ -957,7 +957,7 @@ namespace Game.Chat
if (args.Empty())
return false;
uint phaseGroupId = args.NextUInt32();
int phaseGroupId = args.NextInt32();
Creature creature = handler.getSelectedCreature();
if (!creature || creature.IsPet())
@@ -968,11 +968,11 @@ namespace Game.Chat
creature.ClearPhases();
foreach (uint id in Global.DB2Mgr.GetPhasesForGroup(phaseGroupId))
foreach (uint id in Global.DB2Mgr.GetPhasesForGroup((uint)phaseGroupId))
creature.SetInPhase(id, false, true); // don't send update here for multiple phases, only send it once after adding all phases
creature.UpdateObjectVisibility();
creature.SetDBPhase(-(int)phaseGroupId);
creature.SetDBPhase(-phaseGroupId);
creature.SaveToDB();
@@ -1030,28 +1030,20 @@ namespace Game.Chat
if (args.Empty())
return false;
int spawnTime = args.NextInt32();
if (spawnTime < 0)
{
handler.SendSysMessage(CypherStrings.BadValue);
return false;
}
uint spawnTime = args.NextUInt32();
Creature creature = handler.getSelectedCreature();
ulong guidLow = 0;
if (creature)
guidLow = creature.GetSpawnId();
else
if (!creature)
return false;
ulong guidLow = creature.GetSpawnId();
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_SPAWN_TIME_SECS);
stmt.AddValue(0, spawnTime);
stmt.AddValue(1, guidLow);
DB.World.Execute(stmt);
creature.SetRespawnDelay((uint)spawnTime);
creature.SetRespawnDelay(spawnTime);
handler.SendSysMessage(CypherStrings.CommandSpawntime, spawnTime);
return true;
@@ -1167,11 +1159,10 @@ namespace Game.Chat
return false;
}
int item_int = int.Parse(pitem);
if (item_int <= 0)
uint itemId = uint.Parse(pitem);
if (itemId == 0)
return false;
uint itemId = (uint)item_int;
uint maxcount = args.NextUInt32();
uint incrtime = args.NextUInt32();
uint extendedcost = args.NextUInt32();
+5 -5
View File
@@ -152,14 +152,14 @@ namespace Game.Chat
string maxPureSkill = args.NextString();
int skill = int.Parse(skillStr);
if (skill <= 0)
uint skill = uint.Parse(skillStr);
if (skill == 0)
{
handler.SendSysMessage(CypherStrings.InvalidSkillId, skill);
return false;
}
int level = int.Parse(levelStr);
uint level = uint.Parse(levelStr);
Player target = handler.getSelectedPlayerOrSelf();
if (!target)
{
@@ -180,13 +180,13 @@ namespace Game.Chat
// the max level of the new profession.
ushort max = !string.IsNullOrEmpty(maxPureSkill) ? ushort.Parse(maxPureSkill) : targetHasSkill ? target.GetPureMaxSkillValue((SkillType)skill) : (ushort)level;
if (level <= 0 || level > max || max <= 0)
if (level == 0 || level > max || max <= 0)
return false;
// If the player has the skill, we get the current skill step. If they don't have the skill, we
// add the skill to the player's book with step 1 (which is the first rank, in most cases something
// like 'Apprentice <skill>'.
target.SetSkill((SkillType)skill, (uint)(targetHasSkill ? target.GetSkillStep((SkillType)skill) : 1), (uint)level, max);
target.SetSkill((SkillType)skill, (uint)(targetHasSkill ? target.GetSkillStep((SkillType)skill) : 1), level, max);
handler.SendSysMessage(CypherStrings.SetSkill, skill, skillLine.DisplayName[handler.GetSessionDbcLocale()], handler.GetNameLink(target), level, max);
return true;
}
+1 -1
View File
@@ -278,7 +278,7 @@ namespace Game.Chat.Commands
Player player = handler.GetSession() != null ? handler.GetSession().GetPlayer() : null;
if (player && ticket.IsAssignedNotTo(player.GetGUID()))
{
handler.SendSysMessage(CypherStrings.CommandTicketalreadyassigned, ticket.GetId(), target);
handler.SendSysMessage(CypherStrings.CommandTicketalreadyassigned, ticket.GetId());
return true;
}
+9 -8
View File
@@ -20,6 +20,7 @@ using Framework.IO;
using Game.DataStorage;
using Game.Entities;
using System.Collections.Generic;
using System;
namespace Game.Chat.Commands
{
@@ -34,8 +35,8 @@ namespace Game.Chat.Commands
if (string.IsNullOrEmpty(id_p))
return false;
int id = int.Parse(id_p);
if (id <= 0)
uint id = uint.Parse(id_p);
if (id == 0)
{
handler.SendSysMessage(CypherStrings.InvalidTitleId, id);
return false;
@@ -76,8 +77,8 @@ namespace Game.Chat.Commands
if (string.IsNullOrEmpty(id_p))
return false;
int id = int.Parse(id_p);
if (id <= 0)
uint id = uint.Parse(id_p);
if (id == 0)
{
handler.SendSysMessage(CypherStrings.InvalidTitleId, id);
return false;
@@ -103,7 +104,7 @@ namespace Game.Chat.Commands
string tNameLink = handler.GetNameLink(target);
string titleNameStr = (target.GetGender() == Gender.Male ? titleInfo.NameMale : titleInfo.NameFemale)[handler.GetSessionDbcLocale()] + target.GetName();
string titleNameStr = string.Format((target.GetGender() == Gender.Male ? titleInfo.NameMale : titleInfo.NameFemale)[handler.GetSessionDbcLocale()].ConvertFormatSyntax(), target.GetName());
target.SetTitle(titleInfo);
handler.SendSysMessage(CypherStrings.TitleAddRes, id, titleNameStr, tNameLink);
@@ -119,8 +120,8 @@ namespace Game.Chat.Commands
if (string.IsNullOrEmpty(id_p))
return false;
int id = int.Parse(id_p);
if (id <= 0)
uint id = uint.Parse(id_p);
if (id == 0)
{
handler.SendSysMessage(CypherStrings.InvalidTitleId, id);
return false;
@@ -148,7 +149,7 @@ namespace Game.Chat.Commands
string tNameLink = handler.GetNameLink(target);
string titleNameStr = (target.GetGender() == Gender.Male ? titleInfo.NameMale : titleInfo.NameFemale)[handler.GetSessionDbcLocale()] + target.GetName();
string titleNameStr = string.Format((target.GetGender() == Gender.Male ? titleInfo.NameMale : titleInfo.NameFemale)[handler.GetSessionDbcLocale()].ConvertFormatSyntax(), target.GetName());
handler.SendSysMessage(CypherStrings.TitleRemoveRes, id, titleNameStr, tNameLink);
+3 -3
View File
@@ -227,7 +227,7 @@ namespace Game.Chat.Commands
if (id == 0)
{
handler.SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r");
handler.SendSysMessage("|cffff33ffERROR: No valid waypoint script id not present.|r");
return true;
}
@@ -256,7 +256,7 @@ namespace Game.Chat.Commands
if (arg_string == "setid")
{
uint newid = uint.Parse(arg_3);
handler.SendSysMessage("|cff00ff00Wp Event: Wypoint scipt guid: {0}|r|cff00ffff id changed: |r|cff00ff00{1}|r", newid, id);
handler.SendSysMessage("|cff00ff00Wp Event: Waypoint script guid: {0}|r|cff00ffff id changed: |r|cff00ff00{1}|r", newid, id);
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_ID);
stmt.AddValue(0, newid);
@@ -774,7 +774,7 @@ namespace Game.Chat.Commands
if (show == "first")
{
handler.SendSysMessage("|cff00ff00DEBUG: wp first, GUID: {0}|r", pathid);
handler.SendSysMessage("|cff00ff00DEBUG: wp first, pathid: {0}|r", pathid);
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_FIRST_BY_ID);
stmt.AddValue(0, pathid);
+5 -5
View File
@@ -499,14 +499,14 @@ namespace Game.Entities
UpdatePolygonOrientation();
}
bool UnitFitToActionRequirement(Unit unit, Unit caster, AreaTriggerActionUserTypes targetType)
bool UnitFitToActionRequirement(Unit unit, Unit caster, AreaTriggerAction action)
{
switch (targetType)
switch (action.TargetType)
{
case AreaTriggerActionUserTypes.Friend:
return caster.IsFriendlyTo(unit);
return caster._IsValidAssistTarget(unit, Global.SpellMgr.GetSpellInfo(action.Param));
case AreaTriggerActionUserTypes.Enemy:
return !caster.IsFriendlyTo(unit);
return caster._IsValidAttackTarget(unit, Global.SpellMgr.GetSpellInfo(action.Param));
case AreaTriggerActionUserTypes.Raid:
return caster.IsInRaidWith(unit);
case AreaTriggerActionUserTypes.Party:
@@ -528,7 +528,7 @@ namespace Game.Entities
{
foreach (AreaTriggerAction action in GetTemplate().Actions)
{
if (UnitFitToActionRequirement(unit, caster, action.TargetType))
if (UnitFitToActionRequirement(unit, caster, action))
{
switch (action.ActionType)
{
+1 -1
View File
@@ -229,7 +229,7 @@ namespace Game.Maps
instResetTime[instance] = Tuple.Create(pair.Item1, resettime);
}
}
while (result.NextRow());
while (result2.NextRow());
}
// schedule the reset times
+2 -2
View File
@@ -50,7 +50,7 @@ namespace Game.Scripting
InstanceMap instance = obj.GetMap().ToInstanceMap();
if (instance != null && instance.GetInstanceScript() != null)
if (instance.GetScriptName() == scriptName)
return (T)Activator.CreateInstance(typeof(T), new object[] { obj });
return (T)Activator.CreateInstance(typeof(T), obj);
return null;
}
@@ -305,7 +305,7 @@ namespace Game.Scripting
if (me.GetInstanceScript() != null)
return GetInstanceAI<AI>(me);
else
return (AI)Activator.CreateInstance(typeof(AI), me, _args);
return (AI)Activator.CreateInstance(typeof(AI), new object[] { me }.Combine(_args));
}
object[] _args;
-14
View File
@@ -2741,10 +2741,6 @@ namespace Game.Entities
case 59372: // Energize Cores
spellInfo.GetEffect(0).TargetA = new SpellImplicitTargetInfo(Targets.UnitSrcAreaEnemy);
break;
case 63320: // Glyph of Life Tap
// Entries were not updated after spell effect change, we have to do that manually :/
spellInfo.AttributesEx3 |= SpellAttr3.CanProcWithTriggered;
break;
case 5308: // Execute
spellInfo.AttributesEx3 |= SpellAttr3.CantTriggerProc;
break;
@@ -2834,18 +2830,12 @@ namespace Game.Entities
case 34477: // Misdirection
case 48108: // Hot Streak
case 51124: // Killing Machine
case 57761: // Fireball!
case 64823: // Item - Druid T8 Balance 4P Bonus
case 88819: // Daybreak
spellInfo.ProcCharges = 1;
break;
case 44544: // Fingers of Frost
spellInfo.GetEffect(0).SpellClassMask = new FlagArray128(685904631, 1151048, 0, 0);
break;
case 53257: // Cobra Strikes
spellInfo.ProcCharges = 2;
spellInfo.StackAmount = 0;
break;
case 28200: // Ascendance (Talisman of Ascendance trinket)
spellInfo.ProcCharges = 6;
break;
@@ -2882,10 +2872,6 @@ namespace Game.Entities
case 15290: // Vampiric Embrace
spellInfo.AttributesEx3 |= SpellAttr3.NoInitialAggro;
break;
case 8145: // Tremor Totem (instant pulse)
spellInfo.AttributesEx2 |= SpellAttr2.CanTargetNotInLos;
spellInfo.AttributesEx5 |= SpellAttr5.StartPeriodicAtApply;
break;
case 6474: // Earthbind Totem (instant pulse)
spellInfo.AttributesEx5 |= SpellAttr5.StartPeriodicAtApply;
break;