Jump to content

Recommended Posts

hi,

for the purpose of making a character levelup from monster kills, I was thinking of listening for death events. This is completely new territory however

so I'm a bit lost.I was thinking of something like this in my character.lua :

local function ondeathawardxp(inst,cause,afflicter)
	    -- how to add event handlers
	    -- "entity_death", data = { inst = deadthing, cause = cause, afflicter = afflicter }
	    
	end
	self:ListenForEvent("entity_death",  ondeathawardxp, getworld())

It's probably easier to listen for the "killed" event, which pushes straight from your character instance.

local function awardxp(inst,data)

  --calculate xp

  --give xp to player

  --check levelup

end

inst:ListenForEvent("killed",awardxp)

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