• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Nova Spell

Status
Not open for further replies.
Level 8
Joined
Jul 28, 2008
Messages
211
I made a nova spell and it's doing something weird.

JASS:
scope Death initializer Init

globals

    private constant integer SPELL_ID = 'A000'
    private constant integer MINION_ID = 'u000'
    private constant integer NOVA_RADIUS = 500
    private constant real TIME = 0.035
    private constant  real RADIUS = 100.00
    private constant string NOVA_EFFECT = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl"
    
    private boolexpr b
    private hashtable h = InitHashtable()
    private group GROUP = CreateGroup()

endglobals

private function Damage takes integer lvl returns real
    return I2R(lvl * 25 + 10)
endfunction

private function DamageOverTime takes integer lvl returns real
    return I2R(lvl * 5 + 5)
endfunction

private function NovaFilter takes nothing returns boolean
    return (IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) == false)
endfunction

private function Cond takes nothing returns boolean
    return GetSpellAbilityId() == SPELL_ID
endfunction

private function DoT takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit target = LoadUnitHandle(h, GetHandleId(t), 1)
    local unit caster = LoadUnitHandle(h, GetHandleId(t), 0)
    call UnitDamageTarget(caster, target, DamageOverTime(GetUnitAbilityLevel(caster, SPELL_ID)), false, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    if GetUnitState(target, UNIT_STATE_LIFE) < 0.415 then
        call CreateUnit(GetOwningPlayer(caster), MINION_ID, GetUnitX(target), GetUnitY(target), 0.00)
        call FlushChildHashtable(h, GetHandleId(t))
        call PauseTimer(t)
        call DestroyTimer(t)
    endif
    set t = null
    set target = null
    set caster = null
endfunction

private function StartDoT takes unit Target, unit Caster returns nothing
    local timer t = CreateTimer()
    local unit caster = Caster
    local unit target = Target
    call SaveUnitHandle(h, GetHandleId(t), 0, caster)
    call SaveUnitHandle(h, GetHandleId(t), 1, target)
    call TimerStart(t, 0.035, true, function DoT)
    set caster = null
    set target = null
    set t = null
endfunction

private function Callback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit caster = LoadUnitHandle(h, GetHandleId(t), 0)
    local real dist = LoadReal(h, GetHandleId(t), 1)
    local unit temp
    local integer i = 0
    local real angle = 0
    local real x
    local real y
    if dist >= NOVA_RADIUS then
        call FlushChildHashtable(h, GetHandleId(t))
        call PauseTimer(t)
        call DestroyTimer(t)
    else
        loop
            exitwhen i >= 8
            set x = GetUnitX(caster) + dist * Cos(angle * bj_DEGTORAD)
            set y = GetUnitY(caster) + dist * Sin(angle * bj_DEGTORAD)
            call DestroyEffect(AddSpecialEffect(NOVA_EFFECT, x, y))
            call GroupEnumUnitsInRange(GROUP, x, y, RADIUS, b)
            loop
                set temp = FirstOfGroup(GROUP)
                exitwhen temp == null
                if IsUnitEnemy(temp, GetOwningPlayer(caster)) then
                    call UnitDamageTarget(caster, temp, Damage(GetUnitAbilityLevel(caster, SPELL_ID)), false, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                    if GetUnitState(temp, UNIT_STATE_LIFE) < 0.415 then
                        call StartDoT(temp, caster)
                    else
                        call CreateUnit(GetOwningPlayer(caster), MINION_ID, GetUnitX(temp), GetUnitY(temp), 0.00)
                    endif
                endif
                call GroupRemoveUnit(GROUP, temp)
            endloop
            set angle = angle + 40
            set i = i + 1
            set dist = dist + RADIUS
        endloop
    endif
    set t = null
    set caster = null
endfunction

private function Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real dist = 50.00
    local timer t = CreateTimer()
    
    call SaveUnitHandle(h, GetHandleId(t), 0, caster)
    call SaveReal(h, GetHandleId(t), 1, dist)
    call TimerStart(t, TIME, true, function Callback)
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 Cond))
    call TriggerAddAction(t, function Actions)
    
    set b = Filter(function NovaFilter)
endfunction

endscope

Now, I made the spell in 15 minutes, and I was just typing and typing, so I don't remember some parts of it. And I usually miss some minor things, so I posted it here.

NOTE: I fixed something AFTER the screenshot. The effect spamm is the same, but there are less minions.

Spell Description: The user creates an expanding circle of pure evil. The circle deals instant damage and more damage over time. Units that die under the effect of the nova will be resurected as skeletons.

NOTE 2: Yeah, the spell will last forever. I'll change that later, but my problem is that it isn't a circle (nova).

NOTE 3: I think I know how to make it like a nova, but I'm not sure. So I still need help!
 

Attachments

  • WTF.jpg
    WTF.jpg
    238.9 KB · Views: 94
Level 8
Joined
Jul 28, 2008
Messages
211
Errrm.... what the hell did I write? Now that I took a look at the code, it seems weird and... stupid.

EDIT: It seems that every kill summons 6-8 minions. And when I remove the
JASS:
set dist = dist + RADIUS
it makes a nice snake effect lol

EDIT 2: Wow, I don't even need the Callback trigger...

EDIT 3: Nevermind, I'll remake it. This is all messed up.
 
Last edited:
Status
Not open for further replies.
Top