• 🏆 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!

[Trigger] Converting MPI spell into MUI spell

Status
Not open for further replies.
Level 20
Joined
Oct 21, 2006
Messages
3,231
At the moment my spell is MPI (multi-player-instancable?) but I need it to be MUI. (multi-unit-instancable?) I know it has something to do with integers and custom values, but I never created a real MUI spell so I dont have the idea..

  • Frostbolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt
    • Actions
      • Set Point1 = (Position of (Triggering unit))
      • Set Point2 = (Position of (Target unit of ability being cast))
      • Unit - Create 1 Dummy - Frostbolt for (Owner of (Triggering unit)) at Point1 facing Point2
      • -------- ---------- --------
      • Set Frostbolt[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
      • Set Frostbolt_Target[(Player number of (Owner of (Triggering unit)))] = (Target unit of ability being cast)
  • Frostbolt loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Point1 = (Position of Frostbolt[(Integer A)])
          • Set Point2 = (Point1 offset by 20.00 towards (Facing of Frostbolt[(Integer A)]) degrees)
          • Set Frostbolt_Position[(Integer A)] = (Position of Frostbolt_Target[(Integer A)])
          • Unit - Move Frostbolt[(Integer A)] instantly to Point2, facing Frostbolt_Position[(Integer A)]
          • -------- ---------- --------
          • Set UnitGroup1 = (Units within 50.00 of Point1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of Frostbolt[(Integer A)])) Equal to True))))
          • Set UnitGroup2 = (Random 1 units from UnitGroup1)
          • Unit Group - Pick every unit in UnitGroup2 and do (Actions)
            • Loop - Actions
              • Unit - Order Frostbolt[(Integer A)] to Undead Lich - Frost Nova (Picked unit)
I know it leaks because I havent removed the positions and blabla, but I just havent done it yet, so dont come here to say "onoes it leaks".

I also uploaded the map so you can look around it...
 

Attachments

  • Arena-project.w3x
    64.4 KB · Views: 34
Level 37
Joined
Mar 6, 2006
Messages
9,240
How's this:

  • Frostbolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt
    • Actions
      • Set Point1 = (Position of (Triggering unit))
      • Set Point2 = (Position of (Target unit of ability being cast))
      • Set Temp_Unit1 = (Target unit of ability being cast)
      • -------- ---------- --------
      • Set Temp_Real1 = (Angle from Point1 to Point2)
      • -------- Base damage of the spell --------
      • Set Temp_Real2 = 100.00
      • -------- Bonus damage multiplier --------
      • Set Temp_Integer1 = (Level of (Ability being cast) for (Triggering unit))
      • -------- For crit chance --------
      • Set Temp_Integer2 = ((Level of (Triggering unit)) x 10)
      • -------- ---------- --------
      • Unit - Create 1 Dummy - Frostbolt for (Owner of (Triggering unit)) at Point1 facing Point2
      • Set Temp_Unit2 = (Last created unit)
      • Unit Group - Add (Last created unit) to Frostbolt_Bolts
      • -------- ---------- --------
      • Hashtable - Save Temp_Real1 as (Key Angle) of (Key (Last created unit)) in HashFrostbolt
      • Hashtable - Save Temp_Real2 as (Key Damage) of (Key (Last created unit)) in HashFrostbolt
      • Hashtable - Save Temp_Integer1 as (Key Level) of (Key (Last created unit)) in HashFrostbolt
      • Hashtable - Save Temp_Integer2 as (Key Crit) of (Key (Last created unit)) in HashFrostbolt
      • Hashtable - Save Handle OfTemp_Unit1 as (Key Target) of (Key (Last created unit)) in HashFrostbolt
      • Hashtable - Save Handle OfTemp_Unit2 as (Key Bolt) of (Key (Last created unit)) in HashFrostbolt
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Frostbolt loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Frostbolt loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Point1)
      • Custom script: call RemoveLocation(udg_Point2)
  • Frostbolt loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Frostbolt_Bolts and do (Actions)
        • Loop - Actions
          • -------- ---------- --------
          • Set Temp_Unit1 = (Load (Key Target) of (Key (Picked unit)) in HashFrostbolt)
          • Set Temp_Unit2 = (Picked unit)
          • Set Temp_Integer1 = (Load (Key Level) of (Key (Picked unit)) from HashFrostbolt)
          • Set Temp_Integer2 = (Load (Key Crit) of (Key (Picked unit)) from HashFrostbolt)
          • Set Temp_Real1 = (Load (Key Angle) of (Key (Picked unit)) from HashFrostbolt)
          • Set Temp_Real2 = (Load (Key Damage) of (Key (Picked unit)) from HashFrostbolt)
          • -------- ---------- --------
          • Set Point1 = (Position of (Picked unit))
          • Set Point2 = (Point1 offset by 20.00 towards Temp_Real1 degrees)
          • Set Point3 = (Position of Temp_Unit1)
          • -------- ---------- --------
          • Unit - Move (Picked unit) instantly to Point2, facing Point3
          • -------- ---------- --------
          • Set UnitGroup1 = (Units within 50.00 of Point1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of (Picked unit))) Equal to True))))
          • Set UnitGroup2 = (Random 1 units from UnitGroup1)
          • Unit Group - Pick every unit in UnitGroup2 and do (Actions)
            • Loop - Actions
              • Set Temp_Real2 = (Temp_Real2 + ((Real(Temp_Integer1)) x 100.00))
              • Set Damage_DefaultColors = False
              • Set Damage_Text_Color1Red = 100.00
              • Set Damage_Text_Color2Green = 100.00
              • Set Damage_Text_Color3Blue = 0.00
              • Set Damage_Text_Color4Trans = 0.00
              • -------- ---------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random real number between 0.00 and 100.00) Less than or equal to (Real(Temp_Integer2))
                • Then - Actions
                  • Set Damage_Critical = True
                  • Set Temp_Real2 = (Temp_Real2 + Temp_Real2)
                • Else - Actions
                  • Set Damage_Critical = False
              • -------- ---------- --------
              • Unit - Order Temp_Unit2 to Undead Lich - Frost Nova (Picked unit)
              • Unit - Cause Temp_Unit2 to damage (Picked unit), dealing Temp_Real2 damage of attack type Spells and damage type Normal
              • Set Damage_DefaultColors = True
              • Unit Group - Remove Temp_Unit2 from Frostbolt_Bolts
              • Hashtable - Clear all child hashtables of child (Key Bolt) in HashFrostbolt
              • Unit - Remove Temp_Unit2 from the game
              • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Frostbolt_Bolts is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Point1)
      • Custom script: call RemoveLocation(udg_Point2)
      • Custom script: call RemoveLocation(udg_Point3)
      • Custom script: call DestroyGroup(udg_UnitGroup1)
      • Custom script: call DestroyGroup(udg_UnitGroup2)
I have a bit of a hangover & headache but I hope it turned out ok. It seemed to work.

Now that I think of it, you should do the damage calculation in Frostbolt, and not in Frostbolt loop, and pass that number to Frostbolt loop.
 

Attachments

  • Arena-project.w3x
    67 KB · Views: 50
Level 20
Joined
Oct 21, 2006
Messages
3,231
Nah I figured out how to make MUI spell with custom values and made it by myself.

  • Frostbolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt
    • Actions
      • Set Point1 = (Position of (Triggering unit))
      • Set Point2 = (Position of (Target unit of ability being cast))
      • -------- ---------- --------
      • Set Frostbolt_Total = (Frostbolt_Total + 1)
      • -------- ---------- --------
      • Unit - Create 1 Dummy - Frostbolt for (Owner of (Triggering unit)) at Point1 facing Point2
      • Unit - Set the custom value of (Last created unit) to Frostbolt_Total
      • Unit Group - Add (Last created unit) to Frostbolt_UnitGroup
      • -------- ---------- --------
      • Set Frostbolt_Missile[Frostbolt_Total] = (Last created unit)
      • Set Frostbolt_Target[Frostbolt_Total] = (Target unit of ability being cast)
      • -------- ---------- --------
      • Custom script: call RemoveLocation(udg_Point1)
      • Custom script: call RemoveLocation(udg_Point2)
  • Frostbolt loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Frostbolt_UnitGroup and do (Actions)
        • Loop - Actions
          • Set Temp_Integer = (Player number of (Owner of (Picked unit)))
          • Set Temp_Unit = (Picked unit)
          • -------- ---------- --------
          • Set Point1 = (Position of (Picked unit))
          • Set Point2 = (Position of Frostbolt_Target[(Custom value of (Picked unit))])
          • Set Point3 = (Point1 offset by 3.00 towards (Angle from Point1 to Point2) degrees)
          • Unit - Move (Picked unit) instantly to Point3, facing Point2
          • -------- ---------- --------
          • Set UnitGroup1 = (Units within 50.00 of Point1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of (Picked unit))) Equal to True))))
          • Set UnitGroup2 = (Random 1 units from UnitGroup1)
          • Unit Group - Pick every unit in UnitGroup2 and do (Actions)
            • Loop - Actions
              • Set Temp_Real = (100.00 x (Real((Level of Frostbolt for Hero[Temp_Integer]))))
              • Set Temp_Real = (Temp_Real + (Real(Spell_Damage[Temp_Integer])))
              • Set Damage_DefaultColors = False
              • Set Damage_Text_Color1Red = 100.00
              • Set Damage_Text_Color2Green = 100.00
              • Set Damage_Text_Color3Blue = 0.00
              • Set Damage_Text_Color4Trans = 0.00
              • -------- ---------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random real number between 0.00 and 100.00) Less than or equal to Spell_Critical[Temp_Integer]
                • Then - Actions
                  • Set Damage_Critical = True
                  • Set Temp_Real = (Temp_Real + Temp_Real)
                • Else - Actions
                  • Set Damage_Critical = False
              • -------- ---------- --------
              • Unit - Order Temp_Unit to Undead Lich - Frost Nova (Picked unit)
              • Unit - Cause Temp_Unit to damage (Picked unit), dealing Temp_Real damage of attack type Spells and damage type Normal
              • Set Damage_DefaultColors = True
              • Unit - Remove Temp_Unit from the game
              • -------- ---------- --------
          • Custom script: call RemoveLocation(udg_Point1)
          • Custom script: call RemoveLocation(udg_Point2)
          • Custom script: call RemoveLocation(udg_Point3)
          • Custom script: call DestroyGroup(udg_UnitGroup1)
          • Custom script: call DestroyGroup(udg_UnitGroup2)
btw is it faster to use Temp_Unit (variable) or Picked Unit? Anyway, I'll give u rep for ur headache...
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
Err, nevermind that, hashtables are better.

The unit's handle id is unique, and using that as a parent key in a hashtable you can save reals, locations, integers... (basically anything) in a well organized way. Plus, arrays can only be up to 8192, while the hashtable has no limit.
 
Status
Not open for further replies.
Top