Jump to content
EleTD.com
Sign in to follow this  
Guest Sancdar

Rainbow Tower

Recommended Posts

Guest Sancdar

How about making the color change actually do something? At least changing the damage type would be nice, but maybe also some minor special abilities associated with each element? E-Splash, F-DoT, L-slow, D-range, N-higher damage, and a W-quick attack? Right now, the tower is surprisingly bland for being the most colorful.

Share this post


Link to post

I think its a really great idea, it would make the tower more unpredictable, which is exactly the role it has.

E-Splash, F-DoT, L-slow, D-range, N-higher damage, and a W-quick attack

L-high Range, D-High damage, N-slow sounds to me more logical, but despite of that its a really nice improvement on my side.

I would also like to sintonize furter towers after the first, so that they use same spectrum and attack at the same time.

Share this post


Link to post
Guest mrchak

The original idea was to change the attack element on each attack

Red - Fire

Orange - Earth

Yellow - Light

Green - Nature

Blue - Water

Purple - Darkness

The only way to do that as far as we could figure was to have 6 towers and cycle between them constantly. There was a concern that this would create a lot of laggy problems.

Of course, you can do ANYTHING with JASS, right?

Share this post


Link to post

So basically what you are are going at is to randomify rainbow? So that it will leak every 7th creep and do overkill to another 7th?

And as a result the tower would be as unreliable as dino, but without the splash?

More like another lightning?

Remind me - who uses lightning on vh? :wink:

Share this post


Link to post
Guest GkJ-mo

on the other hand: rainbow is definitly overpowered right now, you can win vh with rainbow and well

Share this post


Link to post
Guest Sancdar
So basically what you are are going at is to randomify rainbow? So that it will leak every 7th creep and do overkill to another 7th?

And as a result the tower would be as unreliable as dino, but without the splash?

More like another lightning?

Remind me - who uses lightning on vh? :wink:

Ideally, I don't think you'd be expecting to 1-shot creeps with the tower in the first place. I figure the abilities would help to counteract the difference in effectiveness of each attack, although I realize that "range" isn't really helpful. But come on, Rainbow's just boring. We have two other single-target damage triples already, and nobody really uses any of them.

Share this post


Link to post
We have two other single-target damage triples already, and nobody really uses any of them.

We have? :o Or do you mean long range single target towers? Long range towers suck ofc. Rainbow and gold are the only short/med range single target towers with composite damage.

Share this post


Link to post

To be frank, I think Rainbow as an idea might get the axe. I don't see a way to salvage it, rather I would like to brainstorm a new idea and replace it altogether. That is why I cannot emphasize enough the Tower Ability Wishlist thread. Getting a pool of potential abilities and characteristics is essential to move forward.

Share this post


Link to post
Guest mrchak

Since the period tower is sortof like a morphing rainbow tower as things stand, I guess Fire, Water, Nature can be something else... Although I like the eye candy of the pretty colors(sure that's a stupid reason, so sue me).

By the way, do pro players use that periodic tower ever? I think its a great addition to the game, but I am not a professional Element TD player, just a recreational player; Do pros ever use the Periodic tower?

Share this post


Link to post
Guest Sancdar

I use it, but just because it looks tight. That and sometimes on random you really don't have jack besides all 6 elements.

Share this post


Link to post
Guest The)TideHunter(
The original idea was to change the attack element on each attack

Red - Fire

Orange - Earth

Yellow - Light

Green - Nature

Blue - Water

Purple - Darkness

The only way to do that as far as we could figure was to have 6 towers and cycle between them constantly. There was a concern that this would create a lot of laggy problems.

Of course, you can do ANYTHING with JASS, right?

Its quite easy to do that with Jass.

Using Type Casting, you can store the current element of the tower in a integer to that tower, then when the unit attacks, add the morph into next tower, order it to use it, then remove the ability.

You can't do everything with Jass, but you have alot more capabilities.

And there is a truely amazing thing with Jass, the new language which was made by Vexorian, called vJass.

There is vJass and vJass compiler, you can use new, special syntax in Jass, then when you save the map, vJass parser changes all the vJass code into real Jass code, so you can do a stupid amount of new things, dynamically and easy.

For example, i could make my own new handle type, called Projectile, which has damage, speed, target, model, attacker, etc all stored into this one handle, like a unit.

I can then make functions that take this new handle, like:

function StartProjectile takes projectile p, target t returns nothing

...

endfunction

It is truely amazing.

A while ago i started to make my CF functions, which we intended to be a huge range of functions that can make your mapping life so much easier, as a open source resource for anybody to use.

I'll show my CFEffectHandler here.

There might be some problems, havnt updated it in months, didnt have the time.

Ok, first is my CF Engine which is needed to run CF modules.

Each of these codes should go in seperate triggers.

The CF Engine is:

//! library CFEngine initializer InitCFEngine
//********************************************************************************
*******
//*
//* Casual Functions Engine v.1.0.1
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//*
//*     Requires:
//*           - vJass Preprocessor to parse this code
//*           - A dummy unit with Vexorian's dummy model
//*
//*     Note:
//*        This Engine is only used to run all other Casual Functions modules.
//*        This Engine does nothing on its own.
//********************************************************************************
*******
globals
    gamecache cfcache = null
    constant string COLOUR_RED = "ff0000"
    constant string COLOUR_BREAK = "|r"
    constant string COLOUR_START = "|c00"
    string array error
    boolean array errorread
    boolean CFEffectHandler_enabled=true
    boolean CFHeightModifier_enabled=true
endglobals

//================================================================================
=======
// Constants
constant function DummyUnitRawcode takes nothing returns integer
return 'h000'
endfunction
constant function MorphAbilityRawcode takes nothing returns integer
return 'amrf'
endfunction

//================================================================================
=======
// Run to initialize CFEngine
private function InitCFEngine takes nothing returns nothing
    call FlushGameCache(InitGameCache("cfcache"))
    set cfcache = InitGameCache("cfcache")
    set error[0]="Dummy Unit Rawcode constant is not set up in the CFEngine library."
    set error[1]="Morph Ability Rawcode constant is not set up in the CFEngine library."
    set error[2]="CFEffectHandler is not enabled"
    set error[3]="CFProjectileHandler is not enabled"
endfunction

//================================================================================
=======
// Error
function CFError takes integer i returns string
local string s = COLOUR_START+COLOUR_RED+"CASUAL FUNCTIONS ERROR #"+I2S(i)+" - "+error[i-1]+COLOUR_BREAK
    if(not errorread[i])then
        set errorread[i]=true
        if(i==1)then
            set CFEffectHandler_enabled=false
            return s+"
  Action taken while ingame:
    Disabled CFEffectHandler
    Disabled CFProjectileHandler"
        elseif(i==2)then
            set CFHeightModifier_enabled=false
            return s+"
  Action taken while ingame:
    Disabled all CF that use height modification"
        endif
        return s
    endif
return " "
endfunction

//================================================================================
=======
// Trig
function LocXOffset takes real x, real distance, real angle returns real
return x+distance*Cos(angle*bj_DEGTORAD)
endfunction
function LocYOffset takes real y, real distance, real angle returns real
return y+distance*Sin(angle*bj_DEGTORAD)
endfunction
function DistanceBetweenXY takes real ax, real ay, real bx, real by returns real
local real a=bx-ax
local real b=by-ay
return SquareRoot(a*a-b*b)
endfunction

//================================================================================
=======
// Safe X/Y
function IsXSafe takes real x returns boolean
    return (x<GetRectMaxX(bj_mapInitialPlayableArea) and x>GetRectMinX(bj_mapInitialPlayableArea))
endfunction
function IsYSafe takes real y returns boolean
    return (y<GetRectMaxY(bj_mapInitialPlayableArea)and y>GetRectMinY(bj_mapInitialPlayableArea))
endfunction
function IsLocSafe takes real x, real y returns boolean
    return IsXSafe(x) and IsYSafe(y)
endfunction
function SetUnitXY takes unit u, real x, real y returns nothing
    if(IsLocSafe(x,y))then
        call SetUnitX(u,x)
        call SetUnitY(u,y)
    endif
endfunction

//================================================================================
=======
// Print to all players
function Print takes string msg returns nothing
    if(not (msg==" "))then
        call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,msg)
    endif
endfunction

//================================================================================
=======
// Colour's and Hex (Thanks Pitzermike)
function ColourToInteger takes integer r, integer g, integer b, integer a returns integer
return r+g*0x100+b*0x10000+a*0x1000000
endfunction
function IntegerGetRed takes integer i returns integer
    if i<0 then
        return ModuloInteger(i + 0x80000000, 0x100)
    endif
return ModuloInteger(i, 0x100)
endfunction
function IntegerGetGreen takes integer i returns integer
    if i<0 then
        return ModuloInteger((i + 0x80000000) / 0x100, 0x100)
    endif
return ModuloInteger(i / 0x100, 0x100)
endfunction
function IntegerGetBlue takes integer i returns integer
    if i<0 then
        return ModuloInteger((i + 0x80000000) / 0x10000, 0x100)
    endif
return ModuloInteger(i / 0x10000, 0x100)
endfunction
function IntegerGetAlpha takes integer i returns integer
    if i<0 then
        return (i + 0x80000000) / 0x1000000 + 0x80
    endif
return i / 0x1000000
endfunction

//================================================================================
=======
// Return Bug
function h2i takes handle H returns integer
return H
return 0
endfunction

private function i2u takes integer I returns unit
return I
return null
endfunction
private function i2e takes integer I returns effect
return I
return null
endfunction
private function i2i takes integer I returns image
return I
return null
endfunction
private function i2s takes integer I returns sound
return I
return null
endfunction
private function i2d takes integer I returns destructable
return I
return null
endfunction

//================================================================================
=======
// Gamecache Storage
function AttachInteger takes integer i, handle h, string k returns nothing
local string s = I2S(h2i(h))
    if(i!=0)then
        call StoreInteger(cfcache,s,k,i)
    else
        call FlushStoredInteger(cfcache,s,k)
    endif
endfunction
function AttachReal takes real r, handle h, string k returns nothing
local string s = I2S(h2i(h))
    if(r!=0.)then
        call StoreReal(cfcache,s,k,r)
    else
        call FlushStoredReal(cfcache,s,k)
    endif
endfunction
function AttachString takes string a, handle h, string k returns nothing
local string s = I2S(h2i(h))
    if(a!="")then
        call StoreString(cfcache,s,k,a)
    else
        call FlushStoredString(cfcache,s,k)
    endif
endfunction
function AttachBoolean takes boolean b, handle h, string k returns nothing
local string s = I2S(h2i(h))
    if(b)then
        call StoreInteger(cfcache,s,"::boolean::"+k,1)
    else
        call FlushStoredInteger(cfcache,s,"::boolean::"+k)
    endif
endfunction
function AttachHandle takes handle a, handle h, string k returns nothing
local string s = I2S(h2i(h))
    if(a!=null)then
        call StoreInteger(cfcache,s,k,h2i(a))
    else
        call FlushStoredInteger(cfcache,s,k)
    endif
endfunction
function GetAttachedInteger takes handle h, string k returns integer
return GetStoredInteger(cfcache,I2S(h2i(h)),k)
endfunction
function GetAttachedReal takes handle h, string k returns real
return GetStoredReal(cfcache,I2S(h2i(h)),k)
endfunction
function GetAttachedString takes handle h, string k returns string
return GetStoredString(cfcache,I2S(h2i(h)),k)
endfunction
function GetAttachedBoolean takes handle h, string k returns boolean
    if(GetStoredInteger(cfcache,I2S(h2i(h)),"::boolean::"+k)==1)then
        return true
    endif
return false
endfunction
function GetAttachedUnit takes handle h, string k returns unit
local integer i = GetStoredInteger(cfcache,I2S(h2i(h)),k)
    if(i!=0)then
        return i2u(i)
    endif
return null
endfunction
function GetAttachedEffect takes handle h, string k returns effect
local integer i = GetStoredInteger(cfcache,I2S(h2i(h)),k)
    if(i!=0)then
        return i2e(i)
    endif
return null
endfunction
function GetAttachedImage takes handle h, string k returns image
local integer i = GetStoredInteger(cfcache,I2S(h2i(h)),k)
    if(i!=0)then
        return i2i(i)
    endif
return null
endfunction
function GetAttachedSound takes handle h, string k returns sound
local integer i = GetStoredInteger(cfcache,I2S(h2i(h)),k)
    if(i!=0)then
        return i2s(i)
    endif
return null
endfunction
function GetAttachedDestructable takes handle h, string k returns destructable
local integer i = GetStoredInteger(cfcache,I2S(h2i(h)),k)
    if(i!=0)then
        return i2d(i)
    endif
return null
endfunction
function FlushHandle takes handle h returns nothing
    call FlushStoredMission(cfcache,I2S(h2i(h)))
endfunction

//! endlibrary

// WE Trigger (Lets this code Parse)
function InitTrig_CFEngine takes nothing returns nothing
endfunction

Then, one of my modules, which was CF Effect handler.

I thought this was a cool way of making effects.

Say you create a special effect, you are limited to 2/3 options, location and model.

With my Effect handler, you can do much much more.

You can:

Pause effects, set their size, set their colour, set their co-ordinates x/y, you can set their height (coord z), you can set which way its facing, you can hide/show it, and set its animation speed.

Here is my CFEffect module:

//! library CFEffectHandler needs CFEngine
//********************************************************************************
*******
//*
//* Casual Functions Effect Handler v.1.0
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//*
//*     Requires:
//*           - vJass Preprocessor to parse this code
//*           - Casual Functions Engine
//*
//*     Note:
//*        These functions cannot be used on any old effect, they have to be created via
//*        the create effect functions provided in this Handler pack.
//********************************************************************************
*******
//================================================================================
=======
// A struct used to carry all infomation used for the effects, thanks to vJass, it makes
// life alot easier.

globals
    constant integer SFXPROPERTY_COLOUR_RED=0   // 0-255
    constant integer SFXPROPERTY_COLOUR_GREEN=1 // 0-255
    constant integer SFXPROPERTY_COLOUR_BLUE=2  // 0-255
    constant integer SFXPROPERTY_COLOUR_ALPHA=3 // 0-255
    constant integer SFXPROPERTY_SIZE=4         // 0.01-10
    constant integer SFXPROPERTY_SPEED=5        // 0.01-10
endglobals



struct sfx
    real x = 0
    real y = 0
    real z = 0
    static unit u = null
    integer c = 0
    real s = 0
    string p = ""
    static effect e = null
    real f = 0
    integer v = 0
    boolean m
    real t = 0

    method Init takes real x, real y, real z, unit u, integer c, real s, string p, effect e, real f, integer v, real t, boolean m returns nothing
        set .x=x
        set .y=y
        set .z=z
        set .u=u
        set .c=c
        set .s=s
        set .p=p
        set .e=e
        set .f=f
        set .v=v
        set .m=m
        set .t=t
    endmethod


    method SetEffectX takes real x returns nothing
        if(IsXSafe(x))then
            set .x=x
            call SetUnitX(.u,x)
        endif
    endmethod
    method SetEffectY takes real y returns nothing
        if(IsYSafe(y)) then
            set .y=y
            call SetUnitY(.u,y)
        endif
    endmethod
    method SetEffectZ takes real z returns nothing
        if(not CFHeightModifier_enabled)then
            call SetUnitFlyHeight(.u,z,0.)
            set .z=z
        endif
    endmethod
    method SetFace takes real face returns nothing
        call SetUnitFacing(.u,face)
        set .f=face
    endmethod
    method SetRed takes integer red returns integer
     local integer g=IntegerGetGreen(.c)
     local integer b=IntegerGetBlue(.c)
     local integer a=IntegerGetAlpha(.c)
        call SetUnitVertexColor(.u,red,g,b,a)
     return ColourToInteger(red,g,b,a)
    endmethod
    method SetGreen takes integer green returns integer
     local integer r=IntegerGetRed(.c)
     local integer b=IntegerGetBlue(.c)
     local integer a=IntegerGetAlpha(.c)
        call SetUnitVertexColor(.u,r,green,b,a)
     return ColourToInteger(r,green,b,a)
    endmethod
    method SetBlue takes integer blue returns integer
     local integer r=IntegerGetRed(.c)
     local integer g=IntegerGetGreen(.c)
     local integer a=IntegerGetAlpha(.c)
        call SetUnitVertexColor(.u,r,g,blue,a)
     return ColourToInteger(r,g,blue,a)
    endmethod
    method SetAlpha takes integer alpha returns integer
     local integer r=IntegerGetRed(.c)
     local integer g=IntegerGetGreen(.c)
     local integer b=IntegerGetBlue(.c)
        call SetUnitVertexColor(.u,r,g,b,alpha)
     return ColourToInteger(r,g,b,alpha)
    endmethod
    method SetSize takes real size returns real
        call SetUnitScale(.u,size,size,size)
     return size
    endmethod
    method Hide takes nothing returns nothing
        call ShowUnit(.u,false)
    endmethod
    method Show takes nothing returns nothing
        call ShowUnit(.u,true)
    endmethod
    method Freeze takes nothing returns nothing
        call SetUnitTimeScale(.u,0.)
        set .m=true
    endmethod
    method Unfreeze takes nothing returns nothing
        call SetUnitTimeScale(.u,1.)
        set .m=false
    endmethod
    method SetSpeed takes real r returns nothing
        if(not .m) then
            call SetUnitTimeScale(.u,r)
            set .t=r
        endif
    endmethod
endstruct

struct sfxgroup
    group g

    method AddEffect takes sfx e returns nothing
         call GroupAddUnit(.g,e.u)
    endmethod
    method RemoveEffect takes sfx e returns nothing
         call GroupRemoveUnit(.g,e.u)
    endmethod
    method ClearGroup takes nothing returns nothing
        call GroupClear(.g)
    endmethod
    method EnumInRange takes real x, real y, real r returns nothing
     local group p
     local unit u
        call GroupEnumUnitsInRange(p,x,y,r,null)
        loop
            set u=FirstOfGroup(p)
            exitwhen u==null
            if(SubString(GetStoredString(cfcache,I2S(h2i(u)),"CF"),10,11)=="EFFECTDUMMY")then
                call GroupAddUnit(.g,u)
            endif
            call GroupRemoveUnit(p,u)
        endloop
        call DestroyGroup(p)
        set p = null
        set u = null
    endmethod
endstruct

//================================================================================
=======
// CFEffectHandler allowance
function CFEffectHandlerOn takes nothing returns boolean
    return CFEffectHandler_enabled
endfunction

//================================================================================
=======
// A simple function, gets a new sfx struct, sets loads of stuff, stores it to the effect
function CreateEffect takes real x, real y, string path returns sfx
local sfx e=sfx.create()
local integer abil = MorphAbilityRawcode()
local location l
local integer i = DummyUnitRawcode()
    if(IsLocSafe(x,y) and CFEffectHandlerOn())then
        if(i==0)then
            call Print(CFError(1))
            call sfx.destroy(e)
            set i = 0
        else
            if(abil==0)then
                call Print(CFError(2))
                call sfx.destroy(e)
                set i = 0
            else
                set l = Location(x,y)
                call StoreString(cfcache,I2S(h2i(e.u)),"CF","EFFECTDUMMY::"+I2S(e))
                call UnitAddAbility(e.u,abil)
                call UnitRemoveAbility(e.u,abil)
                call e.Init(x,y,GetLocationZ(l),CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),i,x,y,bj_UN
IT_FACING),ColourToInteger(255,255,255,0),1.,path,AddSpecialEffectTarget(path,e.u
,"origin"),bj_UNIT_FACING,0,1.,false)
            endif
        endif
    else
        call sfx.destroy(e)
        return 0
    endif
return e
endfunction

//================================================================================
=======
// Remove a effect
function RemoveEffect takes sfx e returns nothing
    call DestroyEffect(e.e)
    call FlushHandle(e.e)
    call FlushHandle(e.u)
    call RemoveUnit(e.u)
    call sfx.destroy(e)
endfunction

//================================================================================
=======
// A ton of setting functions
function SetEffectX takes sfx e, real x returns nothing
    if(CFEffectHandlerOn())then
        call e.SetEffectX(x)
    endif
endfunction
function SetEffectY takes sfx e, real y returns nothing
    if(CFEffectHandlerOn())then
        call e.SetEffectY(y)
    endif
endfunction
function SetEffectZ takes sfx e, real z returns nothing
    if(CFEffectHandlerOn())then
        call e.SetEffectZ(z)
    endif
endfunction
function SetEffectFace takes sfx e, real angle returns nothing
    if(CFEffectHandlerOn())then
        call e.SetFace(angle)
    endif
endfunction
function SetEffectRed takes sfx e, integer r returns nothing
    if(CFEffectHandlerOn())then
        set e.c=e.SetRed(r)
    endif
endfunction
function SetEffectGreen takes sfx e, integer g returns nothing
    if(CFEffectHandlerOn())then
        set e.c=e.SetGreen(g)
    endif
endfunction
function SetEffectBlue takes sfx e, integer b returns nothing
    if(CFEffectHandlerOn())then
        set e.c=e.SetBlue(b)
    endif
endfunction
function SetEffectAlpha takes sfx e, integer a returns nothing
    if(CFEffectHandlerOn())then
        set e.c=e.SetAlpha(a)
    endif
endfunction
function SetEffectColour takes sfx e, integer r, integer g, integer b, integer a returns nothing
    if(CFEffectHandlerOn())then
        set e.c=e.SetRed(r)
        set e.c=e.SetGreen(g)
        set e.c=e.SetBlue(b)
        set e.c=e.SetAlpha(a)
    endif
endfunction
function SetEffectSize takes sfx e, real s returns nothing
    if(CFEffectHandlerOn())then
        set e.s=e.SetSize(s)
    endif
endfunction
function SetEffectValue takes sfx e, integer v returns nothing
    if(CFEffectHandlerOn())then
        set e.v=v
    endif
endfunction
function SetEffectPlaySpeed takes sfx e, real r returns nothing
    if(CFEffectHandlerOn())then
        call e.SetSpeed(r)
    endif
endfunction

//================================================================================
=======
// A ton of getting functions
function GetEffectX takes sfx e returns real
return e.x
endfunction
function GetEffectY takes sfx e returns real
return e.y
endfunction
function GetEffectZ takes sfx e returns real
return e.z
endfunction
function GetEffectFace takes sfx e returns real
return e.f
endfunction
function GetEffectRed takes sfx e returns integer
return IntegerGetRed(e.c)
endfunction
function GetEffectGreen takes sfx e returns integer
return IntegerGetGreen(e.c)
endfunction
function GetEffectBlue takes sfx e returns integer
return IntegerGetBlue(e.c)
endfunction
function GetEffectAlpha takes sfx e returns integer
return IntegerGetAlpha(e.c)
endfunction
function GetEffectColour takes sfx e returns integer
return e.c
endfunction
function GetEffectSize takes sfx e returns real
return e.s
endfunction
function GetEffectValue takes sfx e returns integer
return e.v
endfunction
function GetEffectSpeed takes sfx e returns real
return e.t
endfunction

//================================================================================
=======
// Show/Hide Effect
function HideEffect takes sfx e returns nothing
    if(CFEffectHandlerOn())then
        call e.Hide()
    endif
endfunction
function ShowEffect takes sfx e returns nothing
    if(CFEffectHandlerOn())then
        call e.Show()
    endif
endfunction

//================================================================================
=======
// Freeze/Unfreeze effect (completly pauses the effect's animation)
function FreezeEffect takes sfx e returns nothing
    if(CFEffectHandlerOn())then
        call e.Freeze()
    endif
endfunction
function UnfreezeEffect takes sfx e returns nothing
    if(CFEffectHandlerOn())then
        call e.Unfreeze()
    endif
endfunction

//================================================================================
=======
// Effect Groups
function CreateEffectGroup takes nothing returns sfxgroup
    if(CFEffectHandlerOn())then
        return sfxgroup.create()
    endif
    return 0
endfunction
function DestroyEffectGroup takes sfxgroup g returns nothing
    call DestroyGroup(g.g)
    call sfxgroup.destroy(g)
endfunction

//================================================================================
=======
// Add/Remove effects from effect groups
function AddEffectToGroup takes sfx e, sfxgroup g returns nothing
    if(CFEffectHandlerOn())then
        call g.AddEffect(e)
    endif
endfunction
function RemoveEffectFromGroup takes sfx e, sfxgroup g returns nothing
    if(CFEffectHandlerOn())then
        call g.RemoveEffect(e)
    endif
endfunction

//================================================================================
=======
// Comparison
function IsEffectInGroup takes sfx e, sfxgroup g returns boolean
return IsUnitInGroup(e.u,g.g)
endfunction

function IsEffectProperty takes sfx e, integer property, real r returns boolean
    if(property==0)then
        return GetEffectRed(e)==R2I(r)
    elseif(property==1)then
        return GetEffectGreen(e)==R2I(r)
    elseif(property==2)then
        return GetEffectBlue(e)==R2I(r)
    elseif(property==3)then
        return GetEffectAlpha(e)==R2I(r)
    elseif(property==4)then
        return e.s==r
    elseif(property==5)then
        return e.t==r
    endif
return false
endfunction

//================================================================================
=======
// Effect Group controlling
function ClearEffectGroup takes sfxgroup g returns nothing
    if(CFEffectHandlerOn())then
        call g.ClearGroup()
    endif
endfunction
function GetFirstEffectOfGroup takes sfxgroup g returns sfx
local string s = GetStoredString(cfcache,I2S(h2i(FirstOfGroup(g.g))),"CF")
return S2I(SubString(s,13,StringLength(s)))
endfunction

function EnumAllEffects takes sfxgroup g returns nothing
local group p = CreateGroup()
local unit u
    if(CFEffectHandlerOn())then
        call GroupEnumUnitsInRect(p,bj_mapInitialPlayableArea,null)
        loop
            set u = FirstOfGroup(p)
            exitwhen u==null
            if(SubString(GetStoredString(cfcache,I2S(h2i(u)),"CF"),0,11)=="EFFECTDUMMY")then
                call GroupAddUnit(g.g,u)
            endif
            call GroupRemoveUnit(p,u)
        endloop
    endif
    call DestroyGroup(p)
    set p = null
    set u = null
endfunction
    
function EnumEffectsInRange takes sfxgroup g, real x, real y, real r returns nothing
    if(CFEffectHandlerOn())then
        call g.EnumInRange(x,y,r)
    endif
endfunction
function EnumEffectsWithProperty takes sfxgroup g, integer property, real r returns nothing
local sfxgroup p = sfxgroup.create()
local sfx e
    if(CFEffectHandlerOn())then
        call EnumAllEffects(p)
        loop
            set e = GetFirstEffectOfGroup(p)
            exitwhen e==0
            if(IsEffectProperty(e,property,r))then
                call AddEffectToGroup(e,g)
            endif
            call RemoveEffectFromGroup(e,p)
        endloop
    endif
    call DestroyGroup(p.g)
    call sfxgroup.destroy(g)
endfunction

function DestroyAllEffects takes nothing returns nothing
local sfxgroup g = sfxgroup.create()
local sfx s
    if(CFEffectHandlerOn())then
        call EnumAllEffects(g)
        loop
            set s = GetFirstEffectOfGroup(g)
            exitwhen s==0
            call RemoveEffectFromGroup(s,g)
            call RemoveEffect(s)
        endloop
    endif
    call sfxgroup.destroy(g)
endfunction

//! endlibrary




// WE Trigger (Lets this code Parse)
function InitTrig_CFEffectHandler takes nothing returns nothing
endfunction

And, towards the end of my Module, i added Effect Groups, so you can track effects much easier.

You could for example, make a new effect group and add all effects in a spell, then once the spell has finished destroy the effects in the group using a loop and GetFirstEffectOfGroup.

If you have any questions of what new things can be done, how to add CF into your map, or anything Jass related, don't hesitate to ask.

Share this post


Link to post
Guest Sancdar

Well done! I didn't notice any problems, and I'm glad that you made it easy to destroy effects. I can't stand maps with memory issues or splits due to sloppy effect coding, like some of the old Cube Defense maps.

Share this post


Link to post
Guest The)TideHunter(

Thanks, took me quite a while.

If i finished it with some more modules i would release it.

And seen as Wc3c went down, i didnt have much support.

Its nice to recieve some feedback though, thanks.

Reading over it, i actually made a leak, and thats in the CreateEffect function, i wrote "set l = Location(x,y)" and never destroyed the location.

Dumb mistake, but never the less i doubt it will ever be used.

Share this post


Link to post
Sign in to follow this  

×
×
  • Create New...