WarLuvr3393
Hmmm...too many things to play (WoW, COD4, WC3)
- Reaction score
- 54
Hello everyone. I'm creating a type of infantry map that has two sides. When a unit of that side is created, control is transferred to the computer of that team and is sent to attack 1 of 3 locations: west side, east side and center. The default attack location is the center. Now, using a command, a player can either type in "-attack left", "-attack right", or "attack middle". Now, when I type in "-attack left/right", the units travel to their respective locations. However, whenever I type nothing or "-attack middle" the footman go to the center of the map and then run back to their barracks. Here is this script:
I did this for both sides so this may not work for the other side as well. The "gg_rct_Blue_Castle" is a region around the blue castle, or in the case, the place where the footman attack the center.
Any ideas? Thanks in advanced.
~Spiky (WarLuvr)
JASS:
globals
rect North_Attack = gg_rct_Blue_Castle
endglobals
function North_Attack_Order takes nothing returns nothing
local string s = GetEventPlayerChatString()
if SubString(s, 8, 12) == "left" then
set North_Attack = gg_rct_South_Left
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "|cff80CC33All trained units will now attack the west side of the Southern Empire.")
elseif SubString(s, 8, 13) == "right" then
set North_Attack = gg_rct_South_Right
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "|cff80CC33All trained units will now attack the east side of the Southern Empire.")
elseif SubString(s, 8, 14) == "middle" then
set North_Attack = gg_rct_Blue_Castle
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "|cff80CC33All trained units will now attack the center of the Southern Empire.")
endif
endfunction
function North_Unit_Movement takes nothing returns nothing
local location l
call SetUnitOwner(GetTrainedUnit(),Player(0),false)
set l = GetRectCenter(North_Attack)
call IssuePointOrderLoc(GetTrainedUnit(), "attack", l)
call RemoveLocation(l)
set l = null
endfunction
function InitTrig_North_Sending takes nothing returns nothing
local trigger t = CreateTrigger()
local trigger s = CreateTrigger()
local integer i = 2
loop
exitwhen i > 6
call TriggerRegisterPlayerUnitEventSimple(t,Player(i),EVENT_PLAYER_UNIT_TRAIN_FINISH)
call TriggerRegisterPlayerChatEvent(s, Player(i), "-attack", false)
set i = i + 1
endloop
call TriggerAddAction(t, function North_Unit_Movement)
call TriggerAddAction(s, function North_Attack_Order)
endfunction
I did this for both sides so this may not work for the other side as well. The "gg_rct_Blue_Castle" is a region around the blue castle, or in the case, the place where the footman attack the center.
Any ideas? Thanks in advanced.
~Spiky (WarLuvr)