WolfieeifloW
WEHZ Helper
- Reaction score
- 372
Hey there guys.
I've been trying for an hour now to try and change this trigger to work with multiple spells, but can't get it to work!
I have a trigger that intercepts auto-cast spells that I don't want to be auto-cast, and stops the player from setting them to auto-cast (A mouthful!).
Ex: An ability based on Searing Arrows, used because it just adds onto the hero's attack. I don't want the player to be able to actually use the auto-cast part of it, so the trigger intercepts the auto-cast command and stops it.
Here's my trigger:
Now..
I want to change it so that the if checks what hero unit the trigger is used by.
I want to change so that it disable/enables the used ability.
I've tried so many ways to do something this simple, but it doesn't work..
I'm going to have probably two heroes, with ~3 spells each that use this fake auto-cast spell thing.
So what I want is this trigger changed so that it:
Checks what hero issued the order, and if the order != the 4th spell the hero has.
I'm assuming just like:
Gets whatever integer ability was used, and passes it throughout.
Like:
Can anyone help?
/EDIT: I've tried to change my code like below, but whenever I try to learn a skill it displays the simerror, and whenever I try to auto-cast the spell it displays the simerror (Which it should) but still allows the spell to go on auto-cast.
/EDIT2: This code works, but I don't want to have multiple callback functions:
I've been trying for an hour now to try and change this trigger to work with multiple spells, but can't get it to work!
I have a trigger that intercepts auto-cast spells that I don't want to be auto-cast, and stops the player from setting them to auto-cast (A mouthful!).
Ex: An ability based on Searing Arrows, used because it just adds onto the hero's attack. I don't want the player to be able to actually use the auto-cast part of it, so the trigger intercepts the auto-cast command and stops it.
Here's my trigger:
JASS:
scope NoAutoCast initializer NACInit
globals
private unit nacUnit
private player nacPlayer
private timer nacTimer = CreateTimer()
private constant integer nacMangle = 039;A00C039;
endglobals
private function CallBack takes nothing returns nothing
call SetPlayerAbilityAvailable(nacPlayer, nacMangle, true)
endfunction
private function Conditions takes nothing returns boolean
if (GetIssuedOrderId() == OrderId("coldarrows") and GetUnitTypeId(GetTriggerUnit()) == mDruid) then
set nacUnit = GetTriggerUnit()
set nacPlayer = GetOwningPlayer(nacUnit)
call SetPlayerAbilityAvailable(nacPlayer, nacMangle, false)
call TimerStart(nacTimer, 0.00, false, function CallBack)
call SimError(nacPlayer, "This spell isn039;t auto-cast!")
endif
return false
endfunction
private function NACInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer index = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function Conditions))
set t = null
endfunction
endscope
Now..
I want to change it so that the if checks what hero unit the trigger is used by.
I want to change so that it disable/enables the used ability.
I've tried so many ways to do something this simple, but it doesn't work..
I'm going to have probably two heroes, with ~3 spells each that use this fake auto-cast spell thing.
So what I want is this trigger changed so that it:
Checks what hero issued the order, and if the order != the 4th spell the hero has.
I'm assuming just like:
JASS:
if (GetUnitTypeId(GetTriggerUnit()) == 039;U000039; and GetSpellAbilityId() != 039;A000039; or GetUnitTypeId(GetTriggerUnit()) == 039;U001039; and GetSpellAbilityId() != 039;A001039;) then
Gets whatever integer ability was used, and passes it throughout.
Like:
JASS:
call SetPlayerAbilityAvailable(nacPlayer, GetSpellAbilityId(), false)
Can anyone help?
/EDIT: I've tried to change my code like below, but whenever I try to learn a skill it displays the simerror, and whenever I try to auto-cast the spell it displays the simerror (Which it should) but still allows the spell to go on auto-cast.
JASS:
scope NoAutoCast initializer NACInit
globals
private unit nacUnit
private player nacPlayer
private timer nacTimer = CreateTimer()
private integer nacAbil
endglobals
private function CallBack takes nothing returns nothing
call SetPlayerAbilityAvailable(nacPlayer, nacAbil, true)
endfunction
private function Conditions takes nothing returns boolean
if (GetUnitTypeId(GetTriggerUnit()) == mDruid) then
set nacUnit = GetTriggerUnit()
set nacPlayer = GetOwningPlayer(nacUnit)
set nacAbil = GetSpellAbilityId()
call SetPlayerAbilityAvailable(nacPlayer, nacAbil, false)
call TimerStart(nacTimer, 0.00, false, function CallBack)
call SimError(nacPlayer, "This spell isn039;t auto-cast!")
endif
return false
endfunction
private function NACInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer index = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function Conditions))
set t = null
endfunction
endscope
/EDIT2: This code works, but I don't want to have multiple callback functions:
JASS:
scope NoAutoCast initializer NACInit
globals
private unit nacUnit
private player nacPlayer
private timer nacTimer = CreateTimer()
private constant integer nacMangle = 039;A00C039;
private constant integer nacClaw = 039;A00D039;
endglobals
private function CallbackMangle takes nothing returns nothing
call SetPlayerAbilityAvailable(nacPlayer, nacMangle, true)
endfunction
private function CallbackClaw takes nothing returns nothing
call SetPlayerAbilityAvailable(nacPlayer, nacClaw, true)
endfunction
private function Conditions takes nothing returns boolean
if (GetUnitTypeId(GetTriggerUnit()) == mDruid) then
set nacUnit = GetTriggerUnit()
set nacPlayer = GetOwningPlayer(nacUnit)
if (GetIssuedOrderId() == OrderId("coldarrows")) then
call SetPlayerAbilityAvailable(nacPlayer, nacMangle, false)
call TimerStart(nacTimer, 0.00, false, function CallbackMangle)
call SimError(nacPlayer, "This spell isn039;t auto-cast!")
elseif (GetIssuedOrderId() == OrderId("poisonarrows")) then
call SetPlayerAbilityAvailable(nacPlayer, nacClaw, false)
call TimerStart(nacTimer, 0.00, false, function CallbackClaw)
call SimError(nacPlayer, "This spell isn039;t auto-cast!")
endif
endif
return false
endfunction
private function NACInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer index = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function Conditions))
set t = null
endfunction
endscope