When I make it so that killing an enemy makes a dead body appear I can still attack the corpse. I also want a way to loot the corpse. Please help.
Thanks in advance!
Something like giving a variable of "dead" when you turn into the corpse. Then in your attack code, but a check so if(src.dead) not to let it be attacked.
Ever heard of examples? People usually give examples to others instead of copy+paste codes because people don't bother learning and ask similar question or it can mess up their system (we are not psychic, we do not know how your code is). It is very basic... re-read what Dark said carefully.
#8 Jun 10 2007, 11:44 pm (Edited on Jun 12 2007, 2:12 pm)
You should probably learn some more about if() statements and variables, but its probably best if you learn everything you need to know now.
Once you've learned more about DM by reading the material on the link, stop asking for code you can copy+paste, and still dont know how to do this, then :
-Create a variable for everything, you could define it for everything by the /atom type. This variable will be the on/off set for something being attackable or not.
-In your attack code, include an if() statment in the appropiate place that checks if the object being attacked is attackable or not, and if it isn't then dont attack, otherwise, it can be attacked.
Ex:
mob/verb/Attack(atom/M in oview(1)) if(!M.attackable) usr<<"[M] is not attackable." if(M.attackable) //attack stuff.
This is a simple attack verb, to show you where the appropiate place is, if you didn't know. Also, you might not want to use
if(M.attackable
if you plan on having negative values for attackable, so people that have negative values can't be attacked, then you might want to use
if(M.attackable<=1)
. The first, will check to see if the value of the provided variable is not 0, or "true". The second will let you attack the object if there attackable variable is higher or equal to 1.
Unless you want people staying in safe zones and being able to attack people outside safe zones without getting attacked in return, I suggest you also check some variable to note, or denote whether or not a person is in a safe zone on the attacker, so they can't do this.
Ok well my problem is that whenever I enter a code that you guys give me to stop attacking the corpse, whenever I attack the corpse it will do damage to the dead body and say(example:"Don't kill dead people!") but still do the damage.
I gave you an answer above, if you're not willing to read it, or if you can't understand it you should read the DM guide thoroughly to know more about programming in the DM language.
When you ask questions here, you shouldn't expect people to just hand-out code that will fit perfectly into your code.
Don't make the dead body attackable.