System ss--spellsystem

Vestras

Retired
Reaction score
249
I made this system to make spellmaking easier, and I think I succeded. Not much to say, uses structs and methods, easy to use.

Code: (for those who actually have the time to read.)
JASS:
//==================================================================================================
//                                        SS--SPELLSYSTEM
//                                           BY VESTRAS
//                                          ACTUAL CODE
//                                             v1.00
//==================================================================================================

//==================================================================================================
// History:
// This system was originally created by Vestras for the map Aeon of Souls. Please give credit to 
// me when using!
//
// Why?
// I made this so that spell making could be easier and funnier. I know I've accomplished one of
// the objectives: easier. 
//
// What does it support?
// Currently casters, damage, shapes and sounds. The struct names are: sscaster, ssdamage, ssshapes
// and sssounds. 
//
// I'm always looking for ideas for new structs and methods, so if you have some, please share!
//==================================================================================================

// !!!! START OF SS--SPELLSYSTEM CONFIG !!!! \\
globals
    constant integer     ss_dummy           = 'e000'
    constant integer     ss_heightenabler   = 'Amrf'
    constant integer     ss_player          = 15
    constant real        ss_defaulttime     = 5
    constant attacktype  ss_attacktype      = ATTACK_TYPE_NORMAL
    constant damagetype  ss_defaultdtype    = DAMAGE_TYPE_NORMAL
    constant damagetype  ss_armordtype      = DAMAGE_TYPE_UNIVERSAL
endglobals

// !!!! START OF SS--CASTER MODULE !!!! \\
struct sscaster

    //===============================================================================================
    //     Remember, that dummy casters are slow, so you might want to add a minus cooldown and 
    //     casting time to the dummy ability!

    //=====================//
    static unit dummy      //
    //=====================//
    
    //===============================================================================================
    // create method, if time is 0, a life timer won't be added
    //
    static method create takes player p, real x, real y, real time returns sscaster
        local sscaster d = sscaster.allocate()
        set d.dummy = CreateUnit(p, ss_dummy, x, y, 0)
        if time != 0 then
            call UnitApplyTimedLife(d.dummy, 'BTLF', time)
        else
            call UnitApplyTimedLife(d.dummy, 'BTLF', ss_defaulttime)
        endif
        return d
    endmethod

    method castXY takes integer abilityid, integer level, string orderstring, real tx, real ty returns nothing
        call UnitAddAbility(.dummy, abilityid)
        call SetUnitAbilityLevel(.dummy, abilityid, level)
        call IssuePointOrder(.dummy, orderstring, tx, ty)
    endmethod

    method castLoc takes integer abilityid, integer level, string orderstring, location l returns nothing
        call UnitAddAbility(.dummy, abilityid)
        call SetUnitAbilityLevel(.dummy, abilityid, level)
        call IssuePointOrderLoc(.dummy, orderstring, l)
    endmethod

    method castTarget takes integer abilityid, integer level, string orderstring, unit target returns nothing
        call UnitAddAbility(.dummy, abilityid)
        call SetUnitAbilityLevel(.dummy, abilityid, level)
        call IssueTargetOrder(.dummy, orderstring, target)
    endmethod

    method castInstant takes integer abilityid, integer level, string orderstring returns nothing
        call UnitAddAbility(.dummy, abilityid)
        call SetUnitAbilityLevel(.dummy, abilityid, level)
        call IssueImmediateOrder(.dummy, orderstring)
    endmethod

    //===============================================================================================
    // Removeing methods.
    //
    method removeDummy takes nothing returns nothing
        call RemoveUnit(.dummy)
    endmethod

    method removeDummyTimed takes real time returns nothing
        call UnitApplyTimedLife(.dummy, 'BTLF', time)
    endmethod

    
    //===============================================================================================
    // 
    //
    static method createAndCastXY takes integer abilityid, integer level, real timed, string orderstring, real x, real y, real tx, real ty returns sscaster
        local sscaster d = sscaster.allocate()
        set d.dummy = CreateUnit(Player(ss_player), ss_dummy, x, y, 0)
            call UnitAddAbility(d.dummy, abilityid)
            call SetUnitAbilityLevel(d.dummy, abilityid, level)
            call IssuePointOrder(d.dummy, orderstring, tx, ty)
            call UnitApplyTimedLife(d.dummy, 'BTLF', timed)
        return d
    endmethod

    static method createAndCastLoc takes integer abilityid, integer level, real timed, string orderstring, real x, real y, location l returns sscaster
        local sscaster d = sscaster.allocate()
        set d.dummy = CreateUnit(Player(ss_player), ss_dummy, x, y, 0)
            call UnitAddAbility(d.dummy, abilityid)
            call SetUnitAbilityLevel(d.dummy, abilityid, level)
            call IssuePointOrderLoc(d.dummy, orderstring, l)
            call UnitApplyTimedLife(d.dummy, 'BTLF', timed)
        return d
    endmethod

    static method createAndCastTarget takes integer abilityid, integer level, real timed, string orderstring, real x, real y, unit target returns sscaster
        local sscaster d = sscaster.allocate()
        set d.dummy = CreateUnit(Player(ss_player), ss_dummy, x, y, 0)
            call UnitAddAbility(d.dummy, abilityid)
            call SetUnitAbilityLevel(d.dummy, abilityid, level)
            call IssueTargetOrder(d.dummy, orderstring, target)
            call UnitApplyTimedLife(d.dummy, 'BTLF', timed)
        return d
    endmethod

    static method createAndCastInstant takes integer abilityid, integer level, real timed, string orderstring, real x, real y returns sscaster
        local sscaster d = sscaster.allocate()
        set d.dummy = CreateUnit(Player(ss_player), ss_dummy, x, y, 0)
            call UnitAddAbility(d.dummy, abilityid)
            call SetUnitAbilityLevel(d.dummy, abilityid, level)
            call IssueImmediateOrder(d.dummy, orderstring)
            call UnitApplyTimedLife(d.dummy, 'BTLF', timed)
        return d
    endmethod

    //===============================================================================================
    // 
    //
    string os
    integer aid
    integer lvl
    real time
    real x
    real y
    //====================================//
    static sscaster adata                 //
    static group grpg = CreateGroup()     //
    //====================================//
    //
    // 
    //===============================================================================================
    
    //
    static method AOE_Callback takes nothing returns boolean
        local sscaster a = .adata
        local unit d = CreateUnit(Player(ss_player), ss_dummy, a.x, a.y, 0)
        call UnitAddAbility(d, a.aid)
        call SetUnitAbilityLevel(d, a.aid, a.lvl)
        call IssueTargetOrder(d, a.os, GetFilterUnit())
        call UnitApplyTimedLife(d, 'BTLF', a.time)
        return false
    endmethod

    static method createAndCastAOE takes integer abilityid, integer level, real timed, string orderstring, real x, real y, real radius returns sscaster
        local sscaster d = sscaster.allocate()
        local unit s
            set d.os = orderstring
            set d.aid = abilityid
            set d.lvl = level
            set d.time = timed
            set d.x = x
            set d.y = y
            set sscaster.adata = d
            call GroupEnumUnitsInRange(.grpg, x, y, radius, Filter(function sscaster.AOE_Callback))
        set s = null
        return d
    endmethod

    //===============================================================================================
    // 
    //
    string xos
    integer xaid
    integer xlvl
    real xtime
    real xx
    real xy
    static sscaster grpdata
    //
    // 
    //===============================================================================================
    
    //
    static method Group_Callback takes nothing returns nothing
        local sscaster a = .grpdata
        local unit d = CreateUnit(Player(ss_player), ss_dummy, a.xx, a.xy, 0)
        call UnitAddAbility(d, a.xaid)
        call SetUnitAbilityLevel(d, a.xaid, a.xlvl)
        call IssueTargetOrder(d, a.xos, GetFilterUnit())
        call UnitApplyTimedLife(d, 'BTLF', a.xtime)
    endmethod

    static method createAndCastGroup takes integer abilityid, integer level, real timed, string orderstring, real x, real y, group g returns sscaster
        local sscaster d = sscaster.allocate()
            set d.xos = orderstring
            set d.xaid = abilityid
            set d.xlvl = level
            set d.xtime = timed
            set d.xx = x
            set d.xy = y
            set sscaster.grpdata = d
            call ForGroup(g, function sscaster.Group_Callback)
        return d
    endmethod
    
    //===============================================================================================
    // SetSource methods
    //
    method SetSourceX takes real x returns nothing
        call SetUnitX(.dummy, x)
    endmethod

    method SetSourceY takes real y returns nothing
        call SetUnitY(.dummy, y)
    endmethod
    
    method SetSourceFlyHeight takes real h returns nothing
        call UnitAddAbility(.dummy, ss_heightenabler)
        call SetUnitFlyHeight(.dummy, h, 0)
        call UnitRemoveAbility(.dummy, ss_heightenabler)
    endmethod
    //
    //
    //===============================================================================================
endstruct

// !!!! START OF SS--DAMAGE MODULE !!!! \\
struct ssdamage
    unit damager
    unit target

    static method DamageUnit takes unit damager, unit target, real damage, boolean armor returns nothing
        local ssdamage d = ssdamage.allocate()
        set d.damager = damager
        set d.target = target
        if armor == false then
            call UnitDamageTarget(damager, target, damage, false, false, ss_attacktype, ss_armordtype, null)
        else
            call UnitDamageTarget(damager, target, damage, false, false, ss_attacktype, ss_defaultdtype, null)
        endif
    endmethod

    //===============================================================================================
    //
    //
    unit xdmgr
    real xdmg
    boolean xrm
    //====================================//
    static ssdamage dpedata               //
    static group grpg1 = CreateGroup()    //
    //====================================//
    //
    //
    //===============================================================================================
    
    static method DPE_Callback takes nothing returns boolean
        local ssdamage a = .dpedata
        local ssdamage d
        if IsUnitAlly(GetFilterUnit(), GetOwningPlayer(a.xdmgr)) != true then
            call ssdamage.DamageUnit(a.xdmgr, GetFilterUnit(), a.xdmg, a.xrm)
        endif
        return false
    endmethod

    static method DamagePointEnemies takes unit damager, real x, real y, real radius, real damage, boolean armor returns nothing
        local ssdamage d = ssdamage.allocate()
        set d.xdmgr = damager
        set d.xdmg = damage
        set d.xrm = armor
        set d.damager = damager
        set ssdamage.dpedata = d
            call GroupEnumUnitsInRange(.grpg1, x, y, radius, Filter(function ssdamage.DPE_Callback))
    endmethod

    static method DamagePointEnemiesLoc takes unit damager, location l, real radius, real damage, boolean armor returns nothing
        call .DamagePointEnemies(damager, GetLocationX(l), GetLocationY(l), radius, damage, armor)
    endmethod

    //===============================================================================================
    //
    //
    unit xxdmgr
    real xxdmg
    boolean xxrm
    //====================================//
    static ssdamage dpadata               //
    static group grpg2 = CreateGroup()    //
    //====================================//
    //
    //
    //===============================================================================================
    
    static method DPA_Callback takes nothing returns boolean
        local ssdamage a = .dpadata
        local ssdamage d
        if IsUnitAlly(GetFilterUnit(), GetOwningPlayer(a.xxdmgr)) == true then
            call ssdamage.DamageUnit(a.xxdmgr, GetFilterUnit(), a.xxdmg, a.xxrm)
        endif
        return false
    endmethod

    static method DamagePointAllies takes unit damager, real x, real y, real radius, real damage, boolean armor returns nothing
        local ssdamage d = ssdamage.allocate()
        set d.xxdmgr = damager
        set d.xxdmg = damage
        set d.xxrm = armor
        set d.damager = damager
        set ssdamage.dpadata = d
            call GroupEnumUnitsInRange(.grpg2, x, y, radius, Filter(function ssdamage.DPA_Callback))
    endmethod

    static method DamagePointAlliesLoc takes unit damager, location l, real radius, real damage, boolean armor returns nothing
        call .DamagePointAllies(damager, GetLocationX(l), GetLocationY(l), radius, damage, armor)
    endmethod
    
    //===============================================================================================
    //
    //
    unit xxxdmgr
    real xxxdmg
    boolean xxxrm
    //====================================//
    static ssdamage dpalldata             //
    static group grpg3 = CreateGroup()    //
    //====================================//
    //
    //
    //===============================================================================================
    
    static method DPALL_Callback takes nothing returns boolean
        local ssdamage a = .dpedata
        local ssdamage d 
        call .DamageUnit(a.xxdmgr, GetFilterUnit(), a.xxdmg, a.xxrm)
        return false
    endmethod

    static method DamagePointAll takes unit damager, real x, real y, real radius, real damage, boolean armor returns nothing
        local ssdamage d = ssdamage.allocate()
        set d.xxxdmgr = damager
        set d.xxxdmg = damage
        set d.xxxrm = armor
        set d.damager = damager
        set .dpalldata = d
            call GroupEnumUnitsInRange(.grpg3, x, y, radius, Filter(function ssdamage.DPALL_Callback))
    endmethod

    static method DamagePointAllLoc takes unit damager, location l, real radius, real damage, boolean armor returns nothing
        call .DamagePointAll(damager, GetLocationX(l), GetLocationY(l), radius, damage, armor)
    endmethod

endstruct

// !!!! START OF SS--SHAPES MODULE !!!! \\
struct ssshapes

    //===============================================================================================
    // 
    //
    static method DistanceBetweenCoords takes real x, real y, real tx, real ty returns real
        local real dx = tx - x
        local real dy = ty - y
        return SquareRoot(dx * dx + dy * dy)
    endmethod
    
    static method AngleBetweenCoords takes real xA, real yA, real xB, real yB returns real
        return Atan2(yB - yA, xB - yB)
    endmethod
    //
    //
    //===============================================================================================
    
    static method line takes real x, real y, real tx, real ty, unit c, string fx, integer n, real dmg, real dmgaoe, boolean armor returns nothing
        local ssdamage d
        local integer i = 0
        local real dx = tx - x
        local real dy = ty - y
        local real dist = SquareRoot(dx * dx + dy * dy) / n
        local real angle = Atan2(ty - y, tx - x)
        local real px
        local real py
                
            loop
                set i = i + 1
                exitwhen i > n
                    set px = x + (dist * i) * Cos(angle)
                    set py = y + (dist * i) * Sin(angle)
                    call DestroyEffect(AddSpecialEffect(fx, px, py))
                    call ssdamage.DamagePointEnemies(c, px, py, dmgaoe, dmg, armor)
            endloop
    endmethod

    static method circle takes real x, real y, real radius, unit c, string fx, integer n, real dmg, real dmgaoe, boolean armor returns nothing
        local ssdamage d
        local integer i = 0
        local real angle
        local real px
        local real py
                
            set px = x + radius * Cos(0 * bj_DEGTORAD)
            set py = y + radius * Sin(0 * bj_DEGTORAD)
            call DestroyEffect(AddSpecialEffect(fx, px, py))
            call ssdamage.DamagePointEnemies(c, px, py, dmgaoe, dmg, armor)
            loop
                set i = i + 1
                exitwhen i > n
                    set angle = i * (360 / n)
                    set px = x + radius * Cos(angle * bj_DEGTORAD)
                    set py = y + radius * Sin(angle * bj_DEGTORAD)
                    call DestroyEffect(AddSpecialEffect(fx, px, py))
                    call ssdamage.DamagePointEnemies(c, px, py, dmgaoe, dmg, armor)
            endloop
    endmethod
    
    static method triangle takes real x, real y, real radius, unit c, string fx, real dmg, real dmgaoe, boolean armor returns nothing
        local ssdamage d
        local real angle = GetUnitFacing(c)
        local real px
        local real py
        local integer i = 1
            loop
                set i = i + 1
                exitwhen i > 4
                    set angle = angle + (90 * (i - 1))
                    set px = x + radius * Cos(angle * bj_DEGTORAD)
                    set py = y + radius * Sin(angle * bj_DEGTORAD)
                        call DestroyEffect(AddSpecialEffect(fx, px, py))
                        call ssdamage.DamagePointEnemies(c, px, py, dmgaoe, dmg, armor)
            endloop
    endmethod
    
endstruct

// !!!! START OF SS--SOUND MODULE !!!! \\

struct sssound

    //=================//
    static sound snd   //
    //=================//
    //
    //
    //===============================================================================================
    static method create takes string str returns sssound
    //===============================================================================================
    
    
        local sssound s=sssound.allocate()
        set sssound.snd=CreateSound(str,false,false,true,12700,12700,"")
        return s
    endmethod
    
    method PlaySoundEx takes nothing returns sound
        call StartSound(sssound.snd)
        call KillSoundWhenDone(sssound.snd)
        return sssound.snd
    endmethod
    
    method PlaySoundCone takes real inside, real outside, integer outsideV returns sound
        set sssound.snd=.PlaySoundEx()
        call SetSoundConeAngles(sssound.snd,inside,outside,outsideV)
        return sssound.snd
    endmethod
    
    method AddSpecialEffectWithSound takes string fx, real x, real y, string str returns sound
        set sssound.snd=.PlaySoundEx()
        call DestroyEffect(AddSpecialEffect(fx, x, y))
        return sssound.snd
    endmethod
    
    method AddSpecialEffectTargetWithSound takes string fx, widget target, string attach, string str returns sound
        set sssound.snd=.PlaySoundEx()
        call DestroyEffect(AddSpecialEffectTarget(fx, target, attach))
        return sssound.snd
    endmethod
    // 
    //
    //===============================================================================================
endstruct

// !!!! END OF SS--SPELLSYSTEM !!!! \\


v1.01:
- Fixed minor method stuff.

v1.00:
- Initial release.

Enjoy, and give credit to me if you use.
 

Hatebreeder

So many apples
Reaction score
381
I Personally don't like SpellCasting Systems because they are make Spell creating TOO easy... It is like taking a shortcut (And yes, whenever you take shortcuts, you will regret something).
 

waaaks!

Zinctified
Reaction score
256
can u say that this system is better than vex's caster system? and his latest fucki** awesome xe system?

im just asking
 

Sevion

The DIY Ninja
Reaction score
413
can u say that this system is better than vex's caster system? and his latest fucki** awesome xe system?

^Pwnt^ ^_^

But anyways:

Why use this over the other systems out there? Tell us why we should use this over CS or xe.
 

Vestras

Retired
Reaction score
249
This is beginning to look like spam...
http://www.thehelper.net/forums/showthread.php?t=106367

There's already a thread.
And it's not that busy either...

It's not. I just decided to post it as a resource when I already had posted that.

> I Personally don't like SpellCasting Systems because they are make Spell creating TOO easy... It is like taking a shortcut (And yes, whenever you take shortcuts, you will regret something).

Well, that's opinions. And I don't regret anything so far. :p

> can u say that this system is better than vex's caster system? and his latest fucki** awesome xe system?

im just asking

No, I can't. Because it's a matter of opinion. There's a lot of struct attachment systems too, but those are also for opinion, even though they all in all does the same thing.

> Why use this over the other systems out there? Tell us why we should use this over CS or xe.

As above. You can use this if you in some crazy way like it more than other systems.


EDIT: Updated.
 

waaaks!

Zinctified
Reaction score
256
i think DamagePointAllLoc function is useless, while there is a GUI action for that
 

Matrix

New Member
Reaction score
5
Gj but as for me I don't like such a systems at all.
I personally think that spell have to have all needed in 1 scope without extra systems, etc...

And there is already vex' xe

+rep still!!!
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top