mob/Ice_Wizard/spells
verb
Ice_Idol()
set category = "Spells"
if(istype(usr.loc.loc,/area/no_spell)) {usr << "<b>No casting spells in a no-spell area!"; return;} //In your spellcasting VERB
if(usr.Mana<=25)
usr << "<font color=blue><font size=2>*Not Enough Mana!"
return
if(usr.Mana>=25)
usr.Mana-=25
view() << "<font color=red><font size=2>*[usr] drops to the ground,rises up slowly and summons an ice idol that will last 30 sec!!"
new /obj/wall/iceidol (src.loc)
obj/wall/iceidol/New()
..()
spawn(300) del src
obj/wall/iceidol
icon = 'Spells.dmi'
icon_state = "ice idol"
layer=4
for(var/mob/M in range(4,src))
if(M.element=="Ice Wizard")
M << "<font color=red><font size=2>*You feel the presence of an Ice Idol and you gain power!"
M.Health+=40
M.Mana+=40
return
else
M << "<font color=red><font size=2>*You see an Ice Idol but cannot harness its power."
Problem description:
I am trying to make a spell were you can create an idol on the ground that gives off bonuses for ice wizards only if they are near it. This code is kind of like how I want it to be, when the Ice Idol is present add some stuff, then it disappears after 30 secs and the bonuses retract.
In this case, though, a constant polling loop is no good. Think of all the cycles this thing is going to drain while it's doing nothing, and meanwhile it'll spam anyone in range with messages.
What I'd suggest instead is to create a new type, /obj/proximity, and put the ice idol under that. When a player enters a turf, it checks for any /obj/proximity objects in the area and then checks their range to see if you're in it. If you weren't before, it notifies the object of the change of status and the object will run a proc to display a message or so, and keep operating as long as you're in range. The same notification may occur if the object moves.
Lummox JR