If, then, logical comparisons

rob.woolhouse
I'm sure this is a simple mistake on my part but can anyone help ?

In the procedure below I wish to generate random numbers for the player and the enemy and then compare them to see who wins a round of combat

In the if..then section am I using the wrong comparison notation or am I going wrong somewhere else ? Both player_combat_roll and opponent_combat_roll evaluate to integers in the range expected (thats why I put msg in for debug purposes)

define procedure <CombatAttack>
set numeric <player_combat_roll;$rand(0;%Player_Skill%)$>
msg <%player_combat_roll%>
set string <target; $parameter(1)$>
msg <You lunge for the #@target#>
set numeric <opponent_combat_roll;$rand(0;#(target):Skill#)$>
msg <%opponent_combat_roll%>
if ( %player_combat_roll% >= %opponent_combat_roll% ) then
{
msg <You strike the #@opponent#>
}
else
{
msg <The #@opponent# strikes you>
}
end define

Freak
When asking for help, state exactly what is wrong. The form "I expect _____ to happen, but _____ happens." is usually good.

Elexxorine
Try putting the '{' on the same line as respective 'then' or 'else', not the next line.

rob.woolhouse
Sorry, Freak,

Didn't mean to touch a raw nerve there.

I'm afraid us newbies aren't always up on the etiquette of posting questions so I apologise if my question wasn't framed in the correct way.

Just hoping for some guidance.

Elexxorine
define procedure <CombatAttack>
set numeric <player_combat_roll;$rand(0;%Player_Skill%)$>
msg <%player_combat_roll%>
set string <target; $parameter(1)$>
msg <You lunge for the #@target#>
set numeric <opponent_combat_roll;$rand(0;#(target):Skill#)$>
msg <%opponent_combat_roll%>
if ( %player_combat_roll% >= %opponent_combat_roll% ) then {
msg <You strike the #@opponent#>
}
else {
msg <The #@opponent# strikes you>
}
end define

paul_one
... she's not wrong!!

Thanatos
:o

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums