Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
EVENT_PLAYER_UNIT_DAMAGED or EVENT_PLAYER_UNIT_DAMAGING for that.call TriggerRegisterAnyUnitEventBJ(gg_trg_<trigger_name>, EVENT_PLAYER_UNIT_DAMAGED).
Your Trigger

Events


Comment: -------- Unfortunately, GUI does not offer the option to register a generic version of the PLAYER_UNIT_DAMAGED event --------


Comment: -------- so the registration of this trigger to said event will have to be done in a separate trigger --------

Conditions

Actions


Custom Script: if (BlzGetEventAttackType() != ATTACK_TYPE_NORMAL) then


Custom Script: return


Custom Script: endif


Comment: -------- You can now deal with the spell damage instance as you please --------
Initialization Trigger

Events


Game - Map Initialization

Conditions

Actions


Comment: -------- This will register "Your Trigger" to the event EVENT_PLAYER_UNIT_DAMAGED --------


Custom Script: call TriggerRegisterAnyUnitEventBJ(gg_trg_Your_Trigger, EVENT_PLAYER_UNIT_DAMAGED)
Your Trigger

Events


Game - DamageEvent becomes Greater than 1.00

Conditions

Actions


Comment - This trigger has detected a spell damage instance.
Do you know if you can get the attacking unit in this case ? i'm trying to make a system in which a neutral unit, when attacked becomes hostile and stores the player number of the attacker, and when the unit reaches a certain point, if it has been attacked, its faction then becomes hostile to the attacking player. But as I use the custom script method, "attacking unit" isn't initialized in the fundtion. Here is the code :Yeah. I forgot to mention that when dealing with damage instances, the Unit is attacked event is not the appropriate one to use. Here are two ways to detect spell damage.
You'll need to use the player unit eventEVENT_PLAYER_UNIT_DAMAGEDorEVENT_PLAYER_UNIT_DAMAGINGfor that.
To register the trigger (that should detect spell damage) to these events, you'll have to delve into custom script, and call the following line at map initialization:
call TriggerRegisterAnyUnitEventBJ(gg_trg_<trigger_name>, EVENT_PLAYER_UNIT_DAMAGED).
From there, you can check whether the damage dealt comes from a spell or not based on its attack type. A bit of custom script here and there, and the snippet should somewhat look like this:
Your Trigger
Events
Comment: -------- Unfortunately, GUI does not offer the option to register a generic version of the PLAYER_UNIT_DAMAGED event --------
Comment: -------- so the registration of this trigger to said event will have to be done in a separate trigger --------
Conditions
Actions
Custom Script: if (BlzGetEventAttackType() != ATTACK_TYPE_NORMAL) then
Custom Script: return
Custom Script: endif
Comment: -------- You can now deal with the spell damage instance as you please --------
Initialization Trigger
Events
Game - Map Initialization
Conditions
Actions
Comment: -------- This will register "Your Trigger" to the event EVENT_PLAYER_UNIT_DAMAGED --------
Custom Script: call TriggerRegisterAnyUnitEventBJ(gg_trg_Your_Trigger, EVENT_PLAYER_UNIT_DAMAGED)
Alternatively, if you're okay with using Bribe's Damage Engine 5.9.0.0, download the system and copy-paste it in your map. Then, you can set up your trigger like this:
Your Trigger
Events
Game - DamageEvent becomes Greater than 1.00
Conditions
Actions
Comment - This trigger has detected a spell damage instance.
boatTakesDamage

Events

Conditions


Or - Any (Conditions) are true



Conditions




(Unit-type of (Attacked unit)) Equal to Galion (player)




(Unit-type of (Attacked unit)) Equal to Galion (neutral)




(Unit-type of (Attacked unit)) Equal to Ship of the line




(Unit-type of (Attacked unit)) Equal to Fluit (neutral)




(Unit-type of (Attacked unit)) Equal to Fluit (player)




(Unit-type of (Attacked unit)) Equal to Frigate




(Unit-type of (Attacked unit)) Equal to Sloop

Actions


Game - Display to (All players) the text: (Name of (Owner of (Attacking unit)))


Game - Display to (All players) the text: (Name of (Owner of (Attacked unit)))


Special Effect - Create a special effect at (Position of (Attacked unit)) using Objects\Spawnmodels\Human\FragmentationShards\FragBoomSpawn.mdl


Special Effect - Set Position - Z of (Last created special effect) to 200.00


Special Effect - Set Time of (Last created special effect) to 1.00


Unit Group - Pick every unit in (Units within 2000.00 of (Position of (Attacked unit)) matching (((Matching unit) belongs to an ally of (Owner of (Attacked unit)).) Equal to Vrai).) and do (Actions)



Loop - Actions




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






((Owner of (Picked unit)) controller) Not equal to User





Then - Actions






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








Or - Any (Conditions) are true









Conditions










(Owner of (Picked unit)) Equal to Player 13 (Maroon)










(Owner of (Picked unit)) Equal to Player 14 (Navy)










(Owner of (Picked unit)) Equal to Player 15 (Turquoise)







Then - Actions








Unit - Set Unit: (Attacked unit)'s Integer Field: Gold Bounty Awarded - Number of Dice ('ubdi') to Value: (Player number of (Owner of (Attacking unit)))







Else - Actions






Set VariableSet tmpDest = (Rally-Point of (Attacked unit) as a point)






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








(Owner of (Picked unit)) Equal to Player 13 (Maroon)







Then - Actions








Unit - Change ownership of (Picked unit) to Player 16 (Violet) and Change color








Unit - Order (Picked unit) to Move To (Center of marroonPorts[(Unit: (Picked unit)'s Integer Field: Lumber Bounty Awarded - Base ('ulba'))])







Else - Actions








If (All Conditions are True) then do (Then Actions) else do (Else Actions)









If - Conditions










(Owner of (Picked unit)) Equal to Player 14 (Navy)









Then - Actions










Unit - Change ownership of (Picked unit) to Player 17 (Wheat) and Change color










Unit - Order (Picked unit) to Move To (Center of navyPorts[(Unit: (Picked unit)'s Integer Field: Lumber Bounty Awarded - Base ('ulba'))])









Else - Actions










If (All Conditions are True) then do (Then Actions) else do (Else Actions)











If - Conditions












(Owner of (Picked unit)) Equal to Player 15 (Turquoise)











Then - Actions












Unit - Change ownership of (Picked unit) to Player 18 (Peach) and Change color












Unit - Order (Picked unit) to Move To (Center of turquoisePorts[(Unit: (Picked unit)'s Integer Field: Lumber Bounty Awarded - Base ('ulba'))])











Else - Actions






Game - Display to (All players) the text: (String((Unit: (Picked unit)'s Integer Field: Gold Bounty Awarded - Base ('ubba'))))





Else - Actions
