Name | Type | is_array | initial_value |
Attack_Pet | unit | No | |
Casting_Unit | unit | Yes | |
EasyItem__ERRORSOUND | string | No | |
EasyItem__SPLIT | boolean | No | |
EasyItem__SPLITDROP | boolean | No | |
EasyItem__SPLITSTACK | boolean | No | |
EasyItem__SPLITSTACKDELAY | real | No | |
EasyItem__USEITEMLEVEL | boolean | No | |
EasyItem_integer | integervar | Yes | |
EasyItem_item | item | No | |
EasyItem_items | item | Yes | |
EasyItem_point | location | Yes | |
EasyItem_sound | sound | No | |
EasyItem_string | string | Yes | |
EasyItem_timer | timer | No | |
EasyItem_unit | unit | No | |
EasyItem_units | unit | Yes | |
Genjutsu_Ability | abilcode | No | |
Genjutsu_AbilityLevel | integer | No | |
Genjutsu_Attacker | unit | No | |
Genjutsu_AttackerPosition | location | No | |
Genjutsu_Caster | unit | No | |
Genjutsu_CasterPosition | location | No | |
Genjutsu_Casters | unit | No | |
Genjutsu_CastersPosition | location | No | |
Genjutsu_Chance | integer | No | |
Genjutsu_CreateCurrIntervival | real | No | |
Genjutsu_CreateDummy | unit | No | |
Genjutsu_CreateDummyExpiration | real | No | |
Genjutsu_CreateIntervival | real | No | |
Genjutsu_CreateTemperency | real | No | |
Genjutsu_CrowAngle | real | No | |
Genjutsu_CrowDummy | unit | No | |
Genjutsu_CrowDummyPosition | location | No | |
Genjutsu_CrowExpiration | real | No | |
Genjutsu_CrowMoveAngle | real | No | |
Genjutsu_CrowMoveDistance | real | No | |
Genjutsu_CrowMovePoint | location | No | |
Genjutsu_Crows | boolean | No | |
Genjutsu_Damage | integer | No | |
Genjutsu_Damaged | unit | No | |
Genjutsu_DamageGroup | group | No | |
Genjutsu_FinalPoint | location | No | |
Genjutsu_Group | group | No | |
Genjutsu_MoveAngle | real | No | |
Genjutsu_MoveDamage | integer | No | |
Genjutsu_MoveDamageRange | real | No | |
Genjutsu_MoveDistance | real | No | |
Genjutsu_MovePoint | location | No | |
Genjutsu_MoveSpeed | real | No | |
Genjutsu_Owner | player | No | |
Genjutsu_Table | hashtable | No | |
GroupVar12 | group | No | |
i | integer | No | |
KB_Angle | real | Yes | |
KB_Casters | unit | Yes | |
KB_CountBuffs | integer | No | |
KB_DestroyTrees | boolean | Yes | |
KB_Effects_1 | string | Yes | |
KB_Effects_2 | string | Yes | |
KB_GeneralIntegers | integervar | Yes | |
KB_KnockbackedUnits | group | No | |
KB_Levels | integer | Yes | |
KB_MaxDistance | real | Yes | |
KB_ReachedDistance | real | Yes | |
KB_ReducedReal | real | No | |
KB_ReduceSpeedReal | real | Yes | |
KB_SpecificSpeed | real | Yes | |
KB_StartPositions | location | Yes | |
KB_TempPoint | location | Yes | |
KB_TempReal | real | No | |
KB_TotalKnockUnits | integer | No | |
KB_Units | unit | Yes | |
KBA_Caster | unit | No | |
KBA_DestroyTrees | boolean | No | |
KBA_DistancePerLevel | real | No | |
KBA_Level | integer | No | |
KBA_SpecialEffects | string | Yes | |
KBA_Speed | real | No | |
KBA_StartingPosition | location | No | |
KBA_TargetUnit | unit | No | |
left | boolean | No | |
LS_Dummy | unit | No | |
LS_GeneralInteger | integervar | No | |
LS_Groups | group | Yes | |
LS_TempPoint | location | Yes | |
No | button | No | |
Pet_Follow | unit | No | |
Point | location | Yes | |
Revive | unit | No | |
ReviveDialog | dialog | No | |
right | boolean | No | |
Sfx | effect | Yes | |
specialeffect | effect | Yes | |
SpecialEffect2 | effect | Yes | |
TargetUnit | unit | Yes | |
TempLoc41 | location | No | |
TempLoc42 | location | No | |
TempLoc43 | location | No | |
TempLoc44 | location | No | |
TempLoc48 | location | No | |
Timer | timer | No | |
TimerRevive | timer | No | |
u | unit | Yes | |
Unit | unit | Yes | |
UnitVarAttacked | unit | No | |
UnitVarAttacker | unit | No | |
UnitVarCaster11 | unit | No | |
UnitVarCaster9 | unit | No | |
UnitVarTarget7 | unit | No | |
Yes | button | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
library AdvancedItemHandlingSystem initializer Init
// The_Witcher's
//
// <<advanced item system>>
//
// This system improves the Warcraft III item engine
//
// If a unit gets an item which it already has it stacks (only if item has charges!)
// In addition this works even if the inventory is full!!!
//
// If you double-right-click an item with charges in your inventory it splits up
// and if you move a item onto an equal item and they are stackable they stack
//
// No Setup Part! Don't touch anything fully automatic :)
private struct data
unit u
item ite
integer index
real x
real y
endstruct
globals
private data array DATAS
private integer total = 0
private hashtable h = InitHashtable()
private timer tim = CreateTimer()
private trigger trg = CreateTrigger( )
endglobals
private function IsInventoryFull takes unit u returns boolean
local integer i = 0
loop
exitwhen i == 6
if UnitItemInSlot(u, i) == null then
return false
endif
set i = i + 1
endloop
return true
endfunction
private function ItemWalk takes nothing returns boolean
local integer i = 0
local unit u = GetTriggerUnit()
local item ite = GetOrderTargetItem()
local data dat
if IsInventoryFull(u) and GetItemCharges(ite)!= 0 then
loop
exitwhen i > 5
if GetItemTypeId(ite) == GetItemTypeId(UnitItemInSlot(u, i)) and UnitHasItem(u,ite)== false then
call IssuePointOrder( u, "move", GetItemX(ite),GetItemY(ite) )
if LoadInteger(h,GetHandleId(u),0) == 0 then
set dat = data.create()
set DATAS[total] = dat
set dat.index = total
set total = total + 1
set dat.u = u
set dat.ite = ite
set dat.x = GetItemX(ite)
set dat.y = GetItemY(ite)
call SaveInteger(h,GetHandleId(u),0,dat)
else
set dat = LoadInteger(h,GetHandleId(u),0)
set dat.u = u
set dat.ite = ite
set dat.x = GetItemX(ite)
set dat.y = GetItemY(ite)
endif
set i = 100
endif
set i = i + 1
endloop
set dat = LoadInteger(h,GetHandleId(u),0)
if i < 10 and dat != 0 then
set total = total - 1
set DATAS[dat.index] = DATAS[total]
set DATAS[dat.index].index = dat.index
call FlushChildHashtable(h,GetHandleId(dat.u))
call dat.destroy()
endif
endif
set u = null
set ite = null
return false
endfunction
private function ItemStack takes nothing returns boolean
local integer i = 0
local integer id
local item k
local item m = GetManipulatedItem()
local unit u = GetTriggerUnit()
local integer ite = GetItemTypeId(m)
local integer c = GetItemCharges(m)
local integer it
if GetItemCharges(GetManipulatedItem()) > 0 then
loop
exitwhen i > 6
set it = GetItemTypeId(UnitItemInSlot(u, i - 1))
set k = UnitItemInSlot(u, i - 1)
if ( ( it == ite ) and( m != k ) ) then
call SetItemCharges( k, GetItemCharges(k) + c )
call RemoveItem( m )
set i = 10
endif
set i = i + 1
endloop
endif
set k = null
set m = null
set u = null
return false
endfunction
private function ItemTake takes nothing returns nothing
local real dx
local real dy
local item it
local integer i
local integer ii = 0
local data dat
loop
exitwhen ii >= total
set dat = DATAS[ii]
set dx = GetItemX(dat.ite) - GetUnitX(dat.u)
set dy = GetItemY(dat.ite) - GetUnitY(dat.u)
if ( dx * dx + dy * dy < 10000 ) and IsItemOwned(dat.ite) == false then
set i = 0
loop
exitwhen i > 5
set it = UnitItemInSlot(dat.u,i)
if GetItemTypeId(dat.ite) == GetItemTypeId(it) then
set i = 5
endif
set i = i + 1
endloop
call SetItemCharges( it, GetItemCharges(it) + GetItemCharges(dat.ite) )
call RemoveItem( dat.ite )
set total = total - 1
set DATAS[ii] = DATAS[total]
set DATAS[ii].index = ii
call FlushChildHashtable(h,GetHandleId(dat.u))
call dat.destroy()
call IssueImmediateOrder(dat.u,"stop")
endif
set ii = ii + 1
endloop
set it = null
endfunction
private function ItemWalkAbort1 takes nothing returns boolean
local data dat = LoadInteger(h,GetHandleId(GetTriggerUnit()),0)
if dat != 0 and( GetOrderPointX() != dat.x or GetOrderPointY() != dat.y )then
set total = total - 1
set DATAS[dat.index] = DATAS[total]
set DATAS[dat.index].index = dat.index
call FlushChildHashtable(h,GetHandleId(dat.u))
call dat.destroy()
endif
return false
endfunction
private function ItemWalkAbort2 takes nothing returns boolean
local data dat = LoadInteger(h,GetHandleId(GetTriggerUnit()),0)
if dat != 0 then
set total = total - 1
set DATAS[dat.index] = DATAS[total]
set DATAS[dat.index].index = dat.index
call FlushChildHashtable(h,GetHandleId(dat.u))
call dat.destroy()
endif
return false
endfunction
private function ItemSplit takes nothing returns boolean
local integer i = GetItemCharges(GetOrderTargetItem())
if GetIssuedOrderId() > 852001 and GetIssuedOrderId() < 852008 then
if GetOrderTargetItem() == UnitItemInSlot(GetOrderedUnit(), GetIssuedOrderId()-852002) then
if i > 1 then
set i = i/2
call SetItemCharges(GetOrderTargetItem(), GetItemCharges(GetOrderTargetItem()) - i)
call DisableTrigger(trg)
call UnitAddItemByIdSwapped(GetItemTypeId(GetOrderTargetItem()), GetTriggerUnit())
call EnableTrigger(trg)
call SetItemCharges(bj_lastCreatedItem, i)
endif
else
if i > 0 and GetItemTypeId(GetOrderTargetItem()) == GetItemTypeId(UnitItemInSlot(GetOrderedUnit(), GetIssuedOrderId()-852002)) then
call SetItemCharges(GetOrderTargetItem(), GetItemCharges(GetOrderTargetItem()) + GetItemCharges(UnitItemInSlot(GetOrderedUnit(), GetIssuedOrderId()-852002)))
call RemoveItem(UnitItemInSlot(GetOrderedUnit(), GetIssuedOrderId()-852002))
endif
endif
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger a = CreateTrigger( )
local trigger b = CreateTrigger( )
local trigger c = CreateTrigger( )
local integer i = 0
call TimerStart( tim, 0.05, true, function ItemTake )
loop
call TriggerRegisterPlayerUnitEvent(a, Player(i), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
call TriggerRegisterPlayerUnitEvent(b, Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
call TriggerRegisterPlayerUnitEvent(c, Player(i), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
call TriggerRegisterPlayerUnitEvent(trg, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, null)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( a, Condition( function ItemWalkAbort1 ) )
call TriggerAddCondition( a, Condition( function ItemWalkAbort2 ) )
call TriggerAddCondition( c, Condition( function ItemWalk ) )
call TriggerAddCondition( c, Condition( function ItemSplit ) )
call TriggerAddCondition( trg, Condition( function ItemStack ) )
endfunction
endlibrary
//TESH.scrollpos=209
//TESH.alwaysfold=0
library DroneSystem initializer init
// this system allows you to add drones to a unit which follow/surround it.
// useful for example for space maps: use this system to add weapons to ships
// the weapons will fire even if the ship moves
//
// functions in this system:
//
//
//call CreateDrone( TargetUnit, DroneRawcode, DistanceToTarget, AngleToTarget, IsDroneAttackable)
// unit integer real real boolean
//
//call CreateDroneRotating( TargetUnit, DroneRawcode, DistanceToTarget, RotationSpeed, IsDroneAttackable)
// unit integer real real boolean
//
//call RemoveDrone( Drone )
// unit
//
//call RemoveAllDrones( Owner )
// unit
//
//call SetDroneRotationSpeed( Drone, NewSpeed )
// unit real
//
//call SetDroneAngle( Drone, NewAngle )
// unit real
//
//call SetDroneDistance( Drone, NewDistance )
// unit real
//
//call GetDroneRotationSpeed( Drone ) returns real
// unit
//
//call GetDroneAngle( Drone ) returns real
// unit
//
//call GetDroneDistance( Drone ) returns real
// unit
//
//
// Setup Part:
globals
//the interval of the timed execution (just change this if you have to)
private constant real interval = 0.01
endglobals
// how to implement this system in your map??
// just copy and paste this trigger into your map
//***************Don't modify anything below this line*****************
globals
private group g = CreateGroup()
private group gg = CreateGroup()
private hashtable h = InitHashtable()
endglobals
private struct data
unit Revive
unit array t[99]
real array d[99]
real array s[99]
real array angle[99]
integer array mode[99]
integer total = 0
endstruct
private function Execute takes nothing returns nothing
local integer i
local real x
local real y
local data dat
local real f
local unit Revive
call GroupAddGroup(g,gg)
loop
set Revive = FirstOfGroup(gg)
exitwhen Revive == null
set dat = LoadInteger(h,GetHandleId(Revive),0)
set i = 0
loop
exitwhen i >= dat.total
if dat.mode[i] == 0 then
set f = GetUnitFacing(dat.Revive)
set x = GetUnitX(dat.Revive) + dat.d[i] * Cos((f+dat.angle[i]) * bj_DEGTORAD)
set y = GetUnitY(dat.Revive) + dat.d[i] * Sin((f+dat.angle[i]) * bj_DEGTORAD)
else
set dat.angle[i] = dat.angle[i] + dat.s[i]
set x = GetUnitX(dat.Revive) + dat.d[i] * Cos((dat.angle[i]) * bj_DEGTORAD)
set y = GetUnitY(dat.Revive) + dat.d[i] * Sin((dat.angle[i]) * bj_DEGTORAD)
endif
call SetUnitX(dat.t[i],x)
call SetUnitY(dat.t[i],y)
if GetUnitCurrentOrder(dat.t[i]) == OrderId("move") then
call IssueImmediateOrder(dat.t[i],"stop")
endif
set i = i + 1
endloop
call GroupRemoveUnit(gg,Revive)
endloop
endfunction
private function Create takes unit Revive, integer id, real d, real a, real s, boolean attack, integer mode returns data
local data dat = LoadInteger(h,GetHandleId(Revive),0)
local real x = GetUnitX(Revive) + d * Cos((GetUnitFacing(Revive)+a) * bj_DEGTORAD)
local real y = GetUnitY(Revive) + d * Sin((GetUnitFacing(Revive)+a) * bj_DEGTORAD)
local integer i
if dat == 0 then
set dat = data.create()
set dat.Revive = Revive
call SaveInteger(h,GetHandleId(Revive),0,dat)
endif
set i = dat.total
set dat.t[i] = CreateUnit(GetOwningPlayer(Revive),id,x,y,GetUnitFacing(Revive))
if mode == 0 then
set dat.angle[i] = a
else
set dat.angle[i] = GetUnitFacing(Revive)+a
set dat.s[i] = s
endif
set dat.d[i] = d
set dat.mode[i] = mode
call SetUnitPathing(dat.t[i],false)
call SetUnitInvulnerable(dat.t[i], not attack)
call GroupRemoveUnit(g,Revive)
call GroupAddUnit(g,Revive)
call SaveInteger(h,GetHandleId(dat.t[i]),0,i)
call SaveUnitHandle(h,GetHandleId(dat.t[i]),1,Revive)
set dat.total = dat.total + 1
return dat
endfunction
function CreateDrone takes unit towhich, integer drone, real distance, real angle, boolean attackable returns unit
local data dat = Create(towhich,drone,distance,angle,0,attackable,0)
return dat.t[dat.total-1]
endfunction
function CreateDroneRotating takes unit towhich, integer drone, real distance, real speed, boolean attackable returns unit
local data dat = Create(towhich,drone,distance,0,1,attackable,1)
return dat.t[dat.total-1]
endfunction
function RemoveDrone takes unit drone returns nothing
local unit Revive = LoadUnitHandle(h,GetHandleId(drone),1)
local integer i = LoadInteger(h,GetHandleId(drone),0)
local data dat = LoadInteger(h,GetHandleId(Revive),0)
if drone != null then
call FlushChildHashtable(h,GetHandleId(dat.t[i]))
call RemoveUnit(dat.t[i])
set dat.total = dat.total - 1
set dat.t[i] = dat.t[dat.total]
set dat.d[i] = dat.d[dat.total]
set dat.s[i] = dat.s[dat.total]
set dat.angle[i] = dat.angle[dat.total]
set dat.mode[i] = dat.mode[dat.total]
endif
set Revive = null
endfunction
function RemoveAllDrones takes unit owner returns nothing
local data dat = LoadInteger(h,GetHandleId(owner),0)
local integer i = 0
loop
exitwhen i >= dat.total
call FlushChildHashtable(h,GetHandleId(dat.t[i]))
call RemoveUnit(dat.t[i])
set i = i + 1
endloop
set dat.total = 0
endfunction
function SetDroneRotationSpeed takes unit drone, real speed returns nothing
local unit Revive = LoadUnitHandle(h,GetHandleId(drone),1)
local integer i = LoadInteger(h,GetHandleId(drone),0)
local data dat = LoadInteger(h,GetHandleId(Revive),0)
set dat.s[i] = speed
set Revive = null
endfunction
function SetDroneAngle takes unit drone, real angle returns nothing
local unit Revive = LoadUnitHandle(h,GetHandleId(drone),1)
local integer i = LoadInteger(h,GetHandleId(drone),0)
local data dat = LoadInteger(h,GetHandleId(Revive),0)
set dat.angle[i] = angle
set Revive = null
endfunction
function SetDroneDistance takes unit drone, real distance returns nothing
local unit Revive = LoadUnitHandle(h,GetHandleId(drone),1)
local integer i = LoadInteger(h,GetHandleId(drone),0)
local data dat = LoadInteger(h,GetHandleId(Revive),0)
set dat.d[i] = distance
set Revive = null
endfunction
function GetDroneRotationSpeed takes unit drone returns real
local unit Revive = LoadUnitHandle(h,GetHandleId(drone),1)
local integer i = LoadInteger(h,GetHandleId(drone),0)
local data dat = LoadInteger(h,GetHandleId(Revive),0)
set Revive = null
return dat.s[i]
endfunction
function GetDroneAngle takes unit drone returns real
local unit Revive = LoadUnitHandle(h,GetHandleId(drone),1)
local integer i = LoadInteger(h,GetHandleId(drone),0)
local data dat = LoadInteger(h,GetHandleId(Revive),0)
set Revive = null
return dat.angle[i]
endfunction
function GetDroneDistance takes unit drone returns real
local unit Revive = LoadUnitHandle(h,GetHandleId(drone),1)
local integer i = LoadInteger(h,GetHandleId(drone),0)
local data dat = LoadInteger(h,GetHandleId(Revive),0)
set Revive = null
return dat.d[i]
endfunction
private function remove takes nothing returns boolean
if LoadUnitHandle(h,GetHandleId(GetTriggerUnit()),1) != null then
call RemoveDrone(GetTriggerUnit())
endif
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition(t,Condition(function remove))
set t = CreateTrigger()
call TriggerRegisterTimerEvent( t, interval,true )
call TriggerAddAction(t,function Execute)
endfunction
endlibrary