mIRC Home    About    Download    Register    News    Help

Print Thread
#98476 24/09/04 12:43 AM
Joined: Sep 2004
Posts: 8
T
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2004
Posts: 8
Can anyone help with this script ?

It's somthing i have been working on to do the dies roles for me in the bored game called risk. I don't know were im going rong with it at the mo.


alias risk {
set %player1 0
set %player2 0
set %player1 $$?="How many Defending troops?"
set %player2 $$?="How many Attacking troops?"
goto start
:start
if (%player1 >= 1) { set %defend1 ($rand(1,6)) }
if (%player1 >= 3) { set %defend2 ($rand(1,6)) }
if (%player2 >= 1) { set %attack1 ($rand(1,6)) }
if (%player2 >= 2) { set %attack2 ($rand(1,6)) }
if (%player2 >= 3) { set %attack3 ($rand(1,6)) }
if (%defend1 >= %defend2) { set %defend11 %defend1 { set %defend22 %defend2 }}
if (%defend2 > %defend1) { set %defend11 %defend2 { set %defend22 %defend1 }}
set (%attack1 + %attack2) %numcount1
set (%attack2 + %attack3) %numcount2
set (%attack1 + %attack3) %numcount3
if (%numcount1 >= %numcount2) { set %attackwin1 1 }
if (%numcount2 >= %numcount3) { set %attackwin2 1 }
if (%numcount3 >= %numcount1) { set %attackwin3 1 }
if (%attackwin1 = 1) && (%attack1 >= %attack2) { set %attack11 %attack1 { set %attack22 %attack2 }}
if (%attackwin1 = 1) && (%attack2 > %attack1) { set %attack11 %attack2 { set %attack22 %attack1 }}
if (%attackwin2 = 1) && (%attack2 >= %attack3) { set %attack11 %attack2 { set %attack22 %attack3 }}
if (%attackwin2 = 1) && (%attack3 > %attack2) { set %attack11 %attack3 { set %attack22 %attack2 }}
if (%attackwin3 = 1) && (%attack1 >= %attack3) { set %attack11 %attack1 { set %attack22 %attack3 }}
if (%attackwin3 = 1) && (%attack3 > %attack1) { set %attack11 %attack3 { set %attack22 %attack1 }}
if (%defend11 >= %attack11) { set %player2 (%player2 - 1) }
if (%defend22 >= %attack22) { set %player2 (%player2 - 1) }
if (%attack11 > %defend11) { set %player1 (%player1 - 1) }
if (%attack22 > %defend22) { set %player1 (%player1 - 1) }
if (%player1 = 0) { echo 4 Defenders: %player1 and Attackers: %player2 | goto stop }
if (%player2 = 0) { echo 4 Defenders: %player1 and Attackers: %player2 | goto stop }
set %defend1 0
set %defend2 0
set %attack1 0
set %attack2 0
set %attack2 0
set %defend11 0
set %defend22 0
set %attack11 0
set %attack22 0
set %attackwin1 0
set %attackwin2 0
set %attackwin3 0
set %numcount1 0
set %numcount2 0
set %numcount3 0
goto start
:stop
}


Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Without interpreting the code, I'm just mentioning the syntax errors that you have:

Code:
if (%attackwin1 = 1) && (%attack1 >= %attack2) { set %attack11 %attack1 { set %attack22 %attack2 }}

To separate commands you use a pipe |, not an extra set of curly brackets (that you are not ending properly). So you simply want:

if (%attackwin1 = 1) && (%attack1 >= %attack2) { set %attack11 %attack1 | set %attack22 %attack2 }

Code:
set (%attack1 + %attack2) %numcount1

This too is incorrect, if you're trying to attach the value of %attack1 to the value of %attack2 then set the result as a global variable then you need to adapt it slightly:

set $+(%,%attack1,%attack2) %numcount1

Code:
if (%defend11 >= %attack11) { set %player2 (%player2 - 1) }

To perform a small calculation when setting a variable don't enclose the expression in parentheses:

if (%defend11 >= %attack11) { set %player2 %player2 - 1 }

Or simply:

if (%defend11 >= %attack11) { dec %player2 }

So start by going through and correcting these errors in all the places that they occur, then you could work on shortening it and perhaps using local variables (/help /var) so you don't end up cluttering your variables list. Also remember to view the help file on the areas you're dealing with to avoid these errors in the future

Edit: Just noticed another small error that needs correcting in a few instances:

Code:
if (%player2 >= 3) { set %attack3 ($rand(1,6)) }

You don't want those parentheses wrapped around the $rand(), it will stop the identifier from evaluating:

if (%player2 >= 3) { set %attack3 $rand(1,6) }

Last edited by Sigh; 24/09/04 06:37 AM.

Link Copied to Clipboard