- Joined
- Oct 16, 2008
- Messages
- 10,454
since its already jass, yeah, formulas will be better, and they are a bit easy to edit in jass than in GUI...
//Spell Name: Lightning Cloud v2.0
//Made by: Mckill2009
//NOTE:
//- To all of you who are thinking that this is a rip-off dota's Razor's ultimate spell
// well, you are wrong, I even dont know that spell coz I really dont play DotA
//===HOW TO USE:
//- Make a new trigger and convert to custom text via EDIT >>> CONVERT CUSTOM TEXT
//- The trigger name MUST be >>> InitTrig_LightningCloud (see the name below)
//- Copy ALL that is written here and overwrite the existing texts in the custom text
//- Copy the Dummy/custom abilities/buffs etc... to your object editor
//- Make sure you inputed the correct raw codes of the base spell/buffs/dummy etc...
//- If your raw code is different, you MUST CHANGE IT...
//- You can view the raw codes by pressing CTRL+B in the object editor
//- Examples of raw codes are 'A000', 'h000' etc...
//===REQUIRED VARIABLES:
//- HASH = Hashtable
//- LC_Cloud = Unit
//- LC_TimerN - Integer
//- LC_Timers - Timer Array
//===CONFIGURABLES:
constant function LC_SpellId takes nothing returns integer
return 'A000' //Raw code for the Hero ability
endfunction
constant function LC_DummySpellId takes nothing returns integer
return 'A001' //Raw code for the Lightning Strike ability
endfunction
constant function LC_CloudUnit takes nothing returns integer
return 'h001' //Raw code for the Cloud Unit
endfunction
constant function LC_Damage takes integer i returns real
return i * 20. //This is the ability level multiply by base damage
endfunction
constant function LC_Range takes nothing returns real
return 500. //Maximum range is 3000 or you can adjust it via object editor
endfunction
constant function LC_Duration takes nothing returns real
return 20. //This is the duration of the cloud and spell
endfunction
constant function LC_TimerSpeed takes nothing returns real
return 0.05
endfunction
constant function LC_ATT takes nothing returns attacktype
return ATTACK_TYPE_MAGIC
endfunction
constant function LC_DAM takes nothing returns damagetype
return DAMAGE_TYPE_LIGHTNING
endfunction
//===END OF CONFIGURABLES===
function LC_RTimer takes timer t returns nothing
if t != null then
call PauseTimer(t)
set udg_LC_Timers[udg_LC_TimerN] = t
set udg_LC_TimerN = udg_LC_TimerN + 1
endif
endfunction
//and get a timer
function LC_NTimer takes nothing returns timer
if udg_LC_TimerN == 0 then
return CreateTimer()
endif
set udg_LC_TimerN = udg_LC_TimerN - 1
return udg_LC_Timers[udg_LC_TimerN]
endfunction
function LC_FilterThem takes nothing returns boolean
local unit u = GetFilterUnit()
local boolean b = GetWidgetLife(u) > 0.405 and IsUnitEnemy(u, GetOwningPlayer(udg_LC_Cloud)) and IsUnitType(u, UNIT_TYPE_STRUCTURE)==false
set u = null
return b
endfunction
function LC_Loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer parent = GetHandleId(t)
local integer cloudkey
local unit caster = LoadUnitHandle(udg_HASH, parent, 1)
local unit cloud = LoadUnitHandle(udg_HASH, parent, 2)
local real dur = LoadReal(udg_HASH, parent, 3)
local real range = LoadReal(udg_HASH, parent, 4)
set cloudkey = GetHandleId(cloud)
set udg_LC_Cloud = cloud //should be transfered to a global variable
if dur > 0 and GetWidgetLife(caster) > 0.405 then
call SaveReal(udg_HASH, parent, 3 , dur - LC_TimerSpeed())
call SetUnitX(cloud, GetUnitX(caster))
call SetUnitY(cloud, GetUnitY(caster))
call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(cloud), GetUnitY(cloud), range, Filter(function LC_FilterThem))
call IssueTargetOrder(cloud, "chainlightning" , FirstOfGroup(bj_lastCreatedGroup)) //852119
else
call UnitApplyTimedLife(cloud, 'BTLF', 0.01)
call LC_RTimer(t)
call FlushChildHashtable(udg_HASH, parent)
call FlushChildHashtable(udg_HASH, cloudkey)
endif
set t = null
set cloud = null
set caster = null
endfunction
function LC_Cast takes nothing returns boolean
local timer t
local unit caster
local unit cloud
local integer cloudkey
local integer parent
local integer abilitylevel
if GetSpellAbilityId()==LC_SpellId() then
set caster = GetTriggerUnit()
set abilitylevel = GetUnitAbilityLevel(caster, LC_SpellId())
set t = LC_NTimer()
set parent = GetHandleId(t)
set cloud = CreateUnit(GetTriggerPlayer(), LC_CloudUnit() , GetUnitX(caster), GetUnitY(caster), 0)
set cloudkey = GetHandleId(cloud)
//===This portion saves the caster so that he will deal damage, not the cloud
call SaveUnitHandle(udg_HASH, cloudkey, 1, caster)
call SaveReal(udg_HASH, cloudkey, 2 , LC_Damage(abilitylevel))
//===This portion saves the caster/cloud/duration and range
call SaveUnitHandle(udg_HASH, parent, 1, caster)
call SaveUnitHandle(udg_HASH, parent, 2, cloud)
call SaveReal(udg_HASH, parent, 3, LC_Duration()) //See Function
call SaveReal(udg_HASH, parent, 4, LC_Range()) //See Function
call TimerStart(t, LC_TimerSpeed(), true, function LC_Loop)
elseif GetSpellAbilityId()==LC_DummySpellId() then
set cloudkey = GetHandleId(GetTriggerUnit())
call UnitDamageTarget(LoadUnitHandle(udg_HASH, cloudkey, 1), GetSpellTargetUnit(), LoadReal(udg_HASH, cloudkey, 2), false, false, LC_ATT(), LC_DAM(), null)
endif
set t = null
set caster = null
set cloud = null
return false
endfunction
function InitTrig_LightningCloud takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function LC_Cast))
set udg_HASH = InitHashtable()
set t = null
endfunction