09-01-2005, 01:09 AM
Alright im workin on a Risk Type game i got just about everything done except the battle. I thought i had it working but it turns out i dont and i cant find out whats wrong with it.
Code:
declare sub battle(attackarea,defendarea)
dim shared units(16) 'units (area)
dim shared area(16) 'who owns witch area
randomize timer
area(1)=1
area(2)=2
units(1)=10
units(2)=10
battle(1,2)
sub battle(attackarea,defendarea)
cls
dim adie(3) '3 max attackdie
dim ddie(2) '3 max defenddie
do
numadie=units(attackarea)-1 '1 less die than how many units
if numadie>3 then numadie=3 'cant be greater than 3
if numadie<1 then numadie=1 'and not less than 1
numddie=units(defendarea) 'same amount of die as units
if numddie>2 then numddie=2 'cant be greater than 2
'rolls die
for i=1 to numadie
adie(i)=int(rnd*6)+1
next
for i=1 to numddie
ddie(i)=int(rnd*6)+1
next
'sorts die
for i=1 to numadie
for a=1 to numadie
if adie(i)>adie(a) then swap adie(i),adie(a)
next
next
for i=1 to numddie
for a=1 to numddie
if ddie(i)>ddie(a) then swap ddie(i),ddie(a)
next
next
if numddie>numadie then 'if you have more defence die then
for i=1 to numadie 'only roll how many attack die you have
'if the atak die is more than defence die then defence looses one unit
if adie(i)>ddie(i) then
units(defendarea)=units(defendarea)-1
else'if defence die >= to atk die then atk loses one
units(attackarea)=units(attackarea)-1
end if
next
'works the same as the top one only if the number of atk die is greater
else
for i=1 to numddie
if adie(i)>ddie(i) then
units(defendarea)=units(defendarea)-1
else
units(attackarea)=units(attackarea)-1
end if
next
end if
'just prints the results of each round
print
for i= 1 to numadie
print "Atk die "+str(i)+":",adie(i)
next
for i=1 to numddie
print "Dfnd die "+str(i)+":",adie(i)
next
print "Attk",units(attackarea)
print "Dfnd",units(defendarea)
sleep
'leaves sub if eather side loses
if units(attackarea)<1 then exit sub
if units(defendarea)<1 then exit sub
loop
end sub
his world has been connected...
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless