• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] GUI Auto-cast abilities.

Status
Not open for further replies.
Level 7
Joined
Aug 20, 2005
Messages
98
Below is code for Glaives of Wisdom. As far as I can see it only uses GUI commands. I have been over it for about an hour to try and see how it works, but to no avail. I am looking to make a similar effect but with a different damage calculation mechanic. Can anyone decipher this enough to explain for it works? The biggest trouble I am having the recognizing how to find the exact time when the target unit gets damaged.

JASS:
// Objects used:
// 'A0LZ' = Glaives of Wisdom (Silencer : Nortrom)
// 'B05X' = Glaives of Wisdom

// DEBUG Trigger Number : 72
function Glaives_Damage_Spell takes nothing returns boolean
	return GetLearnedSkill()=='A0LZ'and IsUnitIllusion(GetTriggerUnit())==false
endfunction

function Glaives_Damage_OnOff takes nothing returns boolean
	if(GetTriggerEventId()==EVENT_PLAYER_UNIT_ATTACKED)then
		if(GetUnitAbilityLevel(GetAttacker(),'A0LZ')==0)then
			return false
		elseif(GetBoolean(H2Tx(GetTriggeringTrigger()),"OrbOn"))then
			if IsUnitType(GetTriggerUnit(),UNIT_TYPE_STRUCTURE)==false and GetAttacker()==GetUnit(H2Tx(GetTriggeringTrigger()),"Silencer")then
				return true
			endif
		else
			return false
		endif
	elseif(GetTriggerEventId()==EVENT_UNIT_ISSUED_ORDER)then
		if(GetIssuedOrderId()==OrderId("poisonarrows"))then
			call SetBoolean(H2Tx(GetTriggeringTrigger()),"OrbOn",true)
		elseif(GetIssuedOrderId()==OrderId("unpoisonarrows"))then
			call SetBoolean(H2Tx(GetTriggeringTrigger()),"OrbOn",false)
		endif
	elseif(GetTriggerEventId()==EVENT_UNIT_SPELL_EFFECT)then
		if(GetSpellAbilityId()=='A0LZ')then
			return true
		else
			return false
		endif
	endif
	return false
endfunction

function Glaives_Damage_Main takes nothing returns nothing
	local texttag lgg
	local real ldd
	if UnitHasBuffBJ(GetTriggerUnit(),'B05X') and GetUnitAbilityLevel(GetEventDamageSource(),'A0LZ')>0 and GetUnit(H2Tx(GetTriggeringTrigger()),"Source")==GetEventDamageSource()then
		call DisableTrigger(GetTriggeringTrigger())
		set ldd=.15*I2R(GetUnitAbilityLevel(GetEventDamageSource(),'A0LZ')*GetHeroInt(GetEventDamageSource(),true))
		set lgg=CreateTextTagUnitBJ("+"+I2S(R2I(ldd)),GetTriggerUnit(),64,10,1,85,86,15)
		call SetTextTagVelocityBJ(lgg,64,90)
		call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),ldd,ATTACK_TYPE_HERO,DAMAGE_TYPE_DIVINE)
		call PolledWait(1)
		call DestroyTextTag(lgg)
		call DisableTrigger(GetTriggeringTrigger())
	endif
endfunction

function Glaives_Damage_Event takes nothing returns nothing
	local trigger ltt=CreateTrigger()
	local unit lFB
	local unit lFb
	if(GetTriggerEventId()==EVENT_UNIT_SPELL_EFFECT)then
		set lFB=GetSpellTargetUnit()
		set lFb=GetTriggerUnit()
	else
		set lFB=GetTriggerUnit()
		set lFb=GetAttacker()
	endif
	if IsUnitIllusion(lFb)==false then
		call SetHandle(H2Tx(ltt),"Source",lFb)
		call TriggerRegisterUnitEvent(ltt,lFB,EVENT_UNIT_DAMAGED)
		call TriggerAddAction(ltt,function Glaives_Damage_Main)
	endif
	call PolledWait(2)
	call DisableTrigger(ltt)
endfunction

function Glaives_Damage_Run takes nothing returns nothing
	local unit lfo=GetTriggerUnit()
	local trigger ltt
	if GetUnitAbilityLevel(lfo,'A0LZ')==1 then
		set ltt=CreateTrigger()
		call TriggerRegisterAnyUnitEventBJ(ltt,EVENT_PLAYER_UNIT_ATTACKED)
		call TriggerRegisterUnitEvent(ltt,GetLearningUnit(),EVENT_UNIT_SPELL_EFFECT)
		call TriggerRegisterUnitEvent(ltt,GetLearningUnit(),EVENT_UNIT_ISSUED_ORDER)
		call TriggerAddCondition(ltt,Condition(function Glaives_Damage_OnOff))
		call TriggerAddAction(ltt,function Glaives_Damage_Event)
		call SetHandle(H2Tx(ltt),"Silencer",lfo)
	endif
endfunction

function Glaives_Damage_Init takes nothing returns nothing
	local trigger ltt=CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(ltt,EVENT_PLAYER_HERO_SKILL)
	call TriggerAddCondition(ltt,Condition(function Glaives_Damage_Spell))
	call TriggerAddAction(ltt,function Glaives_Damage_Run)
endfunction


function InitTrig_Glaives_of_Wisdom_Learn takes nothing returns nothing
endfunction
 
Last edited:
Status
Not open for further replies.
Top