• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] GetSpellTargetX() in channel based ability

Status
Not open for further replies.
Level 26
Joined
Feb 2, 2006
Messages
1,695
Hi,
GetSpellTargetX() and maybe other event related functions do not work anymore for my channel based abilities. They always return 0.0.
I don't know if I made some changes at some point. The event is EVENT_UNIT_SPELL_ENDCAST. They neither work in trigger conditions nor in actions. common.j states that ENDCAST should be supported.
 
Level 26
Joined
Feb 2, 2006
Messages
1,695
JASS:
private static method triggerConditionCast takes nothing returns boolean
			local thistype this = AHashTable.global().handleInteger(GetTriggeringTrigger(), "this")
			local boolean result = (GetSpellAbilityId() == this.m_ability)
			if (result) then
				debug call Print("Spell: triggerConditionCast")
				debug call Print("Spell target X: " + R2S(GetSpellTargetX()) + " Y: " + R2S(GetSpellTargetY()))
				debug call Print("Spell target Location in condition: " + R2S(GetLocationX(GetSpellTargetLoc())) + " and " + R2S(GetLocationY(GetSpellTargetLoc())))
				set result = this.onCastCondition()
				if (not result) then
					//taken from wc3jass.com
					//call PauseUnit(this.character().unit(), true)
					call IssueImmediateOrder(this.character().unit(), "stop")
					//call PauseUnit(this.character().unit(), false)
				endif
			endif
			return result
		endmethod

		private static method triggerActionCast takes nothing returns nothing
			local thistype this = AHashTable.global().handleInteger(GetTriggeringTrigger(), "this")
			debug call Print("Spell: triggerActionCast")
			debug call Print("Spell target X: " + R2S(GetSpellTargetX()) + " Y: " + R2S(GetSpellTargetY()))
			debug call Print("Spell target Location in action: " + R2S(GetLocationX(GetSpellTargetLoc())) + " and " + R2S(GetLocationY(GetSpellTargetLoc())))
			call this.onCastAction.execute()
		endmethod

		private method createCastTrigger takes nothing returns nothing
			set this.m_castTrigger = CreateTrigger()
			call TriggerRegisterUnitEvent(this.m_castTrigger, this.character().unit(), EVENT_UNIT_SPELL_ENDCAST)
			call TriggerAddCondition(this.m_castTrigger, Condition(function thistype.triggerConditionCast))
			call TriggerAddAction(this.m_castTrigger, function thistype.triggerActionCast)
			call AHashTable.global().setHandleInteger(this.m_castTrigger, "this", this)
		endmethod

All debug prints print the location 0.0|0.0
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
why endcast? i know effect works. if endcast doesnt work you can probably just index it
 
Level 26
Joined
Feb 2, 2006
Messages
1,695
I use the same event for all spells. Using EVENT_UNIT_SPELL_CHANNEL works for the normal spells but it seems that some channel based abilities just block the unit. In some events GetSpellAbilityId() returns null for channel based abilities and the unit which casts the spell just stops until it casts another spell automatically?!
 
Level 26
Joined
Feb 2, 2006
Messages
1,695
The problem is that I run something like:
JASS:
call UnitRemoveAbility(GetTriggerUnit(), this.grimoireAbility())
where grimoireAbility() is an ability based on spell book which contains the cast ability. Therefore this code should HIDE the triggered ability. It seems that removing the ability while being cast somehow stops the unit forever until it casts an automatic spell like creating corpses.
It worked when I used
JASS:
EVENT_UNIT_SPELL_ENDCAST
because all triggers hat an ability != null but then GetSpellTargetX() did not work.
How can I hide/remove the ability without affecting other triggers in such way? Maybe it is a bug somewhere in my code. One alternative would be to use ENDCAST for spells in grimoire and CHANNEL etc. for spells which require GetSpellTargetX() but then I have to change the events.
 
Status
Not open for further replies.
Top