ID:149031
 
For some reason, when I run this code, the turret kills anyone, even if they're supposed to be on the same team. Both turret types will be shown.

mob/Turret
icon = 'turret.dmi'
density = 1
Team = "Collective"
proc/Kill()
for(var/mob/M in oview(5))
if(M.FakeTeam != src.Team) //Faketeam is the person's team unless changed
M << "You are trespassing!"
M.HP = -1
M.DeathCheck()
spawn(10) Kill()
New()
spawn() Kill()

mob/TitanT
icon = 'turret.dmi'
density = 1
Team = "Titan"
proc/NPCKill()
for(var/mob/M in oview(5))
if(M.FakeTeam != src.Team) //Faketeam is the person's team unless changed
M << "You are trespassing!"
M.HP = -1
M.DeathCheck()
spawn(10) NPCKill()
New()
spawn() NPCKill()

It doesn't not work, it just kills teammates even though the purpose of it is to defend bases/meetings.
Since the check if(M.FakeTeam != src.Team) is apparently returning true, the problem is not in the posted section.

Put in a nice debug check:

world << M.FakeTeam
world << src.Team

Just to make sure they are not equal.
In response to Skysaw
Skysaw wrote:
Since the check if(M.FakeTeam != src.Team) is apparently returning true, the problem is not in the posted section.

Put in a nice debug check:

world << M.FakeTeam
world << src.Team

Just to make sure they are not equal.

Okay, I've done that and found out that the problem comes, not from the turrets, but that the Combat Engineer class doesn't build turrets of the right team. Here is the code:
mob
hidden
verb
Build()
switch(input("What do you want to build?","Team","Collect") in list("Turret","Wall"))
if("Turret")
if(usr.Team == "Titan")
new/mob/Turret(usr.loc)
else
new/mob/TitanT(usr.loc)
if("Wall")
new/turf/Wall(usr.loc)


[edit] I fixed it. But I want it not to kill automatically, which it does.[edit]