- Joined
- Aug 4, 2008
- Messages
- 7
JASS:
scope AutoCastSystem initializer I
globals
private region R
endglobals
private struct ACS
//! runtextmacro PUI()
integer array orderidN [3]
integer array orderidP [3]
integer array orderidAOE [2]
unit caster
endstruct
private function C1 takes nothing returns boolean
return udg_Race[GetPlayerId(GetOwningPlayer(GetFilterUnit()))+1] == "HoMM" and GetUnitState(GetFilterUnit(), UNIT_STATE_MAX_MANA) > 1 and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true
// return udg_Race[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))+1] == "HoMM" and GetUnitState(GetTriggerUnit(), UNIT_STATE_MAX_MANA) > 1 and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true
endfunction
private function C3 takes nothing returns boolean
//call BJDebugMsg("C3")
return udg_Race[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))+1] == "HoMM" and GetUnitState(GetTriggerUnit(), UNIT_STATE_MAX_MANA) > 1
endfunction
private function C2 takes nothing returns boolean
if IsUnitAnEnemy() == false then
//call BJDebugMsg("false")
else
//call BJDebugMsg("true")
endif
return IsUnitAnEnemy() == false
endfunction
private function A2 takes nothing returns nothing
local ACS dat = ACS[GetTriggerUnit()]
local unit u
local integer i = GetRandomInt(1, 2)
call BJDebugMsg(GetUnitName(dat.caster) + "'s ACS is restored?")
set udg_Player = GetOwningPlayer(GetTriggerUnit())
call GroupEnumUnitsInRange(G, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 500, Condition(function IsUnitAnEnemy))
set u = GetRandomUnit(G)
call BJDebugMsg(GetUnitName(u) + " is the targeted unit (ACS)")
//if IssueTargetOrder(dat.caster, "channel", u) == false then
if IssueTargetOrderById(dat.caster, dat.orderidN[0], u) == false then
call BJDebugMsg("1")
if IssueTargetOrderById(dat.caster, dat.orderidN[1], u) == false then
call BJDebugMsg("2")
call IssueTargetOrderById(dat.caster, dat.orderidN[2], u)
endif
endif
call GroupClear(G)
call GroupEnumUnitsInRange(G, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 500, Condition(function C2))
set u = GetRandomUnit(G)
if IssueTargetOrderById(dat.caster, dat.orderidP[0], u) == false then
call BJDebugMsg("1")
if IssueTargetOrderById(dat.caster, dat.orderidP[1], u) == false then
call BJDebugMsg("2")
call IssueTargetOrderById(dat.caster, dat.orderidP[2], u)
endif
endif
call GroupClear(G)
call GroupEnumUnitsInRange(G, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 500, Condition(function IsUnitAnEnemy))
set u = GetRandomUnit(G)
if IssuePointOrderById(dat.caster, dat.orderidN[0], GetUnitX(u), GetUnitY(u)) == false then
if IssuePointOrderById(dat.caster, dat.orderidN[1], GetUnitX(u), GetUnitY(u)) == false then
call IssueTargetOrder(dat.caster, "attack", u)
endif
endif
call GroupClear(G)
set u = null
endfunction
private function A takes nothing returns nothing
local ACS dat = ACS.create()
set dat.caster = GetTriggerUnit()
set ACS[dat.caster] = dat
call BJDebugMsg(GetUnitName(dat.caster) + " now has ACS")
if GetUnitTypeId(GetTriggerUnit()) == 'H029' then // Mage
call BJDebugMsg("MAGE MAGE MAGE")
set dat.orderidN[0] = 852600 // Fist of Wrath
set dat.orderidP[0] = 852577 // Rigtheous Might
elseif GetUnitTypeId(GetTriggerUnit()) == 'H02B' then // Storm Titan
set dat.orderidAOE[0] = 852221 // Stormcaller
elseif GetUnitTypeId(GetTriggerUnit()) == 'H03C' then // Djinn Sultan
set dat.orderidN[0] = 852600 // RandomCB
set dat.orderidP[0] = 852600 // RandomCB
elseif GetUnitTypeId(GetTriggerUnit()) == 'H02Y' then // Shadow Matriarch
set dat.orderidP[0] = 852577 // Rightous Might
set dat.orderidN[0] = 852149 // Vulnerability
set dat.orderidN[1] = 852135 // Slow
set dat.orderidN[2] = 852181 // Confusion
elseif GetUnitTypeId(GetTriggerUnit()) == 'H036' then // Pit Lord
set dat.orderidN[0] = 852149 // Vulnerability
set dat.orderidAOE[0] = 852223 // Fireball
set dat.orderidAOE[1] = 852495 // Meteor Shower
endif
endfunction
//===========================================================================
private function I takes nothing returns nothing
local trigger t = CreateTrigger()
set R = CreateRegion()
call RegionAddRect(R, bj_mapInitialPlayableArea)
call TriggerRegisterEnterRegion(t, R, Condition(function C1))
call TriggerAddAction(t, function A)
set t = CreateTrigger()
call TriggerRegisterAnyUnitTargetAcquired(t)
call TriggerAddCondition(t, Condition(function C3))
call TriggerAddAction(t, function A2)
endfunction
endscope
I'm trying to create an autocasting system for a race of my maul map.
For testing purposes, only a few units are in it yet.
The problem is, ordering never works.
SOMETIMES, it works once (the first time an enemy nears the unit, and my unit notices it, and then casts a spell), but after that, no matter how many enemies come, only the "<unit>'s ACS is restored" text appears, and numbers not.
Thanks for help in advance.