ID:171180
 
I can't keep the NPCs from being killed. Does some have a code to prevent this?
Uh... what do you mean, being "killed" Do you not want them to reappear at a certain point, or do you not want them to die alltogether.

Most people want the opposite, they want their players to die, and their NPCs to be deleted.

You have to supply information.
In response to Ter13
Okay, what I mean is that I don't want some of my NPCs to be attacked. Like the townspeople, royality, anyone helpful, I don't want them to die, just the monsters. (I don't have any mosters just yet, but I'm not making them yet.)
So, If there is a working code out there, please point it out.
In response to GoldenSunMaster3
Never ask for code.

Ask how YOU can make it.

Do you have an attack verb done? You will need a new type of NPC if so.

ONLY define the attack verb in /mob/NPC/combative.

mob
NPC
combative
verb
attack()
set src in oview(1)
//attack code here.
In response to Ter13
My attack verb is interfrring. What should I do?
In response to GoldenSunMaster3
GoldenSunMaster3 wrote:
My attack verb is interfrring. What should I do?

You can go back and set a sub-category for hostile NPCs and another for shopkeepers like suggested previously, or create and check a list to see if the player can attack a certain NPC like so.

Create a procedure much like this:
mob/player
proc
Checkenemy()
var/L[0]
for(var/mob/M in oview(3))
if(istype(M,/mob)) L += M
if(istype(M,/mob/shopkeeper)) L -= M
return L


Then with the attack verb:
mob/player
verb
Attack(mob/M as mob in Checkenemy())


Sure it's a lot more processor load when compared to just categorizing mobs but it's useful if you need to make hostiles peaceful for charming or a faction setup.
In response to Grei
Or he could create npcs from a /obj type.
In response to GoldenSunMaster3
you COULD define the attack verb so that it only detects /mob/NPC/combatants, or you could actually take my suggestion and make the attack verb under the person who is being attacked.
Put all the NPC's under a certain type and in the attack verb make sure that the person being attacked isn't of that type, if the person being attacked IS of that type then don't carry out the verb, otherwise do everything as normal.
In response to DeathAwaitsU
Or, if DeathAwaitsU's explantion is just to complicated, I find it much easier to give all the NPCs a certain var and then have the attack verb check for that var before attacking. I always found it simpler that way.

Chance
In response to DeathAwaitsU
Okay. How would I go about doing that?
In response to GoldenSunMaster3
Well typing usually helps.
In response to GoldenSunMaster3
GoldenSunMaster3 wrote:
Okay. How would I go about doing that?


You're a lazy soul, eh?

mob
verb
attack(mob/npc/N)
if(N.type == "donthurtme")
src<<"Don't hurt him, moron!"
else
//attack code

mob
var
type
npc
shopkeeper
type = "donthurtme"
uberdragon
type = "hurtmebabyyeah!"



You MIGHT want to use binary instead,
        if(N.baddy == 1)
if(N.baddy == 0)


Etc.

Now you owe me your house, and wife/husband.

Oh, and don't copy and paste my code.
I don't owe you anything!