//TESH.scrollpos=0
//TESH.alwaysfold=0
Name | Type | is_array | initial_value |
A | boolean | No | |
HM_ActiveHeathBar | boolean | No | |
HM_ActiveManaBar | boolean | No | |
HM_Bars_Hidden | boolean | Yes | |
HM_Caster | unit | Yes | |
HM_Change_Unit | unit | No | |
HM_Current_Player | player | No | |
HM_Current_Unit | unit | No | |
HM_Data | integer | No | |
HM_DEAD_LOC | real | No | |
HM_Do_Changes | boolean | No | |
HM_Do_Hide | boolean | No | |
HM_EMPTY_MODEL | string | No | |
HM_HandleId | integer | No | |
HM_Hashtable | hashtable | No | |
HM_HP_Z | real | No | |
HM_Illusion_Unit | unit | Yes | |
HM_LightningFE | lightning | Yes | |
HM_LightningH | lightning | Yes | |
HM_LightningM | lightning | Yes | |
HM_LightningSE | lightning | Yes | |
HM_Location | location | No | |
HM_LONG | real | No | |
HM_Loop | integervar | No | |
HM_MUI | integer | No | |
HM_MUI_Data | integer | Yes | |
HM_PERIODIC | real | No | |
HM_Player | player | Yes | |
HM_Player_Integer | integervar | No | |
HM_Release | boolean | Yes | |
HM_SAFE | real | No | |
HM_Scale | real | Yes | |
HM_TIMER | timer | No | |
HM_Unit_Handle | integer | Yes | |
HM_UnitAddBars | unit | No | |
HM_UnitHandleId | integer | Yes | |
HM_UnitSetScale | real | No | |
HM_Z_OFFSET | real | No | |
HP_MODEL | string | No | |
MN_MODEL | string | No | |
TEST_ONLY_Integer | integervar | No |
//TESH.scrollpos=273
//TESH.alwaysfold=0
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************
// M A N A W A V E
// By: Elphis
// - Spell Information:
// - Calls forth a wave of energy that heals a target, if target belong to ally,
// it will bounces to all nearby friendlies around 700 AOE, each bounces heals 100 mana.
// But if the target belong to enemy, it will bounces to all nearby ememies around 700 AOE and
// destroy 100 on the target, every time it bounces to enemy, each wave, mana desrtoy will decreasing by 20.
// - Installation:
// - Import/copy Healing Mana code to your map
// - Import/copy the custom ability and unit to your map and change the SPELL_ID if needed
// - You may view the raw ID of the objects by pressing CTRL+D in the object editor
// - You may play with the configurables below
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************
library ManaWave
//**********************************CONFIGURABLE**********************************
globals
//Spell rawcode
private constant integer SPELL_ID = 'A000'
//Spell period
private constant real PERIODIC = .031250000
//Area of effect
private constant real AOE = 700.
//Heal mana time intevar
private constant real HEAL_INTEVAR = 0.1
//Mana heal count
private constant real MANA_HEAL_BASE = 100.
//Mana destroy decrease every it link from enemy
private constant real MANA_DESTROY_DECREASE = 20.
//Lightning color fade timed
private constant real LIGHTNING_FADE_INTEVAR = 0.02
//***********LIGHTNING COLOR***********//
private constant real LIGHTNING_COLOR_RED = 0.5
private constant real LIGHTNING_COLOR_GREEN = 0.2
private constant real LIGHTNING_COLOR_BLUE = 1.
//***************************************
//Allies buff count
private constant integer ALLIES_COUNT_BASE = 5
//Lightning model
private constant string LIGHTNING_MODEL = "MFPB"
//Effect when no unit in area of effect
private constant string MODEL_EMPTY = "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl"
//Effect when buff allies
private constant string BUFF_EFFECT = "Abilities\\Spells\\Other\\Drain\\ManaDrainTarget.mdl"
//Effect when buff enemies
private constant string BUFF_EFFECT_ENEMY = "Abilities\\Spells\\Other\\Drain\\ManaDrainCaster.mdl"
//Effect linked of the lightning
private constant string EFFECT_LINKED = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl"
//Point attachment
private constant string ATTACH_POINT = "origin"
//Point linked attachment
private constant string ATTACH_POINT_LINKED = "origin"
//***********Non-Configurable***********//
private integer MUI = -1
private integer Plugin_MUI = -1
private constant group G = CreateGroup()
private constant integer array Struct_Data
private constant integer array Plugin_Struct_Data
private constant timer TIMER = CreateTimer()
private constant timer TIMER_2 = CreateTimer()
private constant location LOC = Location(0.,0.)
//***************************************
endglobals
//**********************************END OF CONFIGURABLE**********************************//
//**********************************DO NOT MODIFY ANYTHING BELOW**********************************//
private struct ManaWave
unit caster
unit last_unit
real intevar = 0.
real mana
boolean destroy_mana
group g = CreateGroup()
static method onPeriodic takes nothing returns nothing
local thistype this
local integer i = 0
local unit r
loop
exitwhen i > MUI
set this = Struct_Data[i]
if intevar < HEAL_INTEVAR then
set intevar = intevar + PERIODIC
else
set intevar = 0.
set r = GroupPickRandomUnit(g)
if r != null then
call GroupRemoveUnit(g,r)
call ManaWave_ManaWavePlugin.add(LIGHTNING_MODEL,r,last_unit,mana,destroy_mana)
if destroy_mana then
set mana = mana - MANA_DESTROY_DECREASE
endif
set last_unit = r
else
set Struct_Data[i] = Struct_Data[MUI]
set Struct_Data[MUI] = -2
set MUI = MUI - 1
if MUI == -1 then
call PauseTimer(TIMER)
endif
call DestroyGroup(g)
set g = null
set caster = null
set last_unit = null
call destroy()
endif
endif
set i = i + 1
endloop
endmethod
static method onCast takes nothing returns boolean
local thistype this
local unit f = GetSpellTargetUnit()
local unit ct = GetTriggerUnit()
local player owner = GetTriggerPlayer()
local integer lvl
local integer count
local integer total_unit = 0
local boolean destroy_mn = IsUnitEnemy(f,owner)
//Checking unit around the target....
call GroupEnumUnitsInRange(G,GetUnitX(f),GetUnitY(f),AOE,null)
loop
set f = FirstOfGroup(G)
exitwhen f == null
if f != ct and GetUnitState(f,UNIT_STATE_MAX_MANA) > 0. and not IsUnitType(f,UNIT_TYPE_DEAD) then
if IsUnitEnemy(f,owner) == destroy_mn then
set total_unit = 1
exitwhen true
endif
endif
call GroupRemoveUnit(G,f)
endloop
//Checking conditions before run this spell....
if total_unit == 0 then
call DestroyEffect(AddSpecialEffect(MODEL_EMPTY,GetUnitX(ct),GetUnitY(ct)))
set ct = null
set f = null
return false
endif
set this = allocate()
set total_unit = 0
set MUI = MUI + 1
set Struct_Data[MUI] = this
set caster = ct
set last_unit = GetSpellTargetUnit()
set lvl = GetUnitAbilityLevel(caster,SPELL_ID)
set mana = MANA_HEAL_BASE*lvl
set count = ALLIES_COUNT_BASE+lvl
set destroy_mana = destroy_mn
call GroupEnumUnitsInRange(G,GetUnitX(f),GetUnitY(f),AOE,null)
loop
set f = FirstOfGroup(G)
exitwhen f == null
if f != caster and GetUnitState(f,UNIT_STATE_MAX_MANA) > 0. and not IsUnitType(f,UNIT_TYPE_DEAD) then
if IsUnitEnemy(f,owner) == destroy_mana then
call GroupAddUnit(g,f)
endif
set total_unit = total_unit + 1
endif
call GroupRemoveUnit(G,f)
endloop
set count = total_unit - count
set f = GroupPickRandomUnit(g)
if f != null then
call ManaWave_ManaWavePlugin.add(LIGHTNING_MODEL,last_unit,caster,mana,destroy_mana)
call GroupRemoveUnit(g,last_unit)
loop
exitwhen count < 0
set f = GroupPickRandomUnit(g)
call GroupRemoveUnit(g,f)
set count = count - 1
endloop
endif
if MUI == 0 then
call TimerStart(TIMER,PERIODIC,true,function thistype.onPeriodic)
endif
set owner= null
set ct = null
set f = null
return false
endmethod
static method onInit takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
//
loop
exitwhen i > 15
call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
set i = i + 1
endloop
//
call TriggerAddCondition(t,function thistype.onCast)
set t = null
endmethod
endstruct
public struct ManaWavePlugin
private unit plugin_unit
private unit plugin_caster
private real plugin_color
private real plugin_mana
private real plugin_intevar
private real plugin_fade = 1.
private effect plugin_effect
private lightning plugin_lightning
private boolean plugin_destroy
static method onPeriodic takes nothing returns nothing
local thistype this
local integer i = 0
local real zc
local real zu
local real xc
local real yc
local real xu
local real yu
loop
exitwhen i > Plugin_MUI
set this = Plugin_Struct_Data[i]
set xc = GetUnitX(plugin_caster)
set yc = GetUnitY(plugin_caster)
set zu = GetUnitX(plugin_unit)
set yu = GetUnitY(plugin_unit)
call MoveLocation(LOC,xc,yc)
set zc = GetLocationZ(LOC)+GetUnitFlyHeight(plugin_caster)
call MoveLocation(LOC,xu,yu)
set zc = GetLocationZ(LOC)+GetUnitFlyHeight(plugin_unit)
call MoveLightningEx(plugin_lightning,true,xc,yc,zc,zu,yu,zu)
if plugin_fade > 0. then
set plugin_fade = plugin_fade - LIGHTNING_FADE_INTEVAR
call SetLightningColor(plugin_lightning,LIGHTNING_COLOR_RED,LIGHTNING_COLOR_GREEN,LIGHTNING_COLOR_BLUE,plugin_fade)
if not plugin_destroy then
call SetUnitState(plugin_unit,UNIT_STATE_MANA,GetUnitState(plugin_unit,UNIT_STATE_MANA)+plugin_intevar)
else
call SetUnitState(plugin_unit,UNIT_STATE_MANA,GetUnitState(plugin_unit,UNIT_STATE_MANA)-plugin_intevar)
endif
else
set Plugin_Struct_Data[i] = Plugin_Struct_Data[Plugin_MUI]
set Plugin_Struct_Data[Plugin_MUI] = -2
set Plugin_MUI = Plugin_MUI - 1
if Plugin_MUI == -1 then
call PauseTimer(TIMER_2)
endif
call DestroyEffect(plugin_effect)
call DestroyLightning(plugin_lightning)
set plugin_effect = null
set plugin_lightning = null
set plugin_unit = null
set plugin_caster = null
call destroy()
endif
set i = i + 1
endloop
endmethod
static method add takes string lmodel,unit u,unit caster,real mana,boolean destroy returns nothing
local thistype this = allocate()
set Plugin_MUI = Plugin_MUI + 1
set Plugin_Struct_Data[Plugin_MUI] = this
set plugin_lightning = AddLightningEx(lmodel,true,GetUnitX(caster),GetUnitY(caster),GetUnitFlyHeight(caster),GetUnitX(u),GetUnitY(u),GetUnitFlyHeight(u))
call SetLightningColor(plugin_lightning,LIGHTNING_COLOR_RED,LIGHTNING_COLOR_GREEN,LIGHTNING_COLOR_BLUE,1.)
set plugin_unit = u
set plugin_caster = caster
set plugin_mana = mana
set plugin_intevar = plugin_mana*LIGHTNING_FADE_INTEVAR
set plugin_destroy = destroy
call DestroyEffect(AddSpecialEffectTarget(EFFECT_LINKED,u,ATTACH_POINT_LINKED))
if plugin_destroy then
set plugin_effect = AddSpecialEffectTarget(BUFF_EFFECT_ENEMY,u,ATTACH_POINT)
else
set plugin_effect = AddSpecialEffectTarget(BUFF_EFFECT,u,ATTACH_POINT)
endif
if Plugin_MUI == 0 then
call TimerStart(TIMER_2,PERIODIC,true,function thistype.onPeriodic)
endif
endmethod
endstruct
endlibrary
//TESH.scrollpos=4
//TESH.alwaysfold=0
globals
group HM_Illusion_Group = CreateGroup()
endglobals
function UnitIllusion takes nothing returns boolean
local unit f = GetFilterUnit()
local integer i
if IsUnitIllusion(f) and GetUnitTypeId(f) == GetUnitTypeId(udg_HM_Caster[udg_HM_Data]) and IsUnitOwnedByPlayer(f,udg_HM_Player[udg_HM_Data]) then
set udg_HM_Illusion_Unit[udg_HM_Data] = f
endif
return false
endfunction
function Trig_Illusion_Checker_Plugin_Actions takes nothing returns nothing
call GroupEnumUnitsInRange(HM_Illusion_Group,GetUnitX(udg_HM_Caster[udg_HM_Data]),GetUnitY(udg_HM_Caster[udg_HM_Data]),99999.,function UnitIllusion)
endfunction
//===========================================================================
function InitTrig_Illusion_Checker_Plugin takes nothing returns nothing
set gg_trg_Illusion_Checker_Plugin = CreateTrigger( )
call TriggerAddAction( gg_trg_Illusion_Checker_Plugin, function Trig_Illusion_Checker_Plugin_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_HM_Hide_Bars_To_Player_Actions takes nothing returns nothing
local real alphaNum = 1.
local integer h = GetHandleId(udg_HM_Current_Unit)
local integer curData = LoadIntegerBJ(2,h,udg_HM_Hashtable)
local boolean curHidden
local integer curPlayer
//
if curData > 0 then
if udg_HM_Current_Unit != null then
if udg_HM_Current_Player != null then
//
set curPlayer = GetPlayerId(udg_HM_Current_Player)
// Special case: hidden units.
if not udg_HM_Do_Hide and IsUnitHidden(udg_HM_Current_Unit) then
debug call BJDebugMsg("Can't show bars: the unit is hidden.")
else
//
if udg_HM_Do_Hide then
set alphaNum = 0.
endif
//
call SaveBooleanBJ(udg_HM_Do_Hide,11+curPlayer,h,udg_HM_Hashtable)
//
if GetLocalPlayer() == udg_HM_Current_Player then
call SetLightningColor(udg_HM_LightningH[curData],1.,1.,1.,alphaNum)
call SetLightningColor(udg_HM_LightningM[curData],1.,1.,1.,alphaNum)
call SetLightningColor(udg_HM_LightningSE[curData],1.,1.,1.,alphaNum)
call SetLightningColor(udg_HM_LightningFE[curData],1.,1.,1.,alphaNum)
endif
endif
//
set udg_HM_Current_Player = null
//
else
debug call BJDebugMsg("Can't operate bars: Did you add the current player you want to hide heath/mana bar ?.")
endif
//
set udg_HM_Current_Unit = null
//
else
debug call BJDebugMsg("Can't operate bars: Did you add the current unit have heath/mana bar ?.")
endif
else
debug call BJDebugMsg("Can't operate bars: the unit does not exist.")
endif
endfunction
//===========================================================================
function InitTrig_HM_Hide_Bars_To_Player takes nothing returns nothing
set gg_trg_HM_Hide_Bars_To_Player = CreateTrigger( )
call TriggerAddAction(gg_trg_HM_Hide_Bars_To_Player, function Trig_HM_Hide_Bars_To_Player_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Execution_Actions takes nothing returns nothing
local real alphaNum = 1.
// Special case: hidden units.
if not udg_HM_Do_Hide and IsUnitHidden(udg_HM_Current_Unit) then
debug call BJDebugMsg("Can't show bars: the unit is hidden.")
else
//
if udg_HM_Do_Hide then
set alphaNum = 0.
endif
//
if GetLocalPlayer() == udg_HM_Current_Player then
call SetLightningColor(udg_HM_LightningH[udg_HM_Data],1.,1.,1.,alphaNum)
call SetLightningColor(udg_HM_LightningM[udg_HM_Data],1.,1.,1.,alphaNum)
call SetLightningColor(udg_HM_LightningSE[udg_HM_Data],1.,1.,1.,alphaNum)
call SetLightningColor(udg_HM_LightningFE[udg_HM_Data],1.,1.,1.,alphaNum)
endif
endif
//
endfunction
//===========================================================================
function InitTrig_HM_Hide_Bars_To_Player_Execution takes nothing returns nothing
set gg_trg_HM_Hide_Bars_To_Player_Execution = CreateTrigger( )
call TriggerAddAction(gg_trg_HM_Hide_Bars_To_Player_Execution, function Execution_Actions)
endfunction
//TESH.scrollpos=14
//TESH.alwaysfold=0
function Trig_Hide_Bars_All_Player_Actions takes nothing returns nothing
local integer i = 0
local player casterOwner = udg_HM_Current_Player
local integer curData = LoadIntegerBJ(2,GetHandleId(udg_HM_Current_Unit),udg_HM_Hashtable)
local player curPlayer
if curData > 0 then
if udg_HM_Current_Unit != null then
if udg_HM_Current_Player != null then
loop
exitwhen i > 11
set curPlayer = Player(i)
if curPlayer != casterOwner then
set udg_HM_Current_Player = curPlayer
call TriggerExecute(gg_trg_HM_Hide_Bars_To_Player)
endif
set i = i + 1
endloop
//
set udg_HM_Current_Player = null
//
else
debug call BJDebugMsg("Can't operate bars: Did you add the current player you want to hide heath/mana bar ?.")
endif
else
debug call BJDebugMsg("Can't operate bars: Did you add the current unit have heath/mana bar ?.")
endif
else
debug call BJDebugMsg("Can't operate bars: the unit does not exist.")
endif
endfunction
//===========================================================================
function InitTrig_Hide_Bars_All_Players takes nothing returns nothing
set gg_trg_Hide_Bars_All_Players = CreateTrigger( )
call TriggerAddAction( gg_trg_Hide_Bars_All_Players, function Trig_Hide_Bars_All_Player_Actions )
endfunction
//TESH.scrollpos=64
//TESH.alwaysfold=0
function Trig_Change_Data_Actions takes nothing returns nothing
local integer curData = LoadIntegerBJ(2,GetHandleId(udg_HM_Current_Unit),udg_HM_Hashtable)
//
if curData > 0 then
if udg_HM_Current_Unit != null then
if udg_HM_Change_Unit != null then
if udg_HM_Caster[curData] != udg_HM_Change_Unit then
set udg_HM_Caster[curData] = udg_HM_Change_Unit
else
debug call BJDebugMsg("Can't operate bars: Current unit fit with the unit unit want to transfer heath/mana bar >.<.")
endif
//
set udg_HM_Change_Unit = null
//
else
debug call BJDebugMsg("Can't operate bars: Did you add the unit you want to transfer heath/mana bar ?.")
endif
//
if udg_HM_Do_Changes then
//
if udg_HM_UnitSetScale > 0. then
set udg_HM_Scale[curData] = udg_HM_UnitSetScale
endif
//
set udg_HM_UnitSetScale = 0.
//
if udg_HM_ActiveHeathBar then
if udg_HM_LightningH[curData] != null then
debug call BJDebugMsg("Can't operate this action: HP bar already exist.")
else
set udg_HM_LightningH[curData] = AddLightning(udg_HP_MODEL,true,0.,0.,0.,0.)
set udg_HM_LightningFE[curData] = AddLightning(udg_HM_EMPTY_MODEL,true,0.,0.,0.,0.)
endif
elseif udg_HM_ActiveManaBar then
if udg_HM_LightningM[curData] != null then
debug call BJDebugMsg("Can't operate this action: MP bar already exist.")
else
set udg_HM_LightningM[curData] = AddLightning(udg_MN_MODEL,true,0.,0.,0.,0.)
set udg_HM_LightningSE[curData] = AddLightning(udg_HM_EMPTY_MODEL,true,0.,0.,0.,0.)
endif
endif
//
if not udg_HM_ActiveHeathBar then
if udg_HM_LightningH[curData] == null then
debug call BJDebugMsg("Can't operate this action: HP bar does not exist.")
else
call DestroyLightning(udg_HM_LightningH[curData])
call DestroyLightning(udg_HM_LightningFE[curData])
set udg_HM_LightningH[curData] = null
set udg_HM_LightningFE[curData] = null
endif
elseif not udg_HM_ActiveManaBar then
if udg_HM_LightningM[curData] == null then
debug call BJDebugMsg("Can't operate this action: MP bar does not exist.")
else
call DestroyLightning(udg_HM_LightningM[curData])
call DestroyLightning(udg_HM_LightningSE[curData])
set udg_HM_LightningM[curData] = null
set udg_HM_LightningSE[curData] = null
endif
endif
//
set udg_HM_ActiveHeathBar = false
set udg_HM_ActiveManaBar = false
endif
//
set udg_HM_Current_Unit = null
//
else
debug call BJDebugMsg("Can't operate bars: Did you add the current unit have heath/mana bar ?.")
endif
else
debug call BJDebugMsg("Can't operate bars: the unit does not exist.")
endif
//
endfunction
//===========================================================================
function InitTrig_Change_Data takes nothing returns nothing
set gg_trg_Change_Data = CreateTrigger( )
call TriggerAddAction( gg_trg_Change_Data, function Trig_Change_Data_Actions )
endfunction
//TESH.scrollpos=6
//TESH.alwaysfold=0
function Trig_Remove_Bars_Actions takes nothing returns nothing
local integer curData = LoadIntegerBJ(2,GetHandleId(udg_HM_Current_Unit),udg_HM_Hashtable)
//
if curData > 0 then
if udg_HM_Current_Unit != null then
set udg_HM_Release[curData] = true
else
debug call BJDebugMsg("Can't operate bars: Did you add the current unit have heath/mana bar ?.")
endif
//
set udg_HM_Current_Unit = null
//
else
debug call BJDebugMsg("Can't operate bars: the unit does not exist.")
endif
endfunction
//===========================================================================
function InitTrig_Remove_Bars takes nothing returns nothing
set gg_trg_Remove_Bars = CreateTrigger( )
call TriggerAddAction( gg_trg_Remove_Bars, function Trig_Remove_Bars_Actions )
endfunction
//TESH.scrollpos=11
//TESH.alwaysfold=0
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
// M A N A/ H E A T H B A R S S Y S T E M
// =======
// System created by:
// - Elphis
// What system does:
// This system allow you to create a mana/hp bars on unit :)
//
// H O W T O I M P O R T
// 1: Export LightningData.slk, nhocklanhox6-Elphis.blp, nhocklanhox6-Nyuu.blp, Elphis-Nyuu and import it into your map
// 2: Change path of LightningData.slk = Splats\LightningData.slk
// 3: Change path of nhocklanhox6-Nyuu.blp = ReplaceableTextures\Manabar\nhocklanhox6-Nyuu.blp
// 4: Change path of nhocklanhox6-Elphis.blp = ReplaceableTextures\Manabar\nhocklanhox6-Elphis.blp
// 5: Change path of Elphis-Nyuu = ReplaceableTextures\HitPointBar\Elphis-Nyuu.blp
// WARNING: DO NOT CHANGE THIS PATH, IF YOU CHAGE THIS PATH, ALL LIGHTNING WILL CRASH
// Go to: File -> Preferences -> General -> Check the box labelled "Automatically create unknown variables while pasting trigger data"
// 5: Copy all trigger of folder Resources into your map
// 6: Read the Example Folder
// 7: Enjoy :D
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//TESH.scrollpos=0
//TESH.alwaysfold=0
//vjass link: http://www.hiveworkshop.com/forums/spells-569/vjass-heath-mana-bar-system-v2-1-a-241348/
//GUI: http://www.hiveworkshop.com/forums/spells-569/gui-heath-mana-bar-system-v1-3b-245840/