• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Help with Random Summoning Spell

Status
Not open for further replies.
Level 6
Joined
Aug 26, 2007
Messages
107
The spell is supposed to cast a random level 1 summoning spell. Instead of casting 1, it casts all of them. This is the trigger.
  • Event: A unit casts an ability.
  • Conditions: Ability being cast = to (Randomness).
  • Actions:
  • For each (Integer A) from 1 to 19, do (Actions).
  • Loop - Actions
  • In ((Integer A) Equal to 1) then do (Unit - Create 1 Infernal for (Owner of (Casting unit)) at (Position of (Casting unit)) else do (If ((Integer A) Equal to 2 or 3) then do (Unit create 1 Water elemental) for owner of casting unit at position of casting unit.
The trigger keeps continuing on until all of the units can be summoned. But it summons all of them instead of just 1.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Animate Dead
    • Actions
      • Set CastLoc = (Position of (Triggering unit))
        • Multiple Functions 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 CastLoc facing Default building facing (270.0) degrees
          • Else - Actions
            • Unit - Create 1 Knight for (Owner of (Triggering unit)) at CastLoc facing Default building facing (270.0) degrees
      • Custom script: call RemoveLocation(udg_CastLoc)
CastLoc is a global variable point.
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
Yes.
It is a condition.
Integer comparison.
Math - Random Number.
This trigger is only for two units with a 50% chance of summoning exactly one of them.
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
Well you can set it like this:
  • Untitled Trigger 001
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Animate Dead
  • Actions
    • Set CastLoc = (Position of (Triggering unit))
    • Set RndInt = Random integer number between 1 and x
    • Multiple Functions If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • RndInt Equal to 1
      • Then - Actions
        • Unit - Create 1 *Summon1* for (Owner of (Triggering unit)) at CastLoc facing Default building facing (270.0) degrees
      • Else - Actions
        • Multiple Functions If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • RndInt Equal to 2
          • Then - Actions
            • Unit - Create 1 *Summon2* for (Owner of (Triggering unit)) at CastLoc facing Default building facing (270.0) degrees
          • Else - Actions
            • Multiple Functions If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • RndInt Equal to 3
          • Then - Actions
          • blah
  • Custom script: call RemoveLocation(udg_CastLoc)
This way, a unit is summoned randomly, whereas RndInt is an integer variable, x is the maximum amount of summons you want to include.
Of course, you have to do the sub-if/then/else for each unit you want to summon ;)
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
As I said I made the trigger for 2 types of summons.
As you original trigger summoned as much.
With this trigger a little bit of custom script would be quite useful:
Custom Script: if(udg_RndInt==1) then
You put your GUI actions here
Custom Script: elseif (udg_RndInt==2) then
You put your GUI actions here
Custom Script: elseif (udg_RndInt==3) then
You put your GUI actions here
Custom Script: elseif (udg_RndInt==4) then
You put your GUI actions here
Custom Script: elseif (udg_RndInt==5) then
You put your GUI actions here
Custom Script: endif
This way u can easily add more variations ;)
 
Status
Not open for further replies.
Top