I have been working on a security system for a game so players cant get to certain places without certain items and it has been going pretty good but I cant make it attack players. Here are to codes i have tried for it:
turf/security_system
icon = 'security.dmi'
verb
shock(mob/M in world)
var/damage = 2
usr << "shoot at [M]!"
usr << "[damage] damage!"
M << "[usr] attacks you!"
M << "[damage] damage!"
M.HP -= damage
M.DeathCheck()
if(M in oview(5))
else
usr << "0 damage"
/////this 1 makes the characters click a verb to get shocked
//////////and///////////////////////////////////////
turf/security_system
icon = 'security.dmi'
Bump()
shock(mob/M in world)
var/damage = 2
usr << "shoot at [M]!"
usr << "[damage] damage!"
M << "[usr] attacks you!"
M << "[damage] damage!"
M.HP -= damage
M.DeathCheck()
if(M in oview(5))
else
usr << "0 damage"
/////this 1 gets errors for having a var inside of a var
If u can help then please write on what i can do to fix this
Copyright © 2024 BYOND Software.
All rights reserved.
The problem with the above is that you've defined shock as a verb... a verb is a special procedure that has to be willingly activated by a player... it's a method for giving the player control over a procedure.
The problem with the above is that you've tried to define shock as a proc inside of Bump. Also, Bump is called when a mob runs into something, not when something is run into by a mob. If you want to have the security system shock whoever tries to enter it, define shock() as a proc and call it whenever someone steps into it:
turf/security_system
proc/shock(mob/m)
code goes here
Entered(atom/movable/m)
if (this mob doesn't have the required item) //How you handle this is up to your code.
shock(m)