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

Triggered Bash?

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi!

I'm trying to make a Triggered Bash, but isn't working. Bash has 0 duration (infinite) but is never removed.


I_DS = Damage Source ID
I_DU = Damaged Unit ID

  • Damage Itself
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (Unit-type of GDD_DamageSource) Not equal to DUMMY
    • Actions
      • Set FontSize = 8.00
      • -------- DamagedUnit and DamageSource Id's --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (GDD_DamagedUnit is A Hero) Equal to True
        • Then - Actions
          • Set I_DU = (Player number of (Triggering player))
        • Else - Actions
          • Custom script: set udg_I_DU = GetUnitTypeId(udg_GDD_DamagedUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (GDD_DamageSource is A Hero) Equal to True
        • Then - Actions
          • Set I_DS = (Player number of (Owner of GDD_DamageSource))
        • Else - Actions
          • Custom script: set udg_I_DS = GetUnitTypeId(udg_GDD_DamageSource)
      • Set BashChance = (Load 15 of I_DS from DamageHash)
      • Set BashDuration = (Load 16 of I_DS from DamageHash)
      • -------- Bash Chance --------
      • Custom script: if udg_BashChance > 0 and GetRandomReal(0,1) <= udg_BashChance then
      • Custom script: set udg_i = GetHandleId(udg_GDD_DamagedUnit)
      • Set BashDur = ((Load 17 of i from DamageHash) + BashDuration)
      • Custom script: if udg_BashDur > 2.5 then
      • Custom script: set udg_BashDur = 2.5
      • Custom script: endif
      • Hashtable - Save BashDur as 17 of i in DamageHash
      • Set Point = (Position of GDD_DamagedUnit)
      • Unit - Create 1 DUMMY for (Owner of GDD_DamageSource) at Point facing Point
      • Unit - Order (Last created unit) to Attack GDD_DamagedUnit
      • Unit - Add a 0.20 second Generic expiration timer to (Last created unit)
      • Unit Group - Add GDD_DamagedUnit to StunGroup
      • Trigger - Turn on StunGroup <gen>
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: endif
  • StunGroup
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in StunGroup and do (Actions)
        • Loop - Actions
          • Custom script: set udg_i = GetHandleId(GetEnumUnit())
          • Set BashDur = ((Load 17 of i from DamageHash) - 0.03)
          • Hashtable - Save BashDur as 17 of i in DamageHash
          • Game - Display to (All players) the text: (String(BashDur)) <- Testing Purposes
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BashDur Less than or equal to 0.00
            • Then - Actions
              • Hashtable - Save 0.00 as 17 of i in DamageHash
              • Unit - Remove Stunned (Pause) buff from (Picked unit)
              • Unit Group - Remove (Picked unit) from StunGroup
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in StunGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions

Edit: Updated to the already working trigger.

- Changed the cast of Stormbolt for Passive Bash with 1 hour duration (Long enough). Stormbolt had a 0.27 casting time.
- Changed order from "Cast Stormbolt" to "Attack"
- The dummy just attacks once. Dummy attack has 0.1s speed, but 2 seg cooldown.
- Using "Key(Unit)" wasn't working. Worked when used GetHandleId
- Excluded the Dummy Unit from triggering the damage.
- Hero data = Player Data. Creeps data = Unit-Type data.


I checked the system you made for me, but it requires JNPG and mine doesn't work with hashtables. Thanks a lot.
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Nah, Adiktuz system requires Bribe's Table. And Both require JNPG. He didn't test it also, and me neither (because of the JNPG req) :p. Anyway, I'd like to know why this isn't working and how to make it work :) (Even if I use Adiktuz system later)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
http://www.hiveworkshop.com/forums/jass-functions-413/snippet-new-table-188084/ <- Table

Adiktuz
JASS:
library StunSystem requires Table

    globals
        private Table SST
        private real MAX_STUN = 2.50 //the max duration that a stun can have
        private string STORM = "stormbolt" //the ordersting of stormbolt
        private integer BUFF_STUN = 'B000' //the rawcode of the stun buff used by the custom SB
        private integer STORM_BOLT = 'A000' //the rawcode of the custom storm bolt
        private integer DUMMY_ID = 'u000' //the rawcode of the dummy caster you are using
    endglobals
    
    private module Init
        static method onInit takes nothing returns nothing
            set SST = Table.create
        endmethod
    endmodule
    
    struct StunSystem
    
        static thistype data
        static integer SSCount = 0
        static group g = CreateGroup()
        static timer t = CreateTimer()
        real duration
        
        static method refresh takes nothing returns nothing
            local unit u = GetFilterUnit()
            local integer id = GetHandleId(u)
            set data = SST[id]
            if GetUnitAbilityLevel(u, BUFF_STUN) == 0 then
                call SST.remove(id)
                call data.deallocate()
                set SSCount = SSCount - 1
                call GroupRemoveUnit(g,u)
                return
            endif
            set data.duration = data.duration - .0325
            if data.duration <= 0 then
                call SST.remove(id)
                call data.deallocate()
                set SSCount = SSCount - 1
                call GroupRemoveUnit(g,u)
            endif
        endmethod
        
        static method stunloop takes nothing returns nothing
            call ForGroup(g, function thistype.refresh)
            if SSCount <= 0 then
                call PauseTimer(t)
            endif
        endmethod
        
        static method stun takes unit u, real duration, real x, real y returns nothing
            local integer id = GetHandleId(u)
            local unit a = CreateUnit(GetOwningPlayer(u), DUMMY_ID, x, y, 0.00)
            set data = SST[id]
            if data == 0 then
                set data = .allocate()
                call IssueTargetOrder(a, STORM,u)
                call GroupAddUnit(g, u)
                set SST[id] = data
            endif
            set data.duration = duration
            if data.duration > MAX_STUN then
                set data.duration = MAX_STUN
            endif
            set SSCount = SSCount + 1
            if SSCount == 1 then
                call TimerStart(t, .0325, true, function thistype.stunloop)
            endif
        endmethod
        
        implement Init
        
    endstruct
    
endlibrary
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
How can I add a 2.5 sec stun limit, even if it's stacking?

EDIT: Thanks Magthe, but maybe I'm still too noob to use a complex system like that one (Maybe it's simple, but i'm too lame for it). Anyway, I got my loop working perfectly. Never tough that debug messages could be so usefull :p

Once thing concerns me though. I'm storing the time the unit must be stunned in 17 of Unit ID, but most spells use "Clear all child" of the unit. Wouldn't it delete all the unit data (All stored data from 1 to 17)? I'm storing it based on Unit-Type ID, but it concerns me :p
 
Last edited:
Status
Not open for further replies.
Top