Comments on spells&code

Immolation

Member
Reaction score
20
I've made these 2 spells for a hero, they're actually my first try to create nice spells with structs and I'd like to receive some comments about them.

First spell is,

~Blink Nova
The caster blinks near the targeted enemy, dealing damage and slowing units within 300 range. If there aren't any unit within 300 range except the target, it takes double damage.

JASS:
scope BlinkNova initializer Init

    globals
        //ID& Rawcodes & Orderstrings:
        private constant integer ABILITY_ID = 'A000'
        private constant integer SLOW_ID = 'A001'
        private constant integer BUFF_ID = 'B000'
        private constant string SLOW_ORDERSTRING = "cripple"
        
        //Effects:        
        private constant string NOVA_STRING = "Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl"
        private constant real SLOW_PERIOD = 0.50

    endglobals
    
    private function Damage takes integer level, integer int returns real
        return 35 + (45 * level) + (1.00 + (0.15 * level)) * int
    endfunction
    
    private function Area takes integer level, integer int returns real
        return 300.00
    endfunction

//===========================================================================

    private struct BlinkNova
        unit picked
        player pickedOwner
    endstruct
    
    globals
        private unit caster
        private player casterOwner
        private integer groupCount = 0
        private integer level
        private integer int
    endglobals

    private function ColorCallback takes nothing returns boolean
        local BlinkNova A = KT_GetData()
        if GetUnitAbilityLevel(A.picked, BUFF_ID) == 0 then
            call SmoothMod.green(A.picked, 1.00, 75)
            call SmoothMod.red(A.picked, 1.00, 75)
            return true
        endif
        return false
    endfunction

    private function GroupCallback takes nothing returns boolean
        local BlinkNova A = BlinkNova.create()
        set A.picked = GetFilterUnit()
        set A.pickedOwner = GetOwningPlayer(A.picked)
        if IsPlayerEnemy(casterOwner, A.pickedOwner) == true and GetWidgetLife(A.picked) > 0 then
            if GetUnitAbilityLevel(A.picked, BUFF_ID) == 0 then
                call SmoothMod.green(A.picked, 1.00, -75)
                call SmoothMod.red(A.picked, 1.00, -75)
                call SmoothMod.alpha(A.picked, 1.00, -33)
                call KT_Add(function ColorCallback, A, SLOW_PERIOD)
            endif
            call Damage_Spell(caster, A.picked, Damage(level, int))
            call Utils_DUMMY_TargetCast(SLOW_ID, level, SLOW_ORDERSTRING, A.picked)
            set groupCount = groupCount + 1
        endif
        return false
    endfunction

    private function Main takes nothing returns boolean
        local unit target = GetSpellTargetUnit()
        local real x = GetSpellTargetX()
        local real y = GetSpellTargetY()
        set caster = GetTriggerUnit()
        set casterOwner = GetOwningPlayer(caster)
        set level = GetUnitAbilityLevel(caster, ABILITY_ID)
        set int = GetHeroInt(caster, true)
        call SetUnitPosition(caster, x, y)
        call DestroyEffect(AddSpecialEffect(NOVA_STRING, x, y))
        call GroupEnumUnitsInRange(GROUP, x, y, Area(level, int), Condition(function GroupCallback))
        if groupCount == 1 then
            call Damage_Spell(caster, target, Damage(level, int))
        endif
        set groupCount = 0
        set target = null
        return false
    endfunction

//===========================================================================
    private function Init takes nothing returns nothing
        call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(), ABILITY_ID), Condition(function Main))
        call Utils_PreloadAbility(ABILITY_ID)
        call Utils_PreloadAbility(SLOW_ID)
        call Preload(NOVA_STRING)
    endfunction
endscope


Second spell:

~Blizzard
Creates a blizzard centered around target point, dealing damage and slowing enemies each second.
JASS:
scope Blizzard initializer Init

    globals
        //ID& Rawcodes & Orderstrings:
        private constant integer ABILITY_ID = 'A002'
        private constant integer SLOW_ID = 'A003'
        private constant integer BUFF_ID = 'B001'
        private constant string SLOW_ORDERSTRING = "slow"
        
        //Effects:        
        private constant string BLIZZARD_STRING = "war3mapImported\\FrostAura.mdx"
        private constant string EFFECT_STRING = "Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorDamage.mdl"
        private constant string EFFECT_ATTACH = "chest"
        private constant real DAMAGE_PERIOD = 1.00
        private constant real SLOW_PERIOD = 0.50

    endglobals
    
    private function Damage takes integer glevel, integer gint returns real
        return 12 + 3 * glevel + ((0.08 + (0.02 * glevel)) * gint)
    endfunction
    
    private function Area takes integer level, integer int returns real
        return 300.00
    endfunction

    private function Duration takes integer level, integer int returns integer
        return 15
    endfunction

//===========================================================================

    private struct Blizzard
        unit caster
        real x
        real y
        player casterOwner
        effect sfx
        integer ticks
        integer level
        integer int
        unit picked
        player pickedOwner
    endstruct
    
    globals
        private unit gcaster
        private player gcasterOwner
        private integer glevel
        private integer gint
    endglobals

    private function ColorCallback takes nothing returns boolean
        local Blizzard B = KT_GetData()
        if GetUnitAbilityLevel(B.picked, BUFF_ID) == 0 then
            call SmoothMod.green(B.picked, 1.00, 75)
            call SmoothMod.red(B.picked, 1.00, 75)
            return true
        endif
        return false
    endfunction

    private function GroupCallback takes nothing returns boolean
        local Blizzard B = Blizzard.create()
        set B.picked = GetFilterUnit()
        set B.pickedOwner = GetOwningPlayer(B.picked)
        if IsPlayerEnemy(gcasterOwner, B.pickedOwner) == true and GetWidgetLife(B.picked) > 0 then
            if GetUnitAbilityLevel(B.picked, BUFF_ID) == 0 then
                call SmoothMod.green(B.picked, 1.00, -75)
                call SmoothMod.red(B.picked, 1.00, -75)
                call KT_Add(function ColorCallback, B, SLOW_PERIOD)
            endif
            call Utils_DUMMY_TargetCast(SLOW_ID, glevel, SLOW_ORDERSTRING, B.picked)
            call Damage_Spell(gcaster, B.picked, Damage(glevel, gint))
            call DestroyEffect(AddSpecialEffectTarget(EFFECT_STRING, B.picked, EFFECT_ATTACH))
        endif
        return false
    endfunction

    private function TimerCallback takes nothing returns boolean
        local Blizzard A = KT_GetData()
        set gcaster = A.caster
        set gcasterOwner = A.casterOwner
        set glevel = A.level
        set gint = A.int
        call GroupEnumUnitsInRange(GROUP, A.x, A.y, Area(A.level, A.int), function GroupCallback)
        set A.ticks = A.ticks - 1
        if A.ticks == 5 then
            call DestroyEffect(A.sfx) // The model takes a while to disappear <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
        endif
        if A.ticks == 0 then
            return true
        endif
        return false
    endfunction

    private function Main takes nothing returns boolean
        local Blizzard A = Blizzard.create()
        set A.caster = GetTriggerUnit()
        set A.casterOwner = GetOwningPlayer(A.caster)
        set A.x = GetSpellTargetX()
        set A.y = GetSpellTargetY()
        set A.level = GetUnitAbilityLevel(A.caster, ABILITY_ID)
        set A.int = GetHeroInt(A.caster, true)
        set A.sfx = AddSpecialEffect(BLIZZARD_STRING, A.x, A.y)
        set A.ticks = Duration(A.level, A.int)
        call KT_Add(function TimerCallback, A, DAMAGE_PERIOD)
        return false
    endfunction

//===========================================================================
    private function Init takes nothing returns nothing
        call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(), ABILITY_ID), Condition(function Main))
        call Utils_PreloadAbility(ABILITY_ID)
        call Utils_PreloadAbility(SLOW_ID)
        call Preload(BLIZZARD_STRING)
        call Preload(EFFECT_STRING)
    endfunction
endscope


Notes:
-I'm using two different spells to slow because slowing doesn't stack if applied by the same spell.
-GROUP is a global group variable declared in the header.
-Preload functions are there to prevent lagging.

Systems I'm using
:
-Uberplayer's modified SUM
-KT
-Damage
-GTrigger
-AIDS(required for Damage)
-Event(required for GTrigger and Damage)
-DummyCaster

I plan to create 4 more spells for this hero:

-Shroud of Frost: Just like Immolation, but it has a 8% to slow enemies when dealing damage.
-Frost Refuge: Can't move or act for 5 seconds. While this spell lasts, you regenerate health each sec and take 50% less damage.
-Frost Resonance: Deals additional damage based on how many slowing effects the target enemy is suffering(this is going to be really important with your other three slowing spells). Target takes double damage from this spell if it is hibernated.
-Frost Prison: Target enemy is hibernated and cannot act for 3 seconds. It takes damage each third of a second until this spell ends. When this spell ends, the prison explodes, causing damage in an AoE.

So, to summarize:
I'd like to know what you think about this hero's spells, if they are matching enough and the code of Blink Nova and Blizzard. That's all I think(it's quite too much already :p)
 

Jesus4Lyf

Good Idea™
Reaction score
397
I was skimming through and had to comment:
>-Event(required for GTrigger and Damage)
Actually, GTrigger is standalone. :p

Sorry for the irrelevancy.

>-Uberplayer's modified SUM
Shouldn't submit this requiring an ad hoc kind of resource like this. The nice thing about approved resources are they are supported and get bug fixes and such. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top