- Reaction score
- 889
Well, we're back! Or, at least, I am.
With another spell for you! Wow. Two in less than a week. Ghan has gone completely mad. I know. It's sad.
And, the best part is that it's the most complicated JASS spell I've ever made.
Another scope, a library, structs, handlevars, globals, and methods are all included in this free-for-all spell.
JASS - vJASS (NewGen Required)
MUI - To infinity, and beyond!
Works - Energy spraying everywhere... check!
Fun - You will want this spell.
Leaks - If you look really hard right there... oh, nope, that was just some dust on the monitor.
Efficiency - See that? One location that is changed into real at the beginning, I think I count two BJ functions. It won't crash your computer, let's put it that way.
You've got questions. I've got implementation!
Here is the (much longer than last time) code for your viewing pleasure:
With another spell for you! Wow. Two in less than a week. Ghan has gone completely mad. I know. It's sad.
And, the best part is that it's the most complicated JASS spell I've ever made.
Another scope, a library, structs, handlevars, globals, and methods are all included in this free-for-all spell.
JASS - vJASS (NewGen Required)
MUI - To infinity, and beyond!
Works - Energy spraying everywhere... check!
Fun - You will want this spell.
Leaks - If you look really hard right there... oh, nope, that was just some dust on the monitor.
Efficiency - See that? One location that is changed into real at the beginning, I think I count two BJ functions. It won't crash your computer, let's put it that way.
You've got questions. I've got implementation!
Obelisk of Energy
This spell creates a temporary defensive tower at the target location that periodically fires off energy bolts at nearby enemies. The tower lasts until it is destroyed or runs out of shots.
This spell creates a temporary defensive tower at the target location that periodically fires off energy bolts at nearby enemies. The tower lasts until it is destroyed or runs out of shots.
Here is the (much longer than last time) code for your viewing pleasure:
JASS:
library HandleVars
// ===========================
function H2I takes handle h returns integer
return h
return 0
endfunction
// ===========================
function LocalVars takes nothing returns gamecache
// Replace InitGameCache("jasslocalvars.w3v") with a global variable!!
return InitGameCache("jasslocalvars.w3v")
endfunction
function SetHandleInt takes handle subject, string name, integer value returns nothing
if value==0 then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function GetHandleInt takes handle subject, string name returns integer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
endlibrary
scope ObeliskofEnergy
globals
private constant integer Shots = 20 // This is the number of bolts per level the Obelisk will have.
private constant real Delay = 4.00 // This is the time between casts of the Obelisk's ability. It decreases by one second per level of the main spell.
private constant integer UnitCode = 039;h000039; // This is the code of the Obelisk itself.
private constant integer AbilityCode = 039;A000039; // This is the code of the Obelisk of Energy ability.
private constant integer AttackCode = 039;A001039; // This is the code of the ability the Obelisk uses to attack.
private unit SomeUnit
endglobals
struct Info
unit Obelisk
unit Caster
real X
real Y
method onDestroy takes nothing returns nothing
set this.Obelisk = null
set this.Caster = null
endmethod
endstruct
private function UnitFilter takes nothing returns boolean
local Info data = GetUnitUserData(SomeUnit)
return IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(data.Caster)) and GetWidgetLife(GetFilterUnit()) > .305
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == AbilityCode
endfunction
private function Attack takes nothing returns nothing
local Info data = GetHandleInt(GetExpiredTimer(), "struct")
local group tempgroup = CreateGroup()
local unit tempunit
call UnitAddAbility(data.Obelisk, AttackCode)
set SomeUnit = data.Caster
call SetUnitUserData(SomeUnit, data)
call GroupEnumUnitsInRange(tempgroup, data.X, data.Y, 800.00, Condition(function UnitFilter))
set SomeUnit = null
if(FirstOfGroup(tempgroup) != null) then
call SetUnitUserData(data.Obelisk, GetUnitUserData(data.Obelisk) - 1)
call SetUnitState(data.Obelisk, UNIT_STATE_MANA, GetUnitState(data.Obelisk, UNIT_STATE_MANA) - 1)
endif
set tempunit = GroupPickRandomUnit(tempgroup)
call IssueTargetOrder(data.Obelisk, "chainlightning", tempunit)
call UnitRemoveAbility(data.Obelisk, AttackCode)
set tempunit = null
call DestroyGroup(tempgroup)
set tempgroup = null
if(GetUnitUserData(data.Obelisk) <= 0 or GetWidgetLife(data.Obelisk) < .305) then
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\FeralSpirit\\feralspiritdone.mdl", data.X, data.Y))
call RemoveUnit(data.Obelisk)
call data.destroy()
return
endif
endfunction
private function Trig_ObeliskofEnergy_Actions takes nothing returns nothing
local Info data = Info.create()
local location target = GetSpellTargetLoc()
local timer Time = CreateTimer()
set data.X = GetLocationX(target)
set data.Y = GetLocationY(target)
set data.Caster = GetTriggerUnit()
call RemoveLocation(target)
set target = null
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", data.X, data.Y))
set data.Obelisk = CreateUnit(GetOwningPlayer(GetTriggerUnit()), UnitCode, data.X, data.Y, 0.00)
call SetUnitState(data.Obelisk, UNIT_STATE_MANA, Shots * GetUnitAbilityLevel(GetTriggerUnit(), AbilityCode))
call SetUnitUserData(data.Obelisk, Shots * GetUnitAbilityLevel(GetTriggerUnit(), AbilityCode))
call SetHandleInt(Time, "struct", data)
call TimerStart(Time, Delay - GetUnitAbilityLevel(GetTriggerUnit(), AbilityCode), true, function Attack)
set Time = null
endfunction
//===========================================================================
public function InitTrig takes nothing returns nothing
local trigger ObeliskofEnergy = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(ObeliskofEnergy, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(ObeliskofEnergy, Condition(function Conditions))
call TriggerAddAction(ObeliskofEnergy, function Trig_ObeliskofEnergy_Actions )
endfunction
endscope