- Joined
- Jun 26, 2020
- Messages
- 1,928
I made this trigger to select gamemodes by just typing a code, but is not working, sometimes display the error message even it shouldn't and when no, it doesn't do anything, what's wrong?
JASS:
scope Selection initializer Init
globals
private texttag array Modes
private trigger Select
private group TempGroup
constant integer MAX_HEROS=18
endglobals
//Some functions to use
private function Filter1 takes nothing returns boolean
return GetFilterUnit()!=udg_Golem_de_carne and IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)==false
endfunction
private function Filter2 takes nothing returns nothing
call UnitRemoveAbility(GetEnumUnit(),'A04C')
call UnitRemoveAbility(GetEnumUnit(),'A04D')
endfunction
private function Conditions takes nothing returns boolean
return IsPlayerInForce(GetTriggerPlayer(),udg_Selector_de_modos) and SubString(GetEventPlayerChatString(),0,1)=="-"
endfunction
//The actions to the selector
private function Actions_Select takes nothing returns nothing
local string mode=GetEventPlayerChatString()
local string original=mode
local boolean m2=false
local boolean m3=false
local boolean m4=false
local boolean m5=false
local string sub1
local string sub2
local integer i
//Comprobando validez / Checking
set mode=SubString(mode,1,StringLength(mode))
set sub1=SubString(mode,0,1)
set sub2=SubString(mode,1,2)
if sub1!="u" and sub1!="v" then
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"|cffff0000Not valid mode|r")
return
elseif sub2!="i" and sub2!="t" and sub2!="s" and sub2!="m" and sub2!="l" and sub2!="h" and sub2!="e" then
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"|cffff0000Not valid mode|r")
return
endif
set mode=SubString(mode,2,StringLength(mode))
set sub1=SubString(mode,0,2)
if sub1=="ca" or sub1=="nn" or sub1=="np" or sub1=="nc" or sub1=="" then
set m2=true
elseif sub1!="ns" and sub1!="oc" and sub1!="nr" and sub1!="ds" and sub1!="ap" and sub1!="lu" and sub1!="nl" then
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"|cffff0000Not valid mode|r")
return
endif
set mode=SubString(mode,2,StringLength(mode))
set sub1=SubString(mode,0,2)
if sub1=="ns" or sub1=="oc" or sub1=="nr" or sub1=="" then
set m3=true
elseif sub1!="ds" and sub1!="ap" and sub1!="lu" and sub1!="nl" then
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"|cffff0000Not valid mode|r")
return
endif
set mode=SubString(mode,2,StringLength(mode))
set sub1=SubString(mode,0,2)
if sub1=="ds" or sub1=="ap" or sub1=="" then
set m4=true
elseif sub1!="lu" and sub1!="nl" then
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"|cffff0000Not valid mode|r")
return
endif
set mode=SubString(mode,2,StringLength(mode))
set sub1=SubString(mode,0,2)
if sub1=="lu" or sub1=="nl" or sub1=="" then
set m5=true
else
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"|cffff0000Not valid mode|r")
return
endif
//Modo 1: Relojes
set mode=original
set sub1=SubString(mode,0,1)
set sub2=SubString(mode,1,2)
set mode=SubString(mode,2,StringLength(mode))
if sub1=="v" then
call EnableTrigger(gg_trg_Reloj1)
if sub2=="s" then
set udg_Handicap_varios_relojes=0.60
set udg_Modo[1]="One timer for each mission (31 minutes max.)."
elseif sub2=="m" then
set udg_Handicap_varios_relojes=0.80
set udg_Modo[1]="One timer for each mission (41 minutes max.)."
elseif sub2=="l" then
set udg_Handicap_varios_relojes=1.00
set udg_Modo[1]="One timer for each mission (51 minutes max.)."
elseif sub2=="h" then
set udg_Handicap_varios_relojes=1.20
set udg_Modo[1]="One timer for each mission (61 minutes max.)."
endif
else
call DisableTrigger(gg_trg_Reloj1)
if sub2=="i" then
set udg_Cantidad_de_tiempo_un_reloj=1500.00
set udg_Modo[1]="One timer for the match (25 minutes)."
elseif sub2=="t" then
set udg_Cantidad_de_tiempo_un_reloj=1800.00
set udg_Modo[1]="One timer for the match (30 minutes)."
elseif sub2=="s" then
set udg_Cantidad_de_tiempo_un_reloj=2100.00
set udg_Modo[1]="One timer for the match (35 minutes)."
elseif sub2=="m" then
set udg_Cantidad_de_tiempo_un_reloj=2400.00
set udg_Modo[1]="One timer for the match (40 minutes)."
elseif sub2=="l" then
set udg_Cantidad_de_tiempo_un_reloj=2700.00
set udg_Modo[1]="One timer for the match (45 minutes)."
elseif sub2=="h" then
set udg_Cantidad_de_tiempo_un_reloj=3000.00
set udg_Modo[1]="One timer for the match (50 minutes)."
elseif sub2=="e" then
set udg_Cantidad_de_tiempo_un_reloj=3300.00
set udg_Modo[1]="One timer for the match (55 minutes)."
endif
endif
//Modo 2: Creeps
if m2 then
set sub1=SubString(mode,0,1)
set sub2=SubString(mode,1,2)
set mode=SubString(mode,2,StringLength(mode))
if sub1+sub2=="ca" then
call EnableTrigger(gg_trg_Respawn_campamentos)
set udg_Tip[3]="Watch for the missions (push is useless)."
set udg_Modo[2]="Normal."
elseif sub1=="n" then
if sub2=="n" then
set TempGroup=GetUnitsOfPlayerMatching(Player(PLAYER_NEUTRAL_AGGRESSIVE),Condition(function Filter1))
call ForGroup(TempGroup, function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
set udg_Tip[3]="Watch for the missions (push is useless)."
set udg_Modo[2]="No Neutrals."
elseif sub2=="p" then
set TempGroup=GetUnitsOfTypeIdAll('n00D')
call ForGroup(TempGroup,function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('n00F')
call ForGroup(TempGroup,function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('n00S')
call ForGroup(TempGroup,function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('n002')
call ForGroup(TempGroup,function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
call DisableTrigger(gg_trg_Aqui_vamos)
call DisableTrigger(gg_trg_Estos_grunts_son_tontos)
call EnableTrigger(gg_trg_Respawn_campamentos)
set udg_Tip[3]="Watch for the missions."
set udg_Modo[2]="No |cffff0000Draenei|r and |cff32cd32Demons|r."
elseif sub2=="c" then
set TempGroup=GetUnitsOfPlayerMatching(Player(PLAYER_NEUTRAL_AGGRESSIVE),Condition(function Filter1))
call ForGroup(TempGroup,function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('n00D')
call ForGroup(TempGroup,function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('n00F')
call ForGroup(TempGroup,function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('n00S')
call ForGroup(TempGroup,function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('n002')
call ForGroup(TempGroup,function RemoveUnitbyGroup)
call DestroyGroup(TempGroup)
call DisableTrigger(gg_trg_Aqui_vamos)
call DisableTrigger(gg_trg_Estos_grunts_son_tontos)
call EnableTrigger(gg_trg_Respawn_campamentos)
set udg_Tip[3]="Watch for the missions."
set udg_Modo[2]="No Creeps."
endif
endif
else
call EnableTrigger(gg_trg_Respawn_campamentos)
set udg_Tip[3]="Watch for the missions (push is useless)."
set udg_Modo[2]="Normal."
endif
//Modo 3: Shops
if m3 then
set sub1=SubString(mode,0,2)
set mode=SubString(mode,2,StringLength(mode))
if sub1=="ns" then
set udg_Modo[3]="Normal."
elseif sub1=="oc" then
set TempGroup=GetUnitsOfTypeIdAll('h002')
call ForGroup(TempGroup,function HideUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('h000')
set NewID='h00E'
call ForGroup(TempGroup,function ReplaceUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('h003')
set NewID='h00F'
call ForGroup(TempGroup,function ReplaceUnitbyGroup)
call DestroyGroup(TempGroup)
set udg_Modo[3]="Only consummibles."
elseif sub1=="nr" then
set TempGroup=GetUnitsOfTypeIdAll('h003')
call ForGroup(TempGroup,function HideUnitbyGroup)
call DestroyGroup(TempGroup)
set udg_Modo[3]="No recipes."
endif
else
set udg_Modo[3]="Normal."
endif
//Modo 4: Selección
if m4 then
set sub1=SubString(mode,0,2)
set mode=SubString(mode,2,StringLength(mode))
if sub1=="ds" then
set udg_Modo[4]="Normal."
elseif sub1=="ao" then
set udg_ver_draeneanos=CreateFogModifierRectBJ(true,Player(0),FOG_OF_WAR_VISIBLE,gg_rct_selecionador_demonios)
set udg_ver_demonios=CreateFogModifierRectBJ(true,Player(6),FOG_OF_WAR_VISIBLE,gg_rct_selecionador_draeneanos)
set udg_Modo[4]="Traitor (All pick)."
endif
else
set udg_Modo[4]="Normal."
endif
//Modo 5: Heroes
set sub1=SubString(mode,0,2)
if sub1=="lu" or m5==false then
set udg_Vortex_area=650.00
set i=1
loop
exitwhen i>MAX_HEROS
set TempGroup=GetUnitsOfTypeIdAll(udg_No_Heroe_Tipo[i])
set NewID=udg_Heroe_Tipo[i]
call ForGroup(TempGroup,function ReplaceUnitbyGroup)
set udg_Heroe_Modelo[i]=bj_lastReplacedUnit
call DestroyGroup(TempGroup)
set i=i+1
endloop
call BJDebugMsg("You can only repick until 2 minutes.")
call TimerStart(udg_Wait_Timer[4],120.00,false,null)
call DisableTrigger(gg_trg_Si_mueres)
call DisableTrigger(gg_trg_Si_revives)
call DisableTrigger(gg_trg_Heroes)
call EnableTrigger(gg_trg_Si_mueres_Heroe)
call EnableTrigger(gg_trg_Aviso)
set udg_Tip[1]="There are defensive towers, the demolisher is good for destroy them."
set udg_Tip[2]="You can heal your heros in the base."
set TempGroup=GetUnitsOfTypeIdAll('h001')
set NewID='h009'
call ForGroup(TempGroup,function ReplaceUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('h000')
set NewID='h00A'
call ForGroup(TempGroup,function ReplaceUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('h003')
set NewID='h00D'
call ForGroup( TempGroup, function ReplaceUnitbyGroup)
call DestroyGroup(TempGroup)
call UnitAddAbility(gg_unit_ncop_0124,'A04C')
call UnitAddAbility(gg_unit_ncop_0124,'A04D')
call UnitAddAbility(gg_unit_ncop_0129,'A04C')
call UnitAddAbility(gg_unit_ncop_0129,'A04D')
call UnitAddAbility(gg_unit_h002_0151,'A04C')
call UnitAddAbility(gg_unit_h002_0151,'A04D')
set TempGroup=GetUnitsOfTypeIdAll('n00H')
call ForGroup(TempGroup,function ShowUnitbyGroup)
call DestroyGroup(TempGroup)
set udg_Modo[5]="Hero (Leveling up)."
elseif sub1=="nl" then
set udg_Vortex_area=450.00
call EnableTrigger(gg_trg_Revivir)
set i=1
loop
exitwhen i>MAX_HEROS
set TempGroup=GetUnitsOfTypeIdAll(udg_Heroe_Tipo[i])
set NewID=udg_No_Heroe_Tipo[i]
call ForGroup(TempGroup,function ReplaceUnitbyGroup)
call DestroyGroup(TempGroup)
set i=i+1
endloop
set TempGroup=GetUnitsInRectAll(bj_mapInitialPlayableArea)
call ForGroup(TempGroup,function Filter2)
call DestroyGroup(TempGroup)
set udg_Tip[1]="There are special heros for destroy towers."
set udg_Tip[2]="If you are low of health, you can use -repick to have all life and mana."
set TempGroup=GetUnitsOfTypeIdAll('h009')
set NewID='h001'
call ForGroup(TempGroup,function ReplaceUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup = GetUnitsOfTypeIdAll('h00A')
set NewID='h000'
call ForGroup(TempGroup,function ReplaceUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup = GetUnitsOfTypeIdAll('h00D')
set NewID='h003'
call ForGroup(TempGroup,function ReplaceUnitbyGroup)
call DestroyGroup(TempGroup)
set TempGroup=GetUnitsOfTypeIdAll('n00H')
call ForGroup(TempGroup,function HideUnitbyGroup)
call DestroyGroup(TempGroup)
call DisableTrigger(gg_trg_Aviso)
set udg_Modo[5]="Classic (Not leveling up)."
endif
//Final
loop
exitwhen i>29
call SetTextTagVisibility(Modes[i],false)
set i=i+1
endloop
call ForceClear(udg_Selector_de_modos)
call ConditionalTriggerExecute(gg_trg_Ultimos_detalles)
call DisableTrigger(Select)
endfunction
//If you run this trigger, this actions will be runned
private function Actions_Text takes nothing returns nothing
local integer i=0
loop
exitwhen i>29
call SetTextTagVisibility(Modes[i],true)
set i=i+1
endloop
call EnableTrigger(Select)
if IsPlayerInForce(GetLocalPlayer(),udg_Selector_de_modos) then
call ClearTextMessages()
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,30,"To select a mode you must chat - followed the characters of a specific mode (In order), if you don't specific a mode the game (not type the characters) automatically select the default modes.")
call StartSound(bj_questHintSound)
endif
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local integer i=0
local real x=GetUnitX(gg_unit_U00C_0074)
local real y=GetUnitY(gg_unit_U00C_0074)
set Select=CreateTrigger()
call TriggerRegisterPlayerChatEvent(Select,Player(1),"-",false)
call TriggerRegisterPlayerChatEvent(Select,Player(2),"-",false)
call TriggerRegisterPlayerChatEvent(Select,Player(3),"-",false)
call TriggerRegisterPlayerChatEvent(Select,Player(4),"-",false)
call TriggerRegisterPlayerChatEvent(Select,Player(5),"-",false)
call TriggerRegisterPlayerChatEvent(Select,Player(7),"-",false)
call TriggerRegisterPlayerChatEvent(Select,Player(8),"-",false)
call TriggerRegisterPlayerChatEvent(Select,Player(9),"-",false)
call TriggerRegisterPlayerChatEvent(Select,Player(10),"-",false)
call TriggerRegisterPlayerChatEvent(Select,Player(11),"-",false)
call TriggerAddCondition(Select,Condition(function Conditions))
call TriggerAddAction(Select,function Actions_Select)
call DisableTrigger(Select)
//-- --
set gg_trg_Seleccion_de_modo=CreateTrigger()
call TriggerAddAction(gg_trg_Seleccion_de_modo,function Actions_Text)
//Floating texts to the modes
loop
exitwhen i>31
set Modes[i]=CreateTextTag()
call SetTextTagVisibility(Modes[i],true)
if i<=13 then
call SetTextTagPos(Modes[i],x,y-i*48,100)
elseif i>13 and i<=23 then
call SetTextTagPos(Modes[i],x+320,y-(i-15)*48,100)
elseif i>23 and i<=29 then
call SetTextTagPos(Modes[i],x+640,y-(i-25)*48,100)
endif
set i=i+1
endloop
call SetTextTagText(Modes[0],"|cffff4000Timers|r",12*0.023/10)
call SetTextTagText(Modes[1]," |cff0080ff-v|r: One for each mission.",12*0.023/10)
call SetTextTagText(Modes[2]," |cff00ff80-s|r: 60% (max. 31 minutes).",12*0.023/10)
call SetTextTagText(Modes[3]," |cff00ff80-m|r: 80% (max. 41 minutes).",12*0.023/10)
call SetTextTagText(Modes[4]," |cff00ff80-l|r: 100% (max. 51 minutes).",12*0.023/10)
call SetTextTagText(Modes[5]," |cff00ff80-h|r: 120% (max. 61 minutes).",12*0.023/10)
call SetTextTagText(Modes[6]," |cff0080ff-u|r: One for the match.",12*0.023/10)
call SetTextTagText(Modes[7]," |cff00ff80-i|r: 25 minutes.",12*0.023/10)
call SetTextTagText(Modes[8]," |cff00ff80-t|r: 30 minutes.",12*0.023/10)
call SetTextTagText(Modes[9]," |cff00ff80-s|r: 35 minutes.",12*0.023/10)
call SetTextTagText(Modes[10]," |cff00ff80-m|r: 40 minutes.",12*0.023/10)
call SetTextTagText(Modes[11]," |cff00ff80-l|r: 45 minutes.",12*0.023/10)
call SetTextTagText(Modes[12]," |cff00ff80-h|r: 50 minutes.",12*0.023/10)
call SetTextTagText(Modes[13]," |cff00ff80-e|r: 55 minutes.",12*0.023/10)
call SetTextTagText(Modes[14],"|cffff4000Creeps|r",12*0.023/10)
call SetTextTagText(Modes[15]," |cff0080ff-ca|r: Yes. (Def)",12*0.023/10)
call SetTextTagText(Modes[16]," |cff0080ff-n|r: No.",12*0.023/10)
call SetTextTagText(Modes[17]," |cff00ff80-n|r: Neutral.",12*0.023/10)
call SetTextTagText(Modes[18]," |cff00ff80-p|r: |cffff0000Draenei|r and |cff32cd32Demons|r.",12*0.023/10)
call SetTextTagText(Modes[19]," |cff00ff80-c|r: Both.",12*0.023/10)
call SetTextTagText(Modes[20],"|cffff4000Shops|r",12*0.023/10)
call SetTextTagText(Modes[21]," |cff0080ff-ns|r: Normal. (Def)",12*0.023/10)
call SetTextTagText(Modes[22]," |cff0080ff-oc|r: Only consumibles.",12*0.023/10)
call SetTextTagText(Modes[23]," |cff0080ff-nr|r: No Recipes.",12*0.023/10)
call SetTextTagText(Modes[24],"|cffff4000Selection|r",12*0.023/10)
call SetTextTagText(Modes[25]," |cff0080ff-ds|r: Normal. (Def)",12*0.023/10)
call SetTextTagText(Modes[26]," |cff0080ff-ap|r: Traitor (All pick).",12*0.023/10)
call SetTextTagText(Modes[27],"|cffff4000Heros|r",12*0.023/10)
call SetTextTagText(Modes[28]," |cff0080ff-lu|r: Hero (Leveling up). (Def)",12*0.023/10)
call SetTextTagText(Modes[29]," |cff0080ff-nl|r: Classic (Not levelling up).",12*0.023/10)
endfunction
endscope