Jump to content
Sign in to follow this  
Hasilein

LUA : OnHitZombie -> Add item

Recommended Posts

Okay i've got the crossbow and it works fine. But id like to have the bolts back on hit. Any ideas?

 

 

local function CombatOnHitZombie(zombie, weapon)

   if weapon:getType() == "Crossbow" then    --> How can i solve that?
    zombie:getInventory():AddItem("Xbowbolt");  -> .. and that
 end
end
Events.OnHitZombie.Add(CombatOnHitZombie); 

 

Is there any documetation about all objects and its properties and functions? Then i could maybe stop asking questions and start answer a few ...

Share this post


Link to post
Share on other sites

The following is not really a solution to your problem, but might point you in the right direction.

 

The event "OnHitZombie" is called like this in IsoZombie.class:

 LuaEventManager.triggerEvent("OnHitZombie", this, paramIsoGameCharacter, bodyPartType, paramHandWeapon); 

So I guess your parameters in your function "CombatOnHitZombie" are wrong.

 

I quickly printed the Event hook to this event, the output is this:

LOG  : General, 1586779565623> -- SHARED: OnHitZombie(zombie.characters.IsoZombie@2e627dd, zombie.characters.IsoPlayer@427590b4, Head, zombie.inventory.types.HandWeapon@1a4a79f9)
LOG  : General, 1586779565623> --
LOG  : General, 1586779565623> --
LOG  : General, 1586779565623> --------------------------------------
LOG  : General, 1586779565623> -- CLIENT: OnHitZombie(zombie.characters.IsoZombie@2e627dd, zombie.characters.IsoPlayer@427590b4, Head, zombie.inventory.types.HandWeapon@1a4a79f9)
LOG  : General, 1586779565623> --
LOG  : General, 1586779565623> --
LOG  : General, 1586779565623> --------------------------------------
LOG  : General, 1586779565623> -- SERVER: OnHitZombie(zombie.characters.IsoZombie@2e627dd, zombie.characters.IsoPlayer@427590b4, Head, zombie.inventory.types.HandWeapon@1a4a79f9)
LOG  : General, 1586779565623> --
LOG  : General, 1586779565623> --

If I did everything right (sorry, kinda rusted regarding PZ modding) you can see that the event is fired from every "game-type" and has the arguments passed to the registered function "IsoZombie zombieThatWasHit, IsoPlayer playerThatHitTheZombie, BodyPartType bodyPartThatWasHit, HandWeapon weaponThatHitTheZombie"

 

Hope this helps you.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...