Knights Forum

General Category => Knights Discussion => Topic started by: Stephen on October 20, 2012, 01:03:37 PM

Title: Monster Proposal
Post by: Stephen on October 20, 2012, 01:03:37 PM
ImpassIve made a comment in another thread about wanting a CREATURE_DEATH hook. I have also wanted some more flexible monster hooks in the past.

I propose we add the following fields to the "MonsterType" table:

* on_attack -- this is called when the monster makes an attack / swings its weapon
* on_damage -- this is called when the monster receives non-fatal damage
* on_death -- this is called when the monster is killed

(These are a bit like HOOK_CREATURE_SQUELCH etc, but there is one for each monster type instead of one "global" hook. I think this is better than using hooks :) )
Title: Re: Monster Proposal
Post by: Romanio(Rus) on October 23, 2012, 11:36:39 AM
Fully support this initiative, as it will give much more space to write mods =)
Title: Re: Monster Proposal
Post by: Stephen on December 27, 2012, 04:07:51 PM
This is now implemented. A snapshot is available here: http://www.solarflare.org.uk/snapshots/knights_src_2012_12_27.tar.gz (source code) or http://www.solarflare.org.uk/snapshots/knights_2012_12_27.zip (Windows binary)

In addition to "on_attack", "on_damage" and "on_death", I also added "on_move" which is called whenever the monster moves to a new square.

I also removed the "sound" property because monster sounds can now be implemented using a combination of on_attack, on_damage, on_death and on_move, as required. For example, zombies make a sound whenever on_attack, on_damage, on_death are called, and also 5% of the time when on_move is called. Bats only make their "screeching" sound when on_damage is called.
Title: Re: Monster Proposal
Post by: ImpassIve on December 27, 2012, 05:20:42 PM
Nice news, hehe)
Will try it later

P.S. I just have installed a new router (because from today I have a VDSL connection instead of ADSL) but I have problems with playing some games in online (including Knights)
I hope I will fix this until Sunday... -_-
Title: Re: Monster Proposal
Post by: Moo on August 19, 2014, 03:06:27 PM
I was playing with these...

Currently they give a userdata in cxt.actor and a "monster" in cxt.originator. I presume these are both the thing that was killed/damaged? Neither of those seem to be much use on their own, so I guess to be able to determine what kind of monster, there would need to be something similar to kts.IsKnight added to return the monster type?

It seems like there's no way to get the killer/damage-causer?
on_damage isn't called when fatal damage is done, so that couldn't be used to determine killer either.

on_death and on_damage seem to get called for bats, but not zombies. I didn't try custom monsters.
Title: Re: Monster Proposal
Post by: Stephen on August 21, 2014, 04:50:05 PM
I suppose this is what happens when you make an API up as you go along...