Spell Sacred Circle

Sim

Forum Administrator
Staff member
Reaction score
534
I've been working on this spell for a while and I decided it would make out something great.

So, here it is!

What is it? Here's its description:

"Creates an expanding circle of holy energy, damaging every enemy unit caught."

Simply put, here's a screeny:

spells_230_screenshot.jpg


The spell

- It is MUI
- It is in vJASS
- Leakless
- Very low lag

Steps for implementation are listed, although there are several of them :)

Here's the code!

JASS:
//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
//¤
//¤ ***************** 
//¤ - Sacred Circle - 
//¤ *****************
//¤ 
//¤ By: Daxtreme
//¤ 
//¤ --> How to implement in your map:
//¤     
//¤     1. Copy the game cache variable named "GameCache" in your map.                         
//¤     2. Copy the spell "Sacred Circle" in your map.
//¤     3. Copy everything found in the "Custom script code" section. To do this, click
//¤        on the name of the map in the top-left corner in the trigger editor.
//¤     4. Make a variable called "GameCache".
//¤     5. Copy this trigger into your map.
//¤     6. Import the HolyStrike.mdx model in your map.
//¤
//¤ --> How to customize it:
//¤
//¤     You can configure the spell using the constant functions just below. Change their values.
//¤
//¤ CREDITS:
//¤
//¤     - JetFangInferno's Holy Strike.
//¤     - kenny! for testing, bug-finding, and updating!
//¤
//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

scope SacredCircle2

    globals
        private constant integer    ABIL_ID    = 'A000'       // Sacred Circle's ability Id
        private constant integer    ORDER_ID   = 852183
        private constant real       INTERVAL   = 0.04         // Period
        private constant string     EFFECT     = "war3mapImported\\HolyStrike.mdx"      // Spell model art
        private constant attacktype A_TYPE     = ATTACK_TYPE_CHAOS
        private constant damagetype D_TYPE     = DAMAGE_TYPE_UNIVERSAL
        private constant weapontype W_TYPE     = WEAPON_TYPE_WHOKNOWS
        private constant boolean    STOP_FIRST = false
    endglobals
    
    private function Damage_dealt takes integer lvl returns real
        return 100.00 * lvl
    endfunction
    
    private function Damage_radius takes integer lvl returns real
        return 175.00 + (0.00 * lvl)
    endfunction
    
    private function Filter_enemies takes unit filter, unit caster returns boolean
        return GetWidgetLife(filter) > 0.406 and IsUnitEnemy(filter,GetOwningPlayer(caster)) == true and IsUnitType(filter,UNIT_TYPE_MAGIC_IMMUNE) == false
    endfunction
    
    private struct Data
        
        unit    cast = null
        real    time = 0.00
        real    dist = 0.00
        real    ang  = 0.00
        integer lvl  = 0
        boolean stop = false
        
        static Data     array D
        static integer  D_total = 0
        static timer    Timer   = null
        static group    Group   = null
        static boolexpr Filt    = null
        
        static method filt takes nothing returns boolean
            return true
        endmethod
        
        method onDestroy takes nothing returns nothing
            set .cast = null
        endmethod
        
        method search takes nothing returns nothing
            local integer i = 1
            
            loop
                exitwhen i > Data.D_total
                if Data.D<i>.cast == .cast then
                    if STOP_FIRST then
                        set Data.D<i>.stop = true
                    else
                        set .stop = true
                    endif
                endif
                set i = i + 1
            endloop
        endmethod
        
        method periodic takes nothing returns boolean
            local real x = GetUnitX(.cast)
            local real y = GetUnitY(.cast)
            local unit u = null
            
            if GetUnitCurrentOrder(.cast) != ORDER_ID or .time &lt;= 0 then
                return true
            else
                set x = x + (50.00 + .dist * 10.00) * Cos(.ang * bj_DEGTORAD)
                set y = y + (50.00 + .dist * 10.00) * Sin(.ang * bj_DEGTORAD)
                
                call DestroyEffect(AddSpecialEffect(EFFECT,x,y))
                call GroupEnumUnitsInRange(Data.Group,x,y,Damage_radius(.lvl),Data.Filt)
                loop
                    set u = FirstOfGroup(Data.Group)
                    exitwhen u == null
                    call GroupRemoveUnit(Data.Group,u)
                    if Filter_enemies(u,.cast) then
                        call UnitDamageTarget(.cast,u,Damage_dealt(.lvl),false,false,A_TYPE,D_TYPE,W_TYPE)
                    endif
                endloop
                
                set .ang  = (.ang  + 24.00 - .dist / 6.00)
                set .dist = (.dist + 1.00)
                set .time = (.time - INTERVAL)
            endif
            
            set u = null
            
            return false
        endmethod            
        
        static method update takes nothing returns nothing
            local integer i = 1
            
            loop
                exitwhen i &gt; Data.D_total
                
                if Data.D<i>.stop or Data.D<i>.periodic() then
                    call Data.D<i>.destroy()
                    set Data.D<i> = Data.D[Data.D_total]
                    set Data.D_total = Data.D_total - 1
                    set i = i - 1
                endif
                
                set i = i + 1
            endloop
            
            if Data.D_total &lt;= 0 then
                call PauseTimer(Data.Timer)
                set Data.D_total = 0
            endif
        endmethod
        
        static method actions takes nothing returns boolean
            local Data d = Data.create()
            
            set d.cast = GetTriggerUnit()
            set d.lvl  = GetUnitAbilityLevel(d.cast,ABIL_ID)
            set d.time = 100.00 * INTERVAL
            call d.search()
            
            set Data.D_total = Data.D_total + 1
            set Data.D[Data.D_total] = d
            if Data.D_total == 1 then
                call TimerStart(Data.Timer,INTERVAL,true,function Data.update)
            endif
            
            return false
        endmethod
        
        static method conditions takes nothing returns boolean
            return GetSpellAbilityId() == ABIL_ID
        endmethod
            
        static method onInit takes nothing returns nothing
            local trigger trig = CreateTrigger()
            local integer i    = 0
            
            set Data.Timer = CreateTimer()
            set Data.Group = CreateGroup()
            set Data.Filt  = Filter(function Data.filt)
            
            loop
                call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Data.Filt)
                set i = i + 1
                exitwhen i == bj_MAX_PLAYER_SLOTS
            endloop
            
            call TriggerAddCondition(trig,Condition(function Data.conditions))
            call TriggerAddAction(trig,function Data.actions)
        endmethod
        
    endstruct

endscope
</i></i></i></i></i></i>


--------------------------------------

I made this at first for myself but then I realized the whole community could use it, because I feel it is good.

Tell me what you think!

*Credits to JetFangInferno for the Holy Strike model and KaTTaNa for the Local Handle Vars system!*

EDIT: First update.

EDIT: 2nd update.

EDIT: 3rd update.

EDIT: 4th update.

EDIT: 5th update.

EDIT: (After a while) Update! Credits to kenny! for the whole changes. :)
 

Attachments

  • Sacred Circle.w3x
    39.8 KB · Views: 603
wow, real great....

its made in jass
leakless

did you wrote to your trigger that how to import this spell?
its for people who do not know jass

well its great...+rep
 
SC_RawCode, SC_StrikeDmg, SC_CheckMagicImmune and SC_CheckAlly can (and should) all be constants.
IsUnitType tends to cause an unusual bug if not compared to something...so only in this case you should use "return IsUnitType(targ, UNIT_TYPE_MAGIC_IMMUNE) == false" instead of "return not IsUnitType(targ, UNIT_TYPE_MAGIC_IMMUNE)".

Code:
    loop
        exitwhen GetTriggerEvalCount(trig)>0
        call TriggerSleepAction( 0.10 )
    endloop
Bad idea.
You can check the exec/eval count in the trigger itself (from Trig_Sacred_Circle_Actions_Loop) and disable/clean it there.

Oh and you might wanna use the native instead of AddSpecialEffectLocBJ, this seems to be the only BJ you used (except for PolarProjection).
 
Looks great, those are imported models, right (or am I wrong? Screeny bit small)? Anyway if there are imported any chance you could attach them?
 
You can export those models once you open the map.

> Bad idea.
> You can check the exec/eval count in the trigger itself (from Trig_Sacred_Circle_Actions_Loop) and disable/clean it there.

Will do.

> Oh and you might wanna use the native instead of AddSpecialEffectLocBJ, this seems to be the only BJ you used (except for PolarProjection).

Well, the effect thingy bugged when I used the native, don't know why -_- I will try again though.

The condition functions will be constants.

Thanks guys :)

EDIT:

>did you wrote to your trigger that how to import this spell?
>its for people who do not know jass

Look for yourself! :p
 
Wow Very very nice spell man

I might use it so i give u all credit for this spell ! Very nice again
 
The spell has been updated according to SFilip's comments.
 
have not looked myself, however if you fixed what he said I will move this over, gj
 
Something I forgot last time...
Code:
function LocalVars takes nothing returns gamecache  
    return InitGameCache("jasslocalvars.w3v") 
endfunction   

function GameCache takes nothing returns gamecache
    return udg_GameCache
endfunction
This isn't right, should be something like this
Code:
function LocalVars takes nothing returns gamecache  
    if udg_GameCache == null then
        set udg_GameCache = InitGameCache("jasslocalvars.w3v")
    endif
    return udg_GameCache
endfunction
 
It does look really great ingame, and it certainly deals some serious damage :)

For future consideration, there are somethings that seems unnecessary. At first I simply couldn't figure out what in the world you were using the local trigger for, when I suddenly realized it was a channeling ability. You could have added the END_CAST event to the main trigger, and then had a if statement in your actions trigger like this:
Code:
if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
*Turn on timer, store handle locals*
elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
*turn of timer, flush handle locals, destroy the timer*
endif
The condition will work for both events. Another thing that seemed abit strange, was that your using a region. You could acheive the same result with xypoints.
 
It does look really great ingame, and it certainly deals some serious damage :)

For future consideration, there are somethings that seems unnecessary. At first I simply couldn't figure out what in the world you were using the local trigger for, when I suddenly realized it was a channeling ability. You could have added the END_CAST event to the main trigger, and then had a if statement in your actions trigger like this:
Code:
if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
*Turn on timer, store handle locals*
elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
*turn of timer, flush handle locals, destroy the timer*
endif
The condition will work for both events. Another thing that seemed abit strange, was that your using a region. You could acheive the same result with xypoints.

Well, I had other ideas in mind for this spell, and it needed Handle vars. Once I decided to change it, the handle vars still worked good and everything was already settled so I kept them. I noticed they were only half useful ;)

But I'm lazy.

Also, regions are easy to handle :p

Something I forgot last time...
Code:
function LocalVars takes nothing returns gamecache  
    return InitGameCache("jasslocalvars.w3v") 
endfunction   

function GameCache takes nothing returns gamecache
    return udg_GameCache
endfunction
This isn't right, should be something like this
Code:
function LocalVars takes nothing returns gamecache  
    if udg_GameCache == null then
        set udg_GameCache = InitGameCache("jasslocalvars.w3v")
    endif
    return udg_GameCache
endfunction

Are you sure? In both my maps I use the 2 above functions instead of what you said and... it always worked. Maybe I got a false version of the Handle Vars? :eek:
 
> it always worked
The original works as well without any changes...
Though it causes a memory leak and is much slower as the game cache gets reloaded every time you use it.
 
The original should be:
Code:
function LocalVars takes nothing returns gameache
    return udg_*VariableName*
endfunction
Or SFilips method, which is safer, since it'll automatically create the gamecache if it isn't created by the user.

>Also, regions are easy to handle

Then create a local region and move it around with handle locals. Implementation of a jass spell using a handle vars system should only include copying of triggers, abilities, custom script, and the game cache variable in my opinion
 
alternatively, you could create your gc variable at map init, and always just return it, therefore saving some lines of code every time you get it, or not use a function call in the first place, and wherever you need it just use the gc variable, like I do, which would save even more time
 
I'll use local region good idea *thumbs up*

EDIT: *rect

This isn't right, should be something like this
Code:
function LocalVars takes nothing returns gamecache  
    if udg_GameCache == null then
        set udg_GameCache = InitGameCache("jasslocalvars.w3v")
    endif
    return udg_GameCache
endfunction

Is it the exact code? :p

Anyways, I'll test it as it is.

EDIT: I'd need to change all the handle vars functions because they call the function "GameCache" >_<

I don't really know if my changes would work... Anyone here knows exactly how those functions work and can mess around with them?

Or do I just need to change every "GameCache" call to a "LocalVars" call?

EDIT again (omg): It worked by changing every "GameCache" call to a "LocalVars" call.

pretty cool man...the divine revenant also looks so nice

It isn't made by me though! :p
 
You could add the code from the LocalVars function to your GameCache function. You could also copy paste the LocalVars function, change the function name to GameCache, and then delete the old GameCache function.

Changing all instances of GameCache is a bit complex way to do it :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    +1
  • Varine Varine:
    I've been really into this
  • Varine Varine:
    It's a musical retelling of The Odyssey
  • Varine Varine:
    Also if you want mixed drinks without alcohol, there's a handful of non-alcoholic 'spirits'. Ritual Zero and Free Spirit are the two brands I've tried and they are alright. They don't have a TON of options, but they have some gin and whiskey alternatives that are fun to play with.
  • Varine Varine:
    I got a couple bottles to make some mixy drinks around holidays when I mostly want to drink, they aren't exact replacements but they are surprisingly close.
  • Varine Varine:
    I ended up with some hop water things that I really like instead for when I want to feel like I'm participating
  • Varine Varine:
    I just got moved to unsupervised probation, so I can get away with drinking a bit now. I technically am not supposed to, but I don't think I get checked anymore. I really want to smoke weed but it scares me
  • The Helper The Helper:
    Happy Wednesday! I am not feeling it today, my teeth are bothering me, or the fragments that were left behind are coming up and it is extra painful today. Don't ever let them tell you that getting full dental implants is easy. They have to pull all your teeth to do those and apparently they are not very good at getting all the teeth out all the time.
    +1
  • The Helper The Helper:
    That is true with Dentures too. I am taking the day off and working from home. The big difference is though, I am not drinking anymore so I have a nice tea and coffee regimen set up :)
  • Varine Varine:
    I wish i had a 3D scanner
  • Varine Varine:
    That would make what I'm doing SO much easier
  • Varine Varine:
    I guess I could just take a picture of it and then use that as a reference. I have a circuit board with some weird holes I can't get measured right
  • Varine Varine:
    Oh I got a Klipper mod for my big printer! It comes with a bunch of parts and I don't totally understand what it does but apparently it's way better than Marlin, which is I think what it currently runs
    +1
  • The Helper The Helper:
    Nice!
  • Varine Varine:
    You're people in Florida safe? The only couple I know are safe but I think they evacuated.
  • The Helper The Helper:
    They are without power but safe. Flood damage and stuff alot of tornados hit east Florida. No fatalities or injuries to any of my people that I know of
  • The Helper The Helper:
    They have been through all the Florida hurricanes they are like me I have been through every texas hurricane for the last 50 years.
  • The Helper The Helper:
    Never evacuated.
  • The Helper The Helper:
    Check out this bad ass Chicken Noodle soup recipe - https://www.thehelper.net/threads/crack-chicken-noodle-soup.196687/
  • The Helper The Helper:
    Happy Saturday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top