scope DotaWaterAPI initializer init /* v1.01 by dhguardianes!
****************************************************************************
Change water color in local player like dota command!
you can type
-water random
-water red
-water green
-water blue
-water ,255,255,255
****************************************************************************/
globals
private integer LG
private integer LB
private integer LR
endglobals
//! textmacro LWC takes r g b a
if GetLocalPlayer()==p then
call SetWaterBaseColor($r$, $g$, $b$,$a$)
endif
//! endtextmacro
private function FilterString takes string s returns nothing
local string r = ""
local string g = ""
local string b = ""
local integer i = 0
local integer Sleng = StringLength(s)
local integer EQ2 = 1
loop
exitwhen i > Sleng
if SubString(s, i, i + 1)==" "then
set EQ2 = EQ2 + 1
else
if EQ2==1 then
set r = r + SubString(s, i, i + 1)
elseif EQ2==2 then
set g = g + SubString(s, i, i + 1)
else
set b = b + SubString(s, i, i + 1)
endif
endif
set i = i + 1
endloop
set LR = S2I(r)
set LG = S2I(g)
set LB = S2I(b)
endfunction
private function f takes nothing returns boolean
local string s = SubString(GetEventPlayerChatString(), 7, StringLength(GetEventPlayerChatString()))
local player p = GetTriggerPlayer()
local integer r
local integer g
local integer b
if s=="red"then
//! runtextmacro LWC("255","0","0","255")
elseif s=="blue"then
//! runtextmacro LWC("0","0","255","255")
elseif s=="green"then
//! runtextmacro LWC("0","255","0","255")
elseif s=="default"then
//! runtextmacro LWC("255","255","255","255")
elseif s=="random"then
set r = GetRandomInt(0, 255)
set g = GetRandomInt(0, 255)
set b = GetRandomInt(0, 255)
//! runtextmacro LWC("r","g","b","255")
call DisplayTimedTextToPlayer(p, 0, 0, 5, "water color is: r=" + I2S(r) + " g=" + I2S(g) + " b=" + I2S(b))
else
call FilterString(s)
set r = LR
set g = LG
set b = LB
if r==0 and g==0 and b==0 and s!="0 0 0"then
return false
endif
if r>=0 and r<=255 and g>=0 and g<=255 and b>=0 and b<=255 then
//! runtextmacro LWC("r","g","b","255")
endif
endif
return false
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerChatEvent(t, Player(i), "-water", false )
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function f))
set t = null
endfunction
endscope