ID:262895
 
Ok, first i wrote the verb......it worked fine....then i decided to make the attack verb into a hud attack button....why isnt it compiling?

(please exuse the shear size, the way i coded it was to put the entire battle system into just the attack verb.)
mob/var/wait[500]

obj/hud
Attack
layer = MOB_LAYER+21
name = "Attack"
icon = 'Tiles.dmi'
icon_state = "attack"
screen_loc = "11,13"
Click()
if(mob/M in oview(1))
var/usrdamg = usr.Str-M.Def
var/usrdamag = usrdamg/M.Agl
var/usrdamage = usrdamag+usr.Spd
var/usrdamageww = usrdamage+usr.weapon
var/usrdonedamage = usrdamageww-M.armor
var/waitime = usr.wait/usr.Spd
if(waitime<=10)
waitime = 10
var/Strloss = usr.Str/15
var/Defloss = M.Def/15
var/Aglloss = M.Agl/15
var/Spdloss = usr.Spd/15
var/Stradd = usr.MaxStr/200
var/Defadd = M.MaxDef/200
var/Agladd = M.MaxAgl/200
var/Spdadd = usr.MaxSpd/200
var/HPadd = M.MaxHP/200
if(M.safe == 1)
alert("They do not have their PVP switched on")
else if(usr.safe == 1)
alert("You cannot attack with your PVP switched off")
else if(usr.attacking == 1)
return
else if(usrdonedamage <= 1)
usr<<"<font color=white>You hit [html_encode(M.char_name)] for <font color=red>1<font color=white> damage"
M<<"<font color=white>[html_encode(usr.char_name)] hits you for <font color=red>1<font color=white> damage"
M.HP -= 1
else
M.HP -= usrdonedamage
usr.Str -= Strloss
if(usr.Str<=1)
usr.Str = 1
usr.MaxStr += Stradd
M.Def -= Defloss
if(M.Def<=1)
M.Def = 1
M.MaxDef += Defadd
M.Agl -= Aglloss
if(M.Agl<=1)
M.Agl = 1
M.MaxAgl += Agladd
usr.Spd -= Spdloss
if(usr.Spd<=1)
usr.Spd = 1
usr.MaxSpd += Spdadd
M.MaxHP += HPadd
M.attacklist += src.name
usr.attacking = 1
usr<<"<font color=maroon>You hit [html_encode(M.char_name)] for <font color=red>[usrdonedamage]<font color=maroon> damage"
M<<"<font color=red>[html_encode(usr.char_name)] hits you for <font color=maroon>[usrdonedamage]<font color=red> damage"
if(M.HP <= 1)
M.sight = 1
if(M.npc!=0)
M.safe=1
switch(input("You have defeated [html_encode(M.char_name)], what would you like to do now?","He Is Defeated", text) in list ("Take his money","Kill him","Show him mercy"))
if("Kill him")
Death(M)
world<<"<font color=maroon>Player Info: <font color=red>[M.char_name] has been slaughtered by [usr.char_name]."
if("Take his money")
usr.yen+=M.yen
M.yen = 0
world<<"<font color=maroon>Player Info: <font color=red>[M.char_name] has been mugged by [usr.char_name]."
sleep(30)
M.HP=5
M.sight = 0
else
world<<"<font color=maroon>Player Info: <font color=red>[usr.char_name] has shown mercy to [M.char_name]."
sleep(30)
M.HP=5
M.sight = 0
sleep("[waitime]")
usr.attacking = 0


I have realy been messing up and writing some sloppy code lately......Whats going on?......Must be the lack of sleep.

Please post the compile errors you're getting, and point out the lines on which they are occurring.
In response to Crispy
var/usrdamage = usrdamag+usr.Spd

the whole error shows up as :

Graphics.dm:873:error:var:Expected end of statement
In response to Dark Krow
You have an indentation mistake on the line before that. Looks like a single extra space somewhere.

Incidentally, that is really ugly code...
In response to Crispy
thank you......for the comment i mean :P
In response to Dark Krow
GRRRR.....ok that code is pissing me off. any more takers to figure this one out? I just searched the whole thing 42 times for what crispy said, and i still dont see it!

if someone could please point it out to me i will stand on my head out in the street and shout "Im an idiot"....lol
In response to Dark Krow
 var/usrdamag = usrdamg/M.Agl


Also, in your input, that 'else' is wrong. Whenevr they kill him, it'll say they've shown mercy. Use
if("bla")
..
else if("blabla!")
..
else if("nana")
..


Also, golden lesson;
if(var==1)

becomes
if(var)

AND!
if(var==0)

becomes
if(!var)
In response to Mysame
Mysame wrote:
Also, golden lesson;
if(var==1)

becomes
if(var)

AND!
if(var==0)

becomes
if(!var)


Only if you're dealing with boolean variables, mind. If it's anything else then if(var) would return 1 if the var is 1, or 2, or 3, or any other number (that isn't 0, null, etc.).
In response to Elation
Then again, that should be common sense.
In response to Dark Krow
You seriously can't find it?
        Click()
if(mob/M in oview(1))
var/usrdamg = usr.Str-M.Def
var/usrdamag = usrdamg/M.Agl // Notice that this is over-spaced!
var/usrdamage = usrdamag+usr.Spd
var/usrdamageww = usrdamage+usr.weapon


Also, take what the others said into consideration.

Hiead
In response to Mysame
Mysame wrote:
Also, in your input, that 'else' is wrong. Whenevr they kill him, it'll say they've shown mercy. Use
> if("bla")
> ..
> else if("blabla!")
> ..
> else if("nana")
> ..


Actually, no, that was fine how it was. Look more closely; it's a switch() statement, not an ordinary if().

And even if it was an ordinary if(), you'd be wrong anyway because the first one (if("bla") in your example) will always be true.
In response to Crispy
The 'bla' was supposed to be after the switch, sorry I didn't make that one clear. And I still think it'd be true whenever you kill him... Seeing as the second if() doesn't have an 'else' before it... o.O
In response to Mysame
Mysame wrote:
Also, golden lesson;
if(var==1)

becomes
if(var)

AND!
if(var==0)

becomes
if(!var)


Not really a golden lesson. If you're teaching him something, teach him it correctly =P. <code>if(var)/if(!var)</code> should only be used with boolean vars..

O-matic
In response to O-matic
Damnit, O-matic, they already siad thaaaaat! Scroll up, ebil DBZ gamemaker =P.