//TESH.scrollpos=0
//TESH.alwaysfold=0
Name | Type | is_array | initial_value |
HandleBoard | leaderboard | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
function HandleCounter_Update takes nothing returns nothing
local integer i = 0
local integer id
local location array P
local real result=0
loop
exitwhen i >= 50
set i = i + 1
set P[i] = Location(0,0)
set id = GetHandleId(P[i])
set result = result + (id-0x100000)
endloop
set result = result/i-i/2
loop
call RemoveLocation(P[i])
set P[i] = null
exitwhen i <= 1
set i = i - 1
endloop
call LeaderboardSetItemValue(udg_HandleBoard,0,R2I(result))
endfunction
function HandleCounter_Actions takes nothing returns nothing
set udg_HandleBoard = CreateLeaderboard()
call LeaderboardSetLabel(udg_HandleBoard, "Handle Counter")
call PlayerSetLeaderboard(GetLocalPlayer(),udg_HandleBoard)
call LeaderboardDisplay(udg_HandleBoard,true)
call LeaderboardAddItem(udg_HandleBoard,"Handles",0,Player(0))
call LeaderboardSetSizeByItemCount(udg_HandleBoard,1)
call HandleCounter_Update()
call TimerStart(GetExpiredTimer(),0.01,true,function HandleCounter_Update)
endfunction
function InitTrig_HandleCounter takes nothing returns nothing
call TimerStart(CreateTimer(),0,false,function HandleCounter_Actions)
endfunction
//TESH.scrollpos=113
//TESH.alwaysfold=0
//==============================================================================
// ABC -- STRUCT ATTACHMENT SYSTEM BY COHADAR -- v6.1
//==============================================================================
//==============================================================================
// Quick function index:
//==============================================================================
//
// ----------------------------------------------------------------------
// Set Functions - these functions attach struct to a handle
// ----------------------------------------------------------------------
// SetTimerStructA(timer, struct)
// SetTimerStructB(timer, struct)
// SetTimerStructC(timer, struct)
//
// SetTriggerStructA(trigger, struct)
// SetTriggerStructB(trigger, struct)
// SetTriggerStructC(trigger, struct)
//
// SetDialogStructA(dialog, struct)
// SetDialogStructB(dialog, struct)
// SetDialogStructC(dialog, struct)
//
// SetRegionStructA(region, struct)
// SetRegionStructB(region, struct)
// SetRegionStructC(region, struct)
//
// ----------------------------------------------------------------------
// Get Functions - these functions retrieve attached structs
// ----------------------------------------------------------------------
// GetTimerStructA(timer) -> struct
// GetTimerStructB(timer) -> struct
// GetTimerStructC(timer) -> struct
//
// GetTriggerStructA(trigger) -> struct
// GetTriggerStructB(trigger) -> struct
// GetTriggerStructC(trigger) -> struct
//
// GetDialogStructA(dialog) -> struct
// GetDialogStructB(dialog) -> struct
// GetDialogStructC(dialog) -> struct
//
// GetRegionStructA(region) -> struct
// GetRegionStructB(region) -> struct
// GetRegionStructC(region) -> struct
//
// ----------------------------------------------------------------------
// Clear Functions - these functions clear and return attached value
// ----------------------------------------------------------------------
// ClearTimerStructA(timer) -> struct
// ClearTimerStructB(timer) -> struct
// ClearTimerStructC(timer) -> struct
//
// ClearTriggerStructA(trigger) -> struct
// ClearTriggerStructB(trigger) -> struct
// ClearTriggerStructC(trigger) -> struct
//
// ClearDialogStructA(dialog) -> struct
// ClearDialogStructB(dialog) -> struct
// ClearDialogStructC(dialog) -> struct
//
// ClearRegionStructA(region) -> struct
// ClearRegionStructB(region) -> struct
// ClearRegionStructC(region) -> struct
//
//==============================================================================
//==============================================================================
// DOCUMENTATION:
//==============================================================================
//
// PURPOUSE OF ABC:
// * Type safe handle attaching.
//
// * Currently supported handle types are timer, trigger, dialog and region
//
// PROS:
// * ABC is faster than gamecache based systems.
//
// * You can attach up to 3 structs on the same handle
//
// * System reports collision, and clearing of non-existent value.
//
// * This system will work even if your map leaks
// and will NOT slow down because of it.
//
// CONS:
// * you must manually clear the stored value - REMEMBER THIS RULE!!!
// Don't forget to use Clear functions
//
// DETAILS:
// * You can use Get to check if struct is attached to handle
// It will return 0 if it is not.
//
// * ABC will not interfere with other attachment systems
// You can freely use any other system alongside ABC
//
// * For unit attaching I recommend using PUI
//
// SPECIAL THANKS TO:
// * NagelBagel - for finding errors in versions 4.3 and 4.4
// * Here-b-Trollz - for testing ABC and for making cool spells with it.
// * Toadcop - for being pain in the ass and for pushing me to improve ABC.
// * emjlr3 - for pointing out the need for non-generic trigger attachments
// * PandaMine - I found a bug in ABC by examining his HSAS vs ABC test
// * All those people out there who use and support my systems
// Thank you guys.
//
// HOW TO IMPORT:
// * Just create a trigger named ABC
// * convert it to text and replace the whole trigger text with this one
//
//==============================================================================
//==============================================================================
// Macro function cores
//==============================================================================
//------------------------------------------------------------------------------
//! textmacro ABC_Set takes X, NAME, TYPE
local integer i = GetHandleId(key)
set i = i - (i / HASH) * HASH
if $NAME$Key$X$[i] == null then
set $NAME$Key$X$[i] = key
set $NAME$Value$X$[i] = value
else
debug set $NAME$Collision$X$[i] = $NAME$Collision$X$[i] + 1
debug if $NAME$MaxCollision$X$ < $NAME$Collision$X$[i] then
debug set $NAME$MaxCollision$X$ = $NAME$Collision$X$[i]
debug call BJDebugMsg("Warning: Set$NAME$Struct$X$("+I2S(GetHandleId(key))+", "+I2S(value)+") - index: "+I2S(i)+", collision: "+I2S($NAME$MaxCollision$X$) + ", Please report to Author")
debug endif
call SaveInteger($NAME$Hash, '$X$', GetHandleId(key), value)
endif
//! endtextmacro
//------------------------------------------------------------------------------
//! textmacro ABC_Get takes X, NAME, TYPE
local integer i = GetHandleId(key)
set i = i - (i / HASH) * HASH
if $NAME$Key$X$[i] == key then
return $NAME$Value$X$[i]
else
return LoadInteger($NAME$Hash, '$X$', GetHandleId(key))
endif
//! endtextmacro
//------------------------------------------------------------------------------
//! textmacro ABC_Clear takes X, NAME, TYPE
local integer ret
local integer i = GetHandleId(key)
set i = i - (i / HASH) * HASH
if $NAME$Key$X$[i] == key then
set ret = $NAME$Value$X$[i]
set $NAME$Key$X$[i] = null
set $NAME$Value$X$[i] = 0
else
if HaveSavedInteger($NAME$Hash, '$X$', GetHandleId(key)) then
debug set $NAME$Collision$X$[i] = $NAME$Collision$X$[i] - 1
set ret = LoadInteger($NAME$Hash, '$X$', GetHandleId(key))
call RemoveSavedInteger($NAME$Hash, '$X$', GetHandleId(key))
else
call BJDebugMsg("ERROR: Clear$NAME$Struct$X$("+I2S(GetHandleId(key))+") - clear attempt on bad key, Please report to Author")
set ret = 0
endif
endif
return ret
//! endtextmacro
//==============================================================================
library ABC initializer Init
globals
private constant integer HASH = 8191
private timer array TimerKeyA
private timer array TimerKeyB
private timer array TimerKeyC
private trigger array TriggerKeyA
private trigger array TriggerKeyB
private trigger array TriggerKeyC
private dialog array DialogKeyA
private dialog array DialogKeyB
private dialog array DialogKeyC
private region array RegionKeyA
private region array RegionKeyB
private region array RegionKeyC
private integer array TimerValueA
private integer array TimerValueB
private integer array TimerValueC
private integer array TriggerValueA
private integer array TriggerValueB
private integer array TriggerValueC
private integer array DialogValueA
private integer array DialogValueB
private integer array DialogValueC
private integer array RegionValueA
private integer array RegionValueB
private integer array RegionValueC
private integer array TimerCollisionA
private integer array TimerCollisionB
private integer array TimerCollisionC
private integer array TriggerCollisionA
private integer array TriggerCollisionB
private integer array TriggerCollisionC
private integer array DialogCollisionA
private integer array DialogCollisionB
private integer array DialogCollisionC
private integer array RegionCollisionA
private integer array RegionCollisionB
private integer array RegionCollisionC
private integer TimerMaxCollisionA = 0
private integer TimerMaxCollisionB = 0
private integer TimerMaxCollisionC = 0
private integer TriggerMaxCollisionA = 0
private integer TriggerMaxCollisionB = 0
private integer TriggerMaxCollisionC = 0
private integer DialogMaxCollisionA = 0
private integer DialogMaxCollisionB = 0
private integer DialogMaxCollisionC = 0
private integer RegionMaxCollisionA = 0
private integer RegionMaxCollisionB = 0
private integer RegionMaxCollisionC = 0
private hashtable TimerHash
private hashtable TriggerHash
private hashtable DialogHash
private hashtable RegionHash
endglobals
//==============================================================================
// Collision check functions
//==============================================================================
//------------------------------------------------------------------------------
function GetTimerCollisionA takes nothing returns integer
return TimerMaxCollisionA
endfunction
//------------------------------------------------------------------------------
function GetTimerCollisionB takes nothing returns integer
return TimerMaxCollisionB
endfunction
//------------------------------------------------------------------------------
function GetTimerCollisionC takes nothing returns integer
return TimerMaxCollisionC
endfunction
//------------------------------------------------------------------------------
function GetTriggerCollisionA takes nothing returns integer
return TriggerMaxCollisionA
endfunction
//------------------------------------------------------------------------------
function GetTriggerCollisionB takes nothing returns integer
return TriggerMaxCollisionB
endfunction
//------------------------------------------------------------------------------
function GetTriggerCollisionC takes nothing returns integer
return TriggerMaxCollisionC
endfunction
//------------------------------------------------------------------------------
function GetDialogCollisionA takes nothing returns integer
return DialogMaxCollisionA
endfunction
//------------------------------------------------------------------------------
function GetDialogCollisionB takes nothing returns integer
return DialogMaxCollisionB
endfunction
//------------------------------------------------------------------------------
function GetDialogCollisionC takes nothing returns integer
return DialogMaxCollisionC
endfunction
//------------------------------------------------------------------------------
function GetRegionCollisionA takes nothing returns integer
return RegionMaxCollisionA
endfunction
//------------------------------------------------------------------------------
function GetRegionCollisionB takes nothing returns integer
return RegionMaxCollisionB
endfunction
//------------------------------------------------------------------------------
function GetRegionCollisionC takes nothing returns integer
return RegionMaxCollisionC
endfunction
//==============================================================================
// Set functions
//==============================================================================
//------------------------------------------------------------------------------
function SetTimerStructA takes timer key, integer value returns nothing
//! runtextmacro ABC_Set("A", "Timer", "timer")
endfunction
//------------------------------------------------------------------------------
function SetTimerStructB takes timer key, integer value returns nothing
//! runtextmacro ABC_Set("B", "Timer", "timer")
endfunction
//------------------------------------------------------------------------------
function SetTimerStructC takes timer key, integer value returns nothing
//! runtextmacro ABC_Set("C", "Timer", "timer")
endfunction
//------------------------------------------------------------------------------
function SetTriggerStructA takes trigger key, integer value returns nothing
//! runtextmacro ABC_Set("A", "Trigger", "trigger")
endfunction
//------------------------------------------------------------------------------
function SetTriggerStructB takes trigger key, integer value returns nothing
//! runtextmacro ABC_Set("B", "Trigger", "trigger")
endfunction
//------------------------------------------------------------------------------
function SetTriggerStructC takes trigger key, integer value returns nothing
//! runtextmacro ABC_Set("C", "Trigger", "trigger")
endfunction
//------------------------------------------------------------------------------
function SetDialogStructA takes dialog key, integer value returns nothing
//! runtextmacro ABC_Set("A", "Dialog", "dialog")
endfunction
//------------------------------------------------------------------------------
function SetDialogStructB takes dialog key, integer value returns nothing
//! runtextmacro ABC_Set("B", "Dialog", "dialog")
endfunction
//------------------------------------------------------------------------------
function SetDialogStructC takes dialog key, integer value returns nothing
//! runtextmacro ABC_Set("C", "Dialog", "dialog")
endfunction
//------------------------------------------------------------------------------
function SetRegionStructA takes region key, integer value returns nothing
//! runtextmacro ABC_Set("A", "Region", "region")
endfunction
//------------------------------------------------------------------------------
function SetRegionStructB takes region key, integer value returns nothing
//! runtextmacro ABC_Set("B", "Region", "region")
endfunction
//------------------------------------------------------------------------------
function SetRegionStructC takes region key, integer value returns nothing
//! runtextmacro ABC_Set("C", "Region", "region")
endfunction
//==============================================================================
// Get functions
//==============================================================================
//------------------------------------------------------------------------------
function GetTimerStructA takes timer key returns integer
//! runtextmacro ABC_Get("A", "Timer", "timer")
endfunction
//------------------------------------------------------------------------------
function GetTimerStructB takes timer key returns integer
//! runtextmacro ABC_Get("B", "Timer", "timer")
endfunction
//------------------------------------------------------------------------------
function GetTimerStructC takes timer key returns integer
//! runtextmacro ABC_Get("C", "Timer", "timer")
endfunction
//------------------------------------------------------------------------------
function GetTriggerStructA takes trigger key returns integer
//! runtextmacro ABC_Get("A", "Trigger", "trigger")
endfunction
//------------------------------------------------------------------------------
function GetTriggerStructB takes trigger key returns integer
//! runtextmacro ABC_Get("B", "Trigger", "trigger")
endfunction
//------------------------------------------------------------------------------
function GetTriggerStructC takes trigger key returns integer
//! runtextmacro ABC_Get("C", "Trigger", "trigger")
endfunction
//------------------------------------------------------------------------------
function GetDialogStructA takes dialog key returns integer
//! runtextmacro ABC_Get("A", "Dialog", "dialog")
endfunction
//------------------------------------------------------------------------------
function GetDialogStructB takes dialog key returns integer
//! runtextmacro ABC_Get("B", "Dialog", "dialog")
endfunction
//------------------------------------------------------------------------------
function GetDialogStructC takes dialog key returns integer
//! runtextmacro ABC_Get("C", "Dialog", "dialog")
endfunction
//------------------------------------------------------------------------------
function GetRegionStructA takes region key returns integer
//! runtextmacro ABC_Get("A", "Region", "region")
endfunction
//------------------------------------------------------------------------------
function GetRegionStructB takes region key returns integer
//! runtextmacro ABC_Get("B", "Region", "region")
endfunction
//------------------------------------------------------------------------------
function GetRegionStructC takes region key returns integer
//! runtextmacro ABC_Get("C", "Region", "region")
endfunction
//==============================================================================
// Clear functions
//==============================================================================
//------------------------------------------------------------------------------
function ClearTimerStructA takes timer key returns integer
//! runtextmacro ABC_Clear("A", "Timer", "timer")
endfunction
//------------------------------------------------------------------------------
function ClearTimerStructB takes timer key returns integer
//! runtextmacro ABC_Clear("B", "Timer", "timer")
endfunction
//------------------------------------------------------------------------------
function ClearTimerStructC takes timer key returns integer
//! runtextmacro ABC_Clear("C", "Timer", "timer")
endfunction
//------------------------------------------------------------------------------
function ClearTriggerStructA takes trigger key returns integer
//! runtextmacro ABC_Clear("A", "Trigger", "trigger")
endfunction
//------------------------------------------------------------------------------
function ClearTriggerStructB takes trigger key returns integer
//! runtextmacro ABC_Clear("B", "Trigger", "trigger")
endfunction
//------------------------------------------------------------------------------
function ClearTriggerStructC takes trigger key returns integer
//! runtextmacro ABC_Clear("C", "Trigger", "trigger")
endfunction
//------------------------------------------------------------------------------
function ClearDialogStructA takes dialog key returns integer
//! runtextmacro ABC_Clear("A", "Dialog", "dialog")
endfunction
//------------------------------------------------------------------------------
function ClearDialogStructB takes dialog key returns integer
//! runtextmacro ABC_Clear("B", "Dialog", "dialog")
endfunction
//------------------------------------------------------------------------------
function ClearDialogStructC takes dialog key returns integer
//! runtextmacro ABC_Clear("C", "Dialog", "dialog")
endfunction
//------------------------------------------------------------------------------
function ClearRegionStructA takes region key returns integer
//! runtextmacro ABC_Clear("A", "Region", "region")
endfunction
//------------------------------------------------------------------------------
function ClearRegionStructB takes region key returns integer
//! runtextmacro ABC_Clear("B", "Region", "region")
endfunction
//------------------------------------------------------------------------------
function ClearRegionStructC takes region key returns integer
//! runtextmacro ABC_Clear("C", "Region", "region")
endfunction
//==============================================================================
// Initialization
//==============================================================================
private function Init takes nothing returns nothing
set TimerKeyA[HASH-1] = null
set TimerKeyB[HASH-1] = null
set TimerKeyC[HASH-1] = null
set TriggerKeyA[HASH-1] = null
set TriggerKeyB[HASH-1] = null
set TriggerKeyC[HASH-1] = null
set DialogKeyA[HASH-1] = null
set DialogKeyB[HASH-1] = null
set DialogKeyC[HASH-1] = null
set RegionKeyA[HASH-1] = null
set RegionKeyB[HASH-1] = null
set RegionKeyC[HASH-1] = null
set TimerValueA[HASH-1] = 0
set TimerValueB[HASH-1] = 0
set TimerValueC[HASH-1] = 0
set TriggerValueA[HASH-1] = 0
set TriggerValueB[HASH-1] = 0
set TriggerValueC[HASH-1] = 0
set DialogValueA[HASH-1] = 0
set DialogValueB[HASH-1] = 0
set DialogValueC[HASH-1] = 0
set RegionValueA[HASH-1] = 0
set RegionValueB[HASH-1] = 0
set RegionValueC[HASH-1] = 0
set TimerCollisionA[HASH-1] = 0
set TimerCollisionB[HASH-1] = 0
set TimerCollisionC[HASH-1] = 0
set TriggerCollisionA[HASH-1] = 0
set TriggerCollisionB[HASH-1] = 0
set TriggerCollisionC[HASH-1] = 0
set DialogCollisionA[HASH-1] = 0
set DialogCollisionB[HASH-1] = 0
set DialogCollisionC[HASH-1] = 0
set RegionCollisionA[HASH-1] = 0
set RegionCollisionB[HASH-1] = 0
set RegionCollisionC[HASH-1] = 0
set TimerHash = InitHashtable()
set TriggerHash = InitHashtable()
set DialogHash = InitHashtable()
set RegionHash = InitHashtable()
endfunction
endlibrary
//==============================================================================
// END OF ABC STRUCT ATTACHMENT SYSTEM
//==============================================================================
//TESH.scrollpos=19
//TESH.alwaysfold=0
library CSSafety
//******************************************************************************************
//*
//* CSSafety 14.5
//* ________
//*
//* Utilities to make things safer. Currently this simply includes a timer recycling
//* Stack. Once you replace CreateTimer with NewTimer and DestroyTimer with ReleaseTimer
//* you no longer have to care about setting timers to null nor about timer related issues
//* with the handle index stack.
//*
//******************************************************************************************
//==========================================================================================
globals
private timer array T
private integer N = 0
endglobals
//==========================================================================================
function NewTimer takes nothing returns timer
if (N==0) then
return CreateTimer()
endif
set N=N-1
return T[N]
endfunction
//==========================================================================================
function ReleaseTimer takes timer t returns nothing
call PauseTimer(t)
if (N==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
set T[N]=t
set N=N+1
endif
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library DestThree initializer Init
globals
private rect Rect1 = null
private unit Tree_dummy = null
private boolexpr Tree_filt = null
endglobals
function Destroy_trees takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
function Check_trees takes nothing returns boolean
local destructable dest = GetFilterDestructable()
local boolean result = false
if ( GetWidgetLife(dest) > 0.405 ) then
call PauseUnit(Tree_dummy, false)
set result = IssueTargetOrder(Tree_dummy, "harvest", dest)
call PauseUnit(Tree_dummy, true)
endif
set dest = null
return result
endfunction
function PS_KillTrees takes real x, real y, real radius returns nothing
call SetRect(Rect1,x - radius,y - radius,x + radius,y + radius)
call EnumDestructablesInRect(Rect1,Tree_filt,function Destroy_trees)
endfunction
private function Init takes nothing returns nothing
set Rect1 = Rect(0.00,0.00,1.00,1.00)
set Tree_filt = Filter(function Check_trees)
//****************************************//
set Tree_dummy = CreateUnit(Player(15),'e000',0.00,0.00,0.00)
call UnitAddAbility(Tree_dummy,'Ahrl')
call UnitAddAbility(Tree_dummy,'Aloc')
call PauseUnit(Tree_dummy, true)
call ShowUnit(Tree_dummy, false)
endfunction
endlibrary
//TESH.scrollpos=152
//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.
//* This implementation is particularly useful because the boolexpr you pass to
//* the function will not be evaluated unless the unit is in collisional range
//* of the origin.
//*
//* 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
//If you set this constant to false, the BOOLEXPR_TRUE and BOOLEXPR_FALSE
//boolean expressions will not be initialized in your map. Since they are
//no longer important, this is not a problem, but they are defined by
//default to maintain backwards compatibility.
private constant boolean USE_TRUEFALSE_BOOLEXPRS = true
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 storage purposes
private hashtable ht = InitHashtable()
//* Temporary references used internally
private boolean Flag = false
private group Temp = null
private group Area = CreateGroup()
//* 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.
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(Temp)
set Flag = false
endif
call GroupAddUnit(Temp, GetEnumUnit())
endfunction
function GroupRefresh takes group g returns nothing
set Flag = true
set Temp = g
call ForGroup(Temp, 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
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
local integer id = GetHandleId(g)
if g == null then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Null groups cannot be released")
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 HookDestroyBoolExpr takes boolexpr b returns nothing
local integer bid = GetHandleId(b)
if HaveSavedHandle(ht, 1, bid) then
//Clear the saved boolexpr
call DestroyBoolExpr(LoadBooleanExprHandle(ht, 1, bid))
call RemoveSavedHandle(ht, 1, 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
private function RangeFilter takes nothing returns boolean
return IsUnitInRangeXY(GetFilterUnit(), X, Y, R)
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 RangeFilter)
else
//Check for a saved boolexpr
set bid = GetHandleId(filter)
if HaveSavedHandle(ht, 1, bid) then
//Set the filter to use to the saved one
set filter = LoadBooleanExprHandle(ht, 1, bid)
else
//Create a new And() boolexpr for this filter
set filter = And(Condition(function RangeFilter), filter)
call SaveBooleanExprHandle(ht, 1, 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 unit u = null
call GroupClear(whichGroup)
call GroupEnumUnitsInRange(Area, x, y, GetRadius(radius), null)
loop
set u = FirstOfGroup(Area)
exitwhen u == null
call GroupRemoveUnit(Area, u)
if IsUnitInRangeXY(u, x, y, radius) then
call GroupAddUnit(whichGroup, u)
endif
endloop
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
static if USE_TRUEFALSE_BOOLEXPRS then
set BOOLEXPR_TRUE = Condition(function True)
set BOOLEXPR_FALSE = Condition(function False)
endif
endfunction
endlibrary
//TESH.scrollpos=30
//TESH.alwaysfold=0
//============================================================================
// SpellEffectEvent
// - Version 1.1.0.0
//
// API
// ---
// RegisterSpellEffectEvent(integer abil, code onCast)
//
// Requires
// --------
// RegisterPlayerUnitEvent: hiveworkshop.com/forums/showthread.php?t=203338
//
// Optional
// --------
// Table: hiveworkshop.com/forums/showthread.php?t=188084
//
library SpellEffectEvent requires RegisterPlayerUnitEvent, optional Table
//============================================================================
private module M
static if LIBRARY_Table then
static Table tb
else
static hashtable ht = InitHashtable()
endif
static method onCast takes nothing returns nothing
static if LIBRARY_Table then
call TriggerEvaluate(.tb.trigger[GetSpellAbilityId()])
else
call TriggerEvaluate(LoadTriggerHandle(.ht, 0, GetSpellAbilityId()))
endif
endmethod
private static method onInit takes nothing returns nothing
static if LIBRARY_Table then
set .tb = Table.create()
endif
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, function thistype.onCast)
endmethod
endmodule
//============================================================================
private struct S extends array
implement M
endstruct
//============================================================================
function RegisterSpellEffectEvent takes integer abil, code onCast returns nothing
static if LIBRARY_Table then
if not S.tb.handle.has(abil) then
set S.tb.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(S.tb.trigger[abil], Filter(onCast))
else
if not HaveSavedHandle(S.ht, 0, abil) then
call SaveTriggerHandle(S.ht, 0, abil, CreateTrigger())
endif
call TriggerAddCondition(LoadTriggerHandle(S.ht, 0, abil), Filter(onCast))
endif
endfunction
endlibrary
//TESH.scrollpos=39
//TESH.alwaysfold=0
/**************************************************************
*
* RegisterPlayerUnitEvent
* v5.1.0.1
* By Magtheridon96
*
* I would like to give a special thanks to Bribe, azlier
* and BBQ for improving this library. For modularity, it only
* supports player unit events.
*
* Functions passed to RegisterPlayerUnitEvent must either
* return a boolean (false) or nothing. (Which is a Pro)
*
* Warning:
* --------
*
* - Don't use TriggerSleepAction inside registered code.
* - Don't destroy a trigger unless you really know what you're doing.
*
* API:
* ----
*
* - function RegisterPlayerUnitEvent takes playerunitevent whichEvent, code whichFunction returns nothing
* - Registers code that will execute when an event fires.
* - function RegisterPlayerUnitEventForPlayer takes playerunitevent whichEvent, code whichFunction, player whichPlayer returns nothing
* - Registers code that will execute when an event fires for a certain player.
* - function GetPlayerUnitEventTrigger takes playerunitevent whichEvent returns trigger
* - Returns the trigger corresponding to ALL functions of a playerunitevent.
*
**************************************************************/
library RegisterPlayerUnitEvent // Special Thanks to Bribe and azlier
globals
private trigger array t
endglobals
function RegisterPlayerUnitEvent takes playerunitevent p, code c returns nothing
local integer i = GetHandleId(p)
local integer k = 15
if t[i] == null then
set t[i] = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(t[i], Player(k), p, null)
exitwhen k == 0
set k = k - 1
endloop
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function RegisterPlayerUnitEventForPlayer takes playerunitevent p, code c, player pl returns nothing
local integer i = 16 * GetHandleId(p) + GetPlayerId(pl)
if t[i] == null then
set t[i] = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t[i], pl, p, null)
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function GetPlayerUnitEventTrigger takes playerunitevent p returns trigger
return t[GetHandleId(p)]
endfunction
endlibrary
//TESH.scrollpos=128
//TESH.alwaysfold=0
//******************************************************************//
// дата создания системы 10.08.2016, 13:55 by Lobster_1234 //
//******************************************************************//
library KB initializer Init
globals
private constant integer DUMMY_ID = 'u000'
private constant real TimerInterval = 0.03125
private constant boolean KillThrees = true
private constant real RadiusKillThrees = 128.00
endglobals
private function Parabola takes real h, real d, real x returns real
return (4 * h / d) * (d - x) * (x / d)
endfunction
private struct TS
unit target
real height
real speed
real angle
real cur
real distance
real spkbs
real x
real y
effect sfx
string fxpath
boolean fly
boolean kbs
method discheck takes nothing returns nothing
if ( .kbs ) then
set .distance = .distance - .spkbs
set .x = .x+.distance*Cos(.angle*bj_DEGTORAD)
set .y = .y+.distance*Sin(.angle*bj_DEGTORAD)
else
set .distance = .distance - .speed
set .x = .x+.speed*Cos(.angle*bj_DEGTORAD)
set .y = .y+.speed*Sin(.angle*bj_DEGTORAD)
endif
endmethod
endstruct
private keyword Data
globals
private rect Rect1 = null
private boolexpr Tree_filt = null
private unit Tree_dummy = null
private timer time
private TS array indx
private integer counter = 0
endglobals
private function Looper takes nothing returns nothing
local TS d
local integer i = 0
loop
exitwhen i >= counter
set d = indx[i]
set d.x = GetUnitX(d.target)
set d.y = GetUnitY(d.target)
call d.discheck()
if d.distance <= 5.00 then
call SetUnitFlyHeight( d.target, GetUnitDefaultFlyHeight(d.target), 0.00 )
set d.target = null
set d.sfx = null
call d.destroy()
set counter = counter - 1
set indx[i] = indx[counter]
set i = i - 1
return
else
if IsTerrainPathable(d.x, d.y,PATHING_TYPE_WALKABILITY) then
set d.distance = 0.
else
call SetUnitX(d.target,d.x)
call SetUnitY(d.target,d.y)
call PS_KillTrees(d.x,d.y,125.)
if d.fly then
call SetUnitFlyHeight(d.target,Parabola(d.height,d.cur,d.distance),0.)
endif
if ( d.fxpath ) != null then
call DestroyEffect(AddSpecialEffect(d.fxpath,GetUnitX(d.target),GetUnitY(d.target)))
endif
endif
endif
set i = i + 1
endloop
if counter == 0 then
call PauseTimer(time)
endif
endfunction
public function KB_Set takes unit target, real height, real distance,real speed, real angle, string fxpath, boolean fly, boolean kbs, real spkbs returns nothing
local TS d
set d = TS.create()
set d.target = target
set d.height = height
set d.speed = speed
set d.distance = distance - 5.
set d.cur = distance - 5.
set d.angle = angle
set d.fxpath = fxpath
set d.fly = fly
set d.kbs = kbs
set d.spkbs = spkbs
set d.kbs = kbs
if counter == 0 then
call TimerStart(time,TimerInterval,true,function Looper)
endif
set indx[counter] = d
set counter = counter + 1
endfunction
function KBfly takes unit target, real height ,real distance,real speed, real angle returns nothing
if( target == null or IsUnitType( target, UNIT_TYPE_DEAD ) or distance <= 0. )then
return
else
call UnitAddAbility(target, 1098015094)
call UnitRemoveAbility(target, 1098015094)
call KB_Set(target,height,distance,speed,angle,null,true,false,0.)
endif
endfunction
function KB takes unit target, real distance,real speed, real angle, string fxpath returns nothing
if( target == null or IsUnitType( target, UNIT_TYPE_DEAD ) or distance <= 0. )then
return
else
call KB_Set(target,0.,distance,speed,angle,fxpath,false,false,0.)
endif
endfunction
function KBs takes unit target, real distance, real angle, string fxpath, real spkbs returns nothing
if( target == null or IsUnitType( target, UNIT_TYPE_DEAD ) or distance <= 0. )then
return
else
call KB_Set(target,0.,distance,0.,angle,fxpath,false,true,spkbs)
endif
endfunction
private function Init takes nothing returns nothing
set time = CreateTimer()
endfunction
endlibrary
//TESH.scrollpos=113
//TESH.alwaysfold=0
scope Grenadle initializer Init
globals
private constant integer AbilityID = 'A002'
private constant integer DummyID = 'hfoo'
endglobals
native UnitAlive takes unit id returns boolean
private function AngleBetweenPointsXY takes real x1, real y1, real x2, real y2 returns real
return bj_RADTODEG * Atan2(x1 - y1, x2 - y2)
endfunction
private function UnitFilter takes unit u, player owner returns boolean
return IsUnitEnemy(u, owner) /*
*/ and UnitAlive(u) /*
*/ and not IsUnitType(u, UNIT_TYPE_STRUCTURE)
endfunction
private function DistanceXY2D takes real X, real Y, real X2, real Y2 returns real
return SquareRoot((X2 - X) * (X2 - X) + (Y2 - Y) * (Y2 - Y))
endfunction
private function Parabola takes real h, real d, real x returns real
return (4 * h / d) * (d - x) * (x / d)
endfunction
private function StunTarget takes unit c,unit t,real sec returns nothing
local unit d = CreateUnit(GetOwningPlayer(c),'h000',-70.,-2240,0.)
local integer i = R2I(sec / .05)
call UnitApplyTimedLife(d,'BLTF',1.)
call UnitAddAbility(d,'stun')
call SetUnitAbilityLevel(d,'stun',i)
call IssueTargetOrder(d,"thunderbolt",t)
set c = null
set d = null
endfunction
private struct data
unit c
unit dummy
real x
real y
real angle
real speed
real height
real cur
real distance
integer count
player owner
effect e
timer tick
method Onmove takes nothing returns nothing
call SetUnitX(.dummy,.x)
call SetUnitY(.dummy,.y)
call SetUnitFlyHeight(.dummy,Parabola(.height,.cur,.distance),0.)
endmethod
method onDestroy takes nothing returns nothing
local unit u
local real angle
set bj_lastCreatedTerrainDeformation = TerrainDeformCrater(.x,.y, 275., 80., R2I(0.15 * 1000), false)
call DestroyEffect(AddSpecialEffect("war3mapImported\\NewDirtEXNofire.mdx",.x,.y))
call DestroyEffect(.e)
call RemoveUnit(.dummy)
call GroupUnitsInArea(ENUM_GROUP,.x,.y,250)
loop
set u = FirstOfGroup(ENUM_GROUP)
exitwhen u == null
call GroupRemoveUnit(ENUM_GROUP,u)
if UnitFilter(u,.owner) then
set angle = AngleBetweenPointsXY( GetUnitY(u),GetUnitY(.dummy),GetUnitX(u),GetUnitX(.dummy) )
call UnitDamageTarget(.c,u,50.,false,false,ATTACK_TYPE_CHAOS,null,null)
call StunTarget(.c,u,1.25+0.25*GetUnitAbilityLevel(.c,AbilityID))
call KBs(u,35.,angle,null,1.50)
endif
endloop
set .c = null
set .e = null
set .dummy = null
set .owner = null
call ClearTimerStructA(.tick)
call ReleaseTimer(.tick)
endmethod
endstruct
private function Act takes nothing returns nothing
local data d = GetTimerStructA(GetExpiredTimer())
set d.distance = d.distance - d.speed
set d.x = d.x + d.speed*Cos(d.angle*bj_DEGTORAD)
set d.y = d.y + d.speed*Sin(d.angle*bj_DEGTORAD)
if d.distance <=0. then
if d.count <= 0. then
call d.onDestroy()
else
set d.distance = GetRandomReal(10.,20.)+d.cur/2.50
set d.cur = d.distance
set d.height = d.distance/4.
set d.speed = d.distance/25
endif
set d.count = d.count - 1
else
if d.cur > 500. and d.height > 250. then
call d.Onmove()
else
if IsTerrainPathable(d.x-35., d.y-35., PATHING_TYPE_WALKABILITY) then
set d.angle = d.angle - GetRandomReal(90,180)
else
call d.Onmove()
endif
endif
endif
endfunction
private function Action takes nothing returns nothing
local data d = data.create()
local real ty
local real tx
set d.c = GetTriggerUnit()
set d.x = GetUnitX(d.c)
set d.y = GetUnitY(d.c)
set tx = GetSpellTargetX()
set ty = GetSpellTargetY()
set d.owner = GetOwningPlayer(d.c)
if DistanceXY2D(d.x,d.y,tx,ty) <= 300. then
set d.count = GetRandomInt(1,2)
else
set d.count = GetRandomInt(2,3)
endif
set d.angle = AngleBetweenPointsXY(ty,d.y,tx,d.x)
set d.height = DistanceXY2D(d.x,d.y,tx,ty)/2.50
set d.speed = DistanceXY2D(d.x,d.y,tx,ty)/35.
set d.cur = DistanceXY2D(d.x,d.y,tx,ty)
set d.distance = DistanceXY2D(d.x,d.y,tx,ty)
set d.dummy = CreateUnit(d.owner,DummyID,d.x,d.y,d.angle)
set d.e = AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\CorrosiveBreath\\CorrosiveBreathMissile.mdl",d.dummy,"chest")
set d.x = GetUnitX(d.dummy)
set d.y = GetUnitY(d.dummy)
set d.tick = NewTimer()
call SetTimerStructA(d.tick,d)
call TimerStart(d.tick,0.031250000,true,function Act)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
//// это наш прелоадер чтобы убрать первые лаги в игре
local unit d = CreateUnit(Player(15),'h000',0.,0.,0.)
call UnitAddAbility(d,'stun')
call UnitRemoveAbility(d,'stun')
call RemoveUnit(d)
//===========================================================================
call RegisterSpellEffectEvent(AbilityID,function Action)
set d = null
endfunction
endscope