ID:164431
 
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!
Moocow696 wrote:
When I make it so that killing an enemy makes a dead body appear I can still attack the corpse.

Don't make the dead body attackable.

I also want a way to loot the corpse.

atom/proc/loot(var/mob/looter)
if(contents.len == 0)
looter << "There is nothing to loot"
else
for(var/obj/O in contents)
O.Move(looter)
In response to Garthor
How do I make the dead body "non-attackable"?
In response to Moocow696
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.
In response to DarkD3vil666
do you think that you could give me a coded example? I've tryed but it's not working for me...
In response to Moocow696
if(this.body.dead) //if this body is dead
world<<"Leave the dead be [usr.name]!"
In response to GhostAnime
if(this.body.dead) does not work with my code. I need help =..O
In response to Moocow696
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.
In response to Moocow696
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.

In response to GhostAnime
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.
In response to Moocow696
Someone please ansewer me =..(
In response to Moocow696
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.
In response to Moocow696
Read Zilal's tutorial!
The reason body isn't working is probaly because your one is called person or dude or something.
In response to Tweelik
I know that and i DID read that guys turorial and put in the code that was supposed to stop it but it didnt work