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
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top