mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-25 00:30:19 +01:00
make on_death compatible (return either player or nil)
This commit is contained in:
parent
d20dfa0b41
commit
99bea53af3
9
api.lua
9
api.lua
@ -882,7 +882,14 @@ function mob_class:check_for_death(cmi_cause)
|
|||||||
-- execute official engine on_death function if found
|
-- execute official engine on_death function if found
|
||||||
if self.on_death then
|
if self.on_death then
|
||||||
|
|
||||||
self:on_death(self, cmi_cause)
|
-- only return killer if punched by player
|
||||||
|
if cmi_cause.type == "punch" and is_player(cmi_cause.puncher) then
|
||||||
|
cmi_cause = cmi_cause.puncher
|
||||||
|
else
|
||||||
|
cmi_cause = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
self:on_death(cmi_cause)
|
||||||
|
|
||||||
remove_mob(self, true)
|
remove_mob(self, true)
|
||||||
|
|
||||||
|
3
api.txt
3
api.txt
@ -336,7 +336,8 @@ enhance mob functionality and have them do many interesting things:
|
|||||||
is returned normal attack function continued.
|
is returned normal attack function continued.
|
||||||
'on_die' a function that is called when mob is killed (self, pos), also
|
'on_die' a function that is called when mob is killed (self, pos), also
|
||||||
has access to self.cause_of_death table.
|
has access to self.cause_of_death table.
|
||||||
'on_death' Official engine version of above when mob killed (self, cause).
|
'on_death' Official engine version of above when mob killed (self, killer),
|
||||||
|
'killer' is only returned if player killed the mob.
|
||||||
'on_flop' function called when flying or swimmimng mob is no longer in
|
'on_flop' function called when flying or swimmimng mob is no longer in
|
||||||
air/water, (self) paramater and return true to skip the built
|
air/water, (self) paramater and return true to skip the built
|
||||||
in api flop feature.
|
in api flop feature.
|
||||||
|
Loading…
Reference in New Issue
Block a user