The process of creating randomness

Feralex

Active Member
Reaction score
4
Can someone be so kind and show/tell me step by step how to create randomness?
 

ReVolver

Mega Super Ultra Cool Member
Reaction score
609
I depends what you mean by randomness.. explain more...
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
What type of random you wanT?

Random unit?
Random Number?
 

Feralex

Active Member
Reaction score
4
A number cause thats like what you need? You make a variable with a number and reset that number on the variable to a random number using "Set X Variable=Random number between X and X" and then to make the action you want you create a "if variable is X then do this and that" right?
 

MoonSlinger

I Love using Cheap Tricks... only Results matters
Reaction score
74
I am not sure what kind of random number you need, so i will explain a few:

1. Chance - Critical Strikes, Bash, Axe's Helix (from DOTA)
When there is a chance a unit attacking or being attacked will experience some effects.

E: Unit - A unit Is attacked
C: (Random integer number between 1 and 100) Less than or equal to 5
A: Put in your sets of actions if trigger runs.

The condition will put a random number between 1 to 100. With a check if the random number is less then 5 means there is a 5% chance the trigger will run. To increase the chance, you can increase the value.


2. Random Spawn - Gem TD, Rune TD, Poker TD
When you "build" a unit, it will give random results. Before you use this, you need an array of "Structures" to replace the building ones; the proper towers. In case of Gem TD, it would be the gems.

E: Unit - A unit Finishes construction
C: (Unit-type of (Constructed structure)) Equal to TempTowerUnit
A: Set RandomNumber = (Random integer number between 1 and 10)
Unit - Replace (Constructed structure) with a SomeTower[RandomNumber] using The new unit's max life and mana

You can also use this method for training of units, where the player only have one button for training but random units appears when training is complete. Making random Special Effects is also possible, just make an array for it.


3. Random Pathing - Green Circle TD
When creeps reach a crossroad, they will randomly take a path down.

E: Unit - A unit enters SomeRegion
C:
A: If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random integer number between 1 and 2) Equal to 1
Then - Actions
Unit - Order (Triggering unit) to Move To NextLocation
Else - Actions
Unit - Order (Triggering unit) to Move To AnotherLocation

This is the same as part 1. Just that its used in a different scenario, but the logic is the same.
 

Jonhpath

New Member
Reaction score
2
The last one you explained, its exactely what i need! but the problem is that i need it to have 4 possible result. you think you can help me with it please? i will explain how and why i need it.

Bandits spawn at an area that is hiden this area is caled "creep moveaway" and when a bandit die he revive at this region after 1 sec. Every time a bandit enter this region i wan it to be randomly moved betweed 4 area that are "creep area1" to "creep area4" and when a unit enter one of theyse area, it will move to a random one between the 3 other (its a big forrest so all the 4 area are accessible) but wait.... i think i see how tell me if am right (i will start with the fitst trigger... when they enter the "creeo moveaway" region)

Code:
Creep Moveaway
Event
a unit enter creep moveaway

Condition
Unit-type of entering unit is equal to Bandit

Action
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random integer number between 1 and 2) Equal to 1

Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random integer number between 1 and 2) Equal to 1
Then - Actions
Unit - Order (Triggering unit) to Move To creep area1
Else - Actions
Unit - Order (Triggering unit) to Move To creep area2

Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random integer number between 1 and 2) Equal to 1
Then - Actions
Unit - Order (Triggering unit) to Move To creep area3
Else - Actions
Unit - Order (Triggering unit) to Move To creep area4

is it this that i need? and so on for the other triggers about moving to the other areas
 

MoonSlinger

I Love using Cheap Tricks... only Results matters
Reaction score
74
That would basically be what you need. However, to make it more fair, you would have to adjust slightly.

Given 4 choices, I would recommend
Random integer number between 1 and 4) Equal to 1

For the second one, there 3 choices left (the first one fail)
Random integer number between 1 and 3) Equal to 1

So you have to change the condition when the situation changes. This will ensure a fair distribution. IF you want a long mathematical explanation for that, I can provide it.

-OR-

You can also use my 2nd example using random number with an array. Just set all the target regions/points into an array and use accordingly.
 

Feralex

Active Member
Reaction score
4
Yea thanks MoonSlinger for the great explenation.
BUT i have a problem, this trigger isnt working though it like, should?
Code:
The Symphony of Frost and Fire
    Events
        Unit - Sorceror 0020 <gen> Begins casting an ability
    Conditions
        (Ability being cast) Equal to The Symphony of Frost and Fire 
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random integer number between 1 and 2) Equal to 1
            Then - Actions
                Unit - Create 1 dummy Sorceror for Neutral Extra at (Position of Sorceror 0020 <gen>) facing (Target point of ability being cast)
                Unit - Add Fire Bolt dummy  to (Last created unit)
                Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Target unit of ability being cast)
            Else - Actions
                Unit - Create 1 dummy Sorceror for Neutral Extra at (Position of Sorceror 0020 <gen>) facing (Target point of ability being cast)
                Unit - Add Frost Bolt dummy  to (Last created unit)
                Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Target unit of ability being cast)
 

Exide

I am amazingly focused right now!
Reaction score
448
You are ordering your dummies to 'Mountain King - Storm Bolt' the target.
Make sure your dummy spells were based on the Storm Bolt spell, and that they actually have the spell.
Your trigger leaks points, and 'Unit - Sorceror 0020 <gen>' is a specific unit. This spell with ONLY work for this unit.
 

Feralex

Active Member
Reaction score
4
The spell the dummies get IS stormbolt (remade one) otherwise i wouldnt order them to do that and of course the spell triggers only when Sorceror (its a hero) casts it since he is the only one with the it.
But the problem is frost bolt or fire bolt isnt cast when the Sorceror casts "The symphony of Frost and Fire" which means the condition is wrong somehow?
 

MoonSlinger

I Love using Cheap Tricks... only Results matters
Reaction score
74
I don't know how other people do things, but for me:

If I want a dummy units to use abilities like "Order unit to Human Mountain King - Storm Bolt " I would change the original spell instead of creating a new one.

Since you have two spells, I suggest editing Storm Bolt and Fire Bolt to fit the purpose. Remember to give the spells to the dummy caster.
 

Feralex

Active Member
Reaction score
4
Ok ive fixed it a bit but it seems that sometimes he doesnt cast anything as if there was a chance to do nothing, but shouldnt 1 to 2 cover 100% on this trigger?
 

Exide

I am amazingly focused right now!
Reaction score
448
@Moonslinger:
Don't remake standard settings, like units /items / spells, etc.
If you want to make two similar ones (like in this case), you can't because the standard isn't standard. :p
Instead, 'create custom ability/item/unit/buff' (whatever it might be), and order the dummy to use the ability upon which your custom one was based.

>Ok ive fixed it a bit but it seems that sometimes he doesnt cast anything as if there was a chance to do nothing, but shouldnt 1 to 2 cover 100% on this trigger?
Your random condition looks fine to me, so that shouldn't be the problem.
I still think your dummies and their abilities are the main problem.
 

Feralex

Active Member
Reaction score
4
Well, the spells ARE casted so they are functional (sometimes o_O). There seem to be (roughly) 25% chance to cast fire bolt 25% chance to cast frost bolt and 50% chance to do nothing.
The Fire bolt is a remake of Neutral - Firebolt where i just changed the mana cost, cooldown, missile art and race.
The frost bolt is a remake of Mountain Kings stormbolt, where i changed the same thing as the fire bolts.
SO whats the freakin problem?
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Post your new code here?..
Remember to add code tag to it :p

just like:
[noparse]
Code:
<YourCodeHere>
[/noparse]
 

Feralex

Active Member
Reaction score
4
Here you go mister
Code:
Symphony of Frost and Flame
    Events
        Unit - Sorceror 0020 <gen> Begins casting an ability
    Conditions
        (Ability being cast) Equal to Symphony of Frost and Flame 
    Actions
        Set SymphonyofFrostandFlametarget = (Target unit of ability being cast)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random integer number between 1 and 2) Equal to 1
            Then - Actions
                Unit - Create 1 dummy Sorceror for Neutral Extra at (Position of Sorceror 0020 <gen>) facing (Target point of ability being cast)
                Unit - Add Frost Bolt dummy  to (Last created unit)
                Unit - Order (Last created unit) to Human Mountain King - Storm Bolt SymphonyofFrostandFlametarget
            Else - Actions
                Unit - Create 1 dummy Sorceror for Neutral Extra at (Position of Sorceror 0020 <gen>) facing (Target point of ability being cast)
                Unit - Add Fire bolt dummy  to (Last created unit)
                Unit - Order (Last created unit) to Neutral - Firebolt SymphonyofFrostandFlametarget
 

Exide

I am amazingly focused right now!
Reaction score
448
Oh, by the way.
You create a dummy unit and don't remove it.
Add the Unit - Add Expiration timer, action to (Last Created Unit), with 1 second or so. (Don't make it too short or the unit won't have time to cast the spell. :p)
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>Unit - Sorceror 0020 <gen> Begins casting an ability
use Unit - <Unit> starts the effect of an ability

>>(Random integer number between 1 and 2) Equal to 1
50%?

>>for Neutral Extra
Not for (Owner of Casting Unit) ?

>>Unit - Add Frost Bolt dummy to (Last created unit)
After this line...maybe you should add a line like :

Unit - Set FrostBoltDummy to x Level..


Do the same in the Else's actions
 

Exide

I am amazingly focused right now!
Reaction score
448
>Do you mean random as in realy random like chaos random?
Random isn't as random as one may think it is...

Do this:

Code:
Untitled Trigger 001
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Animate Dead
    Actions
        Set unit = (Target unit of ability being cast)
        Set TempPoint = (Position of (Triggering unit))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random integer number between 1 and 2) Equal to 1
            Then - Actions
                Unit - Create 1 Footman for (Owner of (Triggering unit)) at TempPoint facing 270.00 degrees
                Unit - Order (Last created unit) to Human Mountain King - Storm Bolt unit
                Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
            Else - Actions
                Unit - Create 1 Footman for (Owner of (Triggering unit)) at TempPoint facing 270.00 degrees
                Unit - Order (Last created unit) to Human Mountain King - Storm Bolt unit
                Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
        Custom script:   call RemoveLocation(udg_TempPoint)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top