Skip to content

Commit

Permalink
pet duels fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yrpen committed Mar 25, 2017
1 parent 137a304 commit b11ef64
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pets_system/creature_on_target_combat.lua
@@ -1,6 +1,6 @@
function Creature:onTargetCombat(target)
if PETS and PETS.SYSTEM.DUELS_ONLY then
if self:isPet() and target:isPlayer() or target:isPet() and self:isPlayer() then
if self:isPet() and target:isPlayer() then
return false
end
end
Expand Down
10 changes: 10 additions & 0 deletions pets_system/pet_creaturescript.lua
@@ -1,5 +1,7 @@
-- <event type="preparedeath" name="PetDeath" script="pet_creaturescript.lua" />
-- <event type="kill" name="PetKill" script="pet_creaturescript.lua" />
-- <event type="think" name="PetTeleport" script="pet_creaturescript.lua" />
-- <event type="healthchange" name="PetHealthChange" script="pet_creaturescript.lua" />

function onPrepareDeath(creature, killer)
local player = creature:getMaster()
Expand Down Expand Up @@ -40,3 +42,11 @@ function onThink(creature, interval)
end
return true
end

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if attacker and attacker:isPlayer() then
return 0, primaryType, 0, secondaryType
end

return primaryDamage, primaryType, secondaryDamage, secondaryType
end
4 changes: 4 additions & 0 deletions pets_system/pets_lib.lua
Expand Up @@ -363,6 +363,10 @@ function Player.summonPet(self, position)
pet:registerEvent("PetTeleport")
end

if PETS.SYSTEM.DUELS_ONLY then
pet:registerEvent("PetHealthChange")
end

if PETS.SYSTEM.MOUNTS then
local mountId = self:getPetMountId()
if mountId ~= nil then
Expand Down

0 comments on commit b11ef64

Please sign in to comment.