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

Last minute problem

Status
Not open for further replies.
Level 10
Joined
Jan 21, 2007
Messages
576
(EDIT: Everything should be copied and pasted correctly now o_O 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.

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
This is the trigger that detects whent he ability is casted.
  • 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
          • 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
        • Else - Actions
Any solutions?
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Don't think it passes "Triggering Unit". Try this

(in the function AnyUnitTakesDamage, add the following before TriggerExecute( gg_trg_HEffect ))

JASS:
set bj_ghoul[100] = GetTriggerUnit()

Then, make a global variable called "Triggerer" (unit), or something, and do this at the top of the HEffect trigger

  • Custom script: set udg_Triggerer = bj_ghoul[100]
(replacing Triggerer with whatever you name your variable)
 
Level 10
Joined
Jan 21, 2007
Messages
576
So doding those to things will allow mutliple heroes to cast hinder whenever they want and only get damaged when the unit they targeted is damaged? If so hell yea :emote_hug: .
EDIT: And by global variable you mean avariable in WE variable editor? It should be of type unit, but should it be an array? And should i change in Heffect all the times it says Triggering Unit to the variable Triggerer? (sorry lol im not very versed in jass)
 
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
Nah, it wouldn't be multiinstanceable with waits.

However, unless you use locals (aka JASS), that's not going to change much anyways. (unless, of course, you remove the waits)

But that's an issue with your cast trigger, not with HEffect.

And yes, a variable in the variable editor. And without waits, it need not be an array.
 
Status
Not open for further replies.
Top