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

Detecting Critical Strikes

Status
Not open for further replies.
Level 5
Joined
Oct 24, 2007
Messages
90
Hello everybody.

This is a very simple question (I don't know if its easy though, which isn't the same thing as simple). I just wanted to know how I could detect when a hero performs a critical strike with the ability. I've tried using the event "EVENT_PLAYER_UNIT_SPELL_EFFECT," but it doesn't seem to recognize the spell Critical Strike, neither with "EVENT_PLAYER_UNIT_SPELL_CAST." I don't even set any conditions and it still doesn't recognize it.

Thanks in advance.

By the way, here is the code I used to test it

JASS:
scope Crit initializer Init
    
    private function Actions takes nothing returns nothing
        call BJDebugMsg("Critical!")
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger CritTrig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(CritTrig, EVENT_PLAYER_UNIT_SPELL_EFFECT)     //or SPELL_CAST
        call TriggerAddAction(CritTrig, function Actions)
        set CritTrig = null
    endfunction
    
endscope

just in case I've done anything stupid. :grin:
 
Level 2
Joined
Dec 7, 2010
Messages
14
Well, Critical Strike is neither an effect nor a cast according to most of the game. Your wording may be what is off. I am not all to familiar with JASS, but is ABILITY an option?
 
I've made loads of trigger-based CS before... I may be able to find my posts...

EDIT: I posted this before:
  • CS 1
    • Events
      • Map initialization
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • -------- Removes unit group leak --------
      • Custom script: set bj_wantDestroyGroup =true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in Damage_group) Equal to False
            • Then - Actions
              • -------- Adds it to a unit group so the same unit is not picked twice --------
              • Unit Group - Add (Picked unit) to Damage_group
              • -------- Adds the damage detection event --------
              • Trigger - Add to CS 2 <gen> the event (Unit - (Picked unit) Takes damage)
            • Else - Actions
  • CS 2
    • Events
    • Conditions
      • (Level of Critical Strike for (Damage source)) Greater than 0
    • Actions
      • -------- If a random real is below the %, the action fires --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random real number between 1.00 and 100.00) Less than or equal to 15.00
        • Then - Actions
          • -------- Turns off to stop an endless loop --------
          • Trigger - Turn off (This trigger)
          • -------- By dealing damage again, it is 'doubling' --------
          • Unit - Cause (Damage source) to damage (Triggering unit), dealing (Damage taken) damage of attack type Chaos and damage type Universal
          • -------- Floating text! --------
          • Floating Text - Create floating text that reads (String((Integer((2.00 x (Damage taken)))))) above (Triggering unit) with Z offset 64.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 60.00 towards 90.00 degrees
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.70 seconds
          • -------- Turns on for use again --------
          • Trigger - Turn on (This trigger)
        • Else - Actions
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Yes, you can detect CUSTOM CRITICAL STRIKE, we base it off from default abilities
Use trigger for the custom ability
When the custom ability critical strike is in place (occurs through trigger), you can use that trigger to detect it
And wa-la !
The effect =D
 
Level 5
Joined
Oct 24, 2007
Messages
90
Okay, thanks to everyone. I guess I'll have to make my own critical strike ability then (which isn't hard at all, I'm just lazy and wanted to save some time). I just have this very cool idea for a spell based on critical strike. I'll post it in the spell section when it's finished. Once again, thanks for the help!
 
Status
Not open for further replies.
Top