Passive ability question (sorta)

Avaleirra

Is back. Probably.
Reaction score
128
Hi, I was wondering how to make it so that a passive ability on a unit triggers at a certain point.

Here are some examples of what I'm trying to create (but don't know how to trigger :(

1. Let's say a unit has a passive ability that makes it invulnerable at a certain amount of health

2. A unit has a passive ability that makes it charge at the closest hostile unit

I just need to get the hang of making these kind of spells.


Thanks!
(if I'm not being clear please tell me)

EDIT: forgot one :p

3. A unit has a passive ability that makes it create illusions when it enters combat.
 

roXplosive

New Member
Reaction score
15
For the first thing I have made something that is basicaly giving the hints :

JASS:

function Trig_InvulnerabilityLearn_Conditions takes nothing returns boolean
    return GetLearnedSkill()=='A000'
    //Get ability code of your ability from object editor by pressing Ctrl+D
endfunction

function Trig_InvulnerabilityLearn_Actions takes nothing returns nothing
    call TriggerRegisterUnitEvent( gg_trg_InvulnerabilityDoAction, GetTriggerUnit(), EVENT_UNIT_DAMAGED )
endfunction

//===========================================================================
function InitTrig_InvulnerabilityLearn takes nothing returns nothing
    set gg_trg_InvulnerabilityLearn = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_InvulnerabilityLearn, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_InvulnerabilityLearn, Condition( function Trig_InvulnerabilityLearn_Conditions ) )
    call TriggerAddAction( gg_trg_InvulnerabilityLearn, function Trig_InvulnerabilityLearn_Actions )
endfunction


JASS:

function Conditions takes nothing returns boolean
 return GetUnitStatePercent(GetTriggerUnit(),UNIT_STATE_LIFE,UNIT_STATE_MAX_LIFE)<= 30.00
 // 30% or another percent as you see fit ; maybe even a value determined by skill level of invincibility
endfunction

function Trig_InvulnerabilityDoAction_Actions takes nothing returns nothing
   call UnitAddAbility(GetTriggerUnit(),'Avul') //adds ability invulnerable neutral
   //do other actions and after a while remove invulnerability or use antother trigger to do it
   //I'm thinking of another trigger if you want to make the units lose invulnerability after they regenerated 
   //Idk how to add cooldown to passive abilities because it would most likely need one 
   call UnitRemoveAbility(GetTriggerUnit(),'Avul')
endfunction

//===========================================================================
function InitTrig_InvulnerabilityDoAction takes nothing returns nothing
    set gg_trg_InvulnerabilityDoAction = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_InvulnerabilityDoAction , Condition(function Conditions))
    call TriggerAddAction( gg_trg_InvulnerabilityDoAction, function Trig_InvulnerabilityDoAction_Actions )
endfunction


For the second function I think it would be appropriate to make a periodic trigger checking if around the unit having ability X are enemies of it's owning player . If the closest enemy (select from a group) is farther away than a minimal value then charge him . You could make a group of units that are performing charge actions to they won't prevent them from changing directions in midcharge if another enemy blinks closerthan the first charge target . The minimal distance treshold is there so your units won't permacharge . This can be done in GUI and I hate GUI because it's so slow (tried to make the first triggers in GUI but got bored and just converted them to custom text ) .

As for number 3 I don't have any idea because I don't know how to determine if a unit wasn't attacking and the suddenly started attacking . And if so you could abuse this by spamming stop every attack . Imho I don't think it would work .
 

Avaleirra

Is back. Probably.
Reaction score
128
Sorry, I don't know any JASS.....I'm just getting the hang of GUI. Thanks for posting though :)
 

Tom Jones

N/A
Reaction score
437
The first one is relatively simple:
Trigger:
  • Cant touch this onLearn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to to *Some Spell*
      • (Learned skill level) Equal to 1
    • Actions
      • Trigger - Add to Cant touch this Activate <gen> the event (Unit - (Triggering unit)'s life becomes Less than *Some Real*)

Trigger:
  • Cant touch this Activate
    • Events
    • Conditions
    • Actions
      • Unit - Make (Triggering unit) Invulnerable
      • Wait until ((Life of (Triggering unit)) Greater than or equal to *Some Real*), checking every 1.00 seconds
      • Unit - Make (Triggering unit) Vulnerable
 

roXplosive

New Member
Reaction score
15
Trigger:
  • Cant touch this Activate
    • Events
    • Conditions
      • (Percentage life of (Triggering unit)) Less than 30.00
    • Actions
      • Unit - Make (Triggering unit) Invulnerable
      • Wait until ((Life of (Triggering unit)) Greater than or equal to *Some Real*), checking every 1.00 seconds
      • Unit - Make (Triggering unit) Vulnerable


TomJones you have forgotten to add a condition for life treshold in activation . This should do it (forgot to check real comparison first time I tried ; only tried out integer comparison :) me and gui :thdown: ).
 

Avaleirra

Is back. Probably.
Reaction score
128
Oh btw the unit isn't a hero, so how would this change the trigger?

And any idea for the second ability?


EDIT: just realized something... This unit would be impossible to kill right? Or can you add a cooldown to passive abilities?
 

Yoshii

New Member
Reaction score
74
Oh btw the unit isn't a hero, so how would this change the trigger?

And any idea for the second ability?


EDIT: just realized something... This unit would be impossible to kill right? Or can you add a cooldown to passive abilities?

yes it would be it unkillable, why would you want to make a unit invincible at low hp if you want a cooldown on the ability?
As for the second ability its kinnda complex tbh unless there is an ability that do it which I dont think there are.
 

Avaleirra

Is back. Probably.
Reaction score
128
Okay thanks yoshii, but how can I make it so that the first ability can only happen once?

EDIT: better yet, how can I make it so that the unit is only invincible for 5 seconds?
 

Yoshii

New Member
Reaction score
74
Okay thanks yoshii, but how can I make it so that the first ability can only happen once?

EDIT: better yet, how can I make it so that the unit is only invincible for 5 seconds?
well even with a 5second cooldown if the unit has less than HP X the trigger will just run again, if its a general unit then its a problem.

on the other hand if the unit is already on the map at start up you can refer to it and have a boolean variable to make it only work once for example a boss
Make a new variable of type boolean called Once
event: a specific unit (select the unit on your map) has HP less than X
cond: if Once=false
action:make triggering unit invulnerable
wait 5 game-time second.
-set Once=true
 

SuperSoldier

New Member
Reaction score
10
Wouldn't it be easier for the first and third one to create a spell for each one then give it to the unit when the time comes, make him use it, then get rid of it?

As for the second spell you should be a bit more specific. You said you wanted the hero to charge at the nearest hostile unit, but do you want it to be like if they are too close he won't charge and if someone is within that too close range he won't charge at all :confused: Do you want it to have a cooldown/one time use?
And Yoshii's method isn't as good, a better way would be to just turn the trigger off wouldn't it?

EDIT: Sorry, at school, not going to be on comp again.
 

Yoshii

New Member
Reaction score
74
Wouldn't it be easier for the first and third one to create a spell for each one then give it to the unit when the time comes, make him use it, then get rid of it?

As for the second spell you should be a bit more specific. You said you wanted the hero to charge at the nearest hostile unit, but do you want it to be like if they are too close he won't charge and if someone is within that too close range he won't charge at all :confused: Do you want it to have a cooldown/one time use?
And Yoshii's method isn't as good, a better way would be to just turn the trigger off wouldn't it?

EDIT: Sorry, at school, not going to be on comp again.
you could turn the trigger off incase of a boss but a general unit it wouldnt work out. reading your post i got the idea to do number 3

instead of making the unit invulnerable via trigger; give the unit divine shield ability have it use it(make it last 6 second) and Make sure the cooldown on divine shield is set to like 9999 so the unit wont use it again.

simply getting rid of divine shield will not do as the trigger will run again and add it again.
 

Yoshii

New Member
Reaction score
74
Could you show me the trigger please :p


+rep if this works
Event: a unit has HP less than X
cond:
action: Unit add Divine Shield to triggering unit
- Unit order triggering unit to Divine Shield

now in object editor of the ability Divine SHield
set its mana cost to 0 (level 1)
set its cooldown to 9999(lvl 1)
set its duration on hero/non hero to 6(lvl 1)
 

Yoshii

New Member
Reaction score
74
What would the condition be? Thanks btw :D
none there isnt a need for any
edit: actually there is one sec
Condition: triggering unit belong to computer player ( if not you own unit could gain it not sure if thats what you want as you would be stuck with Divine shield)
 

Avaleirra

Is back. Probably.
Reaction score
128
Hmmm, I thought there would be... It's not a hero btw would that change anything?
 

Yoshii

New Member
Reaction score
74
Hmmm, I thought there would be... It's not a hero btw would that change anything?
doesnt matter as long as the unit can cast it(it can since it cost 0 mana and you just gave it the ability).Remenber tho its currently to every unit, tho including your own they will have the divine shield ability if hp get low.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top