• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Omniblast[suggestions/comments]

Status
Not open for further replies.
This is a script for my spell Omniblast which I made in the map that I'm working on.. I just want to hear your comments or suggestions about it.. About the waits/TSA I need them there and I don't really need that much accuracy....

Here's the script

JASS:
function Trig_OmniBlast_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00L' ) ) then
        return false
    endif
    return true
endfunction

function check takes nothing returns boolean
    return (GetOwningPlayer(GetFilterUnit()) != GetOwningPlayer(GetTriggerUnit()))
endfunction

function Trig_OmniBlast_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit()
    local location b = GetUnitLoc(a)
    local location c = GetSpellTargetLoc()
    local integer d = GetUnitAbilityLevel(a, GetSpellAbilityId())
    local integer e = 0
    local real x
    local real y
    local real z = Atan2(GetLocationY(c) - GetLocationY(b), GetLocationX(c) - GetLocationX(b))
    local player g = GetOwningPlayer(a)
    local unit h
    local group i = CreateGroup()
    local group j = CreateGroup()
    local location l
    local effect m
    local unit u
    local unit v
    loop 
        exitwhen e == 7
        set x = GetLocationX(b) + (100*e) * Cos(z)
        set y = GetLocationY(b) + (100*e) * Sin(z)
        set h = CreateUnit(g, 'h004', x, y, 0.00)
        set l = Location(x,y)
        call GroupEnumUnitsInRangeOfLoc(i, l, 225, Condition(function check))
        loop
            set u = FirstOfGroup(i)
            exitwhen u == null
            set v = CreateUnit(g, 'h002', x, y, 0.00)
            call UnitAddAbility(v, 'A00T')
            call UnitApplyTimedLife(v,'BTLF', 1.00)
            call IssueTargetOrder(v, "cripple", u)
            call GroupRemoveUnit(i, u)
        endloop
        call UnitApplyTimedLife(h,'BTLF', 1.5 + I2R(e)*.1)
        set e = e + 1
    endloop
    set e = 0
    call TriggerSleepAction(.9)
    loop
        exitwhen e == 7
        set x = GetLocationX(b) + (100*e) * Cos(z)
        set y = GetLocationY(b) + (100*e) * Sin(z)
        set m = AddSpecialEffect("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl",x,y)
        call DestroyEffect(m)
        set l = Location(x,y)
        call GroupEnumUnitsInRangeOfLoc(i, l, 225, Condition(function check))
        loop
            set u = FirstOfGroup(i)
            exitwhen u == null
            if IsUnitInGroup(u, j) == false then
                call UnitDamageTarget(a, u, 125*(1 + I2R(d)), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
                call GroupAddUnit(j, u)
            endif
        call GroupRemoveUnit(i, u)
        endloop
        call RemoveLocation(l)
        set e = e + 1
        call TriggerSleepAction(.1)
    endloop
    call DestroyGroup(i)
    call DestroyGroup(j)
    call RemoveLocation(b)
    call RemoveLocation(c)
    set a = null
    set b = null
    set c = null
    set h = null
    set g = null
    set l = null
    set i = null
    set m = null
    set u = null
    set j = null
    set v = null
endfunction

//===========================================================================
function InitTrig_OmniBlast takes nothing returns nothing
    set gg_trg_OmniBlast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_OmniBlast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_OmniBlast, Condition( function Trig_OmniBlast_Conditions ) )
    call TriggerAddAction( gg_trg_OmniBlast, function Trig_OmniBlast_Actions )
endfunction
 
Last edited:
Level 11
Joined
Apr 28, 2008
Messages
696
Timers can be used to trigger a function when they expire.

JASS:
local timer t = CreateTimer()

call TimerStart(t, 1., false,  function YourFunction)

This will create a local timer, starts it with a duratuion of 1 second as nonperiodic and sets the function it should trigger when expired to YourFunction.

You can even shorten the code:

JASS:
call TimerStart(CreateTimer(), 1., false, function YourFunction)

Functions triggered by timer musn't take anys parameters. Means to handle over data to the triggered function you either need globals, gamecache or hashtable.

In the triggered function you should remove the expired timer.

JASS:
function YourFunction takes nothing returns nothing

call DestroyTimer(GetExpiredTimer())

//your actions

endfunction
 
Timers can be used to trigger a function when they expire.

JASS:
local timer t = CreateTimer()

call TimerStart(t, 1., false,  function YourFunction)

This will create a local timer, starts it with a duratuion of 1 second as nonperiodic and sets the function it should trigger when expired to YourFunction.

You can even shorten the code:

JASS:
call TimerStart(CreateTimer(), 1., false, function YourFunction)

Functions triggered by timer musn't take anys parameters. Means to handle over data to the triggered function you either need globals, gamecache or hashtable.

In the triggered function you should remove the expired timer.

JASS:
function YourFunction takes nothing returns nothing

call DestroyTimer(GetExpiredTimer())

//your actions

endfunction

okay... kind of figured out what to do..... so I just replace the TSA with the timer function then move the actions that will happen after the wait into another function then call it using the timer? I'll try it.... thanks...
 
*Remove the locations via GetUnitX/Y, GetSpellTargetX/Y and coordinate use for effects
*Shorten the spell-condition to "return GetSpellAbilityId() = 'A000'"
*Remove the effect variable, "Destroy(AddEffect....)" in one line
*Get GroupUtils or use two global groups for enums
*Get TimerUtils and use a timer (both on wc3c.net)

Hm, can't find more :)
 
*Remove the locations via GetUnitX/Y, GetSpellTargetX/Y and coordinate use for effects
*Shorten the spell-condition to "return GetSpellAbilityId() = 'A000'"
*Remove the effect variable, "Destroy(AddEffect....)" in one line
*Get GroupUtils or use two global groups for enums
*Get TimerUtils and use a timer (both on wc3c.net)

Hm, can't find more :)

okay, thanks... but why should I use global groups?.... and one thing, I don't understand vJass....
 
Why shouldn't you use a global group? Group creation and destruction takes time, but you could always use the same existing (and cleared) group for the enums. vJass is quite easy, don't fear it.... Vexorian wrote a manual for it, it's quite understandable.
In addition: Group/TimerUtils don't require ANY vJass knowledge, it only replaces "createTimer" with "NewTimer" and so on.
 
Why shouldn't you use a global group? Group creation and destruction takes time, but you could always use the same existing (and cleared) group for the enums. vJass is quite easy, don't fear it.... Vexorian wrote a manual for it, it's quite understandable.
In addition: Group/TimerUtils don't require ANY vJass knowledge, it only replaces "createTimer" with "NewTimer" and so on.

but if I use a global group then it wouldn't be MUI because I need a group that collects all units that are already damaged until the end of the effect... I'll try learning it...
 
but if I use a global group then it wouldn't be MUI because I need a group that collects all units that are already damaged until the end of the effect... I'll try learning it...

No, exactly then its MUI; because you have all units affected in the group?! :D
Also, vJass is really good and easy to learn imo.
 
No, exactly then its MUI; because you have all units affected in the group?! :D
Also, vJass is really good and easy to learn imo.

No, because if 2 units casted it at the same time then only one omniblast will cause damage... because as the first one hits a unit then that unit is placed into the damaged group... so if the 2nd omniblast hits the unit it wont cause damage unless the first one ends before the 2nd one hits the unit though if you cast at the same time then I guess that would be impossible....
 
Well, you really should learn about Timers, Structs and object instance stacking.

well yeah if I would want to replace the waits... I already know how to do it with the timers + hashtables I think but I wouldnt be able to cast it successively with the same unit though I dont think that matters because there is something called spell cooldown so you cannot cast it repeatedly..... btw what is a struct?

question, If I use timers in place of the TSAs then place the function to be executed in the same trigger can I still use TriggeringUnit?
 
question, If I use timers in place of the TSAs then place the function to be executed in the same trigger can I still use TriggeringUnit?
No

btw what is a struct?
A struct is a class an object is created from. A spell is for example a class, while the actual spellcast is an object.
 
Level 9
Joined
Nov 28, 2008
Messages
704
A struct is a variable that can hold multiple pieces of data.

A location for exmaple is a struct (although you cant use it like vJass does).

Normally you could have:

local location l = Location(0, 0)

And then access the X and Y parts by:

call BJDebugMsg(R2S(l.X))

And such. Structs are useful for holding a lot of data that you want to use it in a huge array.
 
Status
Not open for further replies.
Top