• 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.

[JASS] Switching Abilities

Status
Not open for further replies.
Level 14
Joined
Sep 17, 2009
Messages
1,297
Im using this code, to swap abilities (which are passive coded with trigger):

JASS:
if GetSpellAbilityId() == SPELL1
    UnitRemoveAbility(u, SPELL1)
    UnitAddAbility(u, SPELL2)
    (...)
elseif GetSpellAbilityId() == SPELL2
    UnitRemoveAbility(u, SPELL2)
    UnitAddAbility(u, SPELL1)
    (...)

Apparently it isnt working, Add+Remove blocks each other. Any idea how to make this working?
Note: Alternative (Buff using) abilities would not be good enough, i have to do this with triggers.
Note2: SPELL1 and SPELL2 both created from channel

Help will be appreciated :ogre_hurrhurr:
 
Level 14
Joined
Sep 17, 2009
Messages
1,297
Here is a fragment of the function, the whole function looks like this, just with more else if-s

Please dont count grammatical errors, because its written in a JASS compiler (Wurst)

The Event of the trigger:
TriggerRegisterUnitEvent( myTrigger, actor, EVENT_UNIT_SPELL_CAST )

JASS:
function switchMode(int spell_id)
			if spell_id == ICE_ABILITY
				UnitRemoveAbility(actor,ICE_ABILITY)
				UnitAddAbility(actor,REVICE_ABILITY)
	            modification = 0
	            DisplayTextToPlayer( GetOwningPlayer( GetSpellAbilityUnit() ), 0, 0, "Normal")
	        else if spell_id == REVICE_ABILITY
				UnitRemoveAbility(actor,REVICE_ABILITY)
				UnitAddAbility(actor,ICE_ABILITY)
	            modification = 1
	            DisplayTextToPlayer( GetOwningPlayer( GetSpellAbilityUnit() ), 0, 0, "Reverse")

The bug is directly connected to the Removeing&Adding ability, because without it, the (passive)abilities work fine.
Only I want this to work because of the user interface. So instead of 2 icons you'd see 1 changing when you click it.
 
Level 7
Joined
Apr 5, 2011
Messages
245
So, try to make different order id for spells in Object Editor. If it will not work try to use another spell for second ability, Ice Nova, for example. If it will not work, try to change your code because there is no other way to make it not working.
 
Status
Not open for further replies.
Top