Misc fixes

This commit is contained in:
hondacrx
2017-09-06 12:00:21 -04:00
parent 38b6c72499
commit 36a74cf873
18 changed files with 161 additions and 312 deletions
+10 -11
View File
@@ -1389,23 +1389,22 @@ namespace Game.Entities
public void SetSpawnHealth()
{
if (m_creatureData == null)
return;
ulong curhealth;
if (!m_regenHealth)
{
if (m_creatureData != null)
curhealth = m_creatureData.curhealth;
if (curhealth != 0)
{
curhealth = m_creatureData.curhealth;
if (curhealth != 0)
{
curhealth = (uint)(curhealth * _GetHealthMod(GetCreatureTemplate().Rank));
if (curhealth < 1)
curhealth = 1;
}
SetPower(PowerType.Mana, (int)m_creatureData.curmana);
curhealth = (uint)(curhealth * _GetHealthMod(GetCreatureTemplate().Rank));
if (curhealth < 1)
curhealth = 1;
}
else
curhealth = GetHealth();
SetPower(PowerType.Mana, (int)m_creatureData.curmana);
}
else
{
+24 -2
View File
@@ -5315,7 +5315,9 @@ namespace Game.Entities
return InventoryResult.ItemMaxLimitCategoryEquippedExceededIs;
// there is an equip limit on this item
if (HasItemOrGemWithLimitCategoryEquipped(itemProto.GetItemLimitCategory(), limitEntry.Quantity - limit_count + 1, except_slot))
if (HasItemWithLimitCategoryEquipped(itemProto.GetItemLimitCategory(), limitEntry.Quantity - limit_count + 1, except_slot))
return InventoryResult.ItemMaxLimitCategoryEquippedExceededIs;
else if (HasGemWithLimitCategoryEquipped(itemProto.GetItemLimitCategory(), limitEntry.Quantity - limit_count + 1, except_slot))
return InventoryResult.ItemMaxCountEquippedSocketed;
}
@@ -5484,7 +5486,7 @@ namespace Game.Entities
return false;
}
bool HasItemOrGemWithLimitCategoryEquipped(uint limitCategory, uint count, byte except_slot)
bool HasItemWithLimitCategoryEquipped(uint limitCategory, uint count, byte except_slot)
{
uint tempcount = 0;
for (byte i = EquipmentSlot.Start; i < EquipmentSlot.End; ++i)
@@ -5506,6 +5508,26 @@ namespace Game.Entities
if (tempcount >= count)
return true;
}
}
return false;
}
bool HasGemWithLimitCategoryEquipped(uint limitCategory, uint count, byte except_slot)
{
uint tempcount = 0;
for (byte i = EquipmentSlot.Start; i < EquipmentSlot.End; ++i)
{
if (i == except_slot)
continue;
Item pItem = GetItemByPos(InventorySlots.Bag0, i);
if (!pItem)
continue;
ItemTemplate pProto = pItem.GetTemplate();
if (pProto == null)
continue;
if (pItem.GetSocketColor(0) != 0 || pItem.GetEnchantmentId(EnchantmentSlot.Prismatic) != 0)
{
+8 -5
View File
@@ -755,13 +755,16 @@ namespace Game.Entities
chance = playerVictim.GetFloatValue(PlayerFields.ParryPercentage);
}
}
else if (victim.IsTypeId(TypeId.Unit) && !(victim.ToCreature().GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.NoParry)))
else
{
chance = 6.0f;
chance += victim.GetTotalAuraModifier(AuraType.ModParryPercent);
if (!victim.IsTotem() && !victim.ToCreature().GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.NoParry))
{
chance = 6.0f;
chance += victim.GetTotalAuraModifier(AuraType.ModParryPercent);
if (levelDiff > 0)
levelBonus = 1.5f * levelDiff;
if (levelDiff > 0)
levelBonus = 1.5f * levelDiff;
}
}
chance += levelBonus;
+3 -9
View File
@@ -894,7 +894,7 @@ namespace Game.Entities
canDodge = false;
// only if in front
if (victim.HasInArc(MathFunctions.PI, this) || victim.HasAuraType(AuraType.IgnoreHitDirection))
if (!victim.HasUnitState(UnitState.Controlled) && (victim.HasInArc(MathFunctions.PI, this) || victim.HasAuraType(AuraType.IgnoreHitDirection)))
{
int deflect_chance = victim.GetTotalAuraModifier(AuraType.DeflectSpells) * 100;
tmp += deflect_chance;
@@ -1043,8 +1043,7 @@ namespace Game.Entities
int tmp = 10000 - HitChance;
int rand = RandomHelper.IRand(0, 10000);
int rand = RandomHelper.IRand(0, 9999);
if (rand < tmp)
return SpellMissInfo.Miss;
@@ -2157,13 +2156,8 @@ namespace Game.Entities
if (victim.HasAuraType(AuraType.IgnoreHitDirection) || victim.HasInArc(MathFunctions.PI, this))
{
// Check creatures flags_extra for disable block
if (victim.IsTypeId(TypeId.Unit) &&
victim.ToCreature().GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.NoBlock))
return false;
float blockChance = GetUnitBlockChance(attackType, victim);
if (RandomHelper.randChance(blockChance))
if (blockChance != 0 && RandomHelper.randChance(blockChance))
return true;
}
return false;