//TESH.scrollpos=0
//TESH.alwaysfold=0
//a
Name | Type | is_array | initial_value |
//TESH.scrollpos=6
//TESH.alwaysfold=0
library GroupUtils initializer Init requires optional xebasic
//******************************************************************************
//* BY: Rising_Dusk
//*
//* This library is a combination of several features relevant to groups. First
//* and foremost, it contains a group stack that you can access dynamic groups
//* from. It also provides means to refresh groups and clear any shadow
//* references within them. The included boolexprs are there for backwards
//* compatibility with maps that happen to use them. Since the 1.24c patch,
//* null boolexprs used in GroupEnumUnits* calls no longer leak, so there is no
//* performance gain to using the BOOLEXPR_TRUE constant.
//*
//* Instead of creating/destroying groups, we have moved on to recycling them.
//* NewGroup pulls a group from the stack and ReleaseGroup adds it back. Always
//* remember to call ReleaseGroup on a group when you are done using it. If you
//* fail to do so enough times, the stack will overflow and no longer work.
//*
//* GroupRefresh cleans a group of any shadow references which may be clogging
//* its hashtable. If you remove a unit from the game who is a member of a unit
//* group, it will 'effectively' remove the unit from the group, but leave a
//* shadow in its place. Calling GroupRefresh on a group will clean up any
//* shadow references that may exist within it. It is only worth doing this on
//* groups that you plan to have around for awhile.
//*
//* Constants that can be used from the library:
//* [group] ENUM_GROUP As you might expect, this group is good for
//* when you need a group just for enumeration.
//* [boolexpr] BOOLEXPR_TRUE This is a true boolexpr, which is important
//* because a 'null' boolexpr in enumeration
//* calls results in a leak. Use this instead.
//* [boolexpr] BOOLEXPR_FALSE This exists mostly for completeness.
//*
//* This library also includes a simple implementation of a group enumeration
//* call that factors collision of units in a given area of effect. This is
//* particularly useful because GroupEnumUnitsInRange doesn't factor collision.
//*
//* In your map, you can just replace all instances of GroupEnumUnitsInRange
//* with GroupEnumUnitsInArea with identical arguments and your spells will
//* consider all units colliding with the area of effect. After calling this
//* function as you would normally call GroupEnumUnitsInRange, you are free to
//* do anything with the group that you would normally do.
//*
//* If you don't use xebasic in your map, you may edit the MAX_COLLISION_SIZE
//* variable below and the library will use that as the added radius to check.
//* If you use xebasic, however, the script will automatically use xe's
//* collision size variable.
//*
//* You are also able to use GroupUnitsInArea. This function returns all units
//* within the area, no matter what they are, which can be convenient for those
//* instances where you actually want that.
//*
//* Example usage:
//* local group MyGroup = NewGroup()
//* call GroupRefresh(MyGroup)
//* call ReleaseGroup(MyGroup)
//* call GroupEnumUnitsInArea(ENUM_GROUP, x, y, 350., BOOLEXPR_TRUE)
//* call GroupUnitsInArea(ENUM_GROUP, x, y, 350.)
//*
globals
//If you don't have xebasic in your map, this value will be used instead.
//This value corresponds to the max collision size of a unit in your map.
private constant real MAX_COLLISION_SIZE = 197.
//If you are insane and don't care about any of the protection involved in
//this library, but want this script to be really fast, set this to true.
private constant boolean LESS_SAFETY = false
endglobals
globals
//* Constants that are available to the user
group ENUM_GROUP = CreateGroup()
boolexpr BOOLEXPR_TRUE = null
boolexpr BOOLEXPR_FALSE = null
endglobals
globals
//* Hashtable for debug purposes
private hashtable ht = InitHashtable()
//* Temporary references for GroupRefresh
private boolean Flag = false
private group Refr = null
//* Arrays and counter for the group stack
private group array Groups
private integer Count = 0
//* Variables for use with the GroupUnitsInArea function
private real X = 0.
private real Y = 0.
private real R = 0.
private hashtable H = InitHashtable()
endglobals
private function HookDestroyGroup takes group g returns nothing
if g == ENUM_GROUP then
call BJDebugMsg(SCOPE_PREFIX+"Warning: ENUM_GROUP destroyed")
endif
endfunction
debug hook DestroyGroup HookDestroyGroup
private function AddEx takes nothing returns nothing
if Flag then
call GroupClear(Refr)
set Flag = false
endif
call GroupAddUnit(Refr, GetEnumUnit())
endfunction
function GroupRefresh takes group g returns nothing
set Flag = true
set Refr = g
call ForGroup(Refr, function AddEx)
if Flag then
call GroupClear(g)
endif
endfunction
function NewGroup takes nothing returns group
if Count == 0 then
set Groups[0] = CreateGroup()
else
set Count = Count - 1
endif
static if not LESS_SAFETY then
call SaveInteger(ht, 0, GetHandleId(Groups[Count]), 1)
endif
return Groups[Count]
endfunction
function ReleaseGroup takes group g returns boolean
local integer id = GetHandleId(g)
static if LESS_SAFETY then
if g == null then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Null groups cannot be released")
return false
elseif Count == 8191 then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Max groups achieved, destroying group")
call DestroyGroup(g)
return false
endif
else
if g == null then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Null groups cannot be released")
return false
elseif not HaveSavedInteger(ht, 0, id) then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Group not part of stack")
return false
elseif LoadInteger(ht, 0, id) == 2 then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Groups cannot be multiply released")
return false
elseif Count == 8191 then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Max groups achieved, destroying group")
call DestroyGroup(g)
return false
endif
call SaveInteger(ht, 0, id, 2)
endif
call GroupClear(g)
set Groups[Count] = g
set Count = Count + 1
return true
endfunction
private function Filter takes nothing returns boolean
return IsUnitInRangeXY(GetFilterUnit(), X, Y, R)
endfunction
private function HookDestroyBoolExpr takes boolexpr b returns nothing
local integer bid = GetHandleId(b)
if HaveSavedHandle(H, 0, bid) then
//Clear the saved boolexpr
call DestroyBoolExpr(LoadBooleanExprHandle(H, 0, bid))
call RemoveSavedHandle(H, 0, bid)
endif
endfunction
hook DestroyBoolExpr HookDestroyBoolExpr
private constant function GetRadius takes real radius returns real
static if LIBRARY_xebasic then
return radius+XE_MAX_COLLISION_SIZE
else
return radius+MAX_COLLISION_SIZE
endif
endfunction
function GroupEnumUnitsInArea takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing
local real prevX = X
local real prevY = Y
local real prevR = R
local integer bid = 0
//Set variables to new values
set X = x
set Y = y
set R = radius
if filter == null then
//Adjusts for null boolexprs passed to the function
set filter = Condition(function Filter)
else
//Check for a saved boolexpr
set bid = GetHandleId(filter)
if HaveSavedHandle(H, 0, bid) then
//Set the filter to use to the saved one
set filter = LoadBooleanExprHandle(H, 0, bid)
else
//Create a new And() boolexpr for this filter
set filter = And(Condition(function Filter), filter)
call SaveBooleanExprHandle(H, 0, bid, filter)
endif
endif
//Enumerate, if they want to use the boolexpr, this lets them
call GroupEnumUnitsInRange(whichGroup, x, y, GetRadius(radius), filter)
//Give back original settings so nested enumerations work
set X = prevX
set Y = prevY
set R = prevR
endfunction
function GroupUnitsInArea takes group whichGroup, real x, real y, real radius returns nothing
local real prevX = X
local real prevY = Y
local real prevR = R
//Set variables to new values
set X = x
set Y = y
set R = radius
//Enumerate
call GroupEnumUnitsInRange(whichGroup, x, y, GetRadius(radius), Condition(function Filter))
//Give back original settings so nested enumerations work
set X = prevX
set Y = prevY
set R = prevR
endfunction
private function True takes nothing returns boolean
return true
endfunction
private function False takes nothing returns boolean
return false
endfunction
private function Init takes nothing returns nothing
set BOOLEXPR_TRUE = Condition(function True)
set BOOLEXPR_FALSE = Condition(function False)
endfunction
endlibrary
//TESH.scrollpos=24
//TESH.alwaysfold=0
library_once TimerUtils initializer init
//*********************************************************************
//* TimerUtils (Blue flavor for 1.23b or later)
//* ----------
//*
//* To implement it , create a custom text trigger called TimerUtils
//* and paste the contents of this script there.
//*
//* To copy from a map to another, copy the trigger holding this
//* library to your map.
//*
//* (requires vJass) More scripts: htt://www.wc3campaigns.net
//*
//* For your timer needs:
//* * Attaching
//* * Recycling (with double-free protection)
//*
//* set t=NewTimer() : Get a timer (alternative to CreateTimer)
//* ReleaseTimer(t) : Relese a timer (alt to DestroyTimer)
//* SetTimerData(t,2) : Attach value 2 to timer
//* GetTimerData(t) : Get the timer's value.
//* You can assume a timer's value is 0
//* after NewTimer.
//*
//* Blue Flavor: Slower than the red flavor, it got a 408000 handle id
//* limit, which means that if more than 408000 handle ids
//* are used in your map, TimerUtils might fail, this
//* value is quite big and it is much bigger than the
//* timer limit in Red flavor.
//*
//********************************************************************
//==================================================================================================
globals
private hashtable hasht //I <3 blizz
endglobals
//It is dependent on jasshelper's recent inlining optimization in order to perform correctly.
function SetTimerData takes timer t, integer value returns nothing
call SaveInteger(hasht,0, GetHandleId(t), value)
endfunction
function GetTimerData takes timer t returns integer
return LoadInteger(hasht, 0, GetHandleId(t))
endfunction
//==========================================================================================
globals
private timer array tT
private integer tN = 0
private constant integer HELD=0x28829022
//use a totally random number here, the more improbable someone uses it, the better.
endglobals
//==========================================================================================
function NewTimer takes nothing returns timer
if (tN==0) then
set tT[0]=CreateTimer()
else
set tN=tN-1
endif
call SetTimerData(tT[tN],0)
return tT[tN]
endfunction
//==========================================================================================
function ReleaseTimer takes timer t returns nothing
if(t==null) then
debug call BJDebugMsg("Warning: attempt to release a null timer")
return
endif
if (tN==8191) then
debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
//stack is full, the map already has much more troubles than the chance of bug
call DestroyTimer(t)
else
call PauseTimer(t)
if(GetTimerData(t)==HELD) then
debug call BJDebugMsg("Warning: ReleaseTimer: Double free!")
return
endif
call SetTimerData(t,HELD)
set tT[tN]=t
set tN=tN+1
endif
endfunction
private function init takes nothing returns nothing
set hasht = InitHashtable()
endfunction
endlibrary
//TESH.scrollpos=21
//TESH.alwaysfold=0
library xebasic
//**************************************************************************
//
// xebasic 0.4
// =======
// XE_DUMMY_UNITID : Rawcode of the dummy unit in your map. It should
// use the dummy.mdx model, so remember to import it as
// well, just use copy&paste to copy the dummy from the
// xe map to yours, then change the rawcode.
//
// XE_HEIGHT_ENABLER: Medivh's raven form ability, you may need to change
// this rawcode to another spell that morphs into a flier
// in case you modified medivh's spell in your map.
//
// XE_TREE_RECOGNITION: The ancients' Eat tree ability, same as with medivh
// raven form, you might have to change it.
//
// XE_ANIMATION_PERIOD: The global period of animation used by whatever
// timer that depends on it, if you put a low value
// the movement will look good but it may hurt your
// performance, if instead you use a high value it
// will not lag but will be fast.
//
// XE_MAX_COLLISION_SIZE: The maximum unit collision size in your map, if
// you got a unit bigger than 197.0 it would be
// a good idea to update this constant, since some
// enums will not find it. Likewise, if none of
// your units can go bellow X and X is much smaller
// than 197.0, it would be a good idea to update
// as well, since it will improve the performance
// those enums.
//
// Notice you probably don't have to update this library, unless I specify
// there are new constants which would be unlikely.
//
//**************************************************************************
//===========================================================================
globals
constant integer XE_DUMMY_UNITID = 'e000'
constant integer XE_HEIGHT_ENABLER = 'Amrf'
constant integer XE_TREE_RECOGNITION = 'Aeat'
constant real XE_ANIMATION_PERIOD = 0.025
constant real XE_MAX_COLLISION_SIZE = 197.0
endglobals
endlibrary
//TESH.scrollpos=164
//TESH.alwaysfold=0
library xedamage initializer init requires xebasic
//************************************************************************
// xedamage 0.8
// --------
// For all your damage and targetting needs.
//
//************************************************************************
//===========================================================================================================
globals
private constant integer MAX_SUB_OPTIONS = 3
private constant real FACTOR_TEST_DAMAGE = 0.01
// a low damage to do on units to test their damage factors for specific
// attacktype/damagetype combos.
// You'll need something as high as 20.0 to make it work well with armor resistances.
// (Yes, you read it correctly, 20 ...
//
// If you use such a large value, there may be conflicts with some things relying on damage
// (ie they are not away of the isDummyDamage tag that xedamage posseses.) which may be quite bad if you think about it...
// then maybe it is better to change it to 0.01 ... then will work fine, just fine - but it will generally ignore armor -
// I am leaving it as 0.01 by default, because honestly, I'd rather make it ignore armor than have a lot of people sending me
// rants about how they detect 20.0 damage where none is visible...
private constant real MAX_DAMAGE_FACTOR = 3.00
// The maximum damage factor in the map. I think 3 is fine.
//=======================================================
private constant real EPSILON = 0.000000001
private unit dmger
private constant integer MAX_SPACE = 8190 // MAX_SPACE/MAX_SUB_OPTIONS is the instance limit for xedamage, usually big enough...
endglobals
private keyword structInit
struct xedamage[MAX_SPACE]
//----
// fields and methods for a xedamage object, they aid determining valid targets and special
// damage factor conditions.
//
// Notice the default values.
//
boolean damageSelf = false // the damage and factor methods usually have a source unit parameter
// xedamage would consider this unit as immune unless you set damageSelf to true
boolean damageAllies = false // Alliance dependent target options.
boolean damageEnemies = true // *
boolean damageNeutral = true // *
boolean ranged = true // Is the attack ranged? This has some effect on the AI of the affected units
// true by default, you may not really need to modify this.
boolean visibleOnly = false // Should only units that are visible for source unit's owner be affected?
boolean deadOnly = false // Should only corpses be affected by "the damage"? (useful when using xedamage as a target selector)
boolean alsoDead = false // Should even corpses and alive units be considered?
boolean damageTrees = false //Also damage destructables? Notice this is used only in certain methods.
//AOE for example targets a circle, so it can affect the destructables
//in that circle, a custom spell using xedamage for targetting configuration
//could also have an if-then-else implemented so it can verify if it is true
//then affect trees manually.
//
// Damage type stuff:
// .dtype : the "damagetype" , determines if the spell is physical, magical or ultimate.
// .atype : the "attacktype" , deals with armor.
// .wtype : the "weapontype" , determines the sound effect to be played when damage is done.
//
// Please use common.j/blizzard.j/ some guide to know what damage/attack/weapon types can be used
//
damagetype dtype = DAMAGE_TYPE_UNIVERSAL
attacktype atype = ATTACK_TYPE_NORMAL
weapontype wtype = WEAPON_TYPE_WHOKNOWS
//
// Damage type 'tag' people might use xedamage.isInUse() to detect xedamage usage, there are other static
// variables like xedamage.CurrentDamageType and xedamage.CurrentDamageTag. The tag allows you to specify
// a custom id for the damage type ** Notice the tag would aid you for some spell stuff, for example,
// you can use it in a way similar to Rising_Dusk's damage system.
//
integer tag = 0
//
// if true, forceDamage will make xedamage ignore dtype and atype and try as hard as possible to deal 100%
// damage.
boolean forceDamage = false
//
// Ally factor! Certain spells probably have double purposes and heal allies while harming enemies. This
// field allows you to do such thing.
//
real allyfactor = 1.0
//
// field: .exception = SOME_UNIT_TYPE
// This field adds an exception unittype (classification), if the unit belongs to this unittype it will
// be ignored.
//
method operator exception= takes unittype ut returns nothing
set this.use_ex=true
set this.ex_ut=ut
endmethod
//
// field: .required = SOME_UNIT_TYPE
// This field adds a required unittype (classification), if the unit does not belong to this unittype
// it will be ignored.
//
method operator required= takes unittype ut returns nothing
set this.use_req=true
set this.req_ut=ut
endmethod
private boolean use_ex = false
private unittype ex_ut = null
private boolean use_req = false
private unittype req_ut = null
private unittype array fct[MAX_SUB_OPTIONS]
private real array fc[MAX_SUB_OPTIONS]
private integer fcn=0
//
// method .factor(SOME_UNIT_TYPE, factor)
// You might call factor() if you wish to specify a special damage factor for a certain classification,
// for example call d.factor(UNIT_TYPE_STRUCTURE, 0.5) makes xedamage do half damage to structures.
//
method factor takes unittype ut, real fc returns nothing
if(this.fcn==MAX_SUB_OPTIONS) then
debug call BJDebugMsg("In one instance of xedamage, you are doing too much calls to factor(), please increase MAX_SUB_OPTIONS to allow more, or cut the number of factor() calls")
return
endif
set this.fct[this.fcn] = ut
set this.fc[this.fcn] = fc
set this.fcn = this.fcn+1
endmethod
private integer array abifct[MAX_SUB_OPTIONS]
private real array abifc[MAX_SUB_OPTIONS]
private integer abifcn=0
//
// method .abilityFactor('abil', factor)
// You might call abilityFactor() if you wish to specify a special damage factor for units that have a
// certain ability/buff.
// for example call d.abilityFactor('A000', 1.5 ) makes units that have the A000 ability take 50% more
// damage than usual.
//
method abilityFactor takes integer abilityId, real fc returns nothing
if(this.abifcn==MAX_SUB_OPTIONS) then
debug call BJDebugMsg("In one instance of xedamage, you are doing too much calls to abilityFactor(), please increase MAX_SUB_OPTIONS to allow more, or cut the number of abilityFactor() calls")
return
endif
set this.abifct[this.abifcn] = abilityId
set this.abifc[this.abifcn] = fc
set this.abifcn = this.abifcn+1
endmethod
private boolean usefx = false
private string fxpath
private string fxattach
//
// method .useSpecialEffect("effect\\path.mdl", "origin")
// Makes it add (and destroy) an effect when damage is performed.
//
method useSpecialEffect takes string path, string attach returns nothing
set this.usefx = true
set this.fxpath=path
set this.fxattach=attach
endmethod
//********************************************************************
//* Now, the usage stuff:
//*
//================================================================================
// static method xedamage.isInUse() will return true during a unit damaged
// event in case this damage was caused by xedamage, in this case, you can
// read variables like CurrentDamageType, CurrentAttackType and CurrentDamageTag
// to be able to recognize what sort of damage was done.
//
readonly static damagetype CurrentDamageType=null
readonly static attacktype CurrentAttackType=null
readonly static integer CurrentDamageTag =0
private static integer inUse = 0
static method isInUse takes nothing returns boolean
return (inUse>0) //inline friendly.
endmethod
readonly static boolean isDummyDamage = false
//========================================================================================================
// This function calculates the damage factor caused by a certain attack and damage
// type, it is static : xedamage.getDamageTypeFactor(someunit, ATTAcK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, 100)
//
static method getDamageTypeFactor takes unit u, attacktype a, damagetype d returns real
local real hp=GetWidgetLife(u)
local real mana=GetUnitState(u,UNIT_STATE_MANA)
local real r
local real fc = FACTOR_TEST_DAMAGE
//Since a unit is in that point, we don't need checks.
call SetUnitX(dmger,GetUnitX(u))
call SetUnitY(dmger,GetUnitY(u))
call SetUnitOwner(dmger,GetOwningPlayer(u),false)
set r=hp
if (hp< FACTOR_TEST_DAMAGE*MAX_DAMAGE_FACTOR) then
call SetWidgetLife(u, hp + FACTOR_TEST_DAMAGE*MAX_DAMAGE_FACTOR )
set r = hp + FACTOR_TEST_DAMAGE*MAX_DAMAGE_FACTOR
set fc = GetWidgetLife(u)-hp + EPSILON
endif
set isDummyDamage = true
call UnitDamageTarget(dmger,u, fc ,false,false,a,d,null)
static if DEBUG_MODE then
if IsUnitType(u, UNIT_TYPE_DEAD) and (hp>0.405) then
call BJDebugMsg("xedamage: For some reason, the unit being tested by getDamageTypeFactor has died. Verify MAX_DAMAGE_FACTOR is set to a correct value. ")
endif
endif
set isDummyDamage = false
call SetUnitOwner(dmger,Player(15),false)
if (mana>GetUnitState(u,UNIT_STATE_MANA)) then
//Unit had mana shield, return 1 and restore mana too.
call SetUnitState(u,UNIT_STATE_MANA,mana)
set r=1
else
set r= (r-GetWidgetLife(u)) / fc
endif
call SetWidgetLife(u,hp)
return r
endmethod
private method getTargetFactorCore takes unit source, unit target, boolean usetypes returns real
local player p=GetOwningPlayer(source)
local boolean allied=IsUnitAlly(target,p)
local boolean enemy =IsUnitEnemy(target,p)
local boolean neutral=allied
local real f
local real negf=1.0
local integer i
if(this.damageAllies != this.damageNeutral) then
set neutral= allied and not (GetPlayerAlliance(GetOwningPlayer(target),p, ALLIANCE_HELP_REQUEST ))
//I thought accuracy was not as important as speed , I think that REQUEST is false is enough to consider
// it neutral.
//set neutral= allied and not (GetPlayerAlliance(GetOwningPlayer(target),p, ALLIANCE_HELP_RESPONSE ))
//set neutral= allied and not (GetPlayerAlliance(GetOwningPlayer(target),p, ALLIANCE_SHARED_XP ))
//set neutral= allied and not (GetPlayerAlliance(GetOwningPlayer(target),p, ALLIANCE_SHARED_SPELLS ))
set allied= allied and not(neutral)
endif
if (not this.damageAllies) and allied then
return 0.0
elseif (not this.damageEnemies) and enemy then
return 0.0
elseif( (not this.damageSelf) and (source==target) ) then
return 0.0
elseif (not this.damageNeutral) and neutral then
return 0.0
elseif( this.use_ex and IsUnitType(target, this.ex_ut) ) then
return 0.0
elseif( this.visibleOnly and not IsUnitVisible(target,p) ) then
return 0.0
elseif ( this.deadOnly and not IsUnitType(target,UNIT_TYPE_DEAD) ) then
return 0.0
elseif ( not(this.alsoDead) and IsUnitType(target,UNIT_TYPE_DEAD) ) then
return 0.0
endif
set f=1.0
if ( IsUnitAlly(target,p) ) then
set f=f*this.allyfactor
if(f<=-EPSILON) then
set f=-f
set negf=-1.0
endif
endif
if (this.use_req and not IsUnitType(target,this.req_ut)) then
return 0.0
endif
set i=.fcn-1
loop
exitwhen (i<0)
if( IsUnitType(target, this.fct[i] ) ) then
set f=f*this.fc[i]
if(f<=-EPSILON) then
set f=-f
set negf=-1.0
endif
endif
set i=i-1
endloop
set i=.abifcn-1
loop
exitwhen (i<0)
if( GetUnitAbilityLevel(target,this.abifct[i] )>0 ) then
set f=f*this.abifc[i]
if(f<=-EPSILON) then
set f=-f
set negf=-1.0
endif
endif
set i=i-1
endloop
set f=f*negf
if ( f<EPSILON) and (f>-EPSILON) then
return 0.0
endif
if( this.forceDamage or not usetypes ) then
return f
endif
set f=f*xedamage.getDamageTypeFactor(target,this.atype,this.dtype)
if ( f<EPSILON) and (f>-EPSILON) then
return 0.0
endif
return f
endmethod
//====================================================================
// With this you might decide if a unit is a valid target for a spell.
//
method getTargetFactor takes unit source, unit target returns real
return this.getTargetFactorCore(source,target,true)
endmethod
//======================================================================
// a little better, I guess
//
method allowedTarget takes unit source, unit target returns boolean
return (this.getTargetFactorCore(source,target,false)!=0.0)
endmethod
//=======================================================================
// performs damage to the target unit, for unit 'source'.
//
method damageTarget takes unit source, unit target, real damage returns boolean
local damagetype dt=.CurrentDamageType
local attacktype at=.CurrentAttackType
local integer tg=.CurrentDamageTag
local real f = this.getTargetFactorCore(source,target,false)
local real pl
if(f!=0.0) then
set .CurrentDamageType = .dtype
set .CurrentAttackType = .atype
set .CurrentDamageTag = .tag
set .inUse = .inUse +1
set pl=GetWidgetLife(target)
call UnitDamageTarget(source,target, f*damage, true, .ranged, .atype, .dtype, .wtype )
set .inUse = .inUse -1
set .CurrentDamageTag = tg
set .CurrentDamageType = dt
set .CurrentAttackType = at
if(pl != GetWidgetLife(target) ) then
if(usefx) then
call DestroyEffect( AddSpecialEffectTarget(this.fxpath, target, this.fxattach) )
endif
return true
endif
endif
return false
endmethod
//=======================================================================================
// The same as damageTarget, but it forces a specific damage value, good if you already
// know the target.
//
method damageTargetForceValue takes unit source, unit target, real damage returns nothing
local damagetype dt=.CurrentDamageType
local attacktype at=.CurrentAttackType
local integer tg=.CurrentDamageTag
set .CurrentDamageType = .dtype
set .CurrentAttackType = .atype
set .CurrentDamageTag = .tag
if( usefx) then
call DestroyEffect( AddSpecialEffectTarget(this.fxpath, target, this.fxattach) )
endif
set .inUse = .inUse +1
call UnitDamageTarget(source,target, damage, true, .ranged, null, null, .wtype )
set .inUse = .inUse -1
set .CurrentDamageTag = tg
set .CurrentDamageType = dt
set .CurrentAttackType = at
endmethod
//=====================================================================================
// Notice: this will not Destroy the group, but it will certainly empty the group.
//
method damageGroup takes unit source, group targetGroup, real damage returns integer
local damagetype dt=.CurrentDamageType
local attacktype at=.CurrentAttackType
local integer tg=.CurrentDamageTag
local unit target
local real f
local integer count=0
local real hp
set .CurrentDamageType = .dtype
set .CurrentAttackType = .atype
set .CurrentDamageTag = .tag
set .inUse = .inUse +1
loop
set target=FirstOfGroup(targetGroup)
exitwhen (target==null)
call GroupRemoveUnit(targetGroup,target)
set f= this.getTargetFactorCore(source,target,false)
if (f!=0.0) then
set count=count+1
if(usefx) then
set hp = GetWidgetLife(target)
endif
call UnitDamageTarget(source,target, f*damage, true, .ranged, .atype, .dtype, .wtype )
if(usefx and (hp > GetWidgetLife(target)) ) then
call DestroyEffect( AddSpecialEffectTarget(this.fxpath, target, this.fxattach) )
endif
endif
endloop
set .inUse = .inUse -1
set .CurrentDamageTag=tg
set .CurrentDamageType = dt
set .CurrentAttackType = at
return count
endmethod
private static xedamage instance
private integer countAOE
private unit sourceAOE
private real AOEx
private real AOEy
private real AOEradius
private real AOEdamage
private static boolexpr filterAOE
private static boolexpr filterDestAOE
private static group enumgroup
private static rect AOERect
private static method damageAOE_Enum takes nothing returns boolean
local unit target=GetFilterUnit()
local xedamage this=.instance //adopting a instance.
local real f
local real hp
if( not IsUnitInRangeXY(target,.AOEx, .AOEy, .AOEradius) ) then
set target=null
return false
endif
set f=.getTargetFactorCore(.sourceAOE, target, false)
if(f!=0.0) then
set .countAOE=.countAOE+1
if(this.usefx) then
set hp =GetWidgetLife(target)
endif
call UnitDamageTarget(.sourceAOE,target, f*this.AOEdamage, true, .ranged, .atype, .dtype, .wtype )
if(this.usefx and (hp > GetWidgetLife(target) ) ) then
call DestroyEffect( AddSpecialEffectTarget(this.fxpath, target, this.fxattach) )
endif
endif
set .instance= this //better restore, nesting IS possible!
set target=null
return false
endmethod
private static method damageAOE_DestructablesEnum takes nothing returns boolean
local destructable target=GetFilterDestructable()
local xedamage this=.instance //adopting a instance.
local real dx=.AOEx-GetDestructableX(target)
local real dy=.AOEy-GetDestructableY(target)
if( dx*dx + dy*dy >= .AOEradius+EPSILON ) then
set target=null
return false
endif
set .countAOE=.countAOE+1
if(.usefx) then
call DestroyEffect( AddSpecialEffectTarget(this.fxpath, target, this.fxattach) )
endif
call UnitDamageTarget(.sourceAOE,target, this.AOEdamage, true, .ranged, .atype, .dtype, .wtype )
set .instance= this //better restore, nesting IS possible!
set target=null
return false
endmethod
//==========================================================================================
// will affect trees if damageTrees is true!
//
method damageAOE takes unit source, real x, real y, real radius, real damage returns integer
local damagetype dt=.CurrentDamageType
local attacktype at=.CurrentAttackType
local integer tg=.CurrentDamageTag
set .CurrentDamageType = .dtype
set .CurrentAttackType = .atype
set .CurrentDamageTag = .tag
set .inUse = .inUse +1
set .instance=this
set .countAOE=0
set .sourceAOE=source
set .AOEx=x
set .AOEradius=radius
set .AOEy=y
set .AOEdamage=damage
call GroupEnumUnitsInRange(.enumgroup,x,y,radius+XE_MAX_COLLISION_SIZE, .filterAOE)
if(.damageTrees) then
call SetRect(.AOERect, x-radius, y-radius, x+radius, y+radius)
set .AOEradius=.AOEradius*.AOEradius
call EnumDestructablesInRect(.AOERect, .filterDestAOE, null)
endif
set .inUse = .inUse -1
set .CurrentDamageTag = tg
set .CurrentDamageType = dt
set .CurrentAttackType = at
return .countAOE
endmethod
method damageAOELoc takes unit source, location loc, real radius, real damage returns integer
return .damageAOE(source, GetLocationX(loc), GetLocationY(loc), radius, damage)
endmethod
//==========================================================================================
// only affects trees, ignores damageTrees
//
method damageDestructablesAOE takes unit source, real x, real y, real radius, real damage returns integer
set .instance=this
set .countAOE=0
set .sourceAOE=source
set .AOEx=x
set .AOEradius=radius*radius
set .AOEy=y
set .AOEdamage=damage
//if(.damageTrees) then
call SetRect(.AOERect, x-radius, y-radius, x+radius, y+radius)
call EnumDestructablesInRect(.AOERect, .filterDestAOE, null)
//endif
return .countAOE
endmethod
method damageDestructablesAOELoc takes unit source, location loc, real radius, real damage returns integer
return .damageDestructablesAOE(source,GetLocationX(loc), GetLocationY(loc), radius, damage)
endmethod
//'friend' with the library init
static method structInit takes nothing returns nothing
set .AOERect= Rect(0,0,0,0)
set .filterAOE= Condition(function xedamage.damageAOE_Enum)
set .filterDestAOE = Condition( function xedamage.damageAOE_DestructablesEnum)
set .enumgroup = CreateGroup()
endmethod
endstruct
private function init takes nothing returns nothing
set dmger=CreateUnit(Player(15), XE_DUMMY_UNITID , 0.,0.,0.)
call UnitAddAbility(dmger,'Aloc')
call xedamage.structInit()
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library ShadowAttack requires TimerUtils, GroupUtils, xedamage
//===============================================================================================
// shadow attack v1.00 by scorpion182
// requires: TimerUtils, xedamage by Vexorian
// GroupUtils by RisingDusk
//
// optional: BoundSentinel by Vexorian (use it if you don't want your hero stuck outside the map bound)
//
//===============================================================================================
globals
private keyword data
//-----------------------CALIBRATION SECTION-----------------------------------------------------
//spell id
private constant integer SPELL_ID = 'A000'
//shadow trail unit id
private constant integer SHADOW_TRAIL = 'h000'
//shadow number
private constant integer MAX_SHADOW = 30
//attack animation index
private constant integer ANIMATION_INDEX = 2
//walk animation index
private constant integer ATTACK_AN_INDEX = 5
//collision distance
private constant real COLLISION_DIST = 75.
//spell order id
private constant string ORDER_ID = "blizzard"
//image special effect
private constant string IMAGE_FX = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl"
//on-damage effect
private constant string ON_DAMAGE_FX = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
//on-damage effect attachment point
private constant string DAMAGE_ATTCH = "origin"
//preload effect?
private constant boolean PRELOAD_FX = true
endglobals
//do damage each hit
private constant function GetDamage takes integer lvl returns real
return 35. + lvl * 10
endfunction
//attack interval
private constant function GetAttackInterval takes integer lvl returns real
return 2. + lvl * 0
endfunction
//maximum number target per level
private constant function GetTargetNum takes integer lvl returns integer
return 2 + lvl * 1
endfunction
//rotation speed
private constant function GetAngleSpeed takes integer lvl returns real
return .05 + lvl * 0.
endfunction
//caster movement speed
private constant function GetSpeed takes integer lvl returns real
return 800. * XE_ANIMATION_PERIOD + lvl * 0
endfunction
//shadow number
private constant function GetShadowNum takes integer lvl returns integer
return 18 + lvl * 0
endfunction
//area of effect
private constant function GetDistance takes integer lvl returns real
return 450. + lvl * 0
endfunction
//filter the target
private function IsValidTarget takes unit u, data s returns boolean
return not IsUnitType(u, UNIT_TYPE_DEAD) and GetUnitTypeId(u) != 0 and IsUnitType(u,UNIT_TYPE_STRUCTURE)==false and IsUnitEnemy(u,GetOwningPlayer(s.caster))==true and IsUnitVisible(u,GetOwningPlayer(s.caster))==true
endfunction
//damage options must match the target filter
private function DamageOptions takes xedamage spellDamage returns nothing
set spellDamage.dtype=DAMAGE_TYPE_UNIVERSAL
set spellDamage.atype=ATTACK_TYPE_NORMAL
set spellDamage.exception=UNIT_TYPE_STRUCTURE
set spellDamage.visibleOnly=true
endfunction
//----------------------END OF CALIBRATION-------------------------------------------------------
globals
private xedamage xed
private constant real A = 2 * bj_PI
endglobals
private struct shadow
unit array shadow[MAX_SHADOW]
real array angle[MAX_SHADOW]
boolean array show[MAX_SHADOW]
group victim
unit target = null
boolean sets = false
boolean attack = false
boolean ready = false
boolean back = false
boolean inpos = false
real interval = 0
real cap = 0
real ag = 0
integer idx = 0
integer num = 0
integer n = 0
integer pos = 0
unit caster
timer t
integer lvl
real cx
real cy
private static thistype temp
static method create takes unit c, real x, real y returns thistype
local thistype this = thistype.allocate()
local integer i = 0
local real a
set .caster = c
set .t = NewTimer()
set .lvl = GetUnitAbilityLevel(c, SPELL_ID)
set .victim = NewGroup()
set .cap = A
set .cx = x
set .cy = y
loop
exitwhen i == GetShadowNum(.lvl)
set a = i * A / GetShadowNum(.lvl)
set .shadow[i] = CreateUnit(GetOwningPlayer(.caster), SHADOW_TRAIL, x, y, a)
set .angle[i] = a
call SetUnitTimeScale(.shadow[i], 2.)
call SetUnitColor(.shadow[i], PLAYER_COLOR_LIGHT_GRAY)
call SetUnitVertexColor(.shadow[i], 255, 255, 255, 125)
call SetUnitAnimationByIndex(.shadow[i], ANIMATION_INDEX)
call ShowUnit(.shadow[i], false)
set i = i + 1
endloop
call SetTimerData(.t, this)
call TimerStart(.t, XE_ANIMATION_PERIOD, true, function thistype.onLoop)
return this
endmethod
//i don't know why i can't detect locust unit, so i reverse it
static method IsCaster takes nothing returns boolean
local unit u = GetFilterUnit()
if u==temp.caster and not temp.sets then
set temp.pos = temp.idx
set temp.sets = true
call RemoveUnit(temp.shadow[temp.idx])
set temp.shadow[temp.idx] = temp.caster
set temp.show[temp.idx] = true
set temp.num = temp.num + 1
endif
set u = null
return false
endmethod
static method IsTarget takes nothing returns boolean
local unit u = GetFilterUnit()
if temp.target == null and IsValidTarget(u, temp) and not IsUnitInGroup(u, temp.victim) then
set temp.target = u
set temp.n = temp.n + 1
set temp.attack = true
call GroupAddUnit(temp.victim, u)
endif
set u = null
return false
endmethod
static method onLoop takes nothing returns nothing
local thistype this = thistype(GetTimerData(GetExpiredTimer()))
local integer i = 0
local real dx
local real dy
local real dis
local real angle
if GetUnitCurrentOrder(.caster) == OrderId(ORDER_ID) then
set temp = this
if .ready then
if .back then
set .interval = .interval + XE_ANIMATION_PERIOD
if .interval > GetAttackInterval(.lvl) then
set .interval = 0.
set .back = false
set .shadow [.pos] = CreateUnit(GetOwningPlayer(.caster), SHADOW_TRAIL, GetUnitX(.caster), GetUnitY(.caster), GetUnitFacing(.caster))
call SetUnitTimeScale(.shadow[.pos], 2.)
call SetUnitColor(.shadow[.pos], PLAYER_COLOR_LIGHT_GRAY)
call SetUnitVertexColor(.shadow[.pos], 255, 255, 255, 125)
call SetUnitAnimationByIndex(.shadow[.pos], ANIMATION_INDEX)
call UnitAddAbility(.shadow[.pos], 'Aloc')
call GroupClear(.victim)
endif
endif
if not .attack and .target == null and .n < GetTargetNum(.lvl) and not .back then
call GroupEnumUnitsInRange(ENUM_GROUP, .cx, .cy, GetDistance(.lvl), function thistype.IsTarget)
if .n == 0 and .target == null and not .inpos then
set .inpos = true
call RemoveUnit(.shadow[.pos])
set .shadow[.pos] = .caster
set .show[.pos] = true
call SetUnitAnimationByIndex(.caster, ANIMATION_INDEX)
endif
if .n >= 1 and .target == null then
set .ready = false
call SetUnitAnimationByIndex(.caster, ANIMATION_INDEX)
endif
elseif .attack and .target!=null then
set dx = GetUnitX(.target) - GetUnitX(.caster)
set dy = GetUnitY(.target) - GetUnitY(.caster)
set dis = SquareRoot(dx * dx + dy * dy)
set angle = Atan2(dy, dx)
if dis > COLLISION_DIST and IsUnitInRangeXY(.target, .cx, .cy, GetDistance(.lvl)) then
call SetUnitX(.caster, GetUnitX(.caster) + GetSpeed(.lvl) * Cos(angle))
call SetUnitY(.caster, GetUnitY(.caster) + GetSpeed(.lvl) * Sin(angle))
call SetUnitFacing(.caster, angle * bj_RADTODEG)
else
call xed.damageTarget(.caster,.target,GetDamage(.lvl))
set .attack = false
set .target = null
call SetUnitAnimationByIndex(.caster, ATTACK_AN_INDEX)
endif
elseif .n == GetTargetNum (.lvl) then
set .ready = false
call SetUnitAnimationByIndex(.caster, ANIMATION_INDEX)
endif
else
if .num == GetShadowNum(.lvl) then
set dx = GetUnitX(.shadow[.pos]) - GetUnitX(.caster)
set dy = GetUnitY(.shadow[.pos]) - GetUnitY(.caster)
set dis = SquareRoot(dx * dx + dy * dy)
set angle = Atan2(dy, dx)
if dis > 215. then
call SetUnitX(.caster, GetUnitX(.caster) + GetSpeed(.lvl) * Cos(angle))
call SetUnitY(.caster, GetUnitY(.caster) + GetSpeed(.lvl) * Sin(angle))
call SetUnitFacing(.caster, angle * bj_RADTODEG)
else
if not .back then
set .back = true
set .ready = true
set .attack = false
set .inpos = false
set .n = 0
set .target = null
set .pos = .pos - 1
if .pos < 0 then
set .pos = GetShadowNum(.lvl) - 1
endif
call RemoveUnit(.shadow[.pos])
set .shadow[.pos] = .caster
set .show[.pos] = true
call SetUnitAnimationByIndex(.caster, ANIMATION_INDEX)
endif
endif
endif
endif
if .sets and .ag > .cap then
set temp.idx = temp.idx - 1
if temp.idx < 0 then
set temp.idx = GetShadowNum(.lvl) - 1
endif
set .ag = 0
if not .show[.idx] then
set .num = .num + 1
if .num > GetShadowNum(.lvl) then
set .num = GetShadowNum(.lvl)
endif
if .num == GetShadowNum(.lvl) then
set .ready = true
set .shadow [.pos] = CreateUnit(GetOwningPlayer(.caster), SHADOW_TRAIL, GetUnitX(.caster), GetUnitY(.caster), GetUnitFacing(.caster))
call SetUnitTimeScale(.shadow[.pos], 2.)
call SetUnitColor(.shadow[.pos], PLAYER_COLOR_LIGHT_GRAY)
call SetUnitVertexColor(.shadow[.pos], 255, 255, 255, 125)
call SetUnitAnimationByIndex(.shadow[.pos], ANIMATION_INDEX)
call UnitAddAbility(.shadow[.pos], 'Aloc')
endif
set .show[.idx] = true
call ShowUnit(.shadow[.idx], true)
call UnitAddAbility(.shadow[.idx], 'Aloc')
call DestroyEffect(AddSpecialEffectTarget(IMAGE_FX, .shadow[.idx], "origin"))
endif
endif
loop
exitwhen i == GetShadowNum(.lvl)
if not .sets then
call GroupEnumUnitsInRange(ENUM_GROUP, GetUnitX(.shadow[i]), GetUnitY(.shadow[i]), COLLISION_DIST, function thistype.IsCaster)
set .idx = i
endif
set .ag = .ag + GetAngleSpeed(.lvl)
set .angle[i] = .angle[i] + GetAngleSpeed(.lvl)
call SetUnitX(.shadow[i], .cx + GetDistance(.lvl) * Cos(.angle[i]))
call SetUnitY(.shadow[i], .cy + GetDistance(.lvl) * Sin(.angle[i]))
call SetUnitFacing(.shadow[i], .angle[i] * bj_RADTODEG + 90. )
set i = i + 1
endloop
else
call .destroy()
endif
endmethod
private method onDestroy takes nothing returns nothing
local integer i = 0
call ReleaseTimer(.t)
call ReleaseGroup(.victim)
call SetUnitTimeScale(.caster, 1.)
loop
exitwhen i == GetShadowNum(.lvl)
set .show[i] = false
if .shadow[i] != .caster then
call SetUnitExploded(.shadow[i], true)
call KillUnit(.shadow[i])
endif
set i = i + 1
endloop
endmethod
endstruct
private struct data
unit caster
timer t
real tx
real ty
integer lvl
real cx
real cy
static method create takes unit c, real x, real y returns thistype
local thistype this = thistype.allocate()
local real angle = bj_RADTODEG * Atan2(y - GetUnitY(c), x - GetUnitX(c))
set .cx = x
set .cy = y
set .caster = c
set .t = NewTimer()
set .lvl = GetUnitAbilityLevel(c, SPELL_ID)
set .tx = x + GetDistance(.lvl) * Cos(angle)
set .ty = y + GetDistance(.lvl) * Sin(angle)
call SetUnitFacing(.caster, angle)
call SetUnitAnimationByIndex(.caster, ANIMATION_INDEX)
call SetUnitTimeScale(.caster, 2.)
return this
endmethod
private method onDestroy takes nothing returns nothing
call ReleaseTimer(.t)
endmethod
static method onLoop takes nothing returns nothing
local thistype this = thistype(GetTimerData(GetExpiredTimer()))
local real dx = .tx - GetUnitX(.caster)
local real dy = .ty - GetUnitY(.caster)
local real dis = SquareRoot(dx * dx + dy * dy)
local real angle = Atan2(dy, dx)
local shadow s
if dis > COLLISION_DIST and GetUnitCurrentOrder(.caster) == OrderId(ORDER_ID) then
call SetUnitX(.caster, GetUnitX(.caster) + GetSpeed(.lvl) * Cos(angle))
call SetUnitY(.caster, GetUnitY(.caster) + GetSpeed(.lvl) * Sin(angle))
call SetUnitFacing(.caster, angle * bj_RADTODEG)
else
call .destroy()
set s = shadow.create(.caster, .cx, .cy)
endif
endmethod
static method SpellEffect takes nothing returns boolean
local thistype this
local unit u = GetTriggerUnit()
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
if GetSpellAbilityId() == SPELL_ID then
set this = thistype.create(u, x, y)
call SetTimerData(.t, this)
call TimerStart(.t, XE_ANIMATION_PERIOD, true, function thistype.onLoop)
endif
set u = null
return false
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function thistype.SpellEffect))
//init xedamage
set xed=xedamage.create()
call DamageOptions(xed)
call xed.useSpecialEffect(ON_DAMAGE_FX, DAMAGE_ATTCH)
//preload fx
static if PRELOAD_FX then
call Preload(IMAGE_FX)
call Preload(ON_DAMAGE_FX)
endif
endmethod
endstruct
endlibrary
//TESH.scrollpos=39
//TESH.alwaysfold=0
library MapUtils initializer init
globals
private constant integer HERO_ID='Naka'
private constant string MAP_NAME=" |cffcdbe70S H A D O W A T T A C K"
private unit hero
private integer lvl=1
private dialog dg=DialogCreate()
private button array bt[5]
private real x
private real y
private camerasetup CS=CreateCameraSetup()
endglobals
private function CreateHero takes nothing returns nothing
set x = GetStartLocationX(0)
set y = GetStartLocationY(0)
set hero=CreateUnit(Player(0),HERO_ID, x, y,GetRandomReal(0.,360.))
call SetCameraPosition(x,y)
call ClearSelection()
call SelectUnit(hero,true)
call SetMapMusic("Sound\\Music\\mp3Music\\IllidansTheme.mp3",false,0)
call DisplayTimedTextToPlayer(Player(0),0,0,20.,MAP_NAME)
call DisplayTimedTextToPlayer(Player(0),0,0,20.," |cffcdbe70 By: scorpion182")
call DisplayTimedTextToPlayer(Player(0),0,0,20.,"|cffcdbe70Press Esc to show dialog stuff.")
endfunction
private function Stuff takes nothing returns nothing
call FogEnable(false)
call FogMaskEnable(false)
endfunction
private function StartDialog takes nothing returns nothing
call DialogDisplay(Player(0),dg,false)
call DialogClear(dg)
call DialogSetMessage(dg,"Setup")
set bt[0]=DialogAddButton(dg,"Level: "+I2S(GetHeroLevel(hero)),0)
set bt[1]=DialogAddButton(dg,"Refresh",0)
set bt[2]=DialogAddButton(dg,"Spawn Footies",0)
set bt[3]=DialogAddButton(dg,"Revive",0)
set bt[4]=DialogAddButton(dg,"Close",0)
call DialogDisplay(Player(0),dg,true)
endfunction
private function DialogSetup takes nothing returns nothing
local integer i = 0
if (GetClickedButton()!=bt[4]) then
if (GetClickedButton()==bt[0]) then
set lvl = GetHeroLevel(hero)
set lvl = lvl + 1
if (lvl>10) then
set lvl=10
endif
call SetHeroLevel(hero,lvl,false)
elseif (GetClickedButton()==bt[1]) then
call SetUnitState(hero,UNIT_STATE_LIFE,GetUnitState(hero,UNIT_STATE_MAX_LIFE))
call SetUnitState(hero,UNIT_STATE_MANA,GetUnitState(hero,UNIT_STATE_MAX_MANA))
elseif (GetClickedButton()==bt[2]) then
loop
exitwhen i > 3
call CreateUnit(Player(1), 'hfoo', x, y, 0)
set i = i + 1
endloop
elseif (GetClickedButton()==bt[3]) then
call ReviveHero(hero,x,y,false)
endif
call StartDialog()
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic(t, Player(0) )
call TriggerAddAction(t, function StartDialog)
set t= CreateTrigger( )
call TriggerRegisterDialogEventBJ(t, dg )
call TriggerAddAction(t, function DialogSetup )
call CreateHero()
call Stuff()
set t=null
endfunction
endlibrary