• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Immolation.

Status
Not open for further replies.
Level 19
Joined
Oct 12, 2007
Messages
1,821
Hey there.

I'm currently making a spell that increases my heroes parry chance by X and decreases his critical strike chance by X. I used the parry chance and crit chance variables in a system already, but there's just something not working. I think it has something to do with the trigger event.
The spell I used is an editted version of Immolation so you can turn it on and off.

Here's the trigger code:
JASS:
scope GuardianStanceOn initializer init

private function OnCast takes nothing returns boolean
    local unit u
    local integer bonus
    local integer i
    
    if GetSpellAbilityId() == 'A04Z' then
        set u = GetTriggerUnit()
        set i = GetPlayerId(GetOwningPlayer(u))
        set bonus = 20
        set PlayerParryBonus[i] = PlayerParryBonus[i] + bonus*3
        set PlayerCritBonus[i] = PlayerCritBonus[i] - bonus*2
        set u = null
    endif
    
    return false
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(trig, Condition(function OnCast))
    set trig = null
endfunction

endscope
JASS:
scope GuardianStanceOff initializer init

private function OnCast takes nothing returns boolean
    local unit u
    local integer bonus
    local integer i
    
    if GetSpellAbilityId() == 'A04Z' then
        set u = GetTriggerUnit()
        set i = GetPlayerId(GetOwningPlayer(u))
        set bonus = 20
        set PlayerParryBonus[i] = PlayerParryBonus[i] - bonus*3
        set PlayerCritBonus[i] = PlayerCritBonus[i] + bonus*2
        set u = null
    endif
    
    return false
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_FINISH)
    call TriggerAddCondition(trig, Condition(function OnCast))
    set trig = null
endfunction

endscope

So am I using the right events here?
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
EVENT_PLAYER_UNIT_SPELL_FINISH

Try when unit Stops the ability coz the spell immolation does not finish coz he is not channeling ;)

And what about the beginning? When I activate the ability he should gain 100% parry chance (just to test it out) but he isn't gaining anything. (my parry system isn't leaking. I also tried it with something like strength gaining)

So the event that tracks the spellcast is wrong, but I dunno which one to use for immolation.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Well u can make simply give the hero 100% in a deactivated Spellbook then remove his critical strike after he stop casting it remove the hidden spellbook then give him back his critical strike ;)

I think you don't know what I'm talking about.

I've got a system that gives people a chance (based on their Deflection (which is an attribute in my game) + Agility) to parry an attack. This spell is supposed to increase that parry chance by 15% and reduce the critical strike chance (Which is not the ability "Critical Strike" but something completely different made by triggers) by 10%.

All I need to know is how to make the trigger react on when the hero activates and deactivates Immolation.:)
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
For immolation, it is better to use issued an order event,, this way you can check when started AND when stopped,,
JASS:
function StartImmolationCheck takes nothing returns boolean
   return GetIssuedOrderId() == OrderId("immolation")
endfunction
 
function StopImmolationCheck takes nothing returns boolean
   return GetIssuedOrderId() == OrderId("unimmolation")
endfunction
 
function Init takes nothing returns nothing
   local trigger t = CreateTrigger()
   call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
   // choose your condition here
   // add actions
endfunction
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
For immolation, it is better to use issued an order event,, this way you can check when started AND when stopped,,
JASS:
function StartImmolationCheck takes nothing returns boolean
   return GetIssuedOrderId() == OrderId("immolation")
endfunction
 
function StopImmolationCheck takes nothing returns boolean
   return GetIssuedOrderId() == OrderId("unimmolation")
endfunction
 
function Init takes nothing returns nothing
   local trigger t = CreateTrigger()
   call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
   // choose your condition here
   // add actions
endfunction


Thanks,
However I changed some things, and got this now, but it still doesn't work.

JASS:
scope GuardianStanceOn initializer init

private function OnCast takes nothing returns boolean
    local unit u
    local integer bonus
    local integer i
    
    set u = GetTriggerUnit()
    if GetIssuedOrderId() == String2OrderIdBJ("immolation") and GetUnitTypeId(u) == 'Nbst' then
        set i = GetPlayerId(GetOwningPlayer(u))
        set bonus = 20
        set PlayerParryBonus[i] = PlayerParryBonus[i] + bonus*3
        set PlayerCritBonus[i] = PlayerCritBonus[i] - bonus*2
        set u = null
    endif
    
    return false
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_ISSUED_ORDER)
    call TriggerAddCondition(trig, Condition(function OnCast))
    set trig = null
endfunction

endscope

Stressy!:p
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
What is it supposed to do? Remember you only set the variables, you need to use them somewhere to make them have effect!
Also, dont put the
JASS:
 set u = null
inside if/then/else, cause you still set it as triggering unit, so it will leak,,
Also, make it a condition,, since all actions are ONLY done if that is true,,
JASS:
scope GuardianStanceOn initializer init
 
   private function Condition takes nothing returns boolean
      return GetIssuedOrderId() == String2OrderIdBJ("immolation") and GetUnitTypeId(GetTriggerUnit()) == 'Nbst'
   endfunction
   private function OnCast takes nothing returns nothing
      local unit u
      local integer bonus
      local integer i
      set u = GetTriggerUnit()
      set i = GetPlayerId(GetOwningPlayer(u))
      set bonus = 20
      set PlayerParryBonus[i] = PlayerParryBonus[i] + bonus*3
      set PlayerCritBonus[i] = PlayerCritBonus[i] - bonus*2
      set u = null 
   endfunction
 
   private function init takes nothing returns nothing
      local trigger trig = CreateTrigger()
      call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_ISSUED_ORDER)
      call TriggerAddCondition(trig, function Condition)
      call TriggerAddAction(trig, function OnCast)
      set trig = null
   endfunction
endscope

Omg? You tried to add all those actions as conditions,, you have to set them as actions, and make conditions seperately
this should work
 
Level 7
Joined
Oct 14, 2008
Messages
340
Using issue order event = fail.
Your trigger will go off if your unit is issued the immolation order EVEN if the unit is stunned or disabled, which can often be.. a bad thing. :) I'd also recommend using buff detection.
 
Level 9
Joined
Apr 5, 2008
Messages
529
Yixx, don't make this hard for him, and don't give him tips as you obviously don't know anything about it.

Teuncreemers, keep coding the way you're doing it, it's more efficient. Using conditions to execute whatever you want to execute is faster than using actions, because you don't have to create a new thread.

And use a timer+struct to detect when the buff is gone, I could do the script for you if you want me to.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Yixx, don't make this hard for him, and don't give him tips as you obviously don't know anything about it.

Teuncreemers, keep coding the way you're doing it, it's more efficient. Using conditions to execute whatever you want to execute is faster than using actions, because you don't have to create a new thread.

And use a timer+struct to detect when the buff is gone, I could do the script for you if you want me to.

Oke thanks for the help:)
Was kinda confused, but not anymore.
You don't have to do the script for me, I will give it a few more tries, and if that goes wrong I will come back and whine here:p

Thank you guys.
 
Status
Not open for further replies.
Top