Trollvottel
never aging title
- Reaction score
- 261
Description:
A fun spell, i made it when i had nothing to do and i wanted to test the timer ticker system
Throws a hammer at the target location. Units in range will be damaged and knockbacked.
GUI/Jass: Jass
vJass: yes (so it requires newgen)
Uses Timer Ticker system.
Hard to take a screenshot...
but here are some screenshots:
Throws the hammer overhead:
Throws it again:
Now you see the eruption (or not) and the knockback
Now the Code (I hope it is leakless):
A fun spell, i made it when i had nothing to do and i wanted to test the timer ticker system
Throws a hammer at the target location. Units in range will be damaged and knockbacked.
GUI/Jass: Jass
vJass: yes (so it requires newgen)
Uses Timer Ticker system.
Hard to take a screenshot...
but here are some screenshots:
Throws the hammer overhead:



Now the Code (I hope it is leakless):
JASS:
scope hammerblow
// //================================================================\\
// || How to implement: ||
// || 1. copy the dummy and the spell ||
// || 2. copy the spellcode and if necessary the time ticker system ||
// || 3. change the values below and have fun ||
// \\================================================================//
globals
private constant integer rawid = 'A000' // spell rawcode
private constant integer dummyraw = 'h000' // dummy rawcode
private constant real knockdis = 400 // distance of knockback
private constant real knockspeed = 20 // knockback speed
private constant real radius = 400 // radius of damage and knockback
private constant real damage = 150 // damage per level
endglobals
globals
private constant string lightningcode = "LEAS"
//Now the Red/Green/Blue/Alpha values of the lightning. 1.00 = 100%
private constant real red = 1
private constant real green = 1
private constant real blue = 1
private constant real alpha = 1.00
endglobals
private function Trig_Spell_Conditions takes nothing returns boolean
return GetSpellAbilityId() == rawid
endfunction
//Knockback
private struct s
unit u
real dis
real speed
real angle
effect e
endstruct
private function knock_child takes nothing returns boolean
local s dat = TT_GetData()
set dat.dis = dat.dis - dat.speed
if dat.dis >= 0 then
call SetUnitFacing(dat.u, GetUnitFacing(dat.u) + 10 )
call SetUnitPosition(dat.u, GetUnitX(dat.u) + dat.speed * Cos(dat.angle * bj_DEGTORAD), GetUnitY(dat.u) + dat.speed * Sin(dat.angle * bj_DEGTORAD))
else
call DestroyEffect(dat.e)
call SetUnitPathing(dat.u, true)
call dat.destroy()
return true
endif
return false
endfunction
function knockback takes unit u, real dis, real speed, real angle returns nothing
local s dat = s.create()
call SetUnitPathing(u, false)
set dat.u = u
set dat.dis = dis
set dat.speed = speed
set dat.angle = angle
set dat.e = AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", dat.u, "origin")
call TT_Start(function knock_child, dat)
endfunction
//Spell
private struct hammer
unit caster
unit dummy
real dis
real angle
real targx
real targy
real curx
real cury
real height = 0
real minus = 0
real curdis
lightning light
method onDestroy takes nothing returns nothing
call RemoveUnit(this.dummy)
call DestroyLightning(this.light)
endmethod
endstruct
private function periodic takes nothing returns boolean
local hammer dat = TT_GetData()
local group g
local unit u
local terraindeformation t
set dat.curx = dat.curx + dat.dis / 10 * Cos(dat.angle * bj_DEGTORAD)
set dat.cury = dat.cury + dat.dis / 10 * Sin(dat.angle * bj_DEGTORAD)
set dat.minus = dat.minus + 1.00
if dat.minus > 10 then
set dat.height = dat.height - dat.curdis / 10
else
set dat.height = dat.height + dat.curdis / 10
endif
call SetUnitPosition(dat.dummy, dat.curx,dat.cury)
call SetUnitFlyHeight(dat.dummy, dat.height, 0)
call MoveLightningEx(dat.light, false, GetUnitX(dat.caster), GetUnitY(dat.caster), 40, dat.curx, dat.cury, dat.height)
set dat.curdis = SquareRoot((GetUnitX(dat.caster) - dat.curx ) * (GetUnitX(dat.caster) - dat.curx ) + (GetUnitY(dat.caster) - dat.cury ) * (GetUnitY(dat.caster) - dat.cury ))
if dat.curdis >= dat.dis then
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", dat.curx, dat.cury))
set t = TerrainDeformCrater(dat.curx, dat.cury, radius, 80, R2I(200), false)
set g = CreateGroup()
call GroupEnumUnitsInRange(g, dat.curx, dat.cury, radius, null)
loop
set u = FirstOfGroup(g)
call GroupRemoveUnit(g,u)
exitwhen u == null
if GetUnitState(u, UNIT_STATE_LIFE) > 0 and IsUnitEnemy(u, GetOwningPlayer(dat.caster)) then
call UnitDamageTarget(dat.caster, u, damage * GetUnitAbilityLevel(dat.caster, rawid), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call knockback(u, knockdis, knockspeed, bj_RADTODEG * Atan2(GetUnitY(u) - dat.cury, GetUnitX(u) - dat.curx ))
endif
endloop
call DestroyGroup(g)
call dat.destroy()
set g = null
set u = null
set t = null
return true
endif
return false
endfunction
private function Trig_Spell_Actions takes nothing returns nothing
local hammer dat = hammer.create()
local location loc = GetSpellTargetLoc()
set dat.targx = GetLocationX(loc)
set dat.targy = GetLocationY(loc)
call RemoveLocation(loc)
set dat.caster = GetTriggerUnit()
set dat.angle = bj_RADTODEG * Atan2(dat.targy - GetUnitY(dat.caster), dat.targx - GetUnitX(dat.caster))
set dat.dis = SquareRoot((GetUnitX(dat.caster) - dat.targx ) * (GetUnitX(dat.caster) - dat.targx ) + (GetUnitY(dat.caster) - dat.targy ) * (GetUnitY(dat.caster) - dat.targy ))
set dat.curx = GetUnitX(dat.caster) - dat.dis * Cos(dat.angle * bj_DEGTORAD)
set dat.cury = GetUnitY(dat.caster) - dat.dis * Sin(dat.angle * bj_DEGTORAD)
set dat.light = AddLightning(lightningcode, false, GetUnitX(dat.caster), GetUnitY(dat.caster), dat.curx, dat.cury)
call SetLightningColor(dat.light, red, green, blue, alpha)
set dat.dummy = CreateUnit(GetOwningPlayer(dat.caster), dummyraw, dat.curx, dat.cury, dat.angle)
call TT_Start( function periodic, dat)
set loc = null
endfunction
//===========================================================================
function InitTrig_Spell takes nothing returns nothing
set gg_trg_Spell = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spell, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
call TriggerAddCondition( gg_trg_Spell, Condition( function Trig_Spell_Conditions ) )
call TriggerAddAction( gg_trg_Spell, function Trig_Spell_Actions )
endfunction
endscope
Attachments
-
23.3 KB Views: 665