Executor
I see you
- Reaction score
- 57
Effect
Effect allows the creation of unit-independent effects with z-parameter and the possibilty to change their color, scaling and position.
- Coding Style: vJass
- Interface: vJass + 'normal' Jass
JASS:
library Effect requires optional AutoFly
// ========== Effect ==========
// Better control over unit-independent effects
// Author: Executor alias Lord_Executor
// ====== Implementation ======
// Make a new trigger called "Effect"
// Convert it to custom text
// Paste the whole code in the empty page
// IMPORTANT:
// Import Vexorian's dummy.mdx
// finally save the map once and AFTER that remove the '!' of the '//!' beneath this line
//! external ObjectMerger w3u ushd vdum unam "Visible Dummy" uabi "Aeth,Avul,Aloc" umvs "520" umvr 1 umvt foot umvh -500 uhpm 99999 uhom 1 ucol -10 umdl "war3mapImported\dummy.mdl" ucbs 0 ucpt 0 ushu "" umvh 0 ufoo 0
// ========== Credits =========
// Vexorian: vJass & Dummy.mdx
// Azlier: Autofly
struct Effect
private static integer DUMMY_ID = 039;vdum039;
private static real DEFAULT_SCALING = 1.
private static real RECYCLE_WAIT = 2.
private static player DUMMY_OWNER = Player(14) // neutral
private unit carrier
private effect sfx
method scale takes real size returns nothing
call SetUnitScale(.carrier,size,size,size)
endmethod
method scalePercent takes real size returns nothing
set size = size * 0.01
call SetUnitScale(.carrier,size,size,size)
endmethod
method color takes integer r, integer g, integer b, integer alpha returns nothing
call SetUnitVertexColor(.carrier,r,g,b,alpha)
endmethod
method move takes real x, real y , real z returns nothing
call SetUnitX(.carrier,x)
call SetUnitY(.carrier,y)
call SetUnitFlyHeight(.carrier,z,0.)
endmethod
method onDestroy takes nothing returns nothing
call SetUnitScale(.carrier,.DEFAULT_SCALING,.DEFAULT_SCALING,.DEFAULT_SCALING)
call SetUnitVertexColor(.carrier,255,255,255,255)
endmethod
method remove takes nothing returns nothing
call DestroyEffect(.sfx)
call TriggerSleepAction(.RECYCLE_WAIT) // transitional
call .destroy()
endmethod
static method new takes string modelName, real x, real y, real z returns thistype
// z depends on floor height!
local thistype this = thistype.allocate()
if .carrier == null then
set .carrier = CreateUnit(.DUMMY_OWNER,.DUMMY_ID,x,y,0.)
call SetUnitPathing(.carrier,false)
static if not AutoFly then
call UnitAddAbility(.carrier,039;Amrf039;)
call UnitRemoveAbility(.carrier,039;Amrf039;)
endif
endif
call SetUnitX(.carrier,x)
call SetUnitY(.carrier,y)
call SetUnitFlyHeight(.carrier, z, 0.)
set .sfx = AddSpecialEffectTarget(modelName, .carrier, "origin")
return this
endmethod
endstruct
function AddEffect takes string modelName, real x, real y, real z returns Effect
return Effect.new(modelName,x,y,z)
endfunction
function ScaleEffect takes Effect e, real scale returns nothing
call e.scale(scale)
endfunction
function ScaleEffectByPercent takes Effect e, real scale returns nothing
call e.scalePercent(scale)
endfunction
function ReColorEffect takes Effect e, integer r, integer g, integer b, integer alpha returns nothing
call e.color(r,g,b,alpha)
endfunction
function MoveEffect takes Effect e, real x, real y, real z returns nothing
call e.move(x,y,z)
endfunction
function RemoveEffect takes Effect e returns nothing
call e.remove()
endfunction
endlibrary
Interface:
JASS:
// Effect Interface:
// new type "Effect"
// vJass:
// local Effect sfx = Effect.new(string model, real x, real y, real z)
// call .scale( real value )
// call .scalePercent( real value )
// call .color( integer red, integer green, integer blue, integer alpha )
// call .move( real x, real y, real z )
// call .remove()
// non-vJass:
// local Effect sfx = AddEffect(string model, real x, real y, real z)
// call ScaleEffect( sfx, real value )
// call ScaleEffectByPercent( sfx, real value )
// call ReColorEffect( sfx, integer red, integer green, integer blue, integer alpha )
// call MoveEffect( sfx, real x, real y, real z )
// call RemoveEffect( sfx )
Example:
JASS:
call RemoveEffect(AddEffect("Abilities\\Weapons\\VengeanceMissile\\VengeanceMissile.mdl",80.,30.,100.))
Note: If you use my sys, keep in mind that you're still able to use 'normal' effects for 'normal' purposes as they should be more efficient in that case.
Didn't find a sys like this via search, so I hope it's useful