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

[Trigger] Dummy to Caster Detection

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2010
Messages
312
I was wondering if there was any way to detect when a dummy kills a unit for it's caster, how would I then go about doing triggers for the casting unit?

I realize i'm not the best at making clean, efficient triggers so don't tell me how I can improve the triggers below, that's not what I'm asking help for.

  • V Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- --------------------------------------------------------------------------------------------- --------
      • -------- Set this to how many kills you want before a bonus is given! --------
      • Set V_KillLimit = 3
      • -------- --------------------------------------------------------------------------------------------- --------
      • -------- Add units below that you don't want to have a ranking! --------
      • Set V_BlockedUnit[1] = Knight
      • Set V_BlockedUnit[2] = Mortar Team
      • -------- Set this number to the total amount of units you are blocking! --------
      • Set V_AmountBlockedUnits = 2
      • -------- --------------------------------------------------------------------------------------------- --------
      • Set V_Abilities[1] = Bear Form
      • Set V_Abilities[2] = Berserker Upgrade
      • Set V_Abilities[3] = Burrow (Crypt Fiend)
      • Set V_Abilities[4] = Corporeal Form
      • Set V_Abilities[5] = Crow Form
      • Set V_Abilities[6] = Destroyer Form
      • Set V_Abilities[7] = Metamorphosis
      • Set V_Abilities[8] = Phoenix Morphing (Egg Related)
      • Set V_Abilities[9] = Stone Form
      • Set V_Abilities[10] = Storm Crow Form
      • Set V_Abilities[11] = Submerge (Myrmidon)
      • Set V_Abilities[12] = Submerge (Royal Guard)
      • Set V_Abilities[13] = Submerge (Snap Dragon)
      • Set V_AbilitiesAmount = 13
      • Hashtable - Create a hashtable
      • Set V_Hashtable = (Last created hashtable)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A structure) Not equal to True)) and do (Actions)
        • Loop - Actions
          • Set V_Unit = (Picked unit)
          • For each (Integer A) from 1 to V_AmountBlockedUnits, do (Actions)
            • Loop - Actions
              • If ((Unit-type of V_Unit) Equal to V_BlockedUnit[(Integer A)]) then do (Skip remaining actions) else do (Do nothing)
          • Set V_HashUnit = (Key (Picked unit))
          • Hashtable - Save 0 as 0 of V_HashUnit in V_Hashtable
          • Unit - Add Rank (Dummy) to V_Unit
          • Unit - Add V_Damage Bonus to V_Unit
          • Unit - Add V_Armor Bonus to V_Unit
  • V Created Units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Set V_HashUnit = (Key (Triggering unit))
      • Set V_Unit = (Triggering unit)
      • For each (Integer A) from 1 to V_AmountBlockedUnits, do (Actions)
        • Loop - Actions
          • If (((Unit-type of V_Unit) Equal to V_BlockedUnit[(Integer A)]) or ((V_Unit is A structure) Equal to True)) then do (Skip remaining actions) else do (Do nothing)
      • Hashtable - Save 0 as 0 of V_HashUnit in V_Hashtable
      • Unit - Add Rank (Dummy) to V_Unit
      • Unit - Add V_Damage Bonus to V_Unit
      • Unit - Add V_Armor Bonus to V_Unit
  • V Start Ability
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • For each (Integer A) from 1 to V_AbilitiesAmount, do (Actions)
        • Loop - Actions
          • If ((Ability being cast) Equal to V_Abilities[(Integer A)]) then do (Do nothing) else do (Skip remaining actions)
          • Set V_AbilityUnit = (Triggering unit)
          • Set V_RankLevel = (Level of Rank (Dummy) for V_AbilityUnit)
  • V End Ability
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
    • Actions
      • For each (Integer A) from 1 to V_AbilitiesAmount, do (Actions)
        • Loop - Actions
          • If ((Ability being cast) Equal to V_Abilities[(Integer A)]) then do (Do nothing) else do (Skip remaining actions)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Rank (Dummy) for V_AbilityUnit) Less than 1
            • Then - Actions
              • Unit - Add Rank (Dummy) to V_AbilityUnit
              • Unit - Set level of Rank (Dummy) for V_AbilityUnit to V_RankLevel
              • Unit - Add V_Damage Bonus to V_AbilityUnit
              • Unit - Set level of V_Armor Bonus for V_AbilityUnit to V_RankLevel
              • Unit - Add V_Armor Bonus to V_AbilityUnit
              • Unit - Set level of V_Damage Bonus for V_AbilityUnit to V_RankLevel
              • If (V_RankLevel Greater than or equal to 5) then do (Unit - Add V_Level 5 to V_AbilityUnit) else do (Do nothing)
              • If (V_RankLevel Greater than or equal to 10) then do (Unit - Add V_Level 10 to V_AbilityUnit) else do (Do nothing)
              • If (V_RankLevel Equal to 15) then do (Unit - Add V_Level 15 to V_AbilityUnit) else do (Do nothing)
            • Else - Actions
  • V Record
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set V_Unit = (Triggering unit)
      • Unit - Remove V_Level 5 from V_Unit
      • Unit - Remove V_Level 10 from V_Unit
      • Unit - Remove V_Level 15 from V_Unit
      • Set V_Killer = (Killing unit)
      • Set V_HashUnit = (Key (Killing unit))
      • Set V_RankKills = ((Load 0 of V_HashUnit from V_Hashtable) + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • V_RankKills Equal to V_KillLimit
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Level of Rank (Dummy) for V_Killer) Greater than 0) and ((Level of Rank (Dummy) for V_Killer) Less than 15)
            • Then - Actions
              • Unit - Increase level of Rank (Dummy) for V_Killer
              • Unit - Increase level of V_Armor Bonus for V_Killer
              • Unit - Increase level of V_Damage Bonus for V_Killer
              • Special Effect - Create a special effect attached to the origin of V_Killer using Abilities\Spells\Items\AIre\AIreTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • If ((Level of Rank (Dummy) for V_Killer) Equal to 5) then do (Unit - Add V_Level 5 to V_Killer) else do (Do nothing)
              • If ((Level of Rank (Dummy) for V_Killer) Equal to 10) then do (Unit - Add V_Level 10 to V_Killer) else do (Do nothing)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Rank (Dummy) for V_Killer) Equal to 15
                • Then - Actions
                  • Unit - Remove V_Level 10 from V_Killer
                  • Unit - Add V_Level 15 to V_Killer
                • Else - Actions
              • Set V_RankKills = ((Load 0 of V_HashUnit from V_Hashtable) - V_KillLimit)
            • Else - Actions
        • Else - Actions
      • Hashtable - Save V_RankKills as 0 of V_HashUnit in V_Hashtable
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
If the skills is MPI you just index the heroes and use the player number to detect it as damage source (If DUmmy owned by player1 deals damage, you use it as the Hero[1] dealed the damage)

If it's MUI, you use a Hashtable to save the ID of the casting unit on the Dummy. When Dummy deals damage or kills the target you assing it to the Caster saved on it's ID
 
Level 13
Joined
Jan 30, 2012
Messages
1,298
I was wondering if there was any way to detect when a dummy kills a unit for it's caster, how would I then go about doing triggers for the casting unit?

maybe this?
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Unit is Dead
      • Killing Unit equal to Dummy
    • Then - Actions
      • Else - Actions
or
  • Events
    • Unit - A unit Dies
  • Conditions
    • Killing Unit equal to Dummy
  • Actions
:\ i'm not sure
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
If you have a unit indexer, then you only need one array and one custom function.

Basically the array points to another indexed unit(the owner of the dummy) and the custom function is for forcibly indexing units(to not have to wait for the unit indexer to catch up when you create a dummy).

If you use Bribe's unit indexer, then this function is what you'll need to add(in a separate trigger).
Also note that you'll have to change the indexer conditions to not allow it to index units twice.
JASS:
function IndexUnitEx takes unit u returns integer
    local integer pdex = udg_UDex
    if ( Trig_Unit_Indexer_Func017C() ) then
        if ( Trig_Unit_Indexer_Func017Func004C() ) then
            set udg_UDex = ( udg_UDexGen + 1 )
            set udg_UDexGen = udg_UDex
        else
            set udg_UDex = udg_UDexRecycle
            set udg_UDexRecycle = udg_UDexNext[udg_UDex]
        endif
        set udg_UDexUnits[udg_UDex] = GetFilterUnit()
        call SetUnitUserData( udg_UDexUnits[udg_UDex], udg_UDex )
        set udg_UDexPrev[udg_UDexNext[0]] = udg_UDex
        set udg_UDexNext[udg_UDex] = udg_UDexNext[0]
        set udg_UDexNext[0] = udg_UDex
        set udg_UnitIndexEvent = 0.00
        set udg_UnitIndexEvent = 1.00
        set udg_UnitIndexEvent = 0.00
        set udg_UDex = pdex
    endif
    return udg_UDex
endfunction
 
Level 9
Joined
Apr 23, 2010
Messages
312
So then I guess my next question is would this still work for multiple dummy casting spells, I don't want it to work for just one specific spell and not others. This would be mroe for people who would import spells they want that use dummies, and not having to set any variables for every single one.
 
Status
Not open for further replies.
Top