Windslash - Weird Offsets.

NeuroToxin

New Member
Reaction score
46
Okay, So In this spell, Im trying to tweak it to use .25 time, (its my spell) And for some reason, on the first cast, when I try to set him to the targeted units X, it doesn't, its actually quite a distance off, and then also, after the first cast, the caster just disappears entirely. Heres the code
JASS:

   scope Windslash initializer init
    //========================================================================================
    //======================================SETUP============================================
    //========================================================================================
    globals
        //The effect that's played with every attack
        private constant string EFFECT_ON_HIT = "Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl"
        
        //The ability code of the ability, "Wind Slash"
        private constant integer ABILITY_CODE = 'A000'
        
        //The ability code of the Crow Form ability (Should be the same unless you tampered with)
        private constant integer CROW_FORM ='Arav'
        
        //The effect attached to the weapon.
        private constant string EFFECT_ON_WEAPON = "Abilities\\Spells\\Orc\\EtherealForm\\SpiritWalkerChange.mdl"
        
        //The effect at the location of the unit being slammed (Final attack)
        private constant string FINAL_EFFECT = "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl"
        
        //Attack type for the damage
        private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
        
        //Damage type for the damage
        private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
        
        //Weapon type for the damage
        private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
        
        //Animation to be played while the attack goes on.
        private constant string ANIMATION_ATTACK = "attack"
        
        //Attachment point for the EFFECT_ON_HIT
        private constant string ATTACHMENT_POINT = "origin"
        
        //Attachment point for the EFFECT_ON_WEAPON effect.
        private constant string CASTER_ATTACH_POINT = "origin"
        
        //The final effect to be played on each individual unit in the final AOE
        private constant string FINAL_AOE_EFFECT = "Objects\\Spawnmodels\\Undead\\UndeadDissipate\\UndeadDissipate.mdl"
        private constant string FINAL_ATTACHED = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
        
        private group tempgroup = CreateGroup()
    endglobals
    
    private function Units takes unit u, player casterOwner returns boolean
        return (not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE)) and IsUnitEnemy(u, casterOwner)
    endfunction
    
    private function NUMBER_OF_SLASHES takes integer lvl returns real
        return 4 + (lvl * 2.)
    endfunction
        
    private function HEIGHT takes integer lvl returns real
        return 200 + (lvl * 25.)
    endfunction
        
    private function DAMAGE_PER_STRIKE takes integer lvl returns real
        return (lvl * 6.25)
    endfunction
        
    private function RATE_OF_FLYING takes integer lvl returns real
        return 600 + (lvl * 0.)
    endfunction
    
    private function FINAL_SPEED takes integer lvl returns real
        return 25 + (lvl * 0.)
    endfunction
    
    private function FINAL_AOE_DAMAGE takes integer lvl returns real
        return lvl * 40.
    endfunction
    
    private function FINAL_AOE takes integer lvl returns real
        return lvl * 60.
    endfunction
        
    //========================================================================================
    //=====================================ENDSETUP=========================================
    //========================================================================================
          
    private struct slash
        unit Caster
        unit Target
        integer Tempint = 1
        effect AttachedEffect
        effect FinalEffect
        static integer structtype
    endstruct
    
    private function FinalUnits takes nothing returns boolean
        local slash s = slash.structtype
        local unit f  = GetFilterUnit()
        local real damage = FINAL_AOE_DAMAGE(GetUnitAbilityLevel(s.Caster, ABILITY_CODE))
        if GetUnitTypeId(f) != GetUnitTypeId(s.Caster) and Units(f, GetOwningPlayer(s.Caster)) then
            call SetUnitX(s.Caster, GetUnitX(f))
            call SetUnitY(s.Caster, GetUnitY(f))
            call SetUnitAnimation(s.Caster, ANIMATION_ATTACK)
            call UnitDamageTarget(s.Caster, f, damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
            call DestroyEffect(AddSpecialEffectTarget(FINAL_AOE_EFFECT, f, ATTACHMENT_POINT))
        endif
        set f = null
        return false
    endfunction
        
        
    private function userFunc takes nothing returns boolean
        local slash s = KT_GetData()
        local integer ability_level = GetUnitAbilityLevel(s.Caster, ABILITY_CODE)
        local real fly_height = HEIGHT(ability_level) + 50 * s.Tempint
        local real rate = RATE_OF_FLYING(ability_level)
        local real damage = DAMAGE_PER_STRIKE(ability_level)
        local real num_slashes = NUMBER_OF_SLASHES(ability_level)
        local real final_attack_speed = FINAL_SPEED(ability_level)
        local real radius = FINAL_AOE(ability_level)
        local real offsetx
        local real offsety
        local real coffsetx
        local real coffsety
        local real angle
        local real casterX = GetUnitX(s.Caster)
        local real casterY = GetUnitY(s.Caster)
        local real targetX = GetUnitX(s.Target)
        local real targetY = GetUnitY(s.Target)
        if s.Tempint < num_slashes and GetWidgetLife(s.Target) > .405 then
            set angle = Atan2(targetY - casterY, targetX - casterX)
            call SetUnitFlyHeight(s.Target, fly_height, rate)
            call SetUnitFlyHeight(s.Caster, fly_height, (rate * .75))
            set offsetx = targetX + 20 * Cos(angle)
            set offsety = targetY + 20 * Sin(angle)
            call SetUnitFacing(s.Caster, angle * bj_RADTODEG)
            call SetUnitAnimation(s.Caster, ANIMATION_ATTACK)
            call UnitDamageTarget(s.Caster, s.Target, damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
            call DestroyEffect(AddSpecialEffectTarget(EFFECT_ON_HIT, s.Target, ATTACHMENT_POINT))
            call SetUnitX(s.Target, offsetx)
            call SetUnitY(s.Target, offsety)
            set s.Tempint = s.Tempint + 1
        elseif s.Tempint >= num_slashes or GetWidgetLife(s.Target) < .405 then
            call SetUnitFlyHeight(s.Target, 0, 1000)
            call SetUnitFlyHeight(s.Caster, 0, (rate * .75))
            set s.FinalEffect = AddSpecialEffectTarget(FINAL_ATTACHED, s.Caster, ATTACHMENT_POINT)
            call DestroyEffect(AddSpecialEffectTarget(EFFECT_ON_HIT, s.Target, ATTACHMENT_POINT))
            call DestroyEffect(AddSpecialEffect(FINAL_EFFECT, targetX, targetY))
            set slash.structtype = s
            call GroupEnumUnitsInRange(tempgroup, targetX, targetY, radius, Filter(function FinalUnits))
            call SelectUnit(s.Caster, true)
            call DestroyEffect(s.AttachedEffect)
            call DestroyEffect(s.FinalEffect)
            call PauseUnit(s.Caster, false)
            call PauseUnit(s.Target, false)
            call s.destroy()
            return true
        endif
        return false
    endfunction
        
    private function OnCast takes nothing returns boolean
        local slash s
        if GetSpellAbilityId() == ABILITY_CODE then
            set s = slash.create()
            set s.Caster = GetTriggerUnit()
            set s.Target = GetSpellTargetUnit()
            call ClearSelectionForPlayer(GetTriggerPlayer())
            call PauseUnit(s.Caster, true)
            call PauseUnit(s.Target, true)
            call UnitAddAbility(s.Caster, CROW_FORM)
            call UnitAddAbility(s.Target, CROW_FORM)
            call UnitRemoveAbility(s.Caster, CROW_FORM)
            call UnitRemoveAbility(s.Target, CROW_FORM)
            set s.AttachedEffect = AddSpecialEffectTarget(EFFECT_ON_WEAPON, s.Caster, CASTER_ATTACH_POINT)
            call SetUnitX(GetTriggerUnit(), GetUnitX(GetSpellTargetUnit()))
            call SetUnitY(GetTriggerUnit(), GetUnitY(GetSpellTargetUnit()))
            call KT_Add(function userFunc, s, .25)
        endif
        return false
    endfunction

    //===========================================================================
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddCondition( t, Condition(function OnCast) )
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    endfunction
endscope
 

emjlr3

Change can be a good thing
Reaction score
395
not that is makes a difference, but why not use s.Caster and s.Target when retrieving your coordinates?

from the looks of things, it should place the caster on top of the target
 

Solmyr

Ultra Cool Member
Reaction score
30
not that is makes a difference, but why not use s.Caster and s.Target when retrieving your coordinates?
Well, actually, it does make a difference :)

For some weird reason, [ljass]GetSpellTargetUnit()[/ljass] returns [ljass]null[/ljass] when unit returned by [ljass]GetTriggerUnit()[/ljass] is paused.

And this is exactly the issue here because you call [ljass]PauseUnit(s.Caster, true)[/ljass] before [ljass]GetUnitX(GetSpellTargetUnit())[/ljass] and [ljass]GetUnitY(GetSpellTargetUnit())[/ljass].

So, just change
to
JASS:
call SetUnitX(s.Caster, GetUnitX(s.Target))
call SetUnitY(s.Caster, GetUnitY(s.Target))

or you could pause the triggering unit after those lines, not before, but the above method is better anyway.

EDIT: And a small suggestion to make the spell look better, remove the pathing of the units during the slash. That way they won't collide midair.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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