HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help combining 2 systems

05-22-2008, 05:20 PM#1
v16
Can't make it so when the unit is dealt damage by the spell that's cast so to start the knockback effect
Trigger:
Untitled Trigger 006
Collapse Events
Time - Elapsed game time is 0.05 seconds
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Collapse Loop - Actions
Trigger - Add to Untitled Trigger 007 <gen> the event (Unit - (Picked unit) Takes damage)
Trigger:
Untitled Trigger 007
Events
Conditions
Collapse Actions
Set damagedunit = (Triggering unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Region 016 <gen> contains (Triggering unit)) Equal to True
Collapse Then - Actions
Hero - Add 10 experience to (Damage source), Hide level-up graphics
Collapse Else - Actions
Do nothing
Trigger:
Knockback Cast
Collapse Events
Unit - A unit Starts the effect of an ability
Conditions
Collapse Actions
Set Temp_Int = 0
Set Timer_Delay = 0.03
Set Caster = (Triggering unit)
Set Caster_Loc = (Position of Caster)
Set Knockback_Value = (0.05 x (Real((Hero experience of Caster))))
Set Knockback_Group = (Units owned by (Owner of (Damage source)))
Countdown Timer - Start Knockback_Timer as a Repeating timer that will expire in Timer_Delay seconds
Wait 1.25 seconds
Countdown Timer - Pause Knockback_Timer
Custom script: call RemoveLocation(udg_Caster_Loc)
Custom script: call DestroyGroup(udg_Knockback_Group)
05-22-2008, 07:38 PM#2
Themerion
If I get it correctly, you want the unit to be knockbacked exactly when it takes damage from a spell. This is a tricky thing to implement in a good way, particularly with triggers(GUI). There are some good systems for this, though most are in Custom Script-form(JASS).

If we were to give it a shot with triggers, you have to accept that the spell wont be MUI (Multi Unit Instanceable). In other words, you can only have 1 unit who can do the knockback (your system seem to have the same limitation, so it's not really a problem. Just keep this in mind).

Trigger:
Set Temp_Int = 0
Set Timer_Delay = 0.03
Set Caster = (Triggering unit)
Set Caster_Loc = (Position of Caster)
Set Knockback_Value = (0.05 x (Real((Hero experience of Caster))))
Set Knockback_Group = (Units owned by (Owner of (Damage source)))
Countdown Timer - Start Knockback_Timer as a Repeating timer that will expire in Timer_Delay seconds
Wait 1.25 seconds
Countdown Timer - Pause Knockback_Timer
Custom script: call RemoveLocation(udg_Caster_Loc)
Custom script: call DestroyGroup(udg_Knockback_Group)

However, this will trigger every time the unit is attacked. To prevent this, I think it would be enough to add a boolean variable:
Trigger:
Knockback Cast
Set HasCastSpell = true
Trigger:
Untitled Trigger 007
Conditions
Caster = (Damage Source)
HasCastSpell equal to true
Actions
Set HasCastSpell = false

EDIT:
IF by any chance the damage is dealt instantly with the spell cast; you only need the last trigger. Just change (Damage Source) into (Target Unit Of Ability Being Cast).
05-23-2008, 09:41 AM#3
v16
can you pls tellme what's hascastspell becouse i don't get it ;(
05-25-2008, 09:43 PM#4
Themerion
Just a boolean variable. You can call it whatever you want to (doesn't have to be "hascastspell")

More on variables:
http://www.wc3campaigns.net/showthread.php?t=81210