//TESH.scrollpos=64
//TESH.alwaysfold=0
// this returns the correct player color code
function GetPlayerStringColor takes player p returns string
local string array s
local integer i = GetPlayerId(p)
set s[0] = "|c00FF0000"
set s[1] = "|c000000FF"
set s[2] = "|c001CE6B9"
set s[3] = "|c00540081"
set s[4] = "|c00FFFC01"
set s[5] = "|c00FEBA0E"
set s[6] = "|c0020C000"
set s[7] = "|c00E55BB0"
set s[8] = "|c00959697"
set s[9] = "|c007EBFF1"
set s[10] = "|c00106246"
set s[11] = "|c004E2A04"
set s[12] = "|c00000000"
set p = null
if i > 11 or i < 0 then
return s[12]
endif
return s[i]
endfunction
// this returns the language of a player (you can add more :P)
function GetPlayerLanguage takes player p returns string
local unit u = CreateUnit(Player(15),'hfoo',0,0,0)
local string s
local string ss = "English"
if GetLocalPlayer() == p then
set s = GetUnitName(u)
endif
call RemoveUnit(u)
set u = null
set p = null
if s =="Soldat" then
set ss= "German"
//elseif s == "???" then
//set ss="???"
//........
endif
return ss
endfunction
// does not work! (as i know)
function FillStringIntoString takes string BasicText, string FillInText, string Symbol returns string
local integer i = 0
local string s
loop
exitwhen i >= StringLength(BasicText)
if SubString (BasicText,i-1,i) == Symbol then
set s = s + FillInText
else
set s = s + SubString (BasicText,i-1,i)
endif
set i = i+1
endloop
return s
endfunction
// creates a "shadow" on the ground.
// can be useful for missle systems
function CreateShadow takes real x, real y, real size returns image
local image img
if size == 0. then
return null
endif
set img = CreateImage("ReplaceableTextures\\Shadows\\ShadowFlyer.blp", size, size, size, x-size*.5, y-size*.5, 0, 0, 0, 0, 2)
call SetImageColor(img,255,255,255,190)
call SetImageRenderAlways( img, true )
call ShowImage(img, true)
return img
endfunction
// lock the camera to a unit with an offset
function SetCameraTargetControllerWithPloarOffset takes player p, unit u, real offset, real angle returns nothing
local real x
local real y
set x = Cos(angle * bj_DEGTORAD) * offset
set y = Sin(angle * bj_DEGTORAD) * offset
if GetLocalPlayer()==p then
call SetCameraTargetController(u,x,y,false)
endif
endfunction
// damages all units i a circle
function DamageUnitsInRange takes real x, real y, real z, real damage, unit damagedealer, real range returns nothing
local group g = CreateGroup()
local unit u= null
local real array r
call GroupEnumUnitsInRange(g,x, y, range, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetOwningPlayer(u) != GetOwningPlayer(damagedealer) then
set r[0] = x - GetUnitX(u)
set r[1] = y - GetUnitY(u)
set r[2] = SquareRoot(r[0] * r[0] + r[1] * r[1])
set r[3] = GetUnitFlyHeight(u)-z
set r[4] = SquareRoot(r[2] * r[2] + r[3] * r[3])
if r[4] <= range then
call UnitDamageTarget(damagedealer, u, damage, true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endif
endif
call GroupRemoveUnit(g,u)
set u = null
endloop
call DestroyGroup(g)
set damagedealer = null
set g = null
set u = null
endfunction
Name | Type | is_array | initial_value |
TempString | string | Yes |
//TESH.scrollpos=9
//TESH.alwaysfold=0
//=================================================================================
// a very short library to store integers to units (better version of UnitUserData)
// USE SetCustomValue(unit, slot, value) to store an integer
// use GetCustomValue(unit, slot) to get the integer
// you also can clear it with ClearCustomValue(unit) or
// ClearCustomValueSimple(unit , slot) to clear the whole or one slot.
//=================================================================================
library CustomValue
globals
private hashtable CustomValueHash = InitHashtable()
endglobals
function SetCustomValue takes unit u, integer slot, integer value returns nothing
call SaveInteger(CustomValueHash, GetHandleId(u), slot, value)
endfunction
function GetCustomValue takes unit u, integer slot returns integer
return LoadInteger(CustomValueHash, GetHandleId(u), slot)
return 0
endfunction
function ClearCustomValue takes unit u returns nothing
call FlushChildHashtable(CustomValueHash, GetHandleId(u))
endfunction
function ClearCustomValueSimple takes unit u, integer slot returns nothing
call SaveInteger(CustomValueHash, GetHandleId(u), slot, 0)
endfunction
endlibrary
//TESH.scrollpos=36
//TESH.alwaysfold=0
library CreepRevive initializer CreepInit
globals
private constant integer EnemyPlayerId = GetPlayerId(Player(PLAYER_NEUTRAL_AGGRESSIVE)) //the enemy player id
private constant string ReviveEffect = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdl" //the effect at respawn
private constant real TimeTillRevive = 30.00 //time befor the units will respawn
// ---------------- END OF SETTINGS ----------------
// ---------- do not change anything below----------
private filterfunc filter
private trigger CreepReviveTrigger = CreateTrigger()
private trigger AddUnitToGroup = CreateTrigger()
private hashtable ReviveHash = InitHashtable()
private group EnemyUnits = CreateGroup()
endglobals
private function TrueFilter takes nothing returns boolean
return true //just a simple function that returns true
endfunction
private function CreepRevive takes nothing returns nothing
local unit u3 = GetTriggerUnit() //the dieing unit
local unit u4
if GetOwningPlayer(u3) == Player(EnemyPlayerId) then //cheks if the unit belongs to the enemy
call PolledWait(TimeTillRevive) //waits
// may i will replace it with timer uititles (or something like that :D)
set u4 = CreateUnit(Player(EnemyPlayerId),LoadInteger(ReviveHash, GetHandleId(u3), 0),LoadReal(ReviveHash, GetHandleId(u3), 1),LoadReal(ReviveHash, GetHandleId(u3), 2),LoadReal(ReviveHash, GetHandleId(u3), 3))
call GroupAddUnit(EnemyUnits, u4)
//create the new unit and add it to the group
call DestroyEffect(AddSpecialEffect(ReviveEffect,LoadReal(ReviveHash, GetHandleId(u3), 1),LoadReal(ReviveHash, GetHandleId(u3), 2)))
//create the sfx
//------------------------------------------------------------------------------
call SaveInteger(ReviveHash,GetHandleId(u4), 0, LoadInteger(ReviveHash, GetHandleId(u3), 0))
call SaveReal(ReviveHash,GetHandleId(u4), 1, LoadReal(ReviveHash, GetHandleId(u3), 1))
call SaveReal(ReviveHash,GetHandleId(u4), 2, LoadReal(ReviveHash, GetHandleId(u3), 2))
call SaveReal(ReviveHash,GetHandleId(u4), 3, LoadReal(ReviveHash, GetHandleId(u3), 3))
call FlushChildHashtable(ReviveHash, GetHandleId(u3))
//store unitId, x, y and facting of the unit in the hashtable and clear the all childs of the old unit
endif
set u3 = null
set u4 = null
//nulling
endfunction
private function NewUnitEnter takes nothing returns nothing
local unit u = GetTriggerUnit()
if GetOwningPlayer(u)==Player(EnemyPlayerId) and IsUnitInGroup( u, EnemyUnits) == false then
call GroupAddUnit(EnemyUnits, u)
call SaveInteger(ReviveHash,GetHandleId(u), 0, GetUnitTypeId(u))
call SaveReal(ReviveHash,GetHandleId(u), 1, GetUnitX(u))
call SaveReal(ReviveHash,GetHandleId(u), 2, GetUnitY(u))
call SaveReal(ReviveHash,GetHandleId(u), 3, GetUnitFacing(u))
endif
endfunction
private function CreepInit takes nothing returns nothing
local unit u3
local group group1 = CreateGroup()
set filter = Filter(function TrueFilter)
call GroupEnumUnitsOfPlayer(group1, Player(EnemyPlayerId),filter)
loop
set u3 = FirstOfGroup(group1)
call GroupAddUnit(EnemyUnits, u3)
exitwhen u3 == null
call SaveInteger(ReviveHash,GetHandleId(u3), 0, GetUnitTypeId(u3))
call SaveReal(ReviveHash,GetHandleId(u3), 1, GetUnitX(u3))
call SaveReal(ReviveHash,GetHandleId(u3), 2, GetUnitY(u3))
call SaveReal(ReviveHash,GetHandleId(u3), 3, GetUnitFacing(u3))
call GroupRemoveUnit(group1,u3)
set u3 = null
endloop
call TriggerRegisterAnyUnitEventBJ(CreepReviveTrigger, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction(CreepReviveTrigger, function CreepRevive)
call TriggerRegisterEnterRectSimple(AddUnitToGroup, GetPlayableMapRect() )
call TriggerAddAction(AddUnitToGroup, function NewUnitEnter)
set AddUnitToGroup = null
set CreepReviveTrigger = null
call DestroyGroup(group1)
set group1 = null
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
// this is not so usefull but i need it and decited to add it here
// can be may usefull for physik systems or arrow key moving
library GroudFriction initializer FrictionInit
globals
private hashtable FrictionHash = InitHashtable()
endglobals
function SetTitleFriction takes integer TitleId, real friction returns nothing
call SaveReal(FrictionHash,TitleId,0,friction)
endfunction
function GetTitleFriction takes integer TitleId returns real
return LoadReal(FrictionHash,TitleId,0)
return 1.
endfunction
private function FrictionInit takes nothing returns nothing
call SetTitleFriction('Ldrt',.96)
call SetTitleFriction('Ldro',.98)
call SetTitleFriction('Lgrd',.99)
endfunction
endlibrary