- Joined
- Sep 9, 2006
- Messages
- 92
Im trying to recreate a gui spell as jass; the spell simply damages the target every second over 9 seconds, but when the target is damaged by the caster (from damage other than the ability itself) there is a chance that the spell will last a second longer (this is timed so theoretically the spell will only last around 15 seconds max). I'm not too good at jass; here is the basic damage "trigger" that will last 9 seconds:
I need help turning
into jass
JASS:
scope Rend initializer Init
globals
//ability id of Rend
private constant integer ABILITY_ID = 'A005'
//refresh rate of timer
private constant real INTERVAL = 0.01
//total ticks of spell
private constant integer TICKS = 9
//number of seconds between ticks
private constant real SECONDS = 1.00
//damage attack type
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
//damage damage type
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
//damage weapon type
private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
//blood effect when dealing damage
private constant string BLOOD_EFFECT = "Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl"
//attach point
private constant string EFFECT_ATTACH = "chest"
//do or dont display floating damage text
private constant boolean DISPLAY_DAMAGE = true
private hashtable h = InitHashtable()
endglobals
private function Damage takes integer level, integer agi, integer str returns real
return I2R(level) * ( I2R(agi) + 3.00 * (I2R(str)) ) / 5.00
endfunction
private struct data
unit c
unit t
timer tim = CreateTimer()
integer lvl
integer ticks = TICKS
integer time = 0
integer agi
integer str
endstruct
private function Text takes unit u, real d returns nothing
local texttag text = CreateTextTag()
local string s = I2S(R2I(d)) + "!"
call SetTextTagText(text, s, .018)
call SetTextTagPosUnit(text, u, 24.00)
call SetTextTagColor(text, 255, 0, 0, 255)
call SetTextTagVelocity( text, 0.00, .089 )
call SetTextTagPermanent( text, false )
call SetTextTagLifespan( text, 1.50 )
call SetTextTagFadepoint( text, 1.00 )
endfunction
private function periodic takes nothing returns nothing
local data dat = LoadInteger(h,GetHandleId(GetExpiredTimer()),0)
local real damage
if GetUnitState(dat.t, UNIT_STATE_LIFE) > 0 then
if dat.time >= 0 then
set dat.time = dat.time - 1
else
if dat.ticks > 0 then
set dat.ticks = dat.ticks - 1
set damage = Damage(dat.lvl, dat.agi, dat.str)
call UnitDamageTarget(dat.c, dat.t, damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
if DISPLAY_DAMAGE == true then
call Text( dat.t, damage )
endif
call DestroyEffect(AddSpecialEffectTarget(BLOOD_EFFECT, dat.t, EFFECT_ATTACH))
if dat.ticks > 0 then
set dat.time = R2I(SECONDS / INTERVAL)
else
call PauseTimer(dat.tim)
call DestroyTimer(dat.tim)
call FlushChildHashtable(h,GetHandleId(dat.tim))
call dat.destroy()
endif
endif
endif
else
call PauseTimer(dat.tim)
call DestroyTimer(dat.tim)
call FlushChildHashtable(h,GetHandleId(dat.tim))
call dat.destroy()
endif
endfunction
private function Conditions takes nothing returns boolean
local data dat
if GetSpellAbilityId() == ABILITY_ID then
set dat = data.create()
set dat.t = GetSpellTargetUnit()
set dat.c = GetTriggerUnit()
set dat.lvl = GetUnitAbilityLevel(dat.c, ABILITY_ID)
set dat.agi = GetHeroAgi(dat.c, true)
set dat.str = GetHeroStr(dat.c, true)
call SaveInteger(h,GetHandleId(dat.tim),0,dat)
call TimerStart(dat.tim,INTERVAL,true,function periodic)
endif
return false
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Conditions ) )
call Preload(BLOOD_EFFECT)
set t = null
endfunction
endscope
I need help turning
-
Unit Group - Pick every unit in AllUnits and do (Actions)
-
Loop - Actions
-
Trigger - Add to Rend AddTicks <gen> the event (Unit - (Picked unit) Takes damage)
-
-