//========================================================================
// KaTTana's functions:
//========================================================================
function Cache takes nothing returns gamecache
if udg_Cache!=null then
return udg_Cache
endif
set udg_Cache=InitGameCache("jasslocalvars.w3v")
return udg_Cache
endfunction
//========================================================================
function HTI takes handle h returns integer
return h
return 0
endfunction
//========================================================================
function SetHandleInteger takes handle h,string label,integer i returns nothing
if i!=0 then
call StoreInteger(Cache(),I2S(HTI(h)),label,i)
else
call FlushStoredInteger(Cache(),I2S(HTI(h)),label)
endif
endfunction
function SetHandleReal takes handle h,string label,real i returns nothing
if i!=0.00 then
call StoreReal(Cache(),I2S(HTI(h)),label,i)
else
call FlushStoredReal(Cache(),I2S(HTI(h)),label)
endif
endfunction
function SetHandleString takes handle h,string label,string i returns nothing
if i!="" then
call StoreString(Cache(),I2S(HTI(h)),label,i)
else
call FlushStoredString(Cache(),I2S(HTI(h)),label)
endif
endfunction
function SetHandleBoolean takes handle h,string label,boolean i returns nothing
if not i then
call StoreBoolean(Cache(),I2S(HTI(h)),label,i)
else
call FlushStoredBoolean(Cache(),I2S(HTI(h)),label)
endif
endfunction
function SetHandleHandle takes handle h,string label,handle i returns nothing
if i!=null then
call StoreInteger(Cache(),I2S(HTI(h)),label,HTI(i))
else
call FlushStoredInteger(Cache(),I2S(HTI(h)),label)
endif
endfunction
//========================================================================
function GetHandleInteger takes handle h,string s returns integer
return GetStoredInteger(Cache(),I2S(HTI(h)),s)
endfunction
function GetHandleBoolean takes handle h,string s returns boolean
return GetStoredBoolean(Cache(),I2S(HTI(h)),s)
endfunction
function GetHandleReal takes handle h,string s returns real
return GetStoredReal(Cache(),I2S(HTI(h)),s)
endfunction
function GetHandleString takes handle h,string s returns string
return GetStoredString(Cache(),I2S(HTI(h)),s)
endfunction
function GetHandleUnit takes handle h,string s returns unit
return GetStoredInteger(Cache(),I2S(HTI(h)),s)
return null
endfunction
function GetHandleGroup takes handle h,string s returns group
return GetStoredInteger(Cache(),I2S(HTI(h)),s)
return null
endfunction
function GetHandlePlayer takes handle h,string s returns player
return GetStoredInteger(Cache(),I2S(HTI(h)),s)
return null
endfunction
function GetHandleTrigger takes handle h,string s returns trigger
return GetStoredInteger(Cache(),I2S(HTI(h)),s)
return null
endfunction
function GetHandleEffect takes handle h,string s returns effect
return GetStoredInteger(Cache(),I2S(HTI(h)),s)
return null
endfunction
function GetHandleAction takes handle h,string s returns triggeraction
return GetStoredInteger(Cache(),I2S(HTI(h)),s)
return null
endfunction
function GetHandleTimer takes handle h,string s returns timer
return GetStoredInteger(Cache(),I2S(HTI(h)),s)
return null
endfunction
//========================================================================
function EraseStoredHandle takes handle h,string s returns nothing
call FlushStoredInteger(Cache(),I2S(HTI(h)),s)
endfunction
function EraseFolder takes handle h returns nothing
call FlushStoredMission(Cache(),I2S(HTI(h)))
endfunction
//##Start##
//*************************************************************************************************
//*
//* Special Events and Templates System
//*
//* To be able to use The spell Templates in your map, or to make your own spell templates,
//* First make sure you have the udg_spellevents and udg_spelltemplates gamecache variables,
//* Either use next "Variable Copying Trigger" or create them with your variable editor.
//*
//* After that, you have to copy this to your map's custom script section!
//* (The Custom Script Section Is at the top of the list of the triggers and has the Map's name.)
//*
//* Select the text from the //##Start## to the //##End## and copy it to the custom script
//* section that is at the top of the trigger list and has your map's name.
//*
//* After copying them and saving in your map, you need to call SetupSpecialEvents() at map
//* Initialization in order to allow the system to work. (check next trigger)
//*
//* If you already have them in your map, Delete the ones in your map, then copy these ones,
//* this is a new version that fixes some memory leaks that were blizzard's fault, also the
//* Special Events functions have a new option.
//*
//* In theory, you may just copy the trigger, making sure it is above any other trigger, then
//* Instantly save, this is easier, but may not work well.
//*
//*************************************************************************************************
//==================================================================================================
// Special Events
//
function Eventscache takes nothing returns gamecache
if udg_spellevents==null then
set udg_spellevents=InitGameCache("spellevents.vx")
endif
return udg_spellevents
endfunction
function GetPassiveAbilityUser takes nothing returns unit
return GetStoredInteger(Eventscache(),"passives","unit")
return null
endfunction
function GetPassiveAbilityId takes nothing returns integer
return GetStoredInteger(Eventscache(),"passives","current")
endfunction
function events_H2I takes handle h returns integer
return h
return 0
endfunction
function PassiveAbilitiesPrepare takes nothing returns nothing
local gamecache g=Eventscache()
local integer n=GetStoredInteger(g,"passives","n")
local integer i=1
local integer array p
local string array s
local unit u
local group a=CreateGroup()
loop
exitwhen (i>n)
set p[i]=GetStoredInteger(g,"passives",I2S(i))
set s[i]=GetStoredString(g,"spelllearnfuncs", I2S(p[i]))
set i=i+1
endloop
call GroupEnumUnitsInRect(a,bj_mapInitialPlayableArea,null)
loop
set u=FirstOfGroup(a)
exitwhen (u==null)
set i=1
call StoreInteger(g,"passives","unit",events_H2I(u))
loop
exitwhen (i>n)
if (GetUnitAbilityLevel(u,p[i])>0) then
call StoreInteger(g,"passives","current",p[i])
call ExecuteFunc(s[i])
endif
set i=i+1
endloop
call GroupRemoveUnit(a,u)
endloop
set a=null
endfunction
//==================================================================================================
function PassiveAbilityBrowse takes gamecache g, unit u, string k returns nothing
local integer n=GetStoredInteger(g,"passives","n")
local integer un=0
local integer i=1
local integer s
call StoreInteger(g,"passives","unit",events_H2I(u))
loop
exitwhen (i>n)
set s=GetStoredInteger(g,"passives",I2S(i))
if (GetUnitAbilityLevel(u,s)>0) then
set un=un+1
call StoreInteger(g,"passiveREG"+I2S(un),k,s)
call StoreInteger(g,"passives","current",s)
call ExecuteFunc(GetStoredString(g,"spelllearnfuncs",I2S(s)))
endif
set i=i+1
endloop
if (un==0) then
call StoreBoolean(g,"pasignore",k,true)
else
call StoreInteger(g,"passiveREGN",k,un)
endif
endfunction
function DoPassiveAbilities takes gamecache g, unit u, string k returns nothing
local integer n=GetStoredInteger(g,"passiveREGN",k)
local integer i=1
local integer s
call StoreInteger(g,"passives","unit",events_H2I(u))
loop
exitwhen (i>n)
set s=GetStoredInteger(g,"passiveREG"+I2S(i),k)
if (GetUnitAbilityLevel(u,s)>0) then
call StoreInteger(g,"passives","current",s)
call ExecuteFunc(GetStoredString(g,"spelllearnfuncs",I2S(s)))
endif
set i=i+1
endloop
endfunction
function PassiveAbilitiesOnCreated takes gamecache g, unit u, string k returns nothing
if HaveStoredInteger(g,"passiveREGN",k) then
call DoPassiveAbilities(g,u,k)
else
call PassiveAbilityBrowse(g,u,k)
endif
endfunction
//==================================================================================================
function Trig_SpecialEvents_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local eventid e=GetTriggerEventId()
local gamecache sp=Eventscache()
local integer s
local string k
if (e==EVENT_PLAYER_UNIT_SPELL_EFFECT) then
set k=I2S(GetSpellAbilityId())
if HaveStoredString( sp, "spellfuncs",k) then
call ExecuteFunc( GetStoredString( sp, "spellfuncs",k))
endif
elseif (e==EVENT_PLAYER_UNIT_SPELL_CAST) then
set k=I2S(GetSpellAbilityId())
if HaveStoredString( sp, "castfuncs", k) then
call ExecuteFunc( GetStoredString( sp, "castfuncs",k))
endif
elseif (e==EVENT_PLAYER_HERO_SKILL) then
set s=GetLearnedSkill()
set k=I2S(s)
if HaveStoredString( sp, "spelllearnfuncs",k) then
call StoreInteger(sp,"passives","unit",events_H2I(u))
call StoreInteger(sp,"passives","current",s)
call ExecuteFunc( GetStoredString( sp, "spelllearnfuncs",k))
endif
elseif (e==EVENT_PLAYER_UNIT_SUMMON) then
set k=I2S(GetUnitTypeId( GetSummonedUnit() ))
if HaveStoredString( sp, "unitfuncs",k) then
call ExecuteFunc( GetStoredString( sp, "unitfuncs", k))
endif
elseif (e==EVENT_PLAYER_UNIT_USE_ITEM) then
set k=I2S( GetItemTypeId( GetManipulatedItem() ))
if HaveStoredString( sp, "itemfuncs", k) then
call ExecuteFunc(GetStoredString(sp,"itemfuncs",k))
endif
elseif (e==EVENT_PLAYER_UNIT_PICKUP_ITEM) then
set k=I2S( GetItemTypeId( GetManipulatedItem() ))
if HaveStoredString( sp, "itemgetfuncs", k) then
call ExecuteFunc(GetStoredString( sp, "itemgetfuncs",k))
endif
else
set k=I2S(GetUnitTypeId(u))
if not(HaveStoredBoolean(sp,"pasignore",k)) then
call PassiveAbilitiesOnCreated(sp,u,k)
endif
endif
set u=null
set e=null
set sp=null
endfunction
//==================================================================================================
// Call This Function at map initialization if you want the whole thing to work.
//
function SetupSpecialEvents takes nothing returns nothing
local trigger trig=CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(trig, Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
call TriggerRegisterPlayerUnitEvent(trig, Player(i),EVENT_PLAYER_UNIT_SUMMON, null)
call TriggerRegisterPlayerUnitEvent(trig, Player(i),EVENT_PLAYER_UNIT_USE_ITEM, null)
call TriggerRegisterPlayerUnitEvent(trig, Player(i),EVENT_PLAYER_UNIT_PICKUP_ITEM, null)
call TriggerRegisterPlayerUnitEvent(trig, Player(i),EVENT_PLAYER_HERO_SKILL, null)
call TriggerRegisterPlayerUnitEvent(trig, Player(i),EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i=i+1
exitwhen i==bj_MAX_PLAYER_SLOTS
endloop
call TriggerRegisterEnterRectSimple(trig,bj_mapInitialPlayableArea)
call TriggerAddAction(trig,function Trig_SpecialEvents_Actions)
call TimerStart(CreateTimer(),0,false,function PassiveAbilitiesPrepare)
set trig=null
endfunction
//==================================================================================================
// Registers the function to be executed when the effect of an ability is started:
//
function RegisterAbilityEvent takes integer abilid, string funcname returns nothing
call StoreString( Eventscache(), "spellfuncs", I2S(abilid), funcname)
endfunction
//==================================================================================================
// Registers the function to be executed when an ability is about to be casted
//
function RegisterAbilityPreCastEvent takes integer abilid, string funcname returns nothing
call StoreString( Eventscache(), "castfuncs", I2S(abilid), funcname)
endfunction
//==================================================================================================
// Registers the function to be executed when an ability is learned:
//
function RegisterAbilityLearnEvent takes integer abilid, string funcname returns nothing
call StoreString( Eventscache(), "spelllearnfuncs", I2S(abilid), funcname)
endfunction
//==================================================================================================
// Registers the function to be executed when an ability is learned:
//
function RegisterPassiveAbility takes integer abilid, string funcname returns nothing
local gamecache g=Eventscache()
local integer n=GetStoredInteger(g,"passives","n")+1
call StoreString( Eventscache(), "spelllearnfuncs", I2S(abilid), funcname)
call StoreInteger(g,"passives","n",n)
call StoreInteger(g,"passives",I2S(n),abilid)
set g=null
endfunction
//==================================================================================================
// Registers the function to be executed when an unit type is summoned:
//
function RegisterItemUseEvent takes integer itemid, string funcname returns nothing
call StoreString( Eventscache(), "itemfuncs", I2S(itemid), funcname)
endfunction
//==================================================================================================
// Registers the function to be executed when an unit type enters to the map:
//
function RegisterUnitSummonEvent takes integer unitid, string funcname returns nothing
call StoreString( Eventscache(), "unitfuncs", I2S(unitid), funcname)
endfunction
//==================================================================================================
// Registers the function to be executed when an item type is acquired:
//
function RegisterItemGetEvent takes integer itemid, string funcname returns nothing
call StoreString( Eventscache(), "itemgetfuncs", I2S(itemid), funcname)
endfunction
//==================================================================================================
// Alternative Templates System
//
function AbiCache takes nothing returns gamecache
if udg_spelltemplates==null then
set udg_spelltemplates=InitGameCache("spells.vx")
endif
return udg_spelltemplates
endfunction
//==================================================================================================
// Old version:
// Setups A template (function name) for an ability abid, if uselearnevent is true it will only
// Work for A hero learns a skill events.
//
function SetAbilityTemplate takes integer abid , string func, boolean uselearnevent returns nothing
if uselearnevent then
call RegisterAbilityLearnEvent( abid, func)
else
call RegisterAbilityEvent( abid, func)
endif
call StoreString( AbiCache(), "funcs", I2S(abid), func)
endfunction
//==================================================================================================
// Setups A template (function name) for an ACTIVE ability abid
//
function SetSpellTemplate takes integer abid, string func returns integer
call RegisterAbilityEvent( abid, func)
call StoreString( AbiCache(), "funcs", I2S(abid), func)
return abid
endfunction
//============================================================================================================
// Setups A template (function name) for a PASSIVE ability abid, the ability won't work if added by triggers
//
function SetPassiveTemplate takes integer abid, string func returns integer
call RegisterPassiveAbility(abid,func)
call StoreString( AbiCache(), "funcs", I2S(abid), func)
return abid
endfunction
//============================================================================================================
// Determine a Spell Template (function)'s default value for a datafield
// This is not a necessary step, just an useful step (integers and reals default as 0, strings as
// null, without this step)
//
function SetTemplateDefaultInt takes string func, string datafield, integer value returns nothing
call StoreInteger( AbiCache(), func, datafield, value)
endfunction
function SetTemplateDefaultReal takes string func, string datafield, real value returns nothing
call StoreReal( AbiCache(), func, datafield, value)
endfunction
function SetTemplateDefaultString takes string func, string datafield, string value returns nothing
call StoreString( AbiCache(), func, datafield, value)
endfunction
//==================================================================================================
// Set the value of an spell's datafield for an specific level, if specified level is 0, it will be
// the new default for all the levels of the ability
//
function SetAbilityDataInt takes integer abid , string datafield, integer l, integer value returns nothing
call StoreInteger( AbiCache(), I2S(abid), datafield+I2S(l), value )
endfunction
function SetAbilityDataReal takes integer abid , string datafield, integer l, real value returns nothing
call StoreReal( AbiCache(), I2S(abid), datafield+I2S(l), value )
endfunction
function SetAbilityDataString takes integer abid , string datafield, integer l, string value returns nothing
call StoreString( AbiCache(), I2S(abid), datafield+I2S(l), value )
endfunction
//==================================================================================================
// Read the value for a datafield of a spell's level, better keep some local level and spell
// variables to use these.
//
function GetAbilityDataInt takes integer s, integer l , string datafield returns integer
local gamecache a=AbiCache()
local integer r=0
if HaveStoredInteger( a, I2S(s), datafield+I2S(l)) then
set r=GetStoredInteger( a, I2S(s), datafield+I2S(l))
elseif HaveStoredInteger( a, I2S(s), datafield+"0") then
set r=GetStoredInteger( a, I2S(s), datafield+"0")
elseif HaveStoredString( a, "funcs", I2S(s) ) then
set r=GetStoredInteger( a, GetStoredString( a, "funcs", I2S(s) ), datafield)
endif
set a=null
return r
endfunction
//==================================================================================================
function GetAbilityDataReal takes integer s, integer l , string datafield returns real
local gamecache a=AbiCache()
local real r=0
if HaveStoredReal( a, I2S(s), datafield+I2S(l)) then
set r=GetStoredReal( a, I2S(s), datafield+I2S(l))
elseif HaveStoredReal( a, I2S(s), datafield+"0") then
set r=GetStoredReal( a, I2S(s), datafield+"0")
elseif HaveStoredString( a, "funcs", I2S(s) ) then
set r=GetStoredReal( a, GetStoredString( a, "funcs", I2S(s) ), datafield)
endif
set a=null
return r
endfunction
//==================================================================================================
function GetAbilityDataString takes integer s, integer l , string datafield returns string
local gamecache a=AbiCache()
local string r=""
if HaveStoredString( a, I2S(s), datafield+I2S(l)) then
set r=GetStoredString( a, I2S(s), datafield+I2S(l))
elseif HaveStoredString( a, I2S(s), datafield+"0") then
set r=GetStoredString( a, I2S(s), datafield+"0")
elseif HaveStoredString( a, "funcs", I2S(s) ) then
set r=GetStoredString( a, GetStoredString( a, "funcs", I2S(s) ), datafield)
endif
set a=null
return r
endfunction
//##End##
Name | Type | is_array | initial_value |
_1st | boolean | No | |
_2nd | boolean | No | |
_3th | boolean | No | |
_4th | boolean | No | |
AmountGold | integer | Yes | |
AmountLumber | integer | Yes | |
Boss_Timer_Green | timer | No | |
Boss_Timer_Red | timer | No | |
Boss_Timer_Teal | timer | No | |
Boss_Timer_Yellow | timer | No | |
Cache | gamecache | No | |
ChoosenAmount | integer | No | |
Defeated_Dialog | dialog | No | |
Diff_Dia | dialog | No | |
diffi | dialog | No | |
Easy | button | No | |
EnemyCount | integer | Yes | |
EnemyGold | integer | Yes | |
EnemyType | unitcode | Yes | |
Hard | button | No | |
Human | button | No | |
i | integer | No | |
Impossible | button | No | |
Kill_Count | integer | Yes | |
Kills | integer | Yes | |
Leaderboard | leaderboard | Yes | |
Level_Timer | timer | Yes | |
Level_Timer_Green | integer | No | |
Level_Timer_Red | integer | No | |
Level_Timer_Teal | integer | No | |
Level_Timer_Yellow | integer | No | |
levelGreen | integer | No | 1 |
levelGreen_Copy | integer | No | 1 |
levelRed | integer | No | 1 |
levelRed_Copy | integer | No | 1 |
levelTeal | integer | No | 1 |
levelTeal_Copy | integer | No | 1 |
levelYellow | integer | No | 1 |
levelYellow_Copy | integer | No | 1 |
List | integer | No | |
Lives | integer | No | |
Lvalue | integer | Yes | |
Medium | button | No | |
MonsterCount | integer | Yes | |
Monstertype | unitcode | Yes | |
Naga | button | No | |
NagaHeroLimit | integer | Yes | |
NagaTraining | unit | Yes | |
Night_Elf | button | No | |
Nightmare | button | No | |
Orc | button | No | |
Player_Colors | string | Yes | |
Player_Count | integer | No | |
Player_Kills | integer | Yes | |
Player_Slot_Status | boolean | Yes | |
PlayerBoat | unit | Yes | |
pointer | integer | No | |
Race | integer | No | |
Race_Dialog | dialog | No | |
SpawnTimerGreen | timer | No | |
SpawnTimerRed | timer | No | |
SpawnTimerTeal | timer | No | |
SpawnTimerYellow | timer | No | |
Spectate | button | No | |
spellevents | gamecache | No | |
spelltemplates | gamecache | No | |
start | boolean | No | |
StartTimer | timer | No | |
TimerWindowGreen | timerdialog | No | |
TimerWindowRed | timerdialog | No | |
TimerWindowTeal | timerdialog | No | |
TimerWindowYellow | timerdialog | No | |
Undead | button | No | |
VoteDialog | dialog | No | |
VoteDone | boolean | No | |
VoteEasy | integer | No | |
VoteHard | integer | No | |
VoteImpossible | integer | No | |
VoteMedium | integer | No | |
VoteNightmare | integer | No |
function Trig_Regrowth_Actions takes nothing returns nothing
local real seconds = 10.00 // Change That Value to what you like
local destructable tree = GetDyingDestructable()
call TriggerSleepAction( seconds )
call DestructableRestoreLife( tree, GetDestructableMaxLife(tree), true )
endfunction
function InitTrig_Regrowth_Register takes nothing returns nothing
if ( GetDestructableTypeId(GetEnumDestructable()) == 'FTtw' ) then
call TriggerRegisterDeathEvent( gg_trg_Regrowth, GetEnumDestructable() )
endif
endfunction
//===========================================================================
function InitTrig_Regrowth takes nothing returns nothing
set gg_trg_Regrowth = CreateTrigger( )
call EnumDestructablesInRectAll( GetPlayableMapRect(), function InitTrig_Regrowth_Register )
call TriggerAddAction( gg_trg_Regrowth, function Trig_Regrowth_Actions )
endfunction