Log in
Current Version: v0.0.01A
Alpha version
Changelogs to come
Latest topics
Version Progress
Changes for v0.02.0A||||||||||||||||||||[●] [general]
||||||||||||||||||||[●] [Heroes]
||||||||||||||||||||[●] [Items]
||||||||||||||||||||[●] [Bugs]
||||||||||||||||||||[●] [Total]
game cache use in hero triggers
Page 1 of 1
game cache use in hero triggers
cause the gache uses the return bug, i gota change this, and i dont understand gamecache, so im posting it here to get help
instructions that came with the map for how to set up hero triggers
and the gamecache code
the hero set up trigger
this line is called when a hero is picked
then the initialization trigger on one of my heros,
and the corresponding part in the spell itself
instructions that came with the map for how to set up hero triggers
- Code:
Several steps need to be adhered to when adding a new hero to ensure that it is correctly instantiated and conforms to the game mechanisms and to ensure that only required triggers are activated.
1.
If the hero requires triggers, then each trigger is not instantiated on initialization, but a call to "StartTrigger" for example the "Slithereen Guard" has a "Slithereen Crush" trigger. The standard initialization function is left blank:
--- function InitTrig_Slithereen_Crush takes nothing returns nothing
--- endfunction
Instead this function is created which will be called if necessary to ensure the trigger is loaded
--- function StartTrigger_Slithereen_Crush takes nothing returns nothing
--- set gg_trg_Slithereen_Crush = CreateTrigger( )
--- call TriggerRegisterAnyUnitEventBJ( gg_trg_Slithereen_Crush, EVENT_PLAYER_UNIT_SPELL_EFFECT )
--- call TriggerAddCondition( gg_trg_Slithereen_Crush, Condition( function Trig_Slithereen_Crush_Conditions ) )
--- call TriggerAddAction( gg_trg_Slithereen_Crush, function Trig_Slithereen_Crush_Actions )
--- endfunction
2.
Each hero that requires triggers possesses a single "Enabling" trigger that calls the StartTriggers of the hero, in the case of the Slithereen Guard:
--- function Trig_Enable_Slithereen_Guard_Actions takes nothing returns nothing
--- call ExecuteFunc("StartTrigger_Slithereen_Crush")
--- endfunction
--- function InitTrig_Enable_Slithereen_Guard takes nothing returns nothing
--- set gg_trg_Enable_Slithereen_Guard = CreateTrigger( )
--- call TriggerAddAction( gg_trg_Enable_Slithereen_Guard, function Trig_Enable_Slithereen_Guard_Actions )
--- endfunction
This trigger is NOT run on map initialization, instead it is manually called when it is required for a given game.
3.
In the "Utility" category the following needs to be set in the "Heroes Setup" trigger: AddHero(type_id, team, enabling_trigger), for example:
--- call AddHero('U001', udg_Scourge, gg_trg_Enable_Slithereen_Guard)
and the gamecache code
- Code:
library cache
// Misc
function InitializeCache takes nothing returns nothing
call FlushGameCache(InitGameCache("CacheSystem.x"))
set udg_Cache=InitGameCache("CacheSystem.x")
endfunction
function H2I takes handle h returns integer
return GetHandleId(h)
endfunction
function CacheOwner takes handle h returns string
return I2S(H2I(h))
endfunction
function ClearCache takes string Owner returns nothing
call FlushStoredMission(udg_Cache, Owner)
endfunction
function ClearTarget takes nothing returns nothing
call FlushStoredMission(udg_Cache, udg_CacheTarget)
endfunction
function SetCacheTarget takes handle Target returns nothing
set udg_CacheTarget = CacheOwner(Target)
endfunction
function SetCacheTargetViaDummy takes handle Target returns integer
set udg_CacheTarget = CacheOwner(Target)
return 0
endfunction
// Integer
function SetCacheInteger takes string Owner, string Label, integer Value returns nothing
call StoreInteger(udg_Cache, Owner, Label, Value)
endfunction
function SetTargetInteger takes string Label, integer Value returns nothing
call StoreInteger(udg_Cache, udg_CacheTarget, Label, Value)
endfunction
function GetCacheInteger takes string Owner, string Label returns integer
return GetStoredInteger(udg_Cache, Owner, Label)
endfunction
function GetTargetInteger takes string Label returns integer
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
endfunction
// Real
function SetCacheReal takes string Owner, string Label, real Value returns nothing
call StoreReal(udg_Cache, Owner, Label, Value)
endfunction
function SetTargetReal takes string Label, real Value returns nothing
call StoreReal(udg_Cache, udg_CacheTarget, Label, Value)
endfunction
function GetCacheReal takes string Owner, string Label returns real
return GetStoredReal(udg_Cache, Owner, Label)
endfunction
function GetTargetReal takes string Label returns real
return GetStoredReal(udg_Cache, udg_CacheTarget, Label)
endfunction
// String
function SetCacheString takes string Owner, string Label, string Value returns nothing
call StoreString(udg_Cache, Owner, Label, Value)
endfunction
function SetTargetString takes string Label, string Value returns nothing
call StoreString(udg_Cache, udg_CacheTarget, Label, Value)
endfunction
function GetCacheString takes string Owner, string Label returns string
return GetStoredString(udg_Cache, Owner, Label)
endfunction
function GetTargetString takes string Label returns string
return GetStoredString(udg_Cache, udg_CacheTarget, Label)
endfunction
// Boolean
function SetCacheBoolean takes string Owner, string Label, boolean Value returns nothing
call StoreBoolean(udg_Cache, Owner, Label, Value)
endfunction
function SetTargetBoolean takes string Label, boolean Value returns nothing
call StoreBoolean(udg_Cache, udg_CacheTarget, Label, Value)
endfunction
function GetCacheBoolean takes string Owner, string Label returns boolean
return GetStoredBoolean(udg_Cache, Owner, Label)
endfunction
function GetTargetBoolean takes string Label returns boolean
return GetStoredBoolean(udg_Cache, udg_CacheTarget, Label)
endfunction
// Object
function SetCacheObject takes string Owner, string Label, handle Object returns nothing
call StoreInteger(udg_Cache, Owner, Label, H2I(Object))
endfunction
function SetTargetObject takes string Label, handle Object returns nothing
call StoreInteger(udg_Cache, udg_CacheTarget, Label, H2I(Object))
endfunction
///// return bugs to get rid of
// Unit
function GetCacheUnit takes string Owner, string Label returns unit
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetUnit takes string Label returns unit
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// Timer
function GetCacheTimer takes string Owner, string Label returns timer
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetTimer takes string Label returns timer
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// Trigger
function GetCacheTrigger takes string Owner, string Label returns trigger
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetTrigger takes string Label returns trigger
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// Trigger Action
function GetCacheTriggerAction takes string Owner, string Label returns triggeraction
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetTriggerAction takes string Label returns triggeraction
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// Group
function GetCacheGroup takes string Owner, string Label returns group
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetGroup takes string Label returns group
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// Effect
function GetCacheEffect takes string Owner, string Label returns effect
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetEffect takes string Label returns effect
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// Location
function GetCacheLocation takes string Owner, string Label returns location
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetLocation takes string Label returns location
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// Player
function GetCachePlayer takes string Owner, string Label returns player
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetPlayer takes string Label returns player
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// Lightning
function GetCacheLightning takes string Owner, string Label returns lightning
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetLightning takes string Label returns lightning
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// TerrainDeformation
function GetCacheTerrainDeformation takes string Owner, string Label returns terraindeformation
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetTerrainDeformation takes string Label returns terraindeformation
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// Destructable
function GetCacheDestructable takes string Owner, string Label returns destructable
return GetStoredInteger(udg_Cache, Owner, Label)
call DoNothing()
return null
endfunction
function GetTargetDestructable takes string Label returns destructable
return GetStoredInteger(udg_Cache, udg_CacheTarget, Label)
call DoNothing()
return null
endfunction
// end return bugs to get rid of
endlibrary
// End Cache System
//==================
the hero set up trigger
- Code:
function AddHero takes integer i, boolean b, trigger t returns nothing
local string s = UnitId2String(i)
local integer j = StringLength(s)
set udg_AllHero[udg_HeroCount] = i
set udg_HeroCount = udg_HeroCount + 1
if b then
set udg_SentiHero[udg_SentinelCount] = i
set udg_SentinelCount = udg_SentinelCount + 1
else
set udg_ScourgeHero[udg_ScourgeCount] = i
set udg_ScourgeCount = udg_ScourgeCount + 1
endif
set s = SubString(s, j - 4, j)
call SetTargetObject(s, t)
endfunction
function SetupHeroes takes nothing returns nothing
call SetCacheTarget(udg_GameHandler)
call AddHero('H008', udg_Sentinel, gg_trg_Enable_Farseer)
call AddHero('H00E', udg_Sentinel, gg_trg_Enable_Libby)
call AddHero('H00H', udg_Sentinel, gg_trg_Enable_Captain)
call AddHero('E001', udg_Sentinel, gg_trg_Enable_Harlequin)
call AddHero('H00R', udg_Sentinel, gg_trg_Enable_Asurmen)
call AddHero('H00N', udg_Sentinel, gg_trg_Enable_Autarch)
call AddHero('H00L', udg_Sentinel, gg_trg_Enable_Avatar)
call AddHero('H00S', udg_Sentinel, gg_trg_Enable_Fuegan)
call AddHero('H00T', udg_Sentinel, gg_trg_Enable_Karandras)
call AddHero('H00W', udg_Sentinel, gg_trg_Enable_Tau)
call AddHero('H012', udg_Sentinel, gg_trg_Enable_Grandmaster)
call AddHero('H01A', udg_Sentinel, gg_trg_Enable_Psyker)
call AddHero('H01C', udg_Sentinel, gg_trg_Enable_Celestine)
call AddHero('O009', udg_Scourge, gg_trg_Enable_Warboss)
call AddHero('O00A', udg_Scourge, gg_trg_Enable_Doc)
call AddHero('O00B', udg_Scourge, gg_trg_Enable_Mek)
call AddHero('O00D', udg_Scourge, gg_trg_Enable_Runtherd)
call AddHero('O00H', udg_Scourge, gg_trg_Enable_Warphead)
call AddHero('O004', udg_Scourge, gg_trg_Enable_Lord_Of_Change)
call AddHero('O00J', udg_Scourge, gg_trg_Enable_Kharn)
call AddHero('O00K', udg_Scourge, gg_trg_Enable_Lucius)
call AddHero('O00L', udg_Scourge, gg_trg_Enable_Typhus)
call AddHero('O00M', udg_Scourge, gg_trg_Enable_Lord)
call AddHero('O00N', udg_Scourge, gg_trg_Enable_Bloodthirster)
call AddHero('O00O', udg_Scourge, gg_trg_Enable_Zoanthrope)
call AddHero('O00P', udg_Scourge, gg_trg_Enable_Mistress)
call AddHero('O00Q', udg_Scourge, gg_trg_Enable_Secrets)
endfunction
//===========================================================================
function InitTrig_Heroes_Setup takes nothing returns nothing
endfunction
this line is called when a hero is picked
- Code:
call ConditionalTriggerExecute(GetCacheTrigger(CacheOwner(udg_GameHandler), SubString(UnitId2String(GetUnitTypeId(u)), 7, 11)))
then the initialization trigger on one of my heros,
- Code:
function Trig_Enable_Farseer_Actions takes nothing returns nothing
call ExecuteFunc("StartEldricthStorm")
call ExecuteFunc("StartDoom")
call ExecuteFunc("StartMindWar")
call ExecuteFunc("StartFortune")
call ExecuteFunc("StartGuide")
call ExecuteFunc("StartGuideLvl")
endfunction
//===========================================================================
function InitTrig_Enable_Farseer takes nothing returns nothing
set gg_trg_Enable_Farseer = CreateTrigger( )
call TriggerAddAction( gg_trg_Enable_Farseer, function Trig_Enable_Farseer_Actions )
endfunction
and the corresponding part in the spell itself
- Code:
function StartGuide takes nothing returns nothing
set gg_trg_guide = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_guide, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_guide, Condition( function Trig_guide_Conditions ) )
call TriggerAddAction( gg_trg_guide, function Trig_guide_Actions )
endfunction
//===========================================================================
function InitTrig_guide takes nothing returns nothing
endfunction
_________________
warning! very-stubborn, sarcastic, self-important, argumentative developer detected!
And unto the masses, He doth spoke:
"Behold The Stuff! It Is Good!"
And the Stuff was good.
Heroes:
Commander Farsight (colab - implemented) - Ku'gaath Plaguefather(incomplete) - Ilyana Arienal(incomplete) - Harlequin Shadowseer(incomplete) - Modular Tau Battlesuit(sandbox)

» Fix for Getting Back into a Crashed Game
» This game sure can be adamant about wanting players to take certain weapons
» Luck O' the Bearish Instant Win Game
» The wish game
» Outcry. The shimmering game
» This game sure can be adamant about wanting players to take certain weapons
» Luck O' the Bearish Instant Win Game
» The wish game
» Outcry. The shimmering game
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
» Faction creeps
» [SCII] [Inquisition] Hector Rex
» [necrons] Orikan, the Diviner
» Talent System
» Capture Points system
» [SCII] [Orks] Warboss(es)
» Game Guide
» [Inquisition] Mordrak
» [inquiition] Kaldor Draigo