tommerbob
Minecraft. :D
- Reaction score
- 110
Okay, I think it's time to start learning Jass. I read through a couple of the tutorials here, and I want to practice as I learn (obviously), so I came up with this spell.
The caster channels for 3 seconds, pulling the target enemy toward him, dealing damage to it equal to 5% of its max hitpoints each second. The target is disabled for the duration.
I realize it probably totally sucks, but hey, its my first real try at Jass. Here is the code:
I'm wondering how I can make it better. (this is a total practice spell, so I don't care if it totally sucks, I can trash it). I have tons of questions, haha, but for now I'm just curious how I can improve on the basic stuff. Thanks for looking.
EDIT: Talk to me like I'm a total noob. I probably won't understand you anyway.
The caster channels for 3 seconds, pulling the target enemy toward him, dealing damage to it equal to 5% of its max hitpoints each second. The target is disabled for the duration.
I realize it probably totally sucks, but hey, its my first real try at Jass. Here is the code:
JASS:
function Pull takes nothing returns nothing
local location c = GetUnitLoc(udg_caster)
local real r = (GetUnitState(udg_target, UNIT_STATE_MAX_LIFE) * 0.05) * 0.03 // Deals damage = 5% max hp per second
local real d = DistanceBetweenPoints(GetUnitLoc(udg_target), c)
local location l = PolarProjectionBJ(GetUnitLoc(udg_target), d * 0.03, GetUnitFacing(udg_target))
call SetUnitFacing(udg_target, AngleBetweenPoints(GetUnitLoc(udg_target), c))
call SetUnitX(udg_target, GetLocationX(l))
call SetUnitY(udg_target, GetLocationY(l))
call UnitDamageTarget(udg_caster, udg_target, r, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
call RemoveLocation(l)
call RemoveLocation(c)
set l = null
set c = null
endfunction
function Cast takes nothing returns nothing
local timer t = CreateTimer()
set udg_caster = GetTriggerUnit()
set udg_target = GetSpellTargetUnit()
call PauseUnit(udg_target, true)
call TimerStart(t, 0.03, true, function Pull)
call TriggerSleepAction(3.00)
call DestroyTimer(t)
call PauseUnit(udg_target, false)
set udg_caster = null
set udg_target = null
set t = null
endfunction
function InitTrig_Test takes nothing returns nothing
set gg_trg_Test = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Test, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction(gg_trg_Test, function Cast)
endfunction
I'm wondering how I can make it better. (this is a total practice spell, so I don't care if it totally sucks, I can trash it). I have tons of questions, haha, but for now I'm just curious how I can improve on the basic stuff. Thanks for looking.
EDIT: Talk to me like I'm a total noob. I probably won't understand you anyway.