Electric Shield
I made a spell about three years ago called Shock Shield, which was coded in GUI. This is an attempt to replace it. (Plus it's my first spell submission thats in vJASS)
The caster concentrates his energy into the form of orbs that circle around him for a duration. If an orb goes near an enemy unit, the unit will be damaged and the orb will not be able to damage any enemies for 2 seconds.
Information:
-Coding Style: vJASS
-MUI/MPI: Should be MUI.
Requires:
-Jass NewGen
-GTrigger
-Timer32
-BoolexprUtils
Can't really see the action going on in this screenshot
Code:
Known Bugs:
-None
How to Implement:
Credits not necessary, but please do not act like the author of this spell.
Feedback is appreciated.
I made a spell about three years ago called Shock Shield, which was coded in GUI. This is an attempt to replace it. (Plus it's my first spell submission thats in vJASS)
The caster concentrates his energy into the form of orbs that circle around him for a duration. If an orb goes near an enemy unit, the unit will be damaged and the orb will not be able to damage any enemies for 2 seconds.
Information:
-Coding Style: vJASS
-MUI/MPI: Should be MUI.
Requires:
-Jass NewGen
-GTrigger
-Timer32
-BoolexprUtils
Can't really see the action going on in this screenshot
Code:
JASS:
scope ElectricShield initializer Init
//CONFIGURABLES BELOW HERE.
//CONFIGURABLES BELOW HERE.
//CONFIGURABLES BELOW HERE.
globals
//The Ability Rawcode.
private constant integer ABIL_ID = 039;A000039;
//The Dummy Unit's Rawcode
private constant integer DUMMY_ID = 039;n000039;
//The Chain Lightning Rawcode. Only needed if you set the SPELL_CAST variable to true.
private constant integer DUMMY_SPELL_ID = 039;A001039;
//Enable if you want the orbs to cast something instead of dealing damage via script
private constant boolean SPELL_CAST = false
//The height of the orbs
private constant real ORB_HEIGHT = 50
//How far away the orbs circle from the caster
private constant real ORBIT_RADIUS = 125
//How fast the orbs orbit the caster.
private constant real ORBIT_SPEED = 10
//How close a unit needs to be to the orb to get damaged
private constant real DAMAGE_RADIUS = 125
//You need to adjust this if you adjust the GetOrbAmount() function.
private constant integer MAX_ORBS = 5
//The special effect used when the orbs are ready.
private constant string READY_SFX = "Abilities\\Spells\\Orc\\LightningBolt\\LightningBoltMissile.mdl"
//The special effect used while the orbs are recharging.
private constant string COOLDOWN_SFX = "Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl"
//The special effect used when the orbs damage a unit.
private constant string DAMAGE_SFX = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl"
//The attack type
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_MAGIC
//The damage type
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_LIGHTNING
//The weapon type
private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
endglobals
private function GetDamage takes integer level returns real
return level*20.
endfunction
private function GetOrbAmount takes integer level returns integer
return 1+level
endfunction
private function GetDuration takes integer level returns real
return 11.+level
endfunction
private function GetCooldown takes integer level returns real
return 2.
endfunction
//CONFIGURABLES ABOVE HERE
//CONFIGURABLES ABOVE HERE
//CONFIGURABLES ABOVE HERE
//DO NOT TOUCH PAST THIS UNLESS YOU KNOW WHAT YOU ARE DOING
//DO NOT TOUCH PAST THIS UNLESS YOU KNOW WHAT YOU ARE DOING
//DO NOT TOUCH PAST THIS UNLESS YOU KNOW WHAT YOU ARE DOING
globals
private group g = CreateGroup()
endglobals
private struct Shield
unit c
unit array d[MAX_ORBS]
effect array e[MAX_ORBS]
real array cooldown[MAX_ORBS]
boolean array onCooldown[MAX_ORBS]
integer level
real durationcounter
real rotatecounter
method periodic takes nothing returns nothing
local real x
local real y
local integer i = 0
local unit u = null
local unit d = null
set .rotatecounter = .rotatecounter + ORBIT_SPEED
loop
set i = i + 1
set x = GetUnitX(.c) + ORBIT_RADIUS * Cos((360/GetOrbAmount(.level)*i+.rotatecounter) * bj_DEGTORAD)
set y = GetUnitY(.c) + ORBIT_RADIUS * Sin((360/GetOrbAmount(.level)*i+.rotatecounter) * bj_DEGTORAD)
call SetUnitX(.d<i>, x)
call SetUnitY(.d<i>, y)
if onCooldown<i> == true then
set cooldown<i> = cooldown<i> - T32_PERIOD
if cooldown<i> <= 0 then
set onCooldown<i> = false
call DestroyEffect(.e<i>)
set .e<i> = AddSpecialEffectTarget(READY_SFX, .d<i>, "origin")
endif
endif
call GroupEnumUnitsInRange(g, x, y, DAMAGE_RADIUS, BOOLEXPR_TRUE)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
if IsUnitEnemy(u, GetOwningPlayer(.c)) == true and .onCooldown<i> == false and GetWidgetLife(u) > 0.405 then
if SPELL_CAST == false then
call UnitDamageTarget(.c, u, GetDamage(.level), false, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
else
set d = CreateUnit(GetOwningPlayer(.c), DUMMY_ID, x, y, 0.)
call UnitAddAbility(d, DUMMY_SPELL_ID)
call SetUnitAbilityLevel(d, DUMMY_SPELL_ID, .level)
call IssueTargetOrder(d, "chainlightning", u)
call UnitApplyTimedLife(d, 039;BTLF039;, 1.)
endif
call DestroyEffect(AddSpecialEffect(DAMAGE_SFX, x, y))
call DestroyEffect(.e<i>)
set .e<i> = AddSpecialEffectTarget(COOLDOWN_SFX, .d<i>, "origin")
set .cooldown<i> = GetCooldown(.level)
set .onCooldown<i> = true
endif
endloop
exitwhen i == MAX_ORBS
endloop
set d = null
if .rotatecounter >= 360 then
set .rotatecounter = 0
endif
set .durationcounter = .durationcounter + T32_PERIOD
if .durationcounter >= GetDuration(.level) then
call .destroy()
call .stopPeriodic()
endif
endmethod
implement T32xs
method onDestroy takes nothing returns nothing
local integer i = 0
loop
set i = i + 1
call KillUnit(.d<i>)
set .d<i> = null
call DestroyEffect(.e<i>)
set .e<i> = null
exitwhen i == MAX_ORBS
endloop
set .c = null
endmethod
endstruct
private function Action takes nothing returns nothing
local Shield d = Shield.create()
local integer i = 0
local real x
local real y
set d.c = GetTriggerUnit()
set d.level = GetUnitAbilityLevel(d.c, ABIL_ID)
set d.rotatecounter = 0
set d.durationcounter = 0
loop
set i = i + 1
set x = GetUnitX(d.c) + ORBIT_RADIUS * Cos(360/GetOrbAmount(d.level)*i * bj_DEGTORAD)
set y = GetUnitY(d.c) + ORBIT_RADIUS * Sin(360/GetOrbAmount(d.level)*i * bj_DEGTORAD)
set d.d<i> = CreateUnit(GetOwningPlayer(d.c), DUMMY_ID, x, y, 0.)
set d.e<i> = AddSpecialEffectTarget(READY_SFX, d.d<i>, "origin")
set d.cooldown<i> = 0
set d.onCooldown<i> = false
exitwhen i == MAX_ORBS
endloop
call d.startPeriodic()
endfunction
private function Init takes nothing returns nothing
call GT_AddStartsEffectAction(function Action, ABIL_ID)
endfunction
endscope</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
Known Bugs:
-None
How to Implement:
-Make sure you have the 'dummy.mdl' model in your map.
-Copy the Ability and the Dummy Unit (that looks like a chicken) into your map.
-If you want the spell to cast a spell instead of damaging, add the dummy chain lightning spell OR make a different dummy spell and set the DUMMY_SPELL_ID variable to the rawcode of the spell (found using ctrl+D when in the object editor)
-Make sure that you have all the requirements met.
-Copy the spell code into your map.
-Copy the Ability and the Dummy Unit (that looks like a chicken) into your map.
-If you want the spell to cast a spell instead of damaging, add the dummy chain lightning spell OR make a different dummy spell and set the DUMMY_SPELL_ID variable to the rawcode of the spell (found using ctrl+D when in the object editor)
-Make sure that you have all the requirements met.
-Copy the spell code into your map.
Credits not necessary, but please do not act like the author of this spell.
Feedback is appreciated.