Hi, I need you help with my triggers; I would like to create a probability system through "dialog" for 8 players
I will give you an exemple of what I want, because I'm not able to do it alone.
I have 7 differents "unit-type" already set on variable. Then, there's a "Icon Dialog" that players can "upgrade" but I would like to add a probability system on it. 3 units type (over dialog item)
For a start SC2 uses Galaxy not Jass (the trigger language of WC3).
To do random chance you will use a Set Variable action definition to set an Integer type local variable using a Random Percent function. You will then have If Then Else action definitions that use Comparison conditions to compare the value of the variable against a Arithmetic (Integer) function of 100 minus a global variable of the Integer type which is your percent chance using a greater than or equals comparator. That way if the random value is larger than the other number it will do your desired actions. If you are storing your units in an array this process could be built into a For Each Integer loop using a second local variable of the Integer type which is used in the loop to correlate unit type with the percent chance.
For the dialogs I would use Label dialog items and Set Dialog Item Text actions that use a Combine Text function and a Convert Integer To Text function. That way you can use your variable for the percent chance to adjust what is displayed next to the fixed text for the unit type.
Rollback Post to RevisionRollBack
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
I don't really understand the first part but What I want exaclty is :
Whenever a player will click the "Dialog Item Button" this will create (from another triggers) an unit (that is already set from "Variable") en random through percent to "triggering player". This will affect next time I will build a building that is used for this.
By exemple : Whenever I will build a Bunker, it will create at random (between the % upagraded) always the available unit for this bunker... (This should not affect the currents "bunkers")
Then,
By clicking the "Dialog Item Button" it change to... Zergling = 100%, then 95%, 90%, 85% ... Baneling = 0%, then 5%, 10%, 10% ... Roach = 0%, then 0%, 0%, 5% ... Hydralisk = 0%, then 0%, 0%, 0% ...
You know you will need to set your Set Random Unit variable again each time you are spawning stuff.
Also you could have used a for each integer loop.
So you want it to always spawn something? In that case you are going to need If Then Else actions that rolls for hydralisk first else roach else baneling etc all the way to zergling.
For a start SC2 uses Galaxy not Jass (the trigger language of WC3).
Technically both StarCraft (original, 1) and Warcraft III use JASS.
One way to implement this is to use a 2D array where one index is for spawn types and the other index is for player. The sum of all unit type indices for a single player equals 100. To determine what to spawn pick a random integer between 1 and 100 (100 different possibilities). Loop through each unit type index for the player and add its chance value to an accumulator. If that accumulator is greater than or equal to the random integer that was rolled then spawn the unit (or save it to a variable to be spawned outside the loop) and break out the loop.
This works for integer probabilities and technically can even work for totals not equal to 100 as long as the appropriate random number range is used.
A more scaleable implementation would use a binary search tree to resolve which result occurred for the random number generated however for your use case a linear search should be sufficient.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hi,
I need you help with my triggers; I would like to create a probability system through "dialog" for 8 players
I will give you an exemple of what I want, because I'm not able to do it alone.
I have 7 differents "unit-type" already set on variable. Then, there's a "Icon Dialog" that players can "upgrade" but I would like to add a probability system on it.
3 units type (over dialog item)
100% - Zergling (without upgrade)
0% - Roaches
0% - Banelings
90% - Zerglings (after upgrade)
10% - Roachs
0% - Banelings
...
That will allowed a player to create a unit (at random through the probability) every x seconds.....
it's an exemple, I don't want Jass, but those on variable triggers (or another part that you could help me)
Thank you,
For a start SC2 uses Galaxy not Jass (the trigger language of WC3).
To do random chance you will use a Set Variable action definition to set an Integer type local variable using a Random Percent function. You will then have If Then Else action definitions that use Comparison conditions to compare the value of the variable against a Arithmetic (Integer) function of 100 minus a global variable of the Integer type which is your percent chance using a greater than or equals comparator. That way if the random value is larger than the other number it will do your desired actions. If you are storing your units in an array this process could be built into a For Each Integer loop using a second local variable of the Integer type which is used in the loop to correlate unit type with the percent chance.
For the dialogs I would use Label dialog items and Set Dialog Item Text actions that use a Combine Text function and a Convert Integer To Text function. That way you can use your variable for the percent chance to adjust what is displayed next to the fixed text for the unit type.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
In reply to DrSuperEvil:
What I want exaclty is :
Whenever a player will click the "Dialog Item Button" this will create (from another triggers) an unit (that is already set from "Variable") en random through percent to "triggering player". This will affect next time I will build a building that is used for this.
By exemple : Whenever I will build a Bunker, it will create at random (between the % upagraded) always the available unit for this bunker... (This should not affect the currents "bunkers")
Then,
By clicking the "Dialog Item Button" it change to...
Zergling = 100%, then 95%, 90%, 85% ...
Baneling = 0%, then 5%, 10%, 10% ...
Roach = 0%, then 0%, 0%, 5% ...
Hydralisk = 0%, then 0%, 0%, 0% ...
Gracias!
So is it working how you want?
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
You know you will need to set your Set Random Unit variable again each time you are spawning stuff.
Also you could have used a for each integer loop.
So you want it to always spawn something? In that case you are going to need If Then Else actions that rolls for hydralisk first else roach else baneling etc all the way to zergling.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
Technically both StarCraft (original, 1) and Warcraft III use JASS.
One way to implement this is to use a 2D array where one index is for spawn types and the other index is for player. The sum of all unit type indices for a single player equals 100. To determine what to spawn pick a random integer between 1 and 100 (100 different possibilities). Loop through each unit type index for the player and add its chance value to an accumulator. If that accumulator is greater than or equal to the random integer that was rolled then spawn the unit (or save it to a variable to be spawned outside the loop) and break out the loop.
This works for integer probabilities and technically can even work for totals not equal to 100 as long as the appropriate random number range is used.
A more scaleable implementation would use a binary search tree to resolve which result occurred for the random number generated however for your use case a linear search should be sufficient.