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

Function to create effect at Z

Status
Not open for further replies.
Level 12
Joined
Sep 4, 2007
Messages
407
I need a library or anything to create a special effect at the exact position I want for the amont of time i want. Oh and this position also includes 'Z' (thats the problem actually...). must be leakless (otherwise i can do it myself) =)

I already know how to gather the Z, just dunno how to make the effect to get a z height (actually i know how it is done, but not how to do. you need to create a EffectDummy unit and attach the effect to it, then alter the EffectDummy FlyHeight)

must use jass or vjass.
 
shouldn't be too hard.

let me take a look.

JASS:
library CreateEffect
globals
    integer dummyid = 'hpea'
endglobals
function CreateEffect takes real x, real y, real z, string filename returns nothing
    local unit dummy = CreateUnit(Player(12), dummyid, x, y, 0)
    local location l = Location(x, y)
    local real z1 = GetLocationZ(l)
    call UnitAddAbility(dummy, 'Arav')
    call SetUnitFlyHeight(dummy, z1+(z-z1), 0)
    call RemoveLocation(l)
    call DestroyEffect(AddSpecialEffectTarget(filename, dummy, "origin"))
    set l = null
    call RemoveUnit(dummy)
    set dummy = null
endfunction
endlibrary
 
JASS:
library CreateEffect
globals
    integer dummyid = 'hpea'
endglobals
function CreateEffect takes real x, real y, real z, string filename, real timeout returns nothing
    local unit dummy = CreateUnit(Player(12), dummyid, x, y, 0)
    local location l = Location(x, y)
    local real z1 = GetLocationZ(l)
    call UnitAddAbility(dummy, 'Arav')
    call SetUnitFlyHeight(dummy, z1+(z-z1), 0)
    call RemoveLocation(l)
    call DestroyEffect(AddSpecialEffectTarget(filename, dummy, "origin"))
    set l = null
    call UnitApplyTimedLife(dummy, 'BTLF', timeout)
    set dummy = null
endfunction
endlibrary
 
There are two options:

1 - This uses an invisible platform to create the effect with Z. Just note that this can lag spike if you make like 200+ of them or something:
JASS:
library EffectZ
    globals
        private effect Zeffect
    endglobals
    
    public function AddSpecialEffectZ takes string path, real x, real y, real z returns effect
        local destructable d = CreateDestructableZ('OTip',x,y,z,0,1,0)
        set Zeffect = AddSpecialEffect(path,x,y)
        call RemoveDestructable(d)
        set d = null
        return Zeffect
    endfunction
endlibrary

    /*This is for automatically adding the location (x,y)'s height.
    globals
        private location L = Location(0,0) //might as well use just one location throughout the map for this func
    endglobals
    public function AddSpecialEffectZ takes string path, real x, real y, real z returns effect
        local destructable d 
        call MoveLocation(L,x,y)
        set d = CreateDestructableZ('OTip',x,y,z+GetLocationZ(L),0,1,0)
        set Zeffect = AddSpecialEffect(path,x,y)
        call RemoveDestructable(d)
        set d = null
        return Zeffect
    endfunction*/

It works fine though.

2 - This method is the same one Ikillforeyou showed:
JASS:
library EffectZ
    globals
        private constant integer DUMCODE = 'h000'
        private location L = Location(0,0)
        private unit dum
    endglobals
    
    public function AddSpecialEffectZ takes string path, real x, real y, real z, real time, real face returns effect
        set dum = CreateUnit(Player(15),DUMCODE,x,y,face)
        call UnitAddAbility(dum,'Amrf')
        call UnitRemoveAbility(dum,'Amrf')
        call MoveLocation(L,x,y)
        call SetUnitFlyHeight(dum,GetLocationZ(L)+z,0)
        call UnitApplyTimedLife(dum,'BTLF',time)
        return AddSpecialEffectTarget(path,dum,"origin")
    endfunction
endlibrary

It just returns the effect instead of destroying it immediately. Although, you can use whichever you'd like.
 
Level 12
Joined
Sep 4, 2007
Messages
407
thanks folks! =}

Uses CustomEffect.

JASS:
library Test requires CustomEffect

function CreateEffectOnPos takes real x, real y, real z, real f, string mdl returns CustomEffect
    local CustomEffect ce = CustomEffect.create(x, y, z, f)
    set ce.sfx = mdl
    return ce
endfunction

endlibrary

the z is not applied. i think the unit's flying height is not being altered o_O
 
Last edited by a moderator:
Level 18
Joined
Jan 21, 2006
Messages
2,552
Pharoah_ said:
Maybe it's because you need
call UnitApplyTimedLife (dummy, 'BTLF', 3.00)
Replace 3.00 with the duration you want.

Actually as long as he kills the unit the unit will still linger around as a corpse for quite some time before being removed from the game. It is plenty enough time for the effect to play and end, there is no need to apply a timed-life.
 
Status
Not open for further replies.
Top