///////////////////////////////////////////////////////////////////////////
//////////////////////PORTAL SYSTEM////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
constant function PortalS_Lightning takes nothing returns integer
return 0
endfunction
constant function PortalS_Player takes nothing returns integer
return 1
endfunction
constant function PortalS_Previewer takes nothing returns integer
return 2
endfunction
constant function PortalS_Rate takes nothing returns integer
return 3
endfunction
constant function PortalS_SFXChannel takes nothing returns integer
return 4
endfunction
constant function PortalS_SFXPortal takes nothing returns integer
return 5
endfunction
constant function PortalS_SFXSummon takes nothing returns integer
return 6
endfunction
constant function PortalS_Summoned takes nothing returns integer
return 7
endfunction
constant function PortalS_Tick takes nothing returns integer
return 8
endfunction
constant function PortalS_X takes nothing returns integer
return 9
endfunction
constant function PortalS_Y takes nothing returns integer
return 10
endfunction
function Portal_Reset takes nothing returns nothing
set udg_PortalS_BeamLink = "CLPB"
set udg_PortalS_Player = Player(0)
set udg_PortalS_Preview = false
set udg_PortalS_Rate = 1
set udg_PortalS_SFXChannel = ""
set udg_PortalS_SFXPortal = ""
set udg_PortalS_SFXSummon = ""
set udg_PortalS_Summoned = -1
set udg_PortalS_Summoner = -1
set udg_PortalS_X = 0.00
set udg_PortalS_Y = 0.00
set udg_PortalS_Keep=false
endfunction
function newportal takes nothing returns nothing
local unit u=CreateUnit(udg_PortalS_Player,udg_PortalS_Summoner,udg_PortalS_X,udg_PortalS_Y,0)
local integer id=GetHandleId(u)
call GroupAddUnit(udg_PortalSG_ActivePortals,u)
call SaveLightningHandle(udg_PortalSG_Hash,id,PortalS_Lightning(),AddLightningEx(udg_PortalS_BeamLink,true,udg_PortalS_X,udg_PortalS_Y,350,GetUnitX(u),GetUnitY(u),25))
call SaveInteger(udg_PortalSG_Hash,id,PortalS_Rate(),udg_PortalS_Rate)
call SaveInteger(udg_PortalSG_Hash,id,PortalS_Tick(),udg_PortalS_Rate)
call SaveInteger(udg_PortalSG_Hash,id,PortalS_Summoned(),udg_PortalS_Summoned)
call SaveEffectHandle(udg_PortalSG_Hash,id,PortalS_SFXPortal(),AddSpecialEffect(udg_PortalS_SFXPortal,udg_PortalS_X,udg_PortalS_Y))
call SaveEffectHandle(udg_PortalSG_Hash,id,PortalS_SFXChannel(),AddSpecialEffectTarget(udg_PortalS_SFXChannel,u,"chest"))
call SaveStr(udg_PortalSG_Hash,id,PortalS_SFXSummon(),udg_PortalS_SFXSummon)
call SaveReal(udg_PortalSG_Hash,id,PortalS_X(),udg_PortalS_X)
call SaveReal(udg_PortalSG_Hash,id,PortalS_Y(),udg_PortalS_Y)
set u=null
if udg_PortalS_Preview then
set u=CreateUnit(udg_PortalS_Player,udg_PortalS_Summoned,udg_PortalS_X,udg_PortalS_Y,GetRandomReal(0,360))
call SetUnitPathing(u,false)
call SetUnitPosition(u,udg_PortalS_X,udg_PortalS_Y)
call SaveUnitHandle(udg_PortalSG_Hash,id,PortalS_Previewer(),u)
call UnitAddAbility(u,'Amrf')
call UnitRemoveAbility(u,'Amrf')
call SetUnitFlyHeight(u,325,2500)
call PauseUnit(u,true)
call UnitAddAbility(u,'Avul')
call UnitAddAbility(u,'Aloc')
call SetUnitVertexColor(u,255,255,255,128)
set u=null
endif
if udg_PortalS_Keep==false then
call Portal_Reset()
else
set udg_PortalS_Keep=false
endif
call EnableTrigger(gg_trg_Portal_System)
endfunction
Name | Type | is_array | initial_value |
Beams | lightningtype | Yes | |
BonusTimer | timer | No | |
Channels | string | Yes | |
Kills | integer | No | |
Lives | integer | No | |
Portals | string | Yes | |
PortalS_BeamLink | lightningtype | No | |
PortalS_Count | integer | No | |
PortalS_Keep | boolean | No | |
PortalS_Player | player | No | |
PortalS_Preview | boolean | No | |
PortalS_Rate | integer | No | |
PortalS_SFXChannel | string | No | |
PortalS_SFXPortal | string | No | |
PortalS_SFXSummon | string | No | |
PortalS_Summoned | unitcode | No | |
PortalS_Summoner | unitcode | No | |
PortalS_X | real | No | |
PortalS_Y | real | No | |
PortalSG_ActivePortals | group | No | |
PortalSG_Hash | hashtable | No | |
Teleports | string | Yes | |
temploc | location | No | |
temploc2 | location | No | |
tempunit | unit | No | |
tmpint1 | integer | No | |
tmpint2 | integer | No | |
x | real | No | |
y | real | No |
===========================================================================
Explaination of variables
===========================================================================
====================
'LOCAL' VARIABLES
====================
udg_PortalS_BeamLink
- String [Lightning Type]
- This is the lightning type you want your portal to have.
- NOTE: Unable to not show it yet.
====================
udg_PortalS_Count
- Integer
- This is used internally to turn off the trigger.
====================
udg_PortalS_Player
- Player
- This is the player to create units form the portal for.
====================
udg_PortalS_Preview
- Boolean
- This tells whether or not to make a ghost of the unit going to be spawned.
====================
udg_PortalS_Rate
- Integer
- How many quarter seconds to wait before spawning a unit, a value of 4 means one second.
====================
udg_PortalS_SFXChannel
- String
- The model of the effect to put on the summoner unit, dies when portal closes.
====================
udg_PortalS_SFXPortal
- String
- Model of the effect to make for the portal, this is the portal itself!
====================
udg_PortalS_SFXSummon
- String
- Model of the effect to create when a unit spawns.
====================
udg_PortalS_Summoned
- Integer [Unit Type]
- Unit ID to spawn for the portal.
====================
udg_PortalS_Summoner
- Integer [Unit Type]
- Unit ID to create to 'hold' the portal open.
====================
udg_PortalS_X
- Real
- X value to make the portal.
====================
udg_PortalS_Y
- Integer [Unit Type]
- Y value to make the portal.
====================
'GLOBAL' VARIABLES
====================
udg_PortalSG_ActivePortals
- Unit Group
- Group of portals to loop over.
- Note: This is the summoner of the portal, not the portal itself!
====================
udg_PortalSG_Hash
- Hashtable
- Stores all data about the portal system.
1 Open this map, open your map, open Trigger Editor.
2 Go to Window->This map (should be the first one).
3 Click the map name (where custom code is) and copy the newportal function.
4 Go to Window->Your map (should be the second one).
5 Paste newportal function into your map's header.
6 Back to my map.
7 Copy the trigger category (folder) Portal System.
8 Check 'create unknown variables'
9 Close my map.
10 paste the trigger category (folder) into the trigger editor on your map.
11 Done! Now make your dummy spell/ect...
function Trig_Portal_System_Loop takes nothing returns nothing
//Load values spacific to each portal
local unit CurPortal=GetEnumUnit()
local integer id=GetHandleId(CurPortal)
local integer Tick=LoadInteger(udg_PortalSG_Hash,id,PortalS_Tick())
local effect Portal=LoadEffectHandle(udg_PortalSG_Hash,id,PortalS_SFXPortal())
local effect Channel=LoadEffectHandle(udg_PortalSG_Hash,id,PortalS_SFXChannel())
local lightning Beam=LoadLightningHandle(udg_PortalSG_Hash,id,PortalS_Lightning())
local unit Previewer=LoadUnitHandle(udg_PortalSG_Hash,id,PortalS_Previewer())
set udg_PortalS_Player = GetOwningPlayer(CurPortal)
set udg_PortalS_Rate = LoadInteger(udg_PortalSG_Hash,id,PortalS_Rate())
set udg_PortalS_SFXSummon = LoadStr(udg_PortalSG_Hash,id,PortalS_SFXSummon())
set udg_PortalS_Summoned = LoadInteger(udg_PortalSG_Hash,id,PortalS_Summoned())
set udg_PortalS_X = LoadReal(udg_PortalSG_Hash,id,PortalS_X())
set udg_PortalS_Y = LoadReal(udg_PortalSG_Hash,id,PortalS_Y())
set udg_PortalS_Count=udg_PortalS_Count+1
call MoveLightningEx(Beam,true,udg_PortalS_X,udg_PortalS_Y,350,GetUnitX(CurPortal),GetWidgetY(CurPortal),25)
set Tick=Tick-1
call SetUnitPosition(Previewer,udg_PortalS_X,udg_PortalS_Y)
call SetUnitFacingTimed(Previewer,GetUnitFacing(Previewer)+30,.25)
if Tick<=0then
set Tick=udg_PortalS_Rate
call CreateUnit(udg_PortalS_Player,udg_PortalS_Summoned,udg_PortalS_X,udg_PortalS_Y,0)
call DestroyEffect(AddSpecialEffect(udg_PortalS_SFXSummon,udg_PortalS_X,udg_PortalS_Y))
endif
//save changed values
call SaveInteger(udg_PortalSG_Hash,id,PortalS_Tick(),Tick)
//if it needs to be removed, remove it +effects
if GetWidgetLife(CurPortal)<=0.405 and IsUnitType(CurPortal,UNIT_TYPE_DEAD)then
call DestroyEffect(Portal)
call DestroyEffect(Channel)
call RemoveUnit(Previewer)
call DestroyLightning(Beam)
call GroupRemoveUnit(udg_PortalSG_ActivePortals,CurPortal)
call FlushChildHashtable(udg_PortalSG_Hash,id)
endif
set Portal=null
set Beam=null
set Channel=null
call Portal_Reset()
endfunction
function Trig_Portal_System_Actions takes nothing returns nothing
set udg_PortalS_Count=0
call ForGroup(udg_PortalSG_ActivePortals,function Trig_Portal_System_Loop)
if udg_PortalS_Count<1then
call DisableTrigger(gg_trg_Portal_System)
endif
endfunction
function InitTrig_Portal_System takes nothing returns nothing
set gg_trg_Portal_System=CreateTrigger()
call DisableTrigger(gg_trg_Portal_System)
call TriggerRegisterTimerEvent(gg_trg_Portal_System,.25,true)
call TriggerAddAction(gg_trg_Portal_System,function Trig_Portal_System_Actions)
endfunction