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

Combat Camera effects when attacked

Status
Not open for further replies.
Level 26
Joined
Dec 3, 2018
Messages
873
I'm trying to make a trigger which should make the screen red and shake it based on how many enemies are attacking a unit and how low that unit is.
I made this trigger but doesn t get the job done
  • Attacked Shake
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Hero Unit for (Triggering unit)) Greater than or equal to 1
    • Actions
      • Set VariableSet Shake[(Player number of (Owner of (Triggering unit)))] = (Shake[(Player number of (Owner of (Triggering unit)))] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Shake[(Player number of (Owner of (Triggering unit)))] Greater than 0
        • Then - Actions
          • Camera - Shake the camera for (Owner of (Triggering unit)) with magnitude (1.00 + ((Real(Shake[(Player number of (Owner of (Triggering unit)))])) / 2.00))
          • Cinematic - Fade out over 5.00 seconds using texture White Mask and color (100.00%, 0.00%, 0.00%) with 95.00% transparency
          • Wait 1.00 seconds
          • Camera - Stop swaying/shaking the camera for (Owner of (Triggering unit)).
        • Else - Actions
          • Wait 2.00 seconds
          • Camera - Stop swaying/shaking the camera for (Owner of (Triggering unit)).
 
Level 39
Joined
Feb 27, 2007
Messages
5,023
"A unit is attacked" runs when a unit begins the windup animation before an attack, not when a unit takes damage. There is no "a unit takes damage" event because it just doesn't exist in the game code. People make Damage Detection Systems (recommended: Damage Engine 5.9.0.0) to overcome this issue, and that's what you need to use to trigger this effect.

That being said I think the problem is just that the magnitude is too low to be noticed, and it only lasts for 1 second while the red fade is over 5s. Also Shake[] is never decreased so what's the point of checking if it's > 0?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,561
Use a timer to stop the camera shake.

A unit is attacked -> Increase intensity and start a 2 second timer

Timer expires -> Stop the camera shake

The Timer will get reset each time the unit is attacked, preventing the camera from stopping until your unit hasn't been attacked by anything for a full 2 seconds.

And shouldn't Shake be a Real variable since the shake magnitude uses a Real.
 
Status
Not open for further replies.
Top