ID:1291846
 
Code:
mob
var

left_arm =0
right_arm = 0
torso = 0
legs = 0
stamina =100
HP=100

mob/verb
Straight(mob/m as mob in oview(1)) //attack a mob within 1 tile range
var/damage = prob(80)//damage from a scale from 1-80
oview() << "[usr] is attacking [m]!" //shows everyone but the player who the player is attacking
if(damage <= 30) //if damage is less than 30 attack misses
usr << "You missed."
else //otherwise subtract damage from mob/m's HP
m.HP -= damage
if(m.torso = 1) // if m's torso is targeted subtract from stamina instead
m.stamina -= damage


Problem description:
Combat.dm:22:error: : missing expression
The errors are still unfamiliar to me. Am I not supposed to do a second if, or is it the fact that I didn't define torso in the verb? If so why does it work for HP and stamina, but not torso? I've fiddled with the indention a few times, changed some things around, but the results have been pretty much the same.
The real problem is that(Sorry I was in the wrong line, in my previous post)

if(m.torso=1)

should be
if(m.torso==1)
//or can also be
if(m.torso)// if it's a switch on and off type of var
thank you.
In response to Ligbyr
Add an additional equal sign to the if(m.torse = 1).

if(critical())
... do a critical hit
else
... "not a critical hit"

critical()
// a 10% chance to do/fail
if(prob(10))
return 1
return 0
As Neimo and I stated you are using the == operator the wrong way. Now be proud, because today you learn that if statement uses == operator. I would be lazy to explain further in detail. Just so you know, there's a "Help Page" on the Dream Maker program. Just click F1 and it'll pop-out
In response to Dark-DVF
The if() statement doesn't actually use any operators.
Operators operate on their own; if() only looks at the completely simplified end result of the expression it contains.
In response to Kaiochao
I realized at ask this question, because I'm sometime confuse because of "if(src.blabla)". Are var that are intended like this:
mob/var/Ninja
Are automatically set to null or are set to 1?
In response to Dark-DVF
null. A quick test would've proven that.
mob/Login()
var asdf
src << (asdf == null)

// outputs TRUE
Incidental: Prob doesn't do what you think it does. prob(80) returns 1 80% of the time, 0 20% of the time. I think you want rand(1, 80)
In response to Jp
I said that on my previous comment, didn't thought he didn't intended right. Jp is pretty much right you can also use pick()
pick() would be a rather poor choice.

pick(1, 2, 3, 4, 5 /*some code snipped*/, 78, 79, 80)


compared to

rand(1, 80)
pick(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80)


No problem
If you think that code is 'no problem', you should maybe not be trying to help people.
In response to Jp
The term I used, "No problem", was replying to:

Ligbyr wrote:
thank you.
Oh, that makes more sense. Sorry.

I think it's still obvious why pick is a poor option here, though.
In response to Jp
Yeah, but it's still good to know the language and its given choice.

EDIT: Also, there were no need of such Sorry. It was mostly my fault for not explaining why I was saying that out of nowhere. That may had seem arrogant of using it in this context. I totally agree on the way you reacted and would've reacted like you did.