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.

      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