scope Diplomacy initializer init
function SetAllianceState takes string s, integer allianceType returns integer
local integer playerhelper = 0
local integer aid = 0
set s = StringCase(s,false)
if s=="red" then
set aid = 1
elseif s=="blue" then
set aid = 2
elseif s=="teal" then
set aid = 3
elseif s=="purple" then
set aid = 4
elseif s=="yellow" then
set aid = 5
elseif s=="orange" or s=="oj" then
set aid = 6
elseif s=="green" then
set aid = 7
elseif s=="pink" then
set aid = 8
elseif s=="gray" then
set aid = 9
elseif s=="light blue" or s=="lightblue" or s=="lb" then
set aid = 10
elseif s=="darkgreen" or s=="dark green" or s=="dg" then
set aid = 11
elseif s=="brown" then
set aid = 12
endif
if aid == 0 then
return 0
endif
call SetPlayerAllianceStateBJ(GetTriggerPlayer(),Player(aid-1),allianceType)
return aid
endfunction
private function UnallyActions takes nothing returns nothing
local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),8,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_UNALLIED)
local integer id = aid
if id == 0 then
return
endif
call SetPlayerAllianceStateBJ(Player(id-1),GetTriggerPlayer(),bj_ALLIANCE_UNALLIED)
call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00has expressed hostility towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction
private function WarActions takes nothing returns nothing
local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),5,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_UNALLIED)
local integer id = aid
if id == 0 then
return
endif
call SetPlayerAllianceStateBJ(Player(id-1),GetTriggerPlayer(),bj_ALLIANCE_UNALLIED)
call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00has expressed hostility towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction
private function NeutActions takes nothing returns nothing
local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),9,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_NEUTRAL)
local integer id = aid
if id == 0 then
return
endif
call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00is showing neutrality towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction
private function NAActions takes nothing returns nothing
local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),4,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_NEUTRAL)
local integer id = aid
if id == 0 then
return
endif
call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00is showing neutrality towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction
private function AllyActions takes nothing returns nothing
local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),6,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_ALLIED_VISION)
local integer id = aid
if id == 0 then
return
endif
call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00has allied|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction
private function init takes nothing returns nothing
local trigger a = CreateTrigger()
local trigger u = CreateTrigger()
local trigger w = CreateTrigger()
local trigger n = CreateTrigger()
local trigger na = CreateTrigger()
local integer i = 0
loop
exitwhen i > 11
call TriggerRegisterPlayerChatEvent(a,Player(i),"-ally ",false)
call TriggerRegisterPlayerChatEvent(u,Player(i),"-unally ",false)
call TriggerRegisterPlayerChatEvent(w,Player(i),"-war ",false)
call TriggerRegisterPlayerChatEvent(n,Player(i),"-neutral ",false)
call TriggerRegisterPlayerChatEvent(na,Player(i),"-na ",false)
set i = i + 1
endloop
call TriggerAddAction(a,function AllyActions)
call TriggerAddAction(u,function UnallyActions)
call TriggerAddAction(w,function WarActions)
call TriggerAddAction(n,function NeutActions)
call TriggerAddAction(na,function NAActions)
endfunction
endscope