- Joined
- Oct 24, 2012
- Messages
- 6,545
hello i have this for a minigame i dont think i forgot anything just wondering if i could change something to make it faster / more efficient thanks to anyone tht helps
note : i did not make the respawn portion i may make tht in another trigger might be easier i didnt decide tht yet tho
note : i did not make the respawn portion i may make tht in another trigger might be easier i didnt decide tht yet tho
JASS:
scope CheckersMoving initializer Init_Checkers_Commands
globals
trigger trg_Checekrs_Commands // not sure if i need this or not
private integer Int
private integer c
private string chat
private integer g1
private integer g2
private integer g3
private integer p
private string OorE
private unit u1
private unit u2
endglobals
private function Kings takes nothing returns nothing
call SetUnitScale( u1, 200, 200, 200 )
call SetUnitUserData( u1, 2000 )
endfunction
private function bPlayer takes nothing returns nothing
local integer p1
if p == 0 then
set p1 = 1
if g2 >= 29 then
call Kings()
endif
elseif p == 1 then
set p1 = 0
if g2 <= 4 then
call Kings()
endif
endif
set b_Checkers_Player = false
set b_Checkers_Player[p1] = true
endfunction
private function move1 takes nothing returns nothing
call GroupRemoveUnit( CheckersG[g1], u1 )
call GroupAddUnit( CheckersG[g2], u1 )
set Checkers_Boolean_Reg[g1] = true
set Checkers_Boolean_Reg[g2] = false
call PauseUnit( u1, false )
call IssuePointOrder( u1, "move", CheckersX[g2], CheckersY[g2] )
call PolledWait( 1.00 )
call PauseUnit( u1, true )
set CheckersCounter = 0
call bPlayer()
endfunction
private function move2 takes nothing returns nothing
call GroupRemoveUnit( CheckersG[g1], u1 )
call GroupRemoveUnit( CheckersG[g3], u2 )
call GroupAddUnit( CheckersG[g2], u1 )
set Checkers_Boolean_Reg[g1] = true
set Checkers_Boolean_Reg[g3] = true
set Checkers_Boolean_Reg[g2] = false
call PauseUnit( u1, false )
call IssuePointOrder( u1, "attackmove", CheckersX[g2], CheckersY[g2] )
call PolledWait( 2.00 )
call PauseUnit( u1, true )
set g1 = g2
call bPlayer()
endfunction
private function Checkers_Checking takes nothing returns nothing
local integer i
set u1 = FirstOfGroup( CheckersG[g1] )
set i = GetUnitUserData( u1 )
if OorE == "odd" then
set g3 = R2I( (I2R( g1 + g2 ) / 2.0) - 0.5 )
set u2 = FirstOfGroup( CheckersG[g3] )
elseif OorE == "even" then
set g3 = R2I( (I2R( g1 + g2 ) / 2.0) + 0.5 )
set u2 = FirstOfGroup( CheckersG[g3] )
endif
if g1 < g2 and IsUnitAlly( u1, Player(p) ) == true and Checkers_Boolean_Reg[g2] == true then
call move1()
elseif g1 < g2 and IsUnitAlly( u1, Player(p) ) == true and IsUnitEnemy( u2, Player(p) ) and Checkers_Boolean_Reg[g2] == true then
call move2()
elseif g1 > g2 and i == 2000 and IsUnitAlly( u1, Player(p) ) == true and Checkers_Boolean_Reg[g2] == true then
call move1()
elseif g1 > g2 and i == 2000 and IsUnitAlly( u1, Player(p) ) == true and IsUnitEnemy( u2, Player(p) ) and Checkers_Boolean_Reg[g2] == true then
call move2()
elseif g1 == g2 then
set g1 = 0
set g2 = 0
set CheckersCounter = 0
call DisplayTextToForce( GetPlayersAll(), "Cant Enter Same Coordinates Twice" )
endif
endfunction
private function Checkers_Actions takes nothing returns nothing
if CheckersCounter == 0 then
set c = 0
set g1 = Int
set CheckersCounter = 1
elseif CheckersCounter == 1 then
set c = 1
set g2 = Int
call Checkers_Checking()
endif
endfunction
private function Checkers_Chats_Setup takes nothing returns nothing
set chat = GetEventPlayerChatString()
set p = GetPlayerId( GetTriggerPlayer() )
if b_Checkers_Player == true then
if chat == "A1" then
set Int = 1
set OorE = "odd"
elseif chat == "A3" then
set Int = 2
set OorE = "odd"
elseif chat == "A5" then
set Int = 3
set OorE = "odd"
elseif chat == "A7" then
set Int = 4
set OorE = "odd"
elseif chat == "B2" then
set Int = 5
set OorE = "even"
elseif chat == "B4" then
set Int = 6
set OorE = "even"
elseif chat == "B6" then
set Int = 7
set OorE = "even"
elseif chat == "B8" then
set Int = 8
set OorE = "even"
elseif chat == "C1" then
set Int = 9
set OorE = "odd"
elseif chat == "C3" then
set Int = 10
set OorE = "odd"
elseif chat == "C5" then
set Int = 11
set OorE = "odd"
elseif chat == "C7" then
set Int = 12
set OorE = "odd"
elseif chat == "D2" then
set Int = 13
set OorE = "even"
elseif chat == "D4" then
set Int = 14
set OorE = "even"
elseif chat == "D6" then
set Int = 15
set OorE = "even"
elseif chat == "D8" then
set Int = 16
set OorE = "even"
elseif chat == "E1" then
set Int = 17
set OorE = "odd"
elseif chat == "E3" then
set Int = 18
set OorE = "odd"
elseif chat == "E5" then
set Int = 19
set OorE = "odd"
elseif chat == "E7" then
set Int = 20
set OorE = "odd"
elseif chat == "F2" then
set Int = 21
set OorE = "even"
elseif chat == "F4" then
set Int = 22
set OorE = "even"
elseif chat == "F6" then
set Int = 23
set OorE = "even"
elseif chat == "F8" then
set Int = 24
set OorE = "even"
elseif chat == "G1" then
set Int = 25
set OorE = "odd"
elseif chat == "G3" then
set Int = 26
set OorE = "odd"
elseif chat == "G5" then
set Int = 27
set OorE = "odd"
elseif chat == "G7" then
set Int = 28
set OorE = "odd"
elseif chat == "H2" then
set Int = 29
set OorE = "even"
elseif chat == "H4" then
set Int = 30
set OorE = "even"
elseif chat == "H6" then
set Int = 31
set OorE = "even"
elseif chat == "H8" then
set Int = 32
set OorE = "even"
elseif chat == "END" then
set CheckersCounter = 0
endif
endif
if Int > 0 then
call Checkers_Actions()
endif
endfunction
//===========================================================================
private function Init_Checkers_Commands takes nothing returns nothing
local trigger t
local integer i
set i = 0
set t = CreateTrigger()
loop
exitwhen i > 1
call TriggerRegisterPlayerChatEvent( t, Player(i), "A1", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "A3", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "A5", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "A7", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "B2", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "B4", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "B6", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "B8", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "C1", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "C3", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "C5", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "C7", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "D2", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "D4", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "D6", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "D8", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "E1", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "E3", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "E5", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "E7", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "F2", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "F4", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "F6", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "F8", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "G1", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "G3", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "G5", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "G7", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "H2", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "H4", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "H6", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "H8", true )
call TriggerRegisterPlayerChatEvent( t, Player(i), "END", true )
set i = i + 1
endloop
call TriggerAddAction( t, function Checkers_Chats_Setup )
set t = null
endfunction
endscope