Spell Power Rage!

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
GetTiggeringUnit() wasn't working properly.

Why do you still have

Jass:
= CreateTimer()?
----------
Why is the group still in the struct?
----------
"thunderbolt" still isn't configurable.

I uploaded bad version.
Group >>Mixed global and struct data.

Also the "tunerbolt is there, well hidden but there :D
JASS:
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
 

WolfieeifloW

WEHZ Helper
Reaction score
372
You still don't need P to be an array though.
And the group should still be a global;
Not a struct member.
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Updating, I'll let you know that when I don't put timer t = CreateTimer()
It won't work.
Before updating, may I have your comments about that?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Create your timer before you start it.
With CSData I think it's:
JASS:
StartTimer

Or something.

You don't need that TriggerHappy (Unless it's a CSData specific thing) :rolleyes: .
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Again, I don't use CSData.
Read the documentation of it.
It will tell you how to create a timer.

EDIT: TimerUtils documentation tells you how (To create a timer for TimerUtils):
JASS:
//* set t=NewTimer()      : Get a timer (alternative to CreateTimer)

So I'm assuming CSData's documentation does too.
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
It doesn't

Why can't I use timer t = CreateTimer()

a) It desyncs
b) It leaks
c) None of these answers, it's because: (you answer there)
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I guess you can;
I just never have.
With TimerUtils you create the timer using the line stated above.

EDIT: Yeah, you can keep it I guess.
I'd make the switch to TimerUtils though.
 

BlackRose

Forum User
Reaction score
239
From the screenshot, it looks weird. Dust under him? Shouldn't it be on him? Though screenie is not very good. I'll test later.
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
May someone aproove this code with TimerUtils before I make an update o_O

JASS:

scope 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 = CreateTimer()
    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 PauseTimer(GetExpiredTimer())
        call DestroyTimer(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)
    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
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
What is the error?

sec.

Undeclared function: NewTimer()
Code:
JASS:
scope 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 = NewTimer()
    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 PauseTimer(GetExpiredTimer())
        call DestroyTimer(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)
    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
 
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