- Joined
- Jun 17, 2014
- Messages
- 236
JASS:
library ZS/*
S.Effect Manager
Created By userid907
http://www.hiveworkshop.com/members/userid907.238703/
Note : THIS LIBRARY REQUIRES NOTHING
This System allow you to create special effect on unit or point with height/z
and custom scale also with duration
How to Import :
1.Import "war3mapImported\DUMMY" from this map to your map if you don't have it.
2.Copy Dummy unit from object manager to your map if you don't have dummy unit
3.Set DUMMYID on globals to your Dummy object id
4.See test trigger on Demo trigger folder on this map to know how to use
[-----]
[-API-]
[-----]
struct ZS
static method onUnit takes string efxmodel,unit target,real z,real scale,real duration returns thistype
- Create special effect on unit (follow unit)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static method onPoint takes string efxmodel,real x1,real y1,real z,real scale,real duration returns thistype
- Create special effect on a fixed coordinate/point (x,y)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static method forceDestroy takes thistype d returns nothing
- Destroy the effect instantly.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static method SetEfxFacing takes thistype d,real newFace returns nothing
- set effect facing
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static method changeXY takes thistype d,real newX,real newY returns nothing
- set effect new X and Y
Note : This does not affect on effect that has unit target, because every (0.0312500) second the effect is moved on unit target X and Y
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static method changeZ takes thistype d,real newZ returns nothing
- set effect newZ
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static method changetoPoint takes thistype d,real newX,real newY returns nothing
- set an effect to a point, mean the effect will not follow the unit target again.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static method changetoUnit takes thistype d,unit target returns nothing
- set an effect to an unit, mean the effect will follow unit target.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
endstruct
*/
// CONFIGURATION
globals
private constant integer DUMMYID = 'eTD3' // set the dummy unit here
// NOTE : DON'T FORGET TO IMPORT "war3mapImported\DUMMY.mdx" ON THIS MAP TO YOUR MAP
private constant player DUMMYOWNER = Player(15) // the owner of DUMMYID unit
private constant real FPS = 0.0312500 // higher value = worth fps, weird effect move, lower value = worst fps, great effect move
private constant boolean TESTMODE = false // IF TRUE THE DEBUG MESSAGE WILL COME OUT
private constant boolean TESTMODELOOP = false
endglobals
// ENDCONFIGURATION
struct ZS
unit target
real duration
unit efx
real x
real y
effect tef
static integer dindex
static timer period
static thistype array data
method destroy takes nothing returns nothing
//Wash leaks
call DestroyEffect(.tef)
call KillUnit(.efx)
set .target = null
set .efx = null
set .tef = null
if dindex == -1 then
call PauseTimer( period )
endif
call this.deallocate( )
endmethod
static method forceDestroy takes thistype d returns nothing
call d.destroy()
endmethod
static method SetEfxFacing takes thistype d,real newface returns nothing
call SetUnitFacing(d.efx,newface)
endmethod
static method changeXY takes thistype d,real newX,real newY returns nothing
call SetUnitX(d.efx,newX)
call SetUnitY(d.efx,newY)
endmethod
static method changeZ takes thistype d,real newZ returns nothing
call SetUnitFlyHeight(d.efx,newZ,99999999.)
endmethod
static method changetoPoint takes thistype d,real newX,real newY returns nothing
set d.target = null
call SetUnitX(d.efx,newX)
call SetUnitY(d.efx,newY)
endmethod
static method changetoUnit takes thistype d,unit target returns nothing
set d.target = target
endmethod
static method onUnit takes string efxmodel,unit target,real z,real scale,real duration returns thistype
local thistype this
set this = thistype.allocate( )
set .target = target
set .efx = CreateUnit(DUMMYOWNER,DUMMYID,GetUnitX(.target),GetUnitY(.target),0.)
call SetUnitScale(.efx,scale,scale,scale)
set .tef = AddSpecialEffectTarget(efxmodel,.efx,"origin")
call SetUnitFlyHeight(.efx,z,99999999.)
if duration > 0.00 then
set .duration = duration
else
set .duration = 99999999.
endif
if TESTMODE then
call BJDebugMsg( "Created SFX with path : '" + efxmodel + "' with : " +GetUnitName(.target) +" as target and z =" + R2S(z) )
endif
set dindex = dindex + 1
set data[dindex] = this
if dindex == 0 then
call TimerStart( period, FPS, true, function thistype.periodic )
endif
return this
endmethod
static method onPoint takes string efxmodel,real x1,real y1,real z,real scale,real duration returns thistype
local thistype this
set this = thistype.allocate( )
set .efx = CreateUnit(DUMMYOWNER,DUMMYID,x1,y1,0.)
call SetUnitScale(.efx,scale,scale,scale)
set .tef = AddSpecialEffectTarget(efxmodel,.efx,"origin")
call SetUnitFlyHeight(.efx,z,99999999.)
if duration > 0.00 then
set .duration = duration
else
set .duration = 99999999.
endif
if TESTMODE then
call BJDebugMsg( "Created SFX with path : '" + efxmodel + "' at(" + R2S(x1) + "," + R2S(y1) + ") with z =" + R2S(z) )
endif
set dindex = dindex + 1
set data[dindex] = this
if dindex == 0 then
call TimerStart( period, FPS, true, function thistype.periodic )
endif
return this
endmethod
static method periodic takes nothing returns nothing
local integer i = 0
local ZS this
loop
exitwhen i > dindex
set this = data[i]
if .target != null then
call SetUnitX(.efx,GetUnitX(.target))
call SetUnitY(.efx,GetUnitY(.target))
endif
set .duration = .duration - FPS
if .duration <= 0 then
set data[i] = data[dindex]
set i = i - 1
set dindex = dindex - 1
call this.destroy( )
endif
set i = i + 1
endloop
endmethod
static method onInit takes nothing returns nothing
set dindex = -1
set period = CreateTimer( )
endmethod
endstruct
endlibrary
JASS:
scope test initializer Init
globals
private ZS sfx1
private ZS sfx2
private ZS sfx3
private ZS knight
private ZS cord
private ZS cord2
endglobals
private function dexcz takes nothing returns nothing
set sfx1 = ZS.onUnit("Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorTarget.mdl",gg_unit_hfoo_0006,50,2,0)
set sfx2 = ZS.onUnit("Abilities\\Weapons\\CryptFiendMissile\\CryptFiendMissileTarget.mdl",gg_unit_hfoo_0000,50,2,0)
set sfx3 = ZS.onUnit("Abilities\\Spells\\Undead\\UnholyFrenzy\\UnholyFrenzyTarget.mdl",gg_unit_hfoo_0007,200,2,0)
set knight = ZS.onUnit("Abilities\\Spells\\Human\\AerialShackles\\AerialShacklesTarget.mdl",gg_unit_hkni_0002,200,2,0)
endfunction
private function act takes nothing returns nothing
//static method onPoint takes string efxmodel,real x1,real y1,real z,real scale,real duration returns thistype
set cord = ZS.onPoint("Abilities\\Spells\\Other\\SoulBurn\\SoulBurnbuff.mdl",634,426,200.,3.,0.)
endfunction
private function act2 takes nothing returns nothing
set cord2 = ZS.onPoint("Abilities\\Spells\\Other\\Incinerate\\IncinerateBuff.mdl",914,426,200.,3.,3.)
endfunction
private function act3 takes nothing returns nothing
call ZS.forceDestroy(sfx1)
call ZS.forceDestroy(sfx2)
call ZS.forceDestroy(sfx3)
call ZS.forceDestroy(cord)
call ZS.forceDestroy(cord2)
call ZS.forceDestroy(knight)
endfunction
private function act4 takes nothing returns nothing
call ZS.changetoPoint(sfx1,800,1200)
call ZS.changetoPoint(sfx2,700,950)
call ZS.changetoPoint(sfx3,1100,950)
endfunction
private function act5 takes nothing returns nothing
call ZS.changetoUnit(cord,gg_unit_hkni_0002)
endfunction
private function act6 takes nothing returns nothing
call ZS.changeXY(sfx1,0,0)
call ZS.changeXY(sfx2,0,0)
call ZS.changeXY(sfx3,0,0)
call ZS.changeXY(cord,0,0)
call ZS.changeXY(cord2,0,0)
call ZS.changeXY(knight,0,0)
endfunction
private function act7 takes nothing returns nothing
call ZS.changeZ(sfx1,S2I(SubString(GetEventPlayerChatString(), 11-1, 14)))
call ZS.changeZ(sfx2,S2I(SubString(GetEventPlayerChatString(), 11-1, 14)))
call ZS.changeZ(sfx3,S2I(SubString(GetEventPlayerChatString(), 11-1, 14)))
call ZS.changeZ(cord,S2I(SubString(GetEventPlayerChatString(), 11-1, 14)))
call ZS.changeZ(cord2,S2I(SubString(GetEventPlayerChatString(), 11-1, 14)))
call ZS.changeZ(knight,S2I(SubString(GetEventPlayerChatString(), 11-1, 14)))
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( t, Player(0) )
call TriggerAddAction( t, function dexcz )
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "cord test", true )
call TriggerAddAction( t, function act)
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "duration test", true )
call TriggerAddAction( t, function act2)
set t = null
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "force end", true )
call TriggerAddAction( t, function act3)
set t = null
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "changetoPoint", true )
call TriggerAddAction( t, function act4)
set t = null
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "changetoUnit", true )
call TriggerAddAction( t, function act5)
set t = null
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "changeXY", true )
call TriggerAddAction( t, function act6)
set t = null
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "changeZ = ", false )
call TriggerAddAction( t, function act7)
set t = null
endfunction
endscope
Change Log :
v0.9 : First Release.
v0.91 : Fixes minor bug and add SetEfxFacing new method
Attachments
Last edited: