Jump to content

LUA : OnHitZombie -> Add item


Hasilein

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 ...

Link to comment
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.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...