(EDIT: Everything should be copied and pasted correctly now lol)
Ok i was finishing up a spell when i got stopped all of a sudden, but first il tell you aboiut the triggers. Ok first off theres the spell wich the hero has, based on storm bolt, when cast a trigger (detecting ability being cast) moves the hero to the position of the targeted unit (the ability targest friendly units) once there both heros continue as normal, but whenever the targeted unit is attack he doesnt lose health, instead the casting unit does. Now i had all that done and working but i want this to be MUI. And i have no way of identifying wich unit to take health from. Sorry if that ^ was hard to understatnd this is kinda hard to explain, basicaly this is the problem, i dont know a way to when a unit witht he buff hinder is attacked, determine who casted hinder on them.
That runs this trigger
Ok i was finishing up a spell when i got stopped all of a sudden, but first il tell you aboiut the triggers. Ok first off theres the spell wich the hero has, based on storm bolt, when cast a trigger (detecting ability being cast) moves the hero to the position of the targeted unit (the ability targest friendly units) once there both heros continue as normal, but whenever the targeted unit is attack he doesnt lose health, instead the casting unit does. Now i had all that done and working but i want this to be MUI. And i have no way of identifying wich unit to take health from. Sorry if that ^ was hard to understatnd this is kinda hard to explain, basicaly this is the problem, i dont know a way to when a unit witht he buff hinder is attacked, determine who casted hinder on them.
JASS:
function AnyUnitTakesDamage takes nothing returns nothing
call TriggerExecute(gg_trg_HEffect)
// Sample Damage display:
// call BJDebugMsg( "Damage: " + R2S(GetEventDamage()) )
endfunction
// part 1
function AddDamageTriggers takes nothing returns nothing
local trigger takedamage = CreateTrigger()
call TriggerRegisterUnitEvent(takedamage,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
call AttachObject(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
call AttachObject(GetTriggerUnit(),"TakeDamageTrigger",takedamage)
endfunction
// part 2
function RemoveDamageTriggers takes nothing returns nothing
local unit u = GetTriggerUnit()
local trigger me = GetAttachedTrigger(GetTriggerUnit(),"TakeDamageTrigger")
local string t = GetAttachmentTable(me)
local boolean revived = false
if not IsUnitType(u,UNIT_TYPE_HERO) then
loop
set revived = (GetWidgetLife(u)>0.405)
exitwhen revived or GetUnitTypeId(u)==0
call TriggerSleepAction(0)
endloop
endif
if not revived then
// delete action and trigger
call TriggerRemoveAction(me,GetTableTriggerAction(t,"action"))
call DestroyTable(t)
call DestroyTrigger(me)
endif
set me = null
set u = null
endfunction
// part 3
function InitTrig_AddDmg takes nothing returns nothing
local trigger entermap = CreateTrigger()
local group startingunits = CreateGroup()
local unit u
local trigger takedamage
local trigger upondeath = CreateTrigger()
call GroupEnumUnitsInRect(startingunits,bj_mapInitialPlayableArea,null)
loop
set u = FirstOfGroup(startingunits)
exitwhen u == null
set takedamage = CreateTrigger()
call TriggerRegisterUnitEvent(takedamage,u,EVENT_UNIT_DAMAGED)
call AttachObject(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
call AttachObject(u,"TakeDamageTrigger",takedamage)
call GroupRemoveUnit(startingunits,u)
endloop
set takedamage = null
// unit enters the map/revives
call TriggerRegisterAnyUnitEventBJ(entermap ,EVENT_PLAYER_HERO_REVIVE_FINISH)
call TriggerRegisterEnterRectSimple(entermap, bj_mapInitialPlayableArea)
call TriggerAddAction(entermap,function AddDamageTriggers)
// unit dies
call TriggerRegisterAnyUnitEventBJ(upondeath,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction(upondeath,function RemoveDamageTriggers)
endfunction
That runs this trigger
-
HEffect
- Events
-
Conditions
- Trig_Hinder Equal to On
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Trig_Hinder Equal to On
- ((Triggering unit) has buff Hinder 1) Equal to True
-
Then - Actions
- Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
- Set L = (Position of (Triggering unit))
- Special Effect - Create a special effect at L using Abilities\Spells\Human\Heal\HealTarget.mdl
- Special Effect - Destroy (Last created special effect)
- Custom script: call RemoveLocation(udg_L)
- Set L = (Position of (Triggering unit))
- Special Effect - Create a special effect at L using Objects\Spawnmodels\Critters\Albatross\CritterBloodAlbatross.mdl
- Special Effect - Destroy (Last created special effect)
- Custom script: call RemoveLocation(udg_L)
- Sound - Play SpellShieldImpact1 <gen>
- Unit - Set life of Caster_Hinder[1] to ((Life of Caster_Hinder[1]) - (Damage taken))
- Game - Display to (All players) the text: HEffect
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
HCast
-
Events
- Unit - A unit Begins casting an ability
-
Conditions
- (Ability being cast) Equal to Hinder
-
Actions
- Set Caster_Hinder[(Player number of (Owner of (Casting unit)))] = (Casting unit)
- Set Boolean_Hinder[(Player number of (Owner of (Casting unit)))] = True
- Set Trig_Hinder = On
- Set L = (Position of (Casting unit))
- Special Effect - Create a special effect at L using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
- Special Effect - Destroy (Last created special effect)
- Custom script: call RemoveLocation(udg_L)
- Set L = (Position of (Casting unit))
- Special Effect - Create a special effect at L using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
- Special Effect - Destroy (Last created special effect)
- Custom script: call RemoveLocation(udg_L)
- Set L = (Position of (Target unit of ability being cast))
- Unit - Move (Casting unit) instantly to L
- Custom script: call RemoveLocation(udg_L)
- Set L = (Position of (Casting unit))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
-
Then - Actions
- Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units within 512.00 of L matching ((((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True) and (((Triggering unit) is alive) Equal to True))) and do (Actions)
-
Loop - Actions
- Custom script: call RemoveLocation(udg_L)
- Unit - Turn collision for (Picked unit) Off
- Unit - Make (Picked unit) face (Target unit of ability being cast) over 0.00 seconds
- Set L = (Position of (Picked unit))
- Unit - Move (Picked unit) instantly to L
- Custom script: call RemoveLocation(udg_L)
- Animation - Play (Picked unit)'s DEATH animation
- Unit - Pause (Picked unit)
- Unit - Cause (Casting unit) to damage (Picked unit), dealing ((Real((Strength of (Casting unit) (Include bonuses)))) x 1.50) damage of attack type Hero and damage type Force
- Wait 10.00 seconds
- Set Trig_Hinder = Off
-
Loop - Actions
- Custom script: set bj_wantDestroyGroup = true
- Set L = (Position of (Casting unit))
-
Unit Group - Pick every unit in (Units within 950.00 of L matching ((((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True) and (((Matching unit) is alive) Equal to True))) and do (Actions)
-
Loop - Actions
- Custom script: call RemoveLocation(udg_L)
- Unit - Unpause (Picked unit)
- Animation - Play (Picked unit)'s stand animation
- Unit - Turn collision for (Picked unit) On
-
Loop - Actions
- Else - Actions
-
Events