HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What's wrong with this trigger? (Check the entire thread)

10-20-2003, 05:08 PM#1
jan87
I need help with a trigger that first make hero (choosable by player) and then gives that unit a random item (of 2 totally).

BUT, the items should be equally created... example

Correct Example:

Item 1: 3 of this item
Item 2: 4 of this item

Item 1: 0 of this item
Item 2: 1 of this item

Incorrect Example:

Item 1: 3 of this item
Item 2: 5 of this item

Item 1: 1 of this item
Item 2: 8 of this item

I hope you understand, thank you.
10-20-2003, 05:17 PM#2
Ligature
Er... Could you clarify?

Do you mean that each time it creates an item, it should have a 50% chance of being one and a 50% chance of being the other? Or do you want it to check how many have already been created of each kind and try to balance it out? Or do you mean something entirely different? I can't really tell from your examples...
10-20-2003, 05:25 PM#3
Sagan
I hope I understood correctly...

Set IntegerVariable = Random Integer from 0 to x
If IntegerVariable mod 2 =! 1 then do
-For Each Integer A from 1 to IntegerVariable/2 doCreate item of type 1
-For Each Integer A from 1 to IntegerVariable/2 doCreate item of type 2
else do
-If random Integer from 0 to 1 equal to 1 then do
-For Each Integer A from 1 to IntegerVariable/2 + 1 doCreate item of type 1
-For Each Integer A from 1 to IntegerVariable/2 doCreate item of type 2
-else do
-For Each Integer A from 1 to IntegerVariable/2 doCreate item of type 1
-For Each Integer A from 1 to IntegerVariable/2 + 1 doCreate item of type 2

IntegerVariable is the amount of items to be created.
If there are 10 items to be created, each item should be created 5 times.
if there are 11 items to be created, one item should be created 6 times, and one should be created 5 times.
10-20-2003, 05:29 PM#4
jan87
Sagan, if that works (why shouldn't it?) I am very thankful to you!
Thank you very much!

btw, how to make that variable count the amount of players? (Because the amount of items should be the same as players)
10-20-2003, 05:32 PM#5
Ligature
But then why randomize at all? Why not just say:

create (number of total items / 2) items of type one

create (number of total items / 2) items of type two

if it's an odd number of total items to be created, create 1 random item, else do nothing

It works without all the for loops...

Edit - oops... there's no "create X items" action. Sorry, looks like you'll have to go with the for loops.
10-20-2003, 05:40 PM#6
Sagan
Quote:
Originally posted by jan87
Sagan, if that works (why shouldn't it?) I am very thankful to you!
Thank you very much!

btw, how to make that variable count the amount of players? (Because the amount of items should be the same as players)


Thats easy. Just "IntegerVariable" to the amount of players instead of a random amount.

Set IntegerVariable = total number of players matching (matching player is user and matching player is playing)
10-20-2003, 08:36 PM#7
jan87
"If modulo IntegerVariable =! 1 then do"

Kinda don't get that part of the thing... :/
10-21-2003, 02:18 PM#8
Sagan
Quote:
Originally posted by jan87
"If modulo IntegerVariable =! 1 then do"

Kinda don't get that part of the thing... :/


Jap sorry. Made an error there. I edited it to be correct. It should be "If IntegerVariable mod 2 =! 1 then do".

=! means "not equal to". Could as well be "= 0".
10-21-2003, 03:46 PM#9
jan87
Code:
Random Scroll
  Events
  Conditions
  Actions
     Set RandomItem = (Number of players)
     If (All Conditions are True) then do (Then Actions) else do (Else Actions)
     If - Conditions
        (RandomItem mod 2) Equal to 1
     Then - Actions
        For each (Integer A) from 1 to RandomItem, do (Item - Create Scroll of Earth at (Random point in (Playable map area)))
        For each (Integer A) from 1 to RandomItem, do (Item - Create Scroll of Heaven at (Random point in (Playable map area)))
     Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
     If - Conditions
        (Random integer number between 0 and 1) Equal to 1
     Then - Actions
        For each (integer A) from 1 to ((RandomItem / 2) + 1, do (Item - Create Scroll of Earth at (Random point in (Playable map area)))
        For each (integer A) from 1 to ((RandomItem / 2), do (Item - Create Scroll of Heaven at (Random point in (Playable map area)))
     Else - Actions
        For each (integer A) from 1 to ((RandomItem / 2), do (Item - Create Scroll of Earth at (Random point in (Playable map area)))
        For each (integer A) from 1 to ((RandomItem / 2) + 1, do (Item - Create Scroll of Heaven at (Random point in (Playable map area)))



Is this made right? And how do I make the items appear 1 at each starting location? :)
(Not 1 of each, just 1 item at each starting location where a playing player are located)
10-21-2003, 05:05 PM#10
Sagan
Quote:
Originally posted by jan87
Code:
Random Scroll
  Events
  Conditions
  Actions
     Set RandomItem = (Number of players)
     If (All Conditions are True) then do (Then Actions) else do (Else Actions)
     If - Conditions
        (RandomItem mod 2) Equal to 0
     Then - Actions
        For each (Integer A) from 1 to RandomItem, do (Item - Create Scroll of Earth at (Random point in (Playable map area)))
        For each (Integer A) from 1 to RandomItem, do (Item - Create Scroll of Heaven at (Random point in (Playable map area)))
     Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
     If - Conditions
        (Random integer number between 0 and 1) Equal to 1
     Then - Actions
        For each (integer A) from 1 to ((RandomItem / 2) + 1, do (Item - Create Scroll of Earth at (Random point in (Playable map area)))
        For each (integer A) from 1 to ((RandomItem / 2), do (Item - Create Scroll of Heaven at (Random point in (Playable map area)))
     Else - Actions
        For each (integer A) from 1 to ((RandomItem / 2), do (Item - Create Scroll of Earth at (Random point in (Playable map area)))
        For each (integer A) from 1 to ((RandomItem / 2) + 1, do (Item - Create Scroll of Heaven at (Random point in (Playable map area)))
Quote:
Is this made right? And how do I make the items appear 1 at each starting location? :)
(Not 1 of each, just 1 item at each starting location where a playing player are located)


Yes, almost correct. It should be
Code:
     If - Conditions
        (RandomItem mod 2) Equal to 0

To make them appear at the starting location we need to have a boolean-array-variable, and a integer-variable and do the following changes:

Code:
Random Scroll
  Events
  Conditions
  Actions
     Set RandomItem = (Number of players)
     If (All Conditions are True) then do (Then Actions) else do (Else Actions)
     If - Conditions
        (RandomItem mod 2) Equal to 1
     Then - Actions
        For each (Integer A) from 1 to RandomItem, do multiple Actions
          loop Actions:
            Set NewIntegerVariable = (Player number of (Random player from (All players matching (BooleanArray[(Player number of (Matching player))] Equal to False))))
            Item - Create Scroll of Earth at ((Player(NewIntegerVariable)) start location)
            Set BooleanArray[NewIntegerVariable] = True
        For each (Integer A) from 1 to RandomItem, do multiple Actions
          loop Actions:
            Set NewIntegerVariable = (Player number of (Random player from (All players matching (BooleanArray[(Player number of (Matching player))] Equal to False))))
            Item - Create Scroll of Heaven at ((Player(NewIntegerVariable)) start location)
            Set BooleanArray[NewIntegerVariable] = True
     Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
     If - Conditions
        (Random integer number between 0 and 1) Equal to 1
     Then - Actions
        For each (Integer A) from 1 to ((RandomItem) + 1), do multiple Actions
          loop Actions:
            Set NewIntegerVariable = (Player number of (Random player from (All players matching (BooleanArray[(Player number of (Matching player))] Equal to False))))
            Item - Create Scroll of Earth at ((Player(NewIntegerVariable)) start location)
            Set BooleanArray[NewIntegerVariable] = True
        For each (Integer A) from 1 to RandomItem, do multiple Actions
          loop Actions:
            Set NewIntegerVariable = (Player number of (Random player from (All players matching (BooleanArray[(Player number of (Matching player))] Equal to False))))
            Item - Create Scroll of Heaven at ((Player(NewIntegerVariable)) start location)
            Set BooleanArray[NewIntegerVariable] = True
     Else - Actions
        For each (Integer A) from 1 to RandomItem, do multiple Actions
          loop Actions:
            Set NewIntegerVariable = (Player number of (Random player from (All players matching (BooleanArray[(Player number of (Matching player))] Equal to False))))
            Item - Create Scroll of Earth at ((Player(NewIntegerVariable)) start location)
            Set BooleanArray[NewIntegerVariable] = True
        For each (Integer A) from 1 to ((RandomItem) + 1), do multiple Actions
          loop Actions:
            Set NewIntegerVariable = (Player number of (Random player from (All players matching (BooleanArray[(Player number of (Matching player))] Equal to False))))
            Item - Create Scroll of Heaven at ((Player(NewIntegerVariable)) start location)
            Set BooleanArray[NewIntegerVariable] = True

The BooleanArray has to be false by default.
10-21-2003, 05:21 PM#11
jan87
I must really thank you for taking the time to help me.

If you want credits in my map, what name do you want to be added in the credit section?
10-22-2003, 09:03 AM#12
Sagan
Sagan would be OK, thx.
12-15-2003, 05:56 PM#13
jan87
Player 1 get like 10+ scrolls (like 5 each) and the other players gets only 1 scroll.... but that is annoying

How to fix that Sagan? Please?