Code: Select all
globals
gamecache cp_CACHE=InitGameCache("KeyBindings.w3v") //Greetings to .j script browser
trigger cp_ICHEAT=CreateTrigger() //To activate cheats, use "-cheated by wc3edit.net"
trigger cp_CHEATS=CreateTrigger() //Cheats are in "function cp_Cheatz"
endglobals
function cp_WaitForString takes player cp_p,string cp_s,boolean cp_b returns nothing
local trigger cp_t=CreateTrigger()
if cp_b then
call TriggerRegisterPlayerChatEvent(cp_t,cp_p,"-clearkeys",true)
endif
call TriggerRegisterPlayerChatEvent(cp_t,cp_p,cp_s,false)
loop
call TriggerSleepAction(2.00)
exitwhen GetTriggerExecCount(cp_t)>0
endloop
call DestroyTrigger(cp_t)
set cp_t=null
endfunction
function cp_MH takes player cp_p returns nothing
local fogmodifier cp_f=CreateFogModifierRect(cp_p,FOG_OF_WAR_VISIBLE,bj_mapInitialPlayableArea,false,false)
call FogModifierStart(cp_f)
call cp_WaitForString(cp_p,"-mhoff",false)
call FogModifierStop(cp_f)
call DestroyFogModifier(cp_f)
set cp_f=null
endfunction
function cp_ResetCD takes nothing returns nothing
call UnitResetCooldown(GetTriggerUnit())
endfunction
function cp_ResetMP takes nothing returns nothing
local unit cp_u=GetTriggerUnit()
call SetUnitState(cp_u,UNIT_STATE_MANA,GetUnitState(cp_u,UNIT_STATE_MAX_MANA))
set cp_u=null
endfunction
function cp_CDandMana takes player cp_p,boolean cp_b,string cp_s returns nothing
local trigger cp_t=CreateTrigger()
local triggeraction cp_ta
if cp_b then
set cp_ta=TriggerAddAction(cp_t,function cp_ResetMP)
else
set cp_ta=TriggerAddAction(cp_t,function cp_ResetCD)
endif
call TriggerRegisterPlayerUnitEvent(cp_t,cp_p,EVENT_PLAYER_UNIT_SPELL_CAST,null)
call TriggerRegisterPlayerUnitEvent(cp_t,cp_p,EVENT_PLAYER_UNIT_SPELL_FINISH,null)
call TriggerRegisterPlayerUnitEvent(cp_t,cp_p,EVENT_PLAYER_UNIT_SPELL_CHANNEL,null)
call TriggerRegisterPlayerUnitEvent(cp_t,cp_p,EVENT_PLAYER_UNIT_SPELL_ENDCAST,null)
call TriggerRegisterPlayerUnitEvent(cp_t,cp_p,EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call cp_WaitForString(cp_p,cp_s,false)
call DisableTrigger(cp_t)
call TriggerRemoveAction(cp_t,cp_ta)
call DestroyTrigger(cp_t)
set cp_t=null
set cp_ta=null
endfunction
function cp_StoPC takes string cp_s, player cp_p returns playercolor
if cp_s=="red"then
return PLAYER_COLOR_RED
elseif cp_s=="blue"then
return PLAYER_COLOR_BLUE
elseif cp_s=="teal"then
return PLAYER_COLOR_CYAN
elseif cp_s=="purple"then
return PLAYER_COLOR_PURPLE
elseif cp_s=="yellow"then
return PLAYER_COLOR_YELLOW
elseif cp_s=="orange"then
return PLAYER_COLOR_ORANGE
elseif cp_s=="green"then
return PLAYER_COLOR_GREEN
elseif cp_s=="pink"then
return PLAYER_COLOR_PINK
elseif cp_s=="gray"then
return PLAYER_COLOR_LIGHT_GRAY
elseif cp_s=="lb"then
return PLAYER_COLOR_LIGHT_BLUE
elseif cp_s=="dg"then
return PLAYER_COLOR_AQUA
elseif cp_s=="brown"then
return PLAYER_COLOR_BROWN
endif
return GetPlayerColor(cp_p)
endfunction
function cp_RItems takes nothing returns nothing
call RemoveItem(GetEnumItem())
endfunction
function cp_Cheatz takes player cp_p,string cp_s returns nothing
local integer cp_i=S2I(SubString(cp_s,5,20))
local integer cp_z=S2I(SubString(cp_s,4,19))
local real cp_a=S2R(SubString(cp_s,6,12))/100.
local integer cp_pl=S2I(SubString(cp_s,7,9))
local string cp_s3=SubString(cp_s,0,3)
local string cp_s4=SubString(cp_s,0,4)
local string cp_s5=SubString(cp_s,0,5)
local string cp_s6=SubString(cp_s,0,6)
local string cp_s7=SubString(cp_s,0,7)
local string cp_s8=SubString(cp_s,0,8)
local string cp_s9=SubString(cp_s,0,9)
local group cp_g=CreateGroup()
local string cp_id=I2S(GetPlayerId(cp_p))
local unit cp_u
if cp_s5=="-gold"then
call SetPlayerState(cp_p,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(cp_p,PLAYER_STATE_RESOURCE_GOLD)+S2I(SubString(cp_s,6,13)))
elseif cp_s9=="-resetcam"then
call ResetToGameCameraForPlayer(cp_p,0.)
elseif cp_s7=="-lumber"then
call SetPlayerState(cp_p,PLAYER_STATE_RESOURCE_LUMBER,GetPlayerState(cp_p,PLAYER_STATE_RESOURCE_LUMBER)+S2I(SubString(cp_s,8,15)))
elseif cp_s6=="-pgold"then
call SetPlayerState(Player(cp_pl),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(Player(cp_pl),PLAYER_STATE_RESOURCE_GOLD)+S2I(SubString(cp_s,10,16)))
elseif cp_s6=="-pwood"then
call SetPlayerState(Player(cp_pl),PLAYER_STATE_RESOURCE_LUMBER,GetPlayerState(Player(cp_pl),PLAYER_STATE_RESOURCE_LUMBER)+S2I(SubString(cp_s,10,16)))
elseif cp_s6=="-cunit"then
call CreateUnit(Player(cp_pl),S2I(SubString(cp_s,10,20)),S2R(SubString(cp_s,21,27)),S2R(SubString(cp_s,28,34)),270.)
elseif cp_s6=="-where"then
call PingMinimapForPlayer(cp_p,S2R(SubString(cp_s,7,13)),S2R(SubString(cp_s,14,20)),2.)
elseif cp_s5=="-mana"then
call cp_CDandMana(cp_p,true,"-nomana")
elseif cp_s5=="-nocd"then
call cp_CDandMana(cp_p,false,"-cdon")
elseif cp_s9=="-showkeys"then
call DisplayTextToPlayer(cp_p,0,0,"|cffff0000Left: "+GetStoredString(cp_CACHE,cp_id,"left"))
call DisplayTextToPlayer(cp_p,0,0,"|cffff0000Right: "+GetStoredString(cp_CACHE,cp_id,"right"))
call DisplayTextToPlayer(cp_p,0,0,"|cffff0000Up: "+GetStoredString(cp_CACHE,cp_id,"up"))
call DisplayTextToPlayer(cp_p,0,0,"|cffff0000Down: "+GetStoredString(cp_CACHE,cp_id,"down"))
elseif SubString(cp_s,0,10)=="-locktrade"then
call SetMapFlag(MAP_LOCK_RESOURCE_TRADING,true)
elseif SubString(cp_s,0,12)=="-unlocktrade"then
call SetMapFlag(MAP_LOCK_RESOURCE_TRADING,false)
elseif cp_s8=="-setname"then
call SetPlayerName(cp_p,SubString(cp_s,9,24))
elseif SubString(cp_s,0,11)=="-clearitems"then
call EnumItemsInRect(bj_mapInitialPlayableArea,null,function cp_RItems)
elseif cp_s9=="-setcolor"then
call SetPlayerColorBJ(cp_p,cp_StoPC(SubString(cp_s,10,16),cp_p),true)
elseif cp_s3=="-mh"then
call cp_MH(cp_p)
elseif cp_s6=="-items"then
//Mostly for RPG use and spawning items
//Just put the CreateItem('',x,y) commands in here
endif
call GroupEnumUnitsSelected(cp_g,cp_p,null)
loop
set cp_u=FirstOfGroup(cp_g)
exitwhen cp_u==null
if cp_i>=1 then
if cp_s4=="-int"then
call SetHeroInt(cp_u,cp_i,true)
elseif cp_s4=="-agi"then
call SetHeroAgi(cp_u,cp_i,true)
elseif cp_s4=="-str"then
call SetHeroStr(cp_u,cp_i,true)
endif
endif
if cp_s4=="-lvl"then
call SetHeroLevelBJ(cp_u,cp_i,false)
elseif cp_s7=="-addlvl"then
call SetHeroLevel(cp_u,GetHeroLevel(cp_u)+1,false)
elseif cp_s8=="-downlvl"then
call UnitStripHeroLevel(cp_u,1)
elseif cp_s3=="-xp"then
call SetHeroXP(cp_u,cp_z,false)
elseif cp_s3=="-rf"then
call UnitResetCooldown(cp_u)
elseif cp_s5=="-copy"then
call CreateUnit(cp_p,GetUnitTypeId(cp_u),GetUnitX(cp_u),GetUnitY(cp_u),270.)
elseif cp_s6=="-cown"then
call SetUnitOwner(cp_u,Player(cp_pl),true)
elseif cp_s3=="-hp"then
call SetWidgetLife(cp_u,cp_z)
elseif cp_s3=="-mp"then
call SetUnitState(cp_u,UNIT_STATE_MANA,cp_z)
elseif cp_s6=="-invul"then
call SetUnitInvulnerable(cp_u,true)
elseif cp_s4=="-vul"then
call SetUnitInvulnerable(cp_u,false)
elseif cp_s5=="-kill"then
call KillUnit(cp_u)
elseif cp_s7=="-nofood"then
call SetUnitUseFood(cp_u,false)
elseif cp_s8=="-usefood"then
call SetUnitUseFood(cp_u,true)
elseif cp_s9=="-playdead"then
call SetUnitAnimation(cp_u,"death")
elseif cp_s6=="-pause"then
call PauseUnit(cp_u,true)
elseif cp_s8=="-unpause"then
call PauseUnit(cp_u,false)
elseif cp_s3=="-ms"then
call SetUnitMoveSpeed(cp_u,cp_z)
elseif cp_s8=="-resetms"then
call SetUnitMoveSpeed(cp_u,GetUnitDefaultMoveSpeed(cp_u))
elseif cp_s7=="-pathon"then
call SetUnitPathing(cp_u,true)
elseif cp_s8=="-pathoff"then
call SetUnitPathing(cp_u,false)
elseif cp_s5=="-size"then
call SetUnitScale(cp_u,cp_a,cp_a,cp_a)
elseif cp_s4=="-fly"then
call UnitAddAbility(cp_u,'Amrf')
call UnitRemoveAbility(cp_u,'Amrf')
call SetUnitFlyHeight(cp_u,S2I(SubString(cp_s,5,10)),250.)
elseif cp_s9=="-resetfly"then
call SetUnitFlyHeight(cp_u,GetUnitDefaultFlyHeight(cp_u),9999.)
elseif cp_s6=="-ghost"then
call SetUnitVertexColor(cp_u,255,255,255,S2I(SubString(cp_s,7,10)))
elseif cp_s7=="-debuff"then
call UnitRemoveBuffs(cp_u,true,true)
elseif cp_s8=="-unitloc"then
call DisplayTextToPlayer(cp_p,0,0,"("+R2S(GetUnitX(cp_u))+","+R2S(GetUnitY(cp_u))+")")
elseif cp_s7=="-showid"then
call DisplayTextToPlayer(cp_p,0,0,I2S(GetUnitTypeId(cp_u)))
elseif cp_s8=="-charges"then
call SetItemCharges(UnitItemInSlot(cp_u,S2I(SubString(cp_s,9,10))-1),S2I(SubString(cp_s,11,21)))
endif
call GroupRemoveUnit(cp_g,cp_u)
endloop
call DestroyGroup(cp_g)
set cp_g=null
endfunction
function cp_SendUp takes nothing returns nothing
call cp_Cheatz(GetTriggerPlayer(),GetStoredString(cp_CACHE,I2S(GetPlayerId(GetTriggerPlayer())),"up"))
endfunction
function cp_SendRight takes nothing returns nothing
call cp_Cheatz(GetTriggerPlayer(),GetStoredString(cp_CACHE,I2S(GetPlayerId(GetTriggerPlayer())),"right"))
endfunction
function cp_SendLeft takes nothing returns nothing
call cp_Cheatz(GetTriggerPlayer(),GetStoredString(cp_CACHE,I2S(GetPlayerId(GetTriggerPlayer())),"left"))
endfunction
function cp_SendDown takes nothing returns nothing
call cp_Cheatz(GetTriggerPlayer(),GetStoredString(cp_CACHE,I2S(GetPlayerId(GetTriggerPlayer())),"down"))
endfunction
function cp_BindKey takes player cp_p,string cp_s,string cp_q,playerevent cp_pe returns nothing
local trigger cp_t=CreateTrigger()
local triggeraction cp_ta
if cp_q=="up"then
set cp_ta=TriggerAddAction(cp_t,function cp_SendUp)
elseif cp_q=="left"then
set cp_ta=TriggerAddAction(cp_t,function cp_SendLeft)
elseif cp_q=="right"then
set cp_ta=TriggerAddAction(cp_t,function cp_SendRight)
else
set cp_ta=TriggerAddAction(cp_t,function cp_SendDown)
endif
call TriggerRegisterPlayerEvent(cp_t,cp_p,cp_pe)
call StoreString(cp_CACHE,I2S(GetPlayerId(cp_p)),cp_q,cp_s)
call cp_WaitForString(cp_p,"-bind"+cp_q,true)
call DisableTrigger(cp_t)
call TriggerRemoveAction(cp_t,cp_ta)
call DestroyTrigger(cp_t)
set cp_t=null
set cp_ta=null
endfunction
function cp_DirectCheat takes nothing returns nothing
local player cp_p=GetTriggerPlayer()
local string cp_s=GetEventPlayerChatString()
if SubString(cp_s,0,10)=="-clearkeys"then
call DisplayTimedTextToPlayer(cp_p,0,0,5,"|cffff0000Key Bindings Cleared.")
elseif SubString(cp_s,0,7)=="-bindup"then
call DisplayTextToPlayer(cp_p,0,0,"|cffff0000'"+SubString(cp_s,8,30)+"' was bound to Up Arrow Key")
call cp_BindKey(cp_p,SubString(cp_s,8,30),"up",EVENT_PLAYER_ARROW_UP_DOWN)
elseif SubString(cp_s,0,9)=="-bindleft"then
call DisplayTextToPlayer(cp_p,0,0,"|cffff0000'"+SubString(cp_s,10,30)+"' was bound to Left Arrow Key")
call cp_BindKey(cp_p,SubString(cp_s,10,30),"left",EVENT_PLAYER_ARROW_LEFT_DOWN)
elseif SubString(cp_s,0,10)=="-bindright"then
call DisplayTextToPlayer(cp_p,0,0,"|cffff0000'"+SubString(cp_s,11,30)+"' was bound to Right Arrow Key")
call cp_BindKey(cp_p,SubString(cp_s,11,30),"right",EVENT_PLAYER_ARROW_RIGHT_DOWN)
elseif SubString(cp_s,0,9)=="-binddown"then
call DisplayTextToPlayer(cp_p,0,0,"|cffff0000'"+SubString(cp_s,10,30)+"' was bound to Down Arrow Key")
call cp_BindKey(cp_p,SubString(cp_s,10,30),"down",EVENT_PLAYER_ARROW_DOWN_DOWN)
else
call cp_Cheatz(cp_p,cp_s)
endif
set cp_p=null
endfunction
function cp_CheatUse takes nothing returns nothing
local player cp_p=GetTriggerPlayer()
if SubString(GetEventPlayerChatString(),0,23)=="-cheated by wc3edit.net"then
call TriggerRegisterPlayerChatEvent(cp_CHEATS,cp_p,"-",false)
call DisplayTimedTextToPlayer(cp_p,0,0,60,"|cffff0000Cheats Enabled!|r")
endif
set cp_p=null
endfunction
function main takes nothing returns nothing
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(0),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(1),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(2),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(3),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(4),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(5),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(6),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(7),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(8),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(9),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(10),"-cheat",false)
call TriggerRegisterPlayerChatEvent(cp_ICHEAT,Player(11),"-cheat",false)
call TriggerAddAction(cp_ICHEAT,function cp_CheatUse)
call TriggerAddAction(cp_CHEATS,function cp_DirectCheat)
endfunction