• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Help to improve this spell

Status
Not open for further replies.
Level 13
Joined
Aug 19, 2014
Messages
1,111
Hello guys I had this very simple triggered spell I made

  • Weapon Slam
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to |cffff4500Weapon Slam|r
    • Actions
      • -------- ------------------------------------------------------------------------------------------------- --------
      • -------- Getting the Spell constants --------
      • -------- ------------------------------------------------------------------------------------------------- --------
      • Set Temp_Unit = (Triggering unit)
      • Set Temp_Target = (Target unit of ability being cast)
      • Set Temp_Stats = (Strength of Temp_Unit (Include bonuses))
      • Set Temp_Ability_Level = (Level of (Ability being cast) for Temp_Unit)
      • -------- ------------------------------------------------------------------------------------------------- --------
      • -------- Setting the Spell values --------
      • -------- ------------------------------------------------------------------------------------------------- --------
      • Set Temp_Base_Value = (50.00 x (Real(Temp_Ability_Level)))
      • Set Temp_Total_Value = (Temp_Base_Value + (0.50 x (Real(Temp_Stats))))
      • -------- ------------------------------------------------------------------------------------------------- --------
      • -------- Creating and setting the dummy unit --------
      • -------- ------------------------------------------------------------------------------------------------- --------
      • Unit - Cause Temp_Unit to damage Temp_Target, dealing Temp_Total_Value damage of attack type Normal and damage type Normal
      • -------- ------------------------------------------------------------------------------------------------- --------
Its really simple right :ogre_hurrhurr: that is why I need some help from you guys to improve it.

Things I want to add in this trigger is.....

-When the hero successfully kills a unit by this ability, it will give him permanent + 1 strength. But if he kills a hero by this ability he will receive permanent + 2 strength instead.
 
Level 21
Joined
Nov 4, 2013
Messages
2,017
Trigger the damage, don't do it through object editor so that we know when the damage dealt. After that, you use if/then/else to check that if the unit is dead and was a non-hero, then you add +1 strength to the caster. If the unit is the dead and it was a hero, then add +2 strength to the caster.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
Trigger the damage, don't do it through object editor so that we know when the damage dealt. After that, you use if/then/else to check that if the unit is dead and was a non-hero, then you add +1 strength to the caster, else add +2 strength (because if it is not a unit then it must be a hero!).

He did trigger the damage

@jonbon:
I haven't tried, but can you try getting the damaged Unit's hp after the Unit Damage and see if it is the hp before or after the damage was done. I guessing it is before but I actually haven't tried it. If the hp is after, then Shadow Fury's suggestion will work.

Another possible way is to create another unit with a unique unit type and instead of Temp_unit to damage Temp_target, make it Last Created Unit damage Temp_Target.
Then create another trig with A unit dies event and if the killing unit is the unique unit-type unit, add str to your caster.
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
He did trigger the damage

@jonbon:
I haven't tried, but can you try getting the damaged Unit's hp after the Unit Damage and see if it is the hp before or after the damage was done. I guessing it is before but I actually haven't tried it. If the hp is after, then Shadow Fury's suggestion will work.

Another possible way is to create another unit with a unique unit type and instead of Temp_unit to damage Temp_target, make it Last Created Unit damage Temp_Target.
Then create another trig with A unit dies event and if the killing unit is the unique unit-type unit, add str to your caster.

Sorry Shadow Flux, I'm confuse :vw_wtf: What do you mean by ''but can you try getting the damaged Unit's hp after the Unit Damage and see if it is the hp before or after the damage was done.''


Trigger the damage, don't do it through object editor so that we know when the damage dealt. After that, you use if/then/else to check that if the unit is dead and was a non-hero, then you add +1 strength to the caster. If the unit is the dead and it was a hero, then add +2 strength to the caster.

Should I make another trigger for this? Or I'll include this one on my trigger that I posted?
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
  • Weapon Slam
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Weapon Slam
    • Actions
      • Set Temp_Unit = (Triggering unit)
      • Set Temp_Target = (Target unit of ability being cast)
      • Set Temp_Stats = (Strength of Temp_Unit (Include bonuses))
      • Set Temp_Ability_Level = (Level of Weapon Slam for Temp_Unit)
      • Set Temp_Base_Value = (50.00 x (Real(Temp_Ability_Level)))
      • Set Temp_Total_Value = (Temp_Base_Value + (0.50 x (Real(Temp_Stats))))
      • Unit - Cause Temp_Unit to damage Temp_Target, dealing Temp_Total_Value damage of attack type Normal and damage type Normal
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of Temp_Target) Less than 0.41
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Temp_Target is A Hero) Equal to True
            • Then - Actions
              • Hero - Modify Strength of Temp_Unit: Add 2
            • Else - Actions
              • Hero - Modify Strength of Temp_Unit: Add 1
        • Else - Actions
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
Hello guys I have another triggered ability and this time its passive, it activates when the hero uses his spells.

  • Battle Born
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to |cffff4500Warcry|r
          • (Ability being cast) Equal to |cffff4500Weapon Slam|r
    • Actions
      • -------- ------------------------------------------------------------------------------------------------- --------
      • -------- Getting the Spell constants --------
      • -------- ------------------------------------------------------------------------------------------------- --------
      • Set Temp_Unit = (Triggering unit)
      • Set Temp_Location = (Position of Temp_Unit)
      • Set TempPlayer = (Owner of Temp_Unit)
      • Set TempAbility = Battle Born (Dummy Ability)
      • -------- ------------------------------------------------------------------------------------------------- --------
      • -------- Creating and setting the dummy unit --------
      • -------- ------------------------------------------------------------------------------------------------- --------
      • Unit - Create 1 Dummy for TempPlayer at Temp_Location facing Default building facing degrees
      • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
      • Unit - Add TempAbility to (Last created unit)
      • Unit - Order (Last created unit) to Human Priest - Inner Fire Temp_Unit
      • -------- ------------------------------------------------------------------------------------------------- --------
      • -------- Clearing Leaks --------
      • -------- ------------------------------------------------------------------------------------------------- --------
      • Custom script: call RemoveLocation(udg_Temp_Location)
My question is how can I make this passive ability to cooldown after the hero uses an ability which activate this passive ability?
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
Requirement: Unit Indexer
Use an Array Boolean in your spell trigger. After you cast it, set it true. After some time, Turn it to false.

Easy ha?

Hi Sir Arad MNK, I just putted Bribe's Unit Indexer in my map. However its my first time to use a library and I'm having troubles which trigger I should attach in my triggered spell.

  • Unit Indexer
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call ExecuteFunc("InitializeUnitIndexer")
      • Custom script: endfunction
      • -------- --------
      • -------- This is the most important function - it provides an index for units as they enter the map --------
      • -------- --------
      • Custom script: function IndexUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • -------- --------
      • -------- You can use the boolean UnitIndexerEnabled to protect some of your undesirable units from being indexed --------
      • -------- - Example: --------
      • -------- -- Set UnitIndexerEnabled = False --------
      • -------- -- Unit - Create 1 Dummy for (Triggering player) at TempLoc facing 0.00 degrees --------
      • -------- -- Set UnitIndexerEnabled = True --------
      • -------- --------
      • -------- You can also customize the following block - if conditions are false the (Matching unit) won't be indexed. --------
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UnitIndexerEnabled Equal to True
        • Then - Actions
          • -------- --------
          • -------- Generate a unique integer index for this unit --------
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UDexRecycle Equal to 0
            • Then - Actions
              • Set UDex = (UDexGen + 1)
              • Set UDexGen = UDex
            • Else - Actions
              • Set UDex = UDexRecycle
              • Set UDexRecycle = UDexNext[UDex]
          • -------- --------
          • -------- Link index to unit, unit to index --------
          • -------- --------
          • Set UDexUnits[UDex] = (Matching unit)
          • Unit - Set the custom value of UDexUnits[UDex] to UDex
          • -------- --------
          • -------- Use a doubly-linked list to store all active indexes --------
          • -------- --------
          • Set UDexPrev[UDexNext[0]] = UDex
          • Set UDexNext[UDex] = UDexNext[0]
          • Set UDexNext[0] = UDex
          • -------- --------
          • -------- Fire index event for UDex --------
          • -------- --------
          • Set UnitIndexEvent = 0.00
          • Set UnitIndexEvent = 1.00
          • Set UnitIndexEvent = 0.00
          • Custom script: set udg_UDex = pdex
        • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • -------- --------
      • -------- The next function is called each time a unit enters the map --------
      • -------- --------
      • Custom script: function IndexNewUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Custom script: local integer ndex
      • -------- --------
      • -------- Recycle indices of units no longer in-play every (15) units created --------
      • -------- --------
      • Set UDexWasted = (UDexWasted + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UDexWasted Equal to 15
        • Then - Actions
          • Set UDexWasted = 0
          • Set UDex = UDexNext[0]
          • Custom script: loop
          • Custom script: exitwhen udg_UDex == 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of UDexUnits[UDex]) Equal to 0
            • Then - Actions
              • -------- --------
              • -------- Remove index from linked list --------
              • -------- --------
              • Custom script: set ndex = udg_UDexNext[udg_UDex]
              • Custom script: set udg_UDexNext[udg_UDexPrev[udg_UDex]] = ndex
              • Custom script: set udg_UDexPrev[ndex] = udg_UDexPrev[udg_UDex]
              • Set UDexPrev[UDex] = 0
              • -------- --------
              • -------- Fire deindex event for UDex --------
              • -------- --------
              • Set UnitIndexEvent = 2.00
              • Set UnitIndexEvent = 0.00
              • -------- --------
              • -------- Recycle the index for later use --------
              • -------- --------
              • Set UDexUnits[UDex] = No unit
              • Set UDexNext[UDex] = UDexRecycle
              • Set UDexRecycle = UDex
              • Custom script: set udg_UDex = ndex
            • Else - Actions
              • Set UDex = UDexNext[UDex]
          • Custom script: endloop
          • Custom script: set udg_UDex = pdex
        • Else - Actions
      • -------- --------
      • -------- Handle the entering unit (Matching unit) --------
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Custom value of (Matching unit)) Equal to 0
        • Then - Actions
          • Custom script: call IndexUnit()
        • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • -------- --------
      • -------- The next function initializes the core of the system --------
      • -------- --------
      • Custom script: function InitializeUnitIndexer takes nothing returns nothing
      • Custom script: local integer i = 0
      • Custom script: local region re = CreateRegion()
      • Custom script: local rect r = GetWorldBounds()
      • Set UnitIndexerEnabled = True
      • Custom script: call RegionAddRect(re, r)
      • Custom script: call TriggerRegisterEnterRegion(CreateTrigger(), re, Filter(function IndexNewUnit))
      • Custom script: call RemoveRect(r)
      • Custom script: set re = null
      • Custom script: set r = null
      • Custom script: loop
      • Custom script: call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, Player(i), Filter(function IndexUnit))
      • Custom script: set i = i + 1
      • Custom script: exitwhen i == 16
      • Custom script: endloop
      • -------- --------
      • -------- This is the "Unit Indexer Initialized" event, use it instead of "Map Initialization" for best results --------
      • -------- --------
      • Set UnitIndexEvent = 3.00
      • Set UnitIndexEvent = 0.00
It is really complicated just by looking at those triggers :ogre_hurrhurr:
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You just place that trigger inside your map.
Then you have the Unit Indexer installed which means that you can use its features.

Then you create a boolean array global variable.
Inside the spell, you check if that boolean under the index of the custom value of the unit is equal to true. If so, you apply the effect.
You also set that boolean to true.
Then you would require a timer or just a timed wait and set the boolean to false again.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
Sorry for being off topic but I feel the need to say this:

Hashtables are slightly slower than Indexes, But Indexes have a 8192 Limit I Think.
Hashtables are indeed quite slow compared to arrays.
And arrays have a 8191 limit... because when you load something from the 8191st index (the 8192nd) then it sometimes crashes the game.
But I pref arrays anyway.

As far as I know,
Hashtable: O(1) + some constant
Array: O(1)

But since it will only check at each cast, it is negligible. Plus, the unit indexer consumes CPU resources too.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
As far as you know?
Array = load from variable using index.
Hashtable = load hashtable object, find parent in list of parents, find child in list of childs, return stored value.

That's why I said O(1) + some constant.
Like i mentioned earlier, if he would use hashtable, the speed difference won't matter because it only runs on each cast not periodically.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Hashtable and arrays have different benefits. Usually the difference comes from a situation where you would need to loop through an array to find the object that you want. The complexity would be O(n) as each additional unit in the array increases the average looping time. However by using a hashtable, you can get the thing you want by using a single action and the complexity is O(1).
 
Status
Not open for further replies.
Top