If, then, logical comparisons

rob.woolhouse
27 Oct 2008, 11:57
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
27 Oct 2008, 15:35
When asking for help, state exactly what is wrong. The form "I expect _____ to happen, but _____ happens." is usually good.

Elexxorine
27 Oct 2008, 17:28
Try putting the '{' on the same line as respective 'then' or 'else', not the next line.

rob.woolhouse
28 Oct 2008, 02:14
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
30 Oct 2008, 12:12
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
01 Nov 2008, 08:45
... she's not wrong!!

Thanatos
02 Nov 2008, 06:07
:o