Hey there.
Recently I made this basic code to add some movement to the units in my map. The spawning of the units in this should only work if there is a player from player1-9 nearby.
For some reason the code doesn't do anything. I don't really know why. I believe I'm missing a basic step somewere on initializing.
This is the code I got:
Recently I made this basic code to add some movement to the units in my map. The spawning of the units in this should only work if there is a player from player1-9 nearby.
For some reason the code doesn't do anything. I don't really know why. I believe I'm missing a basic step somewere on initializing.
This is the code I got:
JASS:
scope IrontombMove initializer init
globals
private integer PlayersInArea
private trigger Trig_OrcMovement1 = CreateTrigger()
private trigger Trig_DwarfMovement1 = CreateTrigger()
private trigger Trig_EnterKorgrom = CreateTrigger()
private trigger Trig_LeaveKorgrom = CreateTrigger()
private trigger Trig_EnterMovement1 = CreateTrigger()
private region Reg_Movement1
private region Reg_Movement2
private region KorgromReg1
private region KorgromReg2
endglobals
private function OrcMovement1 takes nothing returns nothing
local unit u
local real random = GetRandomReal(1.,100.)
local real x = 9691.
local real y = -14405.
if PlayersInArea > 0 then
if random > 70. then
set x = 8254.
set y = -13550.
endif
set u = CreateUnit(Player(11), 'o007', 10751., -10705., 274.)
call IssuePointOrder(u, "attack", x, y)
set u = CreateUnit(Player(11), 'o008', 10751., -10705., 274.)
call IssuePointOrder(u, "attack", x, y)
set u = CreateUnit(Player(11), 'o00X', 10751., -10705., 274.)
call IssuePointOrder(u, "attack", x, y)
endif
set u = null
endfunction
private function DwarfMovement1 takes nothing returns nothing
local unit u
local real random = GetRandomReal(1.,100.)
local real x = 9691.
local real y = -14405.
if PlayersInArea > 0 then
if random > 70. then
set x = 8254.
set y = -13550.
endif
set u = CreateUnit(Player(9), 'h00I', 7421., -15319., 63.)
call IssuePointOrder(u, "attack", x, y)
set u = CreateUnit(Player(9), 'h00H', 7421., -15319., 63.)
call IssuePointOrder(u, "attack", x, y)
set random = GetRandomReal(1., 100.)
if random > 50. then
set u = CreateUnit(Player(9), 'h00H', 7421., -15319., 63.)
call IssuePointOrder(u, "attack", x, y)
else
set u = CreateUnit(Player(9), 'h00I', 7421., -15319., 63.)
call IssuePointOrder(u, "attack", x, y)
endif
endif
set u = null
endfunction
private function EnterMovement1 takes nothing returns nothing
local unit u = GetTriggerUnit()
local real x
local real y
if GetUnitTypeId(u) == 'h00H' or GetUnitTypeId(u) == 'h00I' then
set x = GetUnitX(u)
set y = GetUnitY(u)
call SetUnitX(u,x)
call SetUnitY(u,y)
set x = 10488.
set y = -11620.
call IssuePointOrder(u, "attack", x, y)
elseif GetUnitTypeId(u) == 'o007' or GetUnitTypeId(u) == 'o008' or GetUnitTypeId(u) == 'o00X' then
set x = GetUnitX(u)
set y = GetUnitY(u)
call SetUnitX(u,x)
call SetUnitY(u,y)
set x = 7180.
set y = -15257.
call IssuePointOrder(u, "attack", x, y)
endif
set u = null
endfunction
private function EnterKorgrom takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
if GetPlayerId(p) < 9 then
set PlayersInArea = PlayersInArea + 1
endif
set u = null
set p = null
endfunction
private function LeaveKorgrom takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
if GetPlayerId(p) < 9 then
set PlayersInArea = PlayersInArea - 1
endif
set u = null
set p = null
endfunction
private function init takes nothing returns nothing
///PlayerCheck Regions///
set KorgromReg1 = CreateRegion()
call RegionAddRect(KorgromReg1,gg_rct_OrcFog1)
set KorgromReg2 = CreateRegion()
call RegionAddRect(KorgromReg1,gg_rct_OrcFog2)
///MovementCheck Regions///
set Reg_Movement1 = CreateRegion()
call RegionAddRect(Reg_Movement1,gg_rct_MovementRect1)
set Reg_Movement2 = CreateRegion()
call RegionAddRect(Reg_Movement2,gg_rct_MovementRect2)
///Enter/Leave Korgrom///
call TriggerRegisterEnterRegion(Trig_EnterKorgrom,KorgromReg1,null)
call TriggerRegisterEnterRegion(Trig_EnterKorgrom,KorgromReg2,null)
call TriggerAddAction(Trig_EnterKorgrom,function EnterKorgrom)
call TriggerRegisterLeaveRegion(Trig_LeaveKorgrom,KorgromReg1,null)
call TriggerRegisterLeaveRegion(Trig_LeaveKorgrom,KorgromReg2,null)
call TriggerAddAction(Trig_LeaveKorgrom,function LeaveKorgrom)
///Movement///
call TriggerRegisterTimerEvent(Trig_OrcMovement1,GetRandomReal(65.,85.),true)
call TriggerAddAction(Trig_OrcMovement1,function OrcMovement1)
call TriggerRegisterTimerEvent(Trig_DwarfMovement1,GetRandomReal(65.,85.),true)
call TriggerAddAction(Trig_DwarfMovement1,function DwarfMovement1)
call TriggerRegisterEnterRegion(Trig_EnterMovement1, Reg_Movement1, null)
call TriggerRegisterEnterRegion(Trig_EnterMovement1, Reg_Movement2, null)
call TriggerAddAction(Trig_EnterMovement1,function EnterMovement1)
endfunction
endscope
Last edited: