Spell Power Rage!

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Power Rage!
Made by: Blitz
~ v1.50

Informations
GUI\Jass\vJass - vJass
Mui\Mpi - Mui
Leakless - Yes
Lagless - Yes (The first cast does lag, but not after).
Import Diffculty - Easy / Average

Screenshot

Screenie is not very good, try the spell!
war32009062519174348.png


Description
The caster use his ancestral force to propel hisself in the air. He moves in the direction of his enemys. When he touch the ground, he deals 75 damage * the level of the spell and stun for 1.5 second in a 200 aoe.

Code - vJass:
Requires TimerUtils
Reuiqees NewGen;
-Works with 1.23 and 1.23b.

Please be indulgent with me, it's my first stand-alone vJass spell XD
JASS:

cope PowerRage initializer Init

  globals
    private constant integer SPELL_ID = 'A000' //Id of the spell.
    private constant integer DUMMY_ID = 'h000' //Id of the dummy.
    private constant integer DUMMY_ABILITY_ID = 'A001' //Id of the dummy's spell.
    private constant integer FLY_ID = 'Arav' //What allows the caster to fly.
    private constant string MODEL1 = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl" //Model periodic.
    private constant string MODEL2 = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" //Model at cast and at the end.
    private constant string ORDER = "thunderbolt" //The stun order cast
    private constant real DAMAGE_MULTIPLIER = 75.00 //This amount will be multiplied by the level of the spell.
    private constant real OFFSET   = 20.00 //The speed of the caster.
    private constant real DTS = 25.00 //Distance to stop.
    private constant real HEIGHT_MODIFIER = 12.00 //The height multiplier, every time caster move, he's gain the real as  height.
    private constant attacktype AT = ATTACK_TYPE_NORMAL //Attack type.
    private constant damagetype DT = DAMAGE_TYPE_NORMAL //Damage type.
  endglobals
  
//=================================================================================\\
//===============DO NOT TOUCH BELOW HERE UNLESS YOU KNOW WHAT YOU DO!==============\\
//=================================================================================\\  
  globals
    private player array P
    private integer Index
    private unit Dummy
    private group Group = CreateGroup()
  endglobals

private struct data
    integer level
    integer change
    integer execs
    timer t
    unit caster
    real cx
    real cy
    real lx
    real ly
    real offset
    real angle
    real damage
    real height
    player owner
endstruct

private function Cond takes nothing returns boolean
    return GetSpellAbilityId() == SPELL_ID
endfunction

private function GCond takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), P[Index])
endfunction

private function Callback takes nothing returns nothing
    local data d = GetTimerData(GetExpiredTimer())
    local real x
    local real y
    local real dx
    local real dy
    local unit u
    
    set d.offset = d.offset + OFFSET
    set x = d.cx + d.offset * Cos(d.angle * bj_DEGTORAD)
    set y = d.cy + d.offset * Sin(d.angle * bj_DEGTORAD)
    call SetUnitX(d.caster, x)
    call SetUnitY(d.caster, y)
    call DestroyEffect(AddSpecialEffect(MODEL1, x, y))
    set dx = d.lx - x
    set dy = d.ly - y
    set d.execs = d.execs + 1
    
    if d.execs < d.change then
        set d.height = d.height + HEIGHT_MODIFIER
        call SetUnitFlyHeight(d.caster, d.height, 0.00)
    elseif d.execs > d.change then
        set d.height = d.height - HEIGHT_MODIFIER
        call SetUnitFlyHeight(d.caster, d.height, 0.00)
    endif
    
    if SquareRoot(dx * dx + dy * dy) <= DTS then
        call ReleaseTimer(GetExpiredTimer())
        call GroupEnumUnitsInRange(Group, d.lx, d.ly, 200.00, Condition(function GCond))
        call DestroyEffect(AddSpecialEffect(MODEL2, d.lx, d.ly))
        loop
            set u = FirstOfGroup(Group)
            exitwhen u == null
            set Dummy = CreateUnit(d.owner, DUMMY_ID, d.lx, d.ly, 0.00)
            call UnitAddAbility(Dummy, DUMMY_ABILITY_ID)
            call SetUnitAbilityLevel(Dummy, DUMMY_ABILITY_ID, d.level)
            call GroupRemoveUnit(Group, u)
            call IssueTargetOrder(Dummy, ORDER, u)
            call UnitApplyTimedLife(Dummy, 'BTLF', 1.00)
            call UnitDamageTarget(Dummy, u, d.damage, true, false, AT, DT, WEAPON_TYPE_WHOKNOWS)
        endloop
    endif

endfunction

private function Main takes nothing returns nothing
    local data d = data.create()
    local integer i = GetTriggerExecCount(GetTriggeringTrigger())
    local location l = GetSpellTargetLoc()
    local real range
    local real dx
    local real dy
    
    set d.caster = GetTriggerUnit()
    set Index = i
    set P[Index] = GetOwningPlayer(d.caster)
    set d.level = GetUnitAbilityLevel(d.caster, SPELL_ID)
    set d.cx = GetUnitX(d.caster)
    set d.cy = GetUnitY(d.caster)
    set d.lx = GetLocationX(l)
    set d.ly = GetLocationY(l)
    set dx = d.lx - d.cx
    set dy = d.ly - d.cy
    set range = SquareRoot(dx * dx + dy * dy)
    set d.change = R2I(range / OFFSET) / 2
    set d.execs = 0
    set d.angle = bj_RADTODEG * Atan2( d.ly - d.cy, d.lx - d.cx)
    set d.offset = 0.00
    set d.damage = DAMAGE_MULTIPLIER * I2R(GetUnitAbilityLevel(d.caster, SPELL_ID))
    set d.owner = GetOwningPlayer(d.caster)
    call DestroyEffect(AddSpecialEffect(MODEL2, d.cx, d.cy))
    call UnitAddAbility(d.caster, FLY_ID)
    call UnitRemoveAbility(d.caster, FLY_ID)
    set d.t = NewTimer()
    call TimerStart( d.t, 0.02, true, function Callback)
    call SetTimerData( d.t, d)
    
    call RemoveLocation(l)
    set l = null
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t,Condition(function Cond))
    call TriggerAddAction(t,function Main)
endfunction
endscope


Test Map This spell was the 1800th thread of this section: Tutorial and Ressources.
 

_whelp

New Member
Reaction score
54
Your raw code for the ability you use to make your units hover over the ground is hardcoded, which should be a constant global just in case someone changes the spell's raw code.
 

_whelp

New Member
Reaction score
54
The 'Arav' part. It should be a global because someone might change the raw code...
 

_whelp

New Member
Reaction score
54
Wait [I found out seconds ago], you can't change the raw code, but messing with the flight ability could maybe ruin something while casting your spell.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Your size tag abuse is horrid;
Figured I'd tell you before Romek might :p .

Anyways, can you post the description for the spell :eek: ?
I'll look through the code once I know what it's supposed to do.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
JASS:
return (IsUnitEnemy(GetFilterUnit(), P[Index]) == true)

Could become:
JASS:
return IsUnitEnemy(GetFilterUnit(), P[Index])

----------
Use a global group for 'g'.
Right now you're creating a group every 0.02 seconds;
Very inefficient.
----------
JASS:
call AddSpecialEffect(MODEL1, x, y)
call AddSpecialEffect(MODEL2, d.lx, d.ly)
call AddSpecialEffect(MODEL2, d.cx, d.cy)

Where are these destroyed?
----------
Isn't TimerUtils better then CSData?
----------
If possible, use a global dummy for:
JASS:
set dummy = CreateUnit(d.owner, DUMMY_ID, d.lx, d.ly, 0.00)

----------
"thunderbolt" should be configurable.
----------
JASS:
local unit u = GetTriggerUnit()

Put this as a struct member:
JASS:
unit caster

----------
JASS:
local timer t = CreateTimer()

Put this as a struct member too:
JASS:

----------
Not a big thing;
But you could put all of "Main" in a 'Conditions' block instead of an 'Actions' block.


That's all I got for now.
 

_whelp

New Member
Reaction score
54
From CSData to TimerUtils:

[CSData]

1-StartTimer
2-DestroyTimer
3-SetCSData
4-GetCSData

[TimerUtils]

1-NewTimer
2-ReleaseTimer
3-SetTimerData
4-GetTimerData
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Updated v1.02

JASS:
return (IsUnitEnemy(GetFilterUnit(), P[Index]) == true)

Could become:
JASS:
return IsUnitEnemy(GetFilterUnit(), P[Index])

Fixed
----------
Use a global group for 'g'.
Right now you're creating a group every 0.02 seconds;
Very inefficient.
Fixed
----------
JASS:
call AddSpecialEffect(MODEL1, x, y)
call AddSpecialEffect(MODEL2, d.lx, d.ly)
call AddSpecialEffect(MODEL2, d.cx, d.cy)

Where are these destroyed?
Fixed
----------
Isn't TimerUtils better then CSData?
Nothing changed about this yet.
----------
If possible, use a global dummy for:
JASS:
set dummy = CreateUnit(d.owner, DUMMY_ID, d.lx, d.ly, 0.00)

Nothing changed about this, don't know how to do.
----------
"thunderbolt" should be configurable.
Not sure to understand, if they want to edit, they just have to go in the spell and change the settings?
----------
JASS:
local unit u = GetTriggerUnit()

Put this as a struct member:
JASS:
unit caster

Fixed
----------
JASS:
local timer t = CreateTimer()

Put this as a struct member too:
JASS:

Fixed
----------
Not a big thing;
But you could put all of "Main" in a 'Conditions' block instead of an 'Actions' block.
Not changed, not sure to understand.

That's all I got for now.
 

_whelp

New Member
Reaction score
54
A global dummy would be:

JASS:
scope CrazyDummy initializer Founding
    globals
        private player CrazyPlayer
        private real X = 0
        private real Y = 0
        private unit Dummy
    endglobals

    private function Founding
        set CrazyPlayer = Player(0)
        set Dummy = CreateUnit(CrazyPlayer, DummyId, X, Y, 0)
    endfunction
endscope
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Group 'g' should be in your second globals block, not in the struct.
----------
For these:

Do:
JASS:
call DestroyEffect(AddSpecialEffect(MODEL1, x, y))

----------
TimerUtils is easy to use;
You can stay with CSData though.
----------
The global dummy is fine I guess.
----------
"thunderbolt" should be in the top globals block:
JASS:
private constant string DUMMYORDER = "thunderbolt"

----------
"timer t" does not need the "= CreateTimer()"
----------
Instead of doing:
JASS:
call TriggerAddAction(t,function Main)

Then having the spell check the Conditions and such;
Do this:
JASS:
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Main))
endfunction

Then:
JASS:
private function Main takes nothing returns boolean
    local data d

    if (GetSpellAbilityId() == SPELL_ID) then
        d = data.create()
        [...]
    endif
    return false
endfunction

And then this can be removed:
JASS:
private function Cond takes nothing returns boolean
    return GetSpellAbilityId() == SPELL_ID
endfunction
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Instead of doing:
JASS:
call TriggerAddAction(t,function Main)

Then having the spell check the Conditions and such;
Do this:
JASS:
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Main))
endfunction

Then:
JASS:
private function Main takes nothing returns boolean
    local data d

    if (GetSpellAbilityId() == SPELL_ID) then
        d = data.create()
        [...]
    endif
    return false
endfunction

And then this can be removed:
JASS:
private function Cond takes nothing returns boolean
    return GetSpellAbilityId() == SPELL_ID
endfunction

Others change will be made but this will stay like this, if it's not the good spell casted, it creates locals for nothing.. I'll keep it like that since it doesn't change the spell.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
All those locals could be made struct members.
It also prevents an Actions leak;
And Conditions are better then Actions.
 
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