I'm looking for the specific string that determines when a player _dies_ so that I could get it to check to see if an item is in their inventory, if so, change something else.
If anyone could offer some code... I'm kinda new... which is an understatement. I just want to pick through the code, but I can't find this little thing. If someone could at least point me in the right direction it would be greatly appreciated.
I believe that would be in the damage function - and I think there's even a specific function, "kill_char" or something, that is called whenever a character dies.
These are the only bits of code that even mention killing, or dieing. I need to know which actually does the whole deduct-experience-and-transport-to-room part... *Help!*
Ok so this is the chunk I'm looking for... I think. This at least does the "Blah has been killed by Blah!" I can't tell what exactly the code is doing... I mean it looks like it's just checking to see if they are in POS_DEAD, then telling the world about it. I'm not sure if this is the snippet I'm looking for. I need the code that executes just before the player is moved to the new room.
Awesome! It was raw_kill, thanks for the help :) Now... just to figure out how to check the inventory, check for a specific item's vnum, to restore the player's health... hmm.. gonna take some effort... blarg
If you're trying to save the player from at death, you might want to look where raw_kill is called, and change it there instead. Who knows what else is called before raw_kill is called, so you need to be careful with that.
Ok, but couldn't raw_kill be called in several different places? I do want to save a player from death, but only if they have an item in their inventory, shouldn't I go right to the source at raw_kill?
Does anyone know any good documentation for SMAUG, and also, what would I use to check the inventory? just ch->inventory, or is it something a little more kooky? I'm very new to coding, but I know a lot of C++, I thought this was gonna be... well.. simple.. blarg...any help would be appreciated, and for all help so far, many thanks. *bow*
The danger to directly editing raw_kill for this is that such things as the slay command call raw_kill and your life saving items can now do very unexpected things.
As for how kooky the check is, that depends on a number of factors - is the item nodrop? is the item expected to be in a bag? will it work from within a bag if its not nodrop? Checking for items inside containers and extracting them is a bit more compicated but there are examples in the code (can't think of any offhand though :( )
Ok, really the effect I wanted was the same as a Phoenix Down from Final Fantasy, although instead of dieing, you'd be reset back to full health, and the item would be used from your inventory I don't really expect the item to be in a container, and it's not nodrop. This help so far is awesome! But yeah, if anyone has any documentation, please send a link, or something...
Quote: I'm very new to coding, but I know a lot of C++
How does one manage that? :)
Anyway the thing is, you don't want to touch *all* instances of a player being killed - as Meerclar pointed out that could have some "interesting" side effects. Rather you seem to only want the player to not die whilst in combat - so you want to only check the combat code.
I'm pretty sure that this will work for you if you only put the check in the damage function - or wherever it is that the code calls raw_kill if a character is killed during combat.
As for the 'kookiness' of the check it's not really 'kooky' at all - it's just the way it is. :) You'll have to go through the linked list of the inventory. If the item is guaranteed to not be in a container then your problem is actually pretty easy - just loop through the inventory linked list looking for the right item. I think that's first_carrying to last_carrying.