HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Even and odd numbers

02-22-2004, 06:25 PM#1
Mighty3k
Hi there!

I am running a For loop for creating sheeps in every 0.5 sek. But Half of the times I want to create another kind of sheep.

I was thinking that maybe I could use modulus and divied in 2 to get to see if the integer being "for-looped" is currently Even or Odd. But it doesn't seem to work..

PHP Code:
For each (Integer Afrom 0 to 80, do (Actions)
    
Loop Actions
        Wait 0.25 seconds
        Unit 
Create 1 Thihi Sheep for Neutral Hostile at (Random point in MiniGameCheapSheep <gen>) facing Default building facing degrees
        
If (All Conditions are Truethen do (Then Actions) else do (Else Actions)
            If - 
Conditions
                
((Integer Amod 2Equal to 2
            Then 
Actions
                Unit 
Create 1 Evil Sheep for Neutral Hostile at (Random point in MiniGameCheapSheep <gen>) facing Default building facing degrees
                Unit Group 
Pick every unit in (Units in MiniGameCheapSheep <gen>) and do (Unit Move (Picked unitinstantly to (Random point in MiniGameCheapSheep <gen>))
            Else - 
Actions
                
Do nothing 


thats how it loks right now...

thanks.
02-22-2004, 06:47 PM#2
ThyFlame
Please don't use those colors again, thats too hard to read.


Create a loop, for your if then use a IF integer > 40 THEN
Create sheep (type1)
Else (it'd be < 40)
Create sheep (type2)



That's a basic outline, the specifics I believe you can handle.


[edit]
Er... This should work for your purposes. Modify the values as needed.

Actiobs:
For each (Integer A) from 0 to 80, do (Actions)
If ((Random Integer number between 1 and 2) Equal to 1) then do (Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building degrees) else do (Unit - Create 1 Rifleman for Player 1 (Red) at (Center of (Playable map area)) facing Default building degrees)


Change values as needed.
02-22-2004, 07:15 PM#3
Mighty3k
Hmm.. that could work.. but it wouldn't serve my purpose 100%. I wan the "Evil Sheeps" to be created at a specifik time. Which is every time Integer A is an even number.

I use to to like this in PHP when I want every second row in a table in another color for example.

I think that it should work^^
02-22-2004, 07:26 PM#4
Cubasis
Mighty,

Use [code] instead.

But your problem lies in the modulo Comarison:

3 % 2 = 1
4 % 2 = 0

It's never "2", so compare it with either 0 or 1.

Cubasis
02-22-2004, 07:30 PM#5
Mighty3k
Oh..

Hmm.. You'r right! I think I didn't think enough :P