ID:263891
 
Code:
mob/Spell
verb
Apparate(varX as num, varY as num, varZ as num)
set category = "Spells"
if(varX > world.maxx) // if the number they put in is higher than the map's highest point
src.x = world.maxx //make it go as close as it can, that way they dont go off map and have to relog
else
if(varX < 1) // if its less than one
src.x = 1 //go to one since you cant have negative map points
if(varY > world.maxy)
src.y = world.maxy
else
if(varY < 1)
src.y = 1
if(varZ > world.maxz)
src.z = world.maxz
else
if(varZ < 1)
src.z = 1
src.loc = locate(varX,varY,varZ)
mob/Teacher
verb
Teach_Apparate(mob/M in world)
set category = "Charm Spells"
for(var/mob in world)
M.verbs+=new/mob/Spell/verb/Apparate


Problem description:Since I put in the Teach verb, whenever I click Apparate
it instead makes a list of all mobs in the world instead of making me list an x y and z to teleport to.
well that is cleary because u did not set a mob to attack therefore when you play it will give you a list so you can choose who you want to attack try making it guy have to be infront or somthing
In your Teach verb, your for() loop is useless. I suggest using a verb argument "mob/M in view()" instead.

            M.verbs+=new/mob/Spell/verb/Apparate


Verbs and procs are not objects, and so creating a new instance of one makes no sense. You should simply be adding the type path of the verb to the verbs list.

            for(var/mob in world)


Also, this for() loop is useless. Remove it.

            if(varX > world.maxx) // if the number they put in is higher than the map's highest point
src.x = world.maxx //make it go as close as it can, that way they dont go off map and have to relog


Also, that should be varX = world.maxx, not src.x. Similar for every single if() statement in your verb. However, you can simply use min() and max(), or write a bounds() proc that uses them instead:

proc/bound(var/lower, var/N, var/upper)
if(lower > upper) return max(upper, min(lower, N))
else return min(upper, max(lower, N))<dm>

With that proc, all you need to do is:

<dm>varX = bound(1, varX, world.maxx)
varY = bound(1, varY, world.maxy)
In response to Qwaszx123
You obviously don't understand what this verb and proc is supposed to do, it has nothing to do with attacking >.>. Anyway, thanks for your help, Garthor and kaiochao2536, however I found the problem while exploring a little when my net was offline. The game recognised the Teach Apparate and Apparate verbs to be the same, and the Teach Apparate nulled the Apparate. All I had to do was change the Teach Apparate to Teach Aparate.