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

Need help with a selfmade Spell (Freezing Area)

Status
Not open for further replies.
Level 10
Joined
Mar 30, 2009
Messages
255
hi.
well i tried to make a GUI spell on my own... yeah i pretty much suck at triggering but i just wanted to create something for public...

so i though: "hey make a spellpack" ... ^^

i beg you guys to look through my code, and help me to optimize it (since i know its pretty shitty coded)

also look at it ingame please.

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Freezing Area
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • FA_i1 Less than or equal to 0
      • Then - Actions
        • Trigger - Turn on Freezing Area loop <gen>
      • Else - Actions
    • -------- ------------------------------ Setups ------------------------------ --------
    • Set FA_i1 = (FA_i1 + 1)
    • Set FA_i2 = (FA_i2 + 1)
    • Set FA_Caster[FA_i2] = (Triggering unit)
    • -------- -------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
    • -------- ------------------------------ Sets the Damage dealt per second ------------------------------ --------
    • Set FA_DamagePerSecond[FA_i2] = (10.00 x (Real((Level of (Ability being cast) for FA_Caster[FA_i2]))))
    • -------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
    • -------- ------------------------------ How long should the spell last? set it here! ------------------------------ --------
    • Set FA_SpellDuration[FA_i2] = (7.00 x (Real((Level of (Ability being cast) for FA_Caster[FA_i2]))))
    • -------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
    • Set FA_LoopOn[FA_i2] = True
  • Events
    • Time - Every 0.05 seconds of game time
  • Conditions
  • Actions
    • For each (Integer FA_i3) from 1 to FA_i2, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • FA_LoopOn[FA_i3] Equal to True
          • Then - Actions
            • Set FA_WaitCounter[FA_i3] = (FA_WaitCounter[FA_i3] + 0.05)
            • Set FA_WaitCounter_2[FA_i3] = (FA_WaitCounter_2[FA_i3] + 0.05)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • FA_WaitCounter[FA_i3] Less than or equal to FA_SpellDuration[FA_i3]
              • Then - Actions
                • Set FA_PointIndex[FA_i3] = (Position of FA_Caster[FA_i3])
                • -------- ------------------------------ Clearing Leaks ------------------------------ --------
                • Custom script: set bj_wantDestroyGroup = true
                • -------- ------------------------------------------------------------------------------------------------------ --------
                • -------- ------------------------------ Damage ------------------------------ --------
                • -------- ------------------------------------------------------------------------------------------------------ --------
                • -------- ------------------------------ Slowing Dummies ------------------------------ --------
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • FA_WaitCounter_2[FA_i3] Greater than or equal to 1.00
                  • Then - Actions
                    • Custom script: set bj_wantDestroyGroup = true
                    • Unit Group - Pick every unit in (Units within 800.00 of FA_PointIndex[FA_i3] matching ((((Matching unit) belongs to an enemy of (Owner of FA_Caster[FA_i3])) Equal to True) and ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching and do (Actions)
                      • Loop - Actions
                        • Unit - Cause FA_Caster[FA_i3] to damage (Picked unit), dealing FA_DamagePerSecond[FA_i3] damage of attack type Spells and damage type Normal
                        • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
                        • Special Effect - Destroy (Last created special effect)
                        • Unit - Create 1 FA_Dummy for (Owner of FA_Caster[FA_i3]) at FA_PointIndex[FA_i3] facing Default building facing (270.0) degrees
                        • Unit - Order (Last created unit) to Attack (Picked unit)
                        • Unit - Add a 0.75 second Generic expiration timer to (Last created unit)
                        • Custom script: call RemoveLocation(udg_FA_PointIndex[udg_FA_i3])
                        • Set FA_WaitCounter_2[FA_i3] = 0.00
                  • Else - Actions
                • -------- ------------------------------------------------------------------------------------------------------ --------
                • For each (Integer FA_i4) from 1 to 3, do (Actions)
                  • Loop - Actions
                    • Set FA_PointIndex[FA_i3] = (Position of FA_Caster[FA_i3])
                    • Set FA_Region[FA_i3] = (Rect centered at FA_PointIndex[FA_i3] with size (800.00, 800.00))
                    • Set FA_PointIndex[FA_i4] = (Random point in FA_Region[FA_i3])
                    • Special Effect - Create a special effect at FA_PointIndex[FA_i4] using Abilities\Spells\Undead\FrostArmor\FrostArmorDamage.mdl
                    • Special Effect - Destroy (Last created special effect)
                    • Custom script: call RemoveLocation(udg_FA_PointIndex[udg_FA_i3])
                    • Custom script: call RemoveRect (udg_FA_Region[udg_FA_i3])
              • Else - Actions
                • Custom script: call RemoveLocation(udg_FA_PointIndex[udg_FA_i3])
                • Set FA_WaitCounter[FA_i3] = 0.00
                • Set FA_LoopOn[FA_i3] = False
                • Set FA_i1 = (FA_i1 - 1)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • FA_i1 Less than or equal to 0
                  • Then - Actions
                    • Set FA_i2 = 0
                    • Trigger - Turn off (This trigger)
                  • Else - Actions
          • Else - Actions
Edit: fixed the leaks... someone may know how to improve the sfx? (i made it with the region.. i think it kinda sucks...)

i will give rep and credits...

im glad to learn :)
 

Attachments

  • Spellpack by VoidLordXtreme.w3x
    17.3 KB · Views: 30
Last edited:
  • (Position of FA_Caster[FA_i3])
You leak a point there.

  • Set FA_PointIndex[FA_i3] = (Position of FA_Caster[FA_i3])
  • Custom script: call RemoveLocation(udg_FA_PointIndex[1])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[2])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[3])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[4])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[5])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[6])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[7])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[8])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[9])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[10])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[11])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[12])
    • Custom script: call RemoveLocation(udg_FA_PointIndex[13])
You don't remove it properly. It should look like this:
  • Set FA_PointIndex[FA_i3] = (Position of FA_Caster[FA_i3])
  • Custom script: call RemoveLocation(udg_FA_PointIndex[udg_FA_i3])
  • (Rect centered at FA_PointIndex[FA_i3] with size (800.00, 800.00)))
Also leaks. Create a Region variable and store it before you use it. Then, remove it as:
  • Custom script: call RemoveRect (udg_Region'sNameVariable)
 
Level 11
Joined
Jan 25, 2009
Messages
572
Tr to not use a BJ as you are doing here in spells. You can use it in example, map init but not in spells or systems. Just because BJ´s are really slow. If you would use a variable for the unit group instead of a BJ it would be much smoother. Also, as what i've been told, you don't need to have the "FA_i3" on points that is being use and destroyed in the same trigger when you use Indexing. And also, you don't need to have the "FA_i3" if you redo the BJ with a group variable, you don't need to have like this:
  • Set FA_Group[udg_FA_i3] = Units within 800.... blablabla
The one above is wrong, use this if the group is only in the loop trigger.
  • Set FA_Group[1] = Units withing 800.... blablabla
This one above is correct. You don't need to use a array for that if you just going to use one unit group but if you're going to use more than 2 you should use an array for the group.

Hopes this helped some. Contact me if it being bugs or something. Also, we're on the same stage in triggering ;) I see much in me when i look at you'r scripting xD
 
Status
Not open for further replies.
Top