ID:263226
 
Code:
mob
verb
Attack(mob/M in oview(usr.Cansee))
if(usr.CanAttack)
if(istype(M,/mob/))
while(M in oview(usr.Cansee)&&M in usr.TargetList)
var/damage = usr.Atk-M.Def+rand(-1,4)
var/CriticalDice = "2d12"
var/CriticalRoll = roll(CriticalDice)
var/Miss = usr.Spd - M.Spd
var/LuckyHit = (usr.Spd+usr.Lck+rand(0,5))-M.Spd
if(damage<=0)
damage = 0
if(Miss<=0)
if(LuckyHit>=1)
var/LuckyDamage = round(damage/rand(2,5))
viewers(usr)<<"[usr] got lucky! [LuckyDamage] damage!"
M.Hp-=LuckyDamage
if(M.Hp<=0)
del M
viewers(usr)<<"[M] was defeated by [usr]!"
break
else
sleep(usr.WaitAttack)
else
viewers(usr)<<"[usr] misses [M]!"
sleep(usr.WaitAttack)
else
if(CriticalRoll>=5)
viewers(usr)<<"[usr] landed a deadly blow!"
var/CriticalDamage = round(damage * rand(1.5,4))
M.Hp-=CriticalDamage
if(M.Hp<=0)
del M
viewers(usr)<<"[M] was defeated by [usr]!"
break
else
sleep(usr.WaitAttack)
else
viewers(usr)<<"[usr] hits [M] for [damage] damage!"
M.Hp-=damage
if(M.Hp<=0)
del M
viewers(usr)<<"[M] was defeated by [usr]!"
break
else
sleep(usr.WaitAttack)


else
return


Problem description:I decided to make my Attack Proc a verb, but it still doesn't work, even after I redid it. I know where the error lies, its right after the While() statement. What did I do wrong? Yes, before you ask, CanAttack is set to 1.

Dead_Demon wrote:
>                   while(M in oview(usr.Cansee)&&M in usr.TargetList)


Have you added M into their Target list?
In response to Mechanios
Well, I got everything fixed except for one thing.
In the stat panel, it shows the name of who you are targeting. Or, At least, its supposed to. When you click on something, it only shows your target as /list. Why?

mob
var
list
TargetList = new /list("")
Dead_Demon wrote:
while(M in oview(usr.Cansee)&&M in usr.TargetList)


The in operator has a lower precedence than the logical AND operator (&&), so you need to put parenthesis around the specific checks.

while((M in oview(usr.Cansee)) && (M in usr.TargetList))


~~> Unknown Person
In response to Unknown Person
Thanks, but it didn't work. I think it has something to do with my targetlist varible. It used to be...
mob
var
Marker
TargetIcon = 'Target.dmi'
TargetList = ""
mob
proc
Target(M)
del src.Marker
src.TargetList = ""
src.TargetList = M
if(M:client)
src<<"<font color = yellow><b>You cannot target yourself.</b></font>"
return
else
src<<"<font color = yellow><b>You look at [M]</font>"
src.Marker = image(usr.TargetIcon,M)
src<<Marker
..()

but now I think I have to make it a real list, so I did this...

mob
var
Marker
TargetIcon = 'Target.dmi'
list
TargetList = new /list
mob
proc
Target(mob/M)
del src.Marker
for(M in src.TargetList)
src.TargetList.Remove(M)
src.TargetList.Add(M)
if(M:client)
src<<"<font color = yellow><b>You cannot target yourself.</b></font>"
return
else
src<<"<font color = yellow><b>You look at [M]</font>"
src.Marker = image(usr.TargetIcon,M)
src<<Marker
..()

And now I get this error:
runtime error: Cannot read null.client
proc name: Target (/mob/proc/Target)
usr: Dead_Demon (/mob/Player)
src: Dead_Demon (/mob/Player)
call stack:
Dead_Demon (/mob/Player): Target(null)
Dead_Demon (/client): Click(Squirrel (/mob/Monster/Docile/Squirrel), Grass (68,23,2) (/turf/Grass))

When I take out the TargetList part in my Attack Verb, it works fine...