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

Two spells depending on the target

Status
Not open for further replies.
Level 2
Joined
Jun 4, 2011
Messages
17
Hi, I am looking for some help in creating an ability code that calls one spell (spell 1) if the target is a friend unit and a second spell (spell 2) if the target is an enemy unit. So, in general terms, how can I write the conditionals in the trigger for this kind of spell? For example, the spell 1 could increase movement and the spell 2 could decrease movement, just that in my case spell 1 is complete different of spell 2 because have his own different triggers. Thanks in advance.
 
Level 2
Joined
Jun 4, 2011
Messages
17
Thank you very much. I am not a programmer or whatever but I understand some of coding and your answer reminds me that thing of boolean comparison I read in other spells. Thanks again for the the quick answer, I am gonna check it right now.
 
Level 2
Joined
Jun 4, 2011
Messages
17
Well, I have a problem, they are not triggers spells, they are just 2 different modified abilities, so I can not figure out how to merge the 2 "no trigger" spells into one "trigger spell" using the boolean comparison, so ... can somebody give me a hand?
 
Use one ability, set Targets allowed to Ground for example (let Allied and Enemy unticked - it will be used on both target types) and trigger the condition. You can use Channel as the base ability, with Target Type Unit, Options -> Visible, Follow through time: 0, Disable other abilities: False. Use a dummy unit to cast the ability you want.
 
Level 2
Joined
Jun 4, 2011
Messages
17
Thanks for the answers but I finished the spells, a decided not to merge the 2 spells and have them separate:ogre_hurrhurr:, but thanks anyway, you are very nice people.
 
Level 6
Joined
Jun 24, 2011
Messages
202
lets say if you target a ally that the spell heals, and it damages enemy units...

  • spell
    • Events
      • Unit - No unit Begins casting an ability
    • Conditions
    • Actions
      • Set target = (Target unit of ability being cast)
      • If ((Color of (Owner of target)) Equal to Blue) then do (Unit - Cause (Triggering unit) to damage target, dealing 500.00 damage of attack type Spells and damage type Normal) else do (Do nothing)
      • If ((Color of (Owner of target)) Equal to Red) then do (Unit - Set life of target to ((Life of target) + 200.00)) else do (Do nothing)
      • Wait 10.00 seconds
      • Set target = No unit
set no unit in the event to the hero, target is a variable of the unit type. I know you gave up on this but heres the answer.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
monkeypieman9, that trigger makes absoultly no sense. You are selecting effect based on player colour which has nothing to do with allience properties. Both Blue and Red might be allied in his map but this ability will damage blue and heal red. Further more, it will not do anything to any other players.

Because it is a 2 state machine (eithor friend or foe), you can use the else structure from a branch statement.

JASS:
if IsUnitAlly(GetSpellTargetUnit(),GetOwningPlayer(GetTriggerUnit())) then
    //Positive code here
else
    //Negative code here
endif
 
Level 6
Joined
Jun 24, 2011
Messages
202
if red and blue are allies he can change it... He didnt give me specifics so .... what do you expect me to do. Besides that he already said thanks, so im guessing its what he wanted. Now yours works too, but some people here dont know how to do Jass. Get it now why I did what I did?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
No I still do not get why you did that... I am 90% sure GUI has simlar code to test if a player is allied to another player (which might be slower than mine but still lets you compare the owners of the 2 units). In the case of a map with more than 2 players this is a lot more efficient as it cuts back on procedural coupling.

Why even test colour? You can change colours via triggers meaning it is open for more bugs. Rather just test the owner of the unit against a player if you must use that method.

Your method would work if for some reason he decides to give all players on 1 team the same colour. I can not deny that. However that is very rare, infact I do not recall a single common map which did this.
 
Level 7
Joined
Jun 14, 2009
Messages
235
if red and blue are allies he can change it... He didnt give me specifics so .... what do you expect me to do. Besides that he already said thanks, so im guessing its what he wanted. Now yours works too, but some people here dont know how to do Jass. Get it now why I did what I did?

But even in gui, you could just check if the target is an ally or enemy, why use player color?
 
Level 6
Joined
Jun 24, 2011
Messages
202
when he said ally it could mean the same player or it could mean a group of allied players. HE DIDNT SAY! It could be easily changed either way... Its basic GUI nothing special, easily editable. Unlike jass which only people who know it can understand. GUI is easily readable for everyone.
 
Status
Not open for further replies.
Top