Spell Unholy Pervasion

cr4xzZz

Also known as azwraith_ftL.
Unholy Pervasion


A spell from my map - Mini Ashenvale Arena.
Idea came from Cohadar's Ancestral Spirits, so this is why they look similar.

GUI/JASS/vJASS? vJASS.
MUI? Yes.
Leakless? Yes.
Lagless? Yes. (It's normal to lag on first cast)
Follows JESP? I couldn't find a way to make it fully JESP... Only two arguments aren't.
Requires?
- TT v3.4 by Cohadar
- JASS NewGen Pack v1.5a

Description:
Creates spirits that will follow you everywhere but will return if they go too far away. The spirits will attack all enemies they acquire, while in the same time, enemies will be slowed greatly. Spirits cannot be killed unless they are Purged or targeted by a really powerful spell. Attacked spirits will explode violently, sending dark waves everywhere and burning mana. Duration, number of spirits, strength of the slow and the damaging from each explosion increases each level. The slow lasts as long as the spell continues, even if all spirits are killed.


Code:
JASS:

scope UnholyPervasion initializer DoIt

//===========================================================================
// Unholy Pervasion by cr4xzZz (also known as azwraith_ftL)
// Date: August 13, 2008
// Version: 1[1].0b
//===========================================================================
// C O N F I G U R A T I O N     M E N U
//===========================================================================
globals
// Raw code of the Summer Storm ability.
    private constant integer AID_UNHOLY_PERVASION = 'A000'
// Raw code of the Wave ability (Unholy Pervasion Wave in Object Editor).
    private constant integer AID_UNHOLY_PERVASION_WAVE = 'A001'
// String for casting the Wave ability (Unholy Pervasion Wave in Object Editor).
    private constant string SID_WAVE = "breathoffire"
// Raw code of the Slow ability (Unholy Pervasion Slow in Object Editor).
    private constant integer AID_UNHOLY_PERVASION_SLOW = 'A002'
// String for casting the Slow ability (Unholy Pervasion Slow in Object Editor).
    private constant string SID_SLOW = "slow"
// Raw code of the Spirit unit (Unholy Pervasion Spirit in Object Editor).
    private constant integer UID_UNHOLY_PERVASION_SPIRIT = 'h000'
// Raw code of the Dummy Unit.
    private constant integer UID_DUMMY = 'u001'
// What kind of order the spirit to issue when it has to move periodically.
// Note that it issues an order on a location, not a unit.
    private constant string SID_ORDER = "attack"
    
// Period between casting AID_UNHOLY_PERVASION_SLOW and movement of spirits.
    private constant real PERIOD = 1.

// Effect attached to the caster during the effect of the ability.
    private constant string SFX_ATTACH = "Abilities\\Spells\\Other\\HowlOfTerror\\HowlTarget.mdl"
// Attachment point for the SFX_ATTACH special effect.
    private constant string AP_ATTACH = "chest"
// Effect created when a spirit explodes.
    private constant string SFX_EXPLODE = "Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl"
    
// One of these two effects will be created on enemies randomly every time Slow is casted (just some eyecandy).
    private constant string SFX_ONE = "Objects\\Spawnmodels\\Undead\\UndeadDissipate\\UndeadDissipate.mdl"
    private constant string SFX_TWO = "Abilities\\Spells\\Undead\\OrbOfDeath\\AnnihilationMissile.mdl"
// Attachment point of the two effects above.
    private constant string AP_ONETWO = "origin"
endglobals
// I have included the caster below because someone might want to base values on his attributes.

// Number of Spirits that are created.
    private function SPIRIT_NUMBER takes unit cast, integer lvl returns integer
        return 1 + (1 * lvl)
    endfunction
// Red colouring of the Spirits.
    private function SPIRIT_RED takes unit cast, integer lvl returns integer
        return 255
    endfunction
// Green colouring of the Spirits.
    private function SPIRIT_GREEN takes unit cast, integer lvl returns integer
        return 255
    endfunction
// Blue colouring of the Spirits.
    private function SPIRIT_BLUE takes unit cast, integer lvl returns integer
        return 255
    endfunction
// Transparency of the Spirits.
    private function SPIRIT_ALPHA takes unit cast, integer lvl returns integer
        return 128
    endfunction
// Max distance for the spirits. If they pass it, they will be instantly returned to the caster.
    private function SPIRIT_DISTANCE takes unit cast, integer lvl returns real
        return 450. + (25. * lvl)
    endfunction
// Mana burned when a Spirit explodes.
    private constant function MANA_BURN takes nothing returns real
        return 50.
    endfunction
// AoE in which the units get their mana burned when a Spirit explodes.
    private constant function MANA_AOE takes nothing returns real
        return 300.
    endfunction
// In this AoE all enemies will be slowed every X seconds (PERIOD).
    private function AOE takes unit cast, integer lvl returns real
        return 450. + (25. * lvl)
    endfunction
// Duration of the spell.
    private function DURATION takes unit cast, integer lvl returns real
        return 5. * lvl
    endfunction
//===========================================================================
// E N D     O F     C O N F I G U R A T I O N     M E N U
//===========================================================================

private struct Data
    unit cast
    integer lvl
    unit array spirit[100] // if you are crazy enough to create more than 100 spirits...
    integer fps = R2I(PERIOD / TT_PERIOD)
    integer ticks  
    effect sfx
    
    method onDestroy takes nothing returns nothing
        local integer i = 0
        call DestroyEffect(.sfx)
        loop
            exitwhen .spirit<i> == null
            call KillUnit(.spirit<i>)
            set .spirit<i> = null
            set i = i + 1
        endloop
    endmethod
endstruct

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == AID_UNHOLY_PERVASION
endfunction

private function Enum takes nothing returns boolean
    if IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) then
        if IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) == false then 
            if IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false then
                return true
            endif
        endif
    endif
    return false
endfunction

private function Attack takes nothing returns boolean
    local unit first = null
    local group gr = null
    local unit at = null
    local integer i = 1
    local real x
    local real y 
    if GetUnitTypeId(GetTriggerUnit()) == UID_UNHOLY_PERVASION_SPIRIT and IsUnitEnemy(GetAttacker(), GetOwningPlayer(GetTriggerUnit())) then
        set at = GetTriggerUnit()
        set gr = CreateGroup()
        call GroupEnumUnitsInRange(gr, GetUnitX(at), GetUnitY(at), MANA_AOE(), Condition(function Enum))
        loop
            set first = FirstOfGroup(gr)
            exitwhen first == null
            call SetUnitState(first, UNIT_STATE_MANA, GetUnitState(first, UNIT_STATE_MANA) - MANA_BURN())
            call GroupRemoveUnit(gr, first)
        endloop
        call DestroyGroup(gr)
        loop
            exitwhen i &gt; 8
            set first = CreateUnit(GetOwningPlayer(at), UID_DUMMY, GetUnitX(at), GetUnitY(at), 0.)
            call UnitAddAbility(first, AID_UNHOLY_PERVASION_WAVE)
            set x = GetUnitX(at) + 200. * Cos((45. * i) * bj_DEGTORAD)
            set y = GetUnitY(at) + 200. * Sin((45. * i) * bj_DEGTORAD)
            call IssuePointOrder(first, SID_WAVE, x, y)
            call UnitApplyTimedLife(first, 'BTLF', 2.)
            set i = i + 1
        endloop
        call KillUnit(at)
        set gr = null
        set first = null
        set at = null
        return true
    endif
    return false
endfunction

private function Callback takes nothing returns boolean
    local Data d = TT_GetData()
    local integer i = 0
    local real x = GetUnitX(d.cast)
    local real y = GetUnitY(d.cast)
    local real dx
    local real dy
    local real sr
    local group gr = null
    local unit first = null
    set d.ticks = d.ticks - 1
    if GetWidgetLife(d.cast) &lt; .405 or d.ticks &lt;= 0 then
        call d.destroy()
        return true
    else
        set d.fps = d.fps - 1
        if d.fps &lt;= 0 then
            set d.fps = R2I(PERIOD / TT_PERIOD)
            loop
                exitwhen i &gt; SPIRIT_NUMBER(d.cast, d.lvl) - 1
                set dx = x - GetUnitX(d.spirit<i>)
                set dy = y - GetUnitY(d.spirit<i>)
                set sr = SquareRoot(dx * dx + dy * dy)
                if sr &gt; SPIRIT_DISTANCE(d.cast, d.lvl) then
                    call SetUnitX(d.spirit<i>, x)
                    call SetUnitY(d.spirit<i>, y)
                endif
                set sr = GetRandomReal(0., 360.)
                set dx = GetUnitX(d.spirit<i>) + 400. * Cos(sr * bj_DEGTORAD)
                set dy = GetUnitY(d.spirit<i>) + 400. * Sin(sr * bj_DEGTORAD)
                call IssuePointOrder(d.spirit<i>, SID_ORDER, dx, dy)
                set i = i + 1
            endloop
            set gr = CreateGroup()
            call GroupEnumUnitsInRange(gr, x, y, AOE(d.cast, d.lvl), Condition(function Enum))
            loop
                set first = FirstOfGroup(gr)
                exitwhen first == null
                if IsUnitEnemy(first, GetOwningPlayer(d.cast)) then
                    set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(d.cast), UID_DUMMY, x, y, 0.)
                    call UnitAddAbility(bj_lastCreatedUnit, AID_UNHOLY_PERVASION_SLOW)
                    call SetUnitAbilityLevel(bj_lastCreatedUnit, AID_UNHOLY_PERVASION_SLOW, d.lvl)
                    call IssueTargetOrder(bj_lastCreatedUnit, SID_SLOW, first)
                    call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 2.)
                    if GetRandomInt(1, 2) == 1 then
                        call DestroyEffect(AddSpecialEffectTarget(SFX_ONE, first, AP_ONETWO))
                    else
                        call DestroyEffect(AddSpecialEffectTarget(SFX_TWO, first, AP_ONETWO))
                    endif
                endif
                call GroupRemoveUnit(gr, first)
            endloop
            call DestroyGroup(gr)
            set gr = null
            set first = null
        endif
    endif
    return false
endfunction

private function Actions takes nothing returns nothing
    local Data d = Data.create()
    local integer i = 0
    set d.cast = GetTriggerUnit()
    set d.lvl = GetUnitAbilityLevel(d.cast, AID_UNHOLY_PERVASION)
    loop
        exitwhen i &gt; SPIRIT_NUMBER(d.cast, d.lvl) - 1
        set d.spirit<i> = CreateUnit(GetOwningPlayer(d.cast), UID_UNHOLY_PERVASION_SPIRIT, GetUnitX(d.cast), GetUnitY(d.cast), GetRandomReal(1., 360.))
        call UnitApplyTimedLife(d.spirit<i>, 'BTLF', DURATION(d.cast, d.lvl))
        call SetUnitVertexColor(d.spirit<i>, SPIRIT_RED(d.cast, d.lvl), SPIRIT_GREEN(d.cast, d.lvl), SPIRIT_BLUE(d.cast, d.lvl), SPIRIT_ALPHA(d.cast, d.lvl))
        set i = i + 1
    endloop
    set d.ticks = R2I(DURATION(d.cast, d.lvl) * d.fps)
    set d.sfx = AddSpecialEffectTarget(SFX_ATTACH, d.cast, AP_ATTACH)
    call TT_Start(function Callback, d)
endfunction

private function DoIt takes nothing returns nothing
    local trigger trig
    set trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(trig, Condition(function Conditions))
    call TriggerAddAction(trig, function Actions)
    
    set trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(trig, Condition(function Attack))
endfunction

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



Screenshots:
Attached to the post... But it's better to see the spell in-game.


Credits:
Credits to Cohadar for TT, PUI and CreepRevival and to Tinki3 for the Test Map Template (edited though).
 

Attachments

cr4xzZz

Also known as azwraith_ftL.
> I love this Spell
Hehe. Couldn't do it fully as you suggested, never used illusions before... Must start practicing some day.

> Might take it over for my Game xD
Sure, but wait until (if) it gets approved. There still may be 1-2 leaks out there. :)
 

Cohadar

master of fugue
Well this spell sux, mostly because it missed the theme.
It looks absolutely holy but it claims to be unholy, even the hero has holy attack lol.
And fire lord model has nothing to do with holy, unholy or even ghost theme.

I suggest you choose some better models/effects or change the theme completely.
Perhaps some skeleton models since you already got skeleton on that icon.

As for coding:
JASS:

    method onDestroy takes nothing returns nothing
        local integer i = 0
        call DestroyEffect(.sfx)
        loop
            exitwhen .spirit<i> == null  // when you use null for loop check
            call KillUnit(.spirit<i>)
            set .spirit<i> = null // You must null the stuff you are looping
            set i = i + 1
        endloop
    endmethod
</i></i></i>


JASS:

// learn to write conditions and filters in multiple lines
private function Enum takes nothing returns boolean
    if IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) then
        if IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) == false then
            if IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false then
                return true
            endif
        endif
    endif
    return false
endfunction


JASS:

// wtf is this? use scope initializer.
function InitTrig_UnholyPervasion takes nothing returns nothing
 

cr4xzZz

Also known as azwraith_ftL.
> Well this spell sux, mostly because it missed the theme.
Maybe. That's why I made it fully customizeable. But I like it the way it is. People have different tastes.
Really, just because holy light uses some yellow flash and my spell uses this flash it automatically has to be holy.

> And fire lord model has nothing to do with holy, unholy or even ghost theme.
No? But I love it for undeadish/unholy spells.

> or change the theme completely.
Well, if other people don't like it the way it is, I will change it to something really unholy.

> // You must null the stuff you are looping
Will null.

> // learn to write conditions and filters in multiple lines
Yeah, better readability...

> // wtf is this? use scope initializer.
Had a problem in the past and stopped using public InitTrig. I'll fix it but if I still have them, I'll stick to the current one.

EDIT: Actually, I'll edit the theme right now...
 

Cohadar

master of fugue
Had a problem in the past and stopped using public InitTrig. I'll fix it but if I still have them, I'll stick to the current one.
I am not talking about public InitTrig, I am talking about this:
JASS:
scope SomeScopeName initializer SomeInitializerName

private function Actions takes nothing returns nothing
   //...
endfunction

private function SomeInitializerName takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerAddActions(trig, function Actions)
    //...
endfunction

endscope

Same stuff as for libraries

Btw initializer functions can be public, private or none, it does not matter.
I just like them private.
 

cr4xzZz

Also known as azwraith_ftL.
Updated as Cohadar suggested. Changed the theme to something more undeadish (now it's purple ^^) but did no coding modifications on the spell. Only minor stuff. Working on screenshots.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I was hoping you were going to say you wanted to be a cook and wished to open up a Food Truck there are so many opportunities for that here
  • The Helper The Helper:
    you can only open the bar if you sell food and a food truck in the parking lot counts
  • The Helper The Helper:
    here in houston
  • The Helper The Helper:
    most bars are struggling to build food prep and even some I know are doing there own food trucks
  • The Helper The Helper:
    but yeah man you should come to Houston there is so much more opportunity here than San Antonio. Just look at all the homeless people on the Riverwalk and downtown there you cannot even walk down the street without getting mobbed them
  • The Helper The Helper:
    check out this place apparently it is the best roommate site out there roommates.com lol
  • Varine Varine:
    The homeless people reminded me of New York
  • Varine Varine:
    I'll check it out, my lease expires in like a few months so I need to figure something out.
  • Varine Varine:
    I tried to open a food truck in Sandpoint a few years ago but the city said no, then like two years later they passed new laws to encourage it and gave them all fucking tax breaks and shit. And at that point I didn't have enough money to go buy one so I was way too late to the game once other cities realized they could just bring their existing truck there, or sell their brick and mortar.
  • Varine Varine:
    I do like food trucks though, they're way more fun than restaurants and usually I also get some of that tip money there.
  • Varine Varine:
    Restaurants are really hard if you don't have a back up source of income to fund them sometimes, in my experience most owners either got really really lucky, had existing money that allowed them to buy an already successful one, or they have family money to fall back on for loans. It's few and far between to see very inspiring success stories where the person actually got it through hard work and perseverance. I thought about opening one lots and I always just end up not thinking it'll work. I would much rather just find someone that has that money and go work for them
  • The Helper The Helper:
    i am not talking about opening a brick and mortar I am talking about food trucks though I have seen some brick and mortar mexican places open up during covid that are doing good because there food is awesome!
  • The Helper The Helper:
    Food trucks are killing out here because Bars cannot open unless they sell food and the governor ok'd the use of a food truck in front as serving food
  • The Helper The Helper:
    Just not enough food trucks
  • The Helper The Helper:
    a buddy of mine just opened up a food truck and he is killing it but he is a great cook and has awesome food right in the middle of the pandemic too food trucks are immune to pandemic because they are take out in Texas you will always be able to get take out or delivery
  • The Helper The Helper:
    He is in the different food facebook groups in houston and posts videos of him making his food
  • The Helper The Helper:
    he is killing it
  • jonas jonas:
    @Varine with the restaurants, there surely is a lot of luck and hard work but most restaurants fail because they suck. Flair isn't right, economics not well thought through, food is mediocre or sucks, location is bad, etc. If you're thinking about opening one, make sure you're looking at the stories of those that would be playing at your level, don't let your hopes be dragged down by all the subpar restaurants out there.
  • jonas jonas:
    I'm a bit worried about the future of data science, there's an influx of incompetent people hired by incompetent managers, that can't last. But I'm sure smart data scientists will always be useful and hireable. Same as smart security people.
  • jonas jonas:
    My sister in law worked in a vegan food truck, the owners were also making a killing, added several trucks and opened two restaurants over 5 years
  • Ghan Ghan:
    The CompTIA stuff is pretty much crap unfortunately. The places that ask for those low-level certs aren't likely places you want to work. For IT you really want a degree, but in the meantime you need to figure out some way to learn the skills. Cybersecurity is really hot right now so competition is fierce.
  • tom_mai78101 tom_mai78101:
    I realized I don't have anything much to say, other than "Good luck!". Compared to other places, I'm just very lucky we didn't have a lot of surges of cases coming in.
  • The Helper The Helper:
    My daughter just got back from school at Georgetown TX, outside of Austin and said there were 100 cases in the last week but she also said nobody was wearing a mask anywhere so people mask up and stay safe!
    +2
  • thewrongvine thewrongvine:
    happy thanksgiving folks!

    Members online

    No members online now.

    Affiliates

    Hive Workshop
    Top