• 🏆 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!

[General] Can't transfer info to the Buff System

Status
Not open for further replies.
Level 7
Joined
Feb 9, 2021
Messages
301
I am using [vJASS] - Buff System and [vJASS] - Movespeed. With this, I am trying to create a slow buff. The problem is that I can't pass a real to the slow buff from the first time for some reason, and I can't understand what is the problem. In other words, percentBonus returns zero.

JASS:
library SlowBuff /*
    [I]/ uses /[/I]
    [I]/ Buff /[/I]
    */ Movespeed

    struct SlowBuff extends Buff
        private static constant integer RAWCODE         = 'A01E'
        private static constant integer DISPEL_TYPE     = BUFF_NEGATIVE
        private static constant integer STACK_TYPE      = BUFF_STACK_FULL
   
        public real percentBonus
        public integer flatBonus
        public string slowEffectId
        public string slowEffectAttachment
        //real slowDuration
        private effect sfx
   
        Movespeed ms
 
        method onRemove takes nothing returns nothing
            call this.ms.destroy()
            call DestroyEffect(this.sfx)
       
            set this.sfx = null
        endmethod
 
        method onApply takes nothing returns nothing
            debug call BJDebugMsg("SlowBuff Applied to the Target: " + GetUnitName(target))

            set this.ms = Movespeed.create(target, -this.percentBonus, -this.flatBonus)
            set this.sfx = AddSpecialEffectTarget(this.slowEffectId, target, this.slowEffectAttachment)
            //call Effect.createTarget(this.slowEffectId, target, "origin", 3.0)
            debug call BJDebugMsg("SlowEffect Applied to the Target: " + GetUnitName(target))
            debug call BJDebugMsg("SlowEffect Slow Percent = " + R2S(-this.percentBonus) + "; Flat Reduction = " + R2S(-this.flatBonus) )

        endmethod

        implement BuffApply
    endstruct
endlibrary



JASS:
library CrocPoison /*

    [I]/ uses /[/I]
    [I]/SpellFramework    /[/I]
    [I]/BaseFunctions     /[/I]
    [I]/DDS               /[/I]
    */Buff
    private module SpellConfiguration

        static constant integer SPELL_ABILITY_ID    = 'A01L'
   
        //Models and Effects
        static constant string POISION_EFFECT_ID    = "Abilities\\PWeapons\\PPoisonSting\\PPoisonStingTarget.mdl"
        static constant string SLOW_BUFF_EFFECT     = ""
        static constant string SLOW_BUFF_ATTACHMENT = ""
   
   
        //Params

        static constant real POISION_DURATION       = 4.0
        static constant real POISION_SLOW           = 5.
        static constant real POISION_PEREODIC       = 1.0
   
        static method Dmg takes unit caster returns real
            return 50.0 * GetUnitLevel(caster) + 0.1 * GetHeroStr(caster, true) * POISION_PEREODIC / POISION_DURATION
        endmethod
   
        static method Targets takes unit caster, unit target returns boolean
            return GetWidgetLife(target) > 0.405 and /*
             [I]/ not IsUnitType(target, UNIT_TYPE_STRUCTURE) and /[/I]
             [I]/ not IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) and /[/I]
             */ IsUnitEnemy(target, GetOwningPlayer(caster))
        endmethod
   
    endmodule

    struct HookPoisionBuff extends Buff
        implement SpellConfiguration

        private static constant integer RAWCODE         = 'A01K'
        private static constant integer DISPEL_TYPE     = BUFF_NEGATIVE
        private static constant integer STACK_TYPE      = BUFF_STACK_NONE
   
        //Damage Types
        static constant attacktype ATTACK_TYPE          = ATTACK_TYPE_MAGIC
        static constant damagetype DAMAGE_TYPE          = DAMAGE_TYPE_MAGIC
        static constant weapontype WEAPON_TYPE          = WEAPON_TYPE_WHOKNOWS
   
        real dps
        private timer timer
        private effect effect
 
        method onRemove takes nothing returns nothing
            call DestroyEffect(effect)
            call ReleaseTimer(this.timer)
            set this.timer = null
            set this.effect = null
        endmethod
   
        static method periodic takes nothing returns nothing
            local thistype this = GetTimerData(GetExpiredTimer())
            set damageCode = UnitIndex[source]
            call UnitDamageTarget(source, target, dps, false, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
        endmethod
 
        method onApply takes nothing returns nothing
            set this.timer = NewTimerEx(this)
            call TimerStart(this.timer, POISION_PEREODIC , true, function thistype.periodic)
            set effect = AddSpecialEffectTarget(POISION_EFFECT_ID, target, "origin")
            debug call BJDebugMsg("[Hook Poision] Buff Applied")

        endmethod
   
        implement DDS
        implement BuffApply
    endstruct

    struct HookPoistionSpell extends array
        implement SpellConfiguration
        private real dps

        private method onDamageOutgoing takes nothing returns nothing
            local SlowBuff sb
            local HookPoisionBuff hp
            if (archetype == Archetype.PHYSICAL) then
                debug call BJDebugMsg("[Hook Poision] Poision Applied")
                set hp = HookPoisionBuff.add(source, target)
                set hp.duration = POISION_DURATION
                set hp.dps = Dmg(source)
                set sb = SlowBuff.add(source, target)
                set sb.duration = POISION_DURATION
                set sb.percentBonus = POISION_SLOW
                set sb.slowEffectId = SLOW_BUFF_EFFECT
                set sb.slowEffectAttachment = SLOW_BUFF_ATTACHMENT          
            endif
       
        endmethod
   
        implement DDS
   
        private static method run takes nothing returns nothing
            local unit caster = GetTriggerUnit()
            local integer abilityLevel = GetUnitAbilityLevel(caster, SPELL_ABILITY_ID)
            local thistype this = UnitIndex[caster]
            if GetLearnedSkill() == SPELL_ABILITY_ID then
                if abilityLevel == 1 then
                    call enableDamageEventLocalOutgoing()
                endif
           
                set this.dps = Dmg(caster)
            endif
       
            set caster = null
        endmethod
   
        private static method onInit takes nothing returns nothing
                call RegisterAnyPlayerUnitEvent(EVENT_PLAYER_HERO_SKILL, function thistype.run)
        endmethod

    endstruct

endlibrary
 
Last edited:
Status
Not open for further replies.
Top