Spell Artillery Barrage

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
I wouldn't be surprised if there is another spell somewhere similar to this, but I didn't find one and I wanted to make this anyway. :p

It's my first spell using vJASS and a scope, so look out for that code! :D

JASS - vJASS (NewGen Required)
MUI - Very
Works - Is that a question for a spell submission? :p
Fun - Great explosions will be had by all!
Leaks - 0 Rads of exposure and falling

Thanks to Tinki3 for the cool test map!

Implementation inside! :D


Artillery Barrage

This spell gives the hero the ability to call up an attack of artillery units from off-screen to splatter your enemies across the map. Or, at least, the spell's AoE. :p


Barrage1.jpg


Barrage2.jpg




Here's the code for it. Critiques appreciated.

JASS:
scope ShockArtillery
    
    globals
        private constant integer Number = 10 // This indicates the number of artillery attacks.
        private constant integer ArtilleryUnit = 'h000' // This is the rawcode of the artillery unit.
        private constant integer AbilityCode = 'A000' // This is the rawcode of the actual artillery ability.
        private constant integer Range = 400 // This is the range of the attack area of the artillery units.
    endglobals
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == AbilityCode
    endfunction
    
    private function ShockArtilleryActions takes nothing returns nothing
        local location targetloc = GetSpellTargetLoc()
        local location UnitLoc = PolarProjectionBJ(targetloc, 4000, GetUnitFacing(GetTriggerUnit()) + 180)
        local location RandomLoc
        local integer count = 0
        local integer AbilityLevel = GetUnitAbilityLevel(GetTriggerUnit(), AbilityCode)
        local unit Artillery
        loop
            exitwhen count >= Number*AbilityLevel
            set count = count + 1
            set Artillery = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), ArtilleryUnit, UnitLoc, 0.00)
            call ShowUnit(Artillery, false)
            set RandomLoc = PolarProjectionBJ(targetloc, GetRandomInt(0, Range/2), GetRandomReal(0, 360))
            call IssuePointOrderLoc( Artillery, "attackground", RandomLoc )
            call UnitApplyTimedLife(Artillery, 'BTLF', 1.50)
            call PolledWait(GetRandomReal(0.10, 0.85))
            call RemoveLocation(RandomLoc)
        endloop        
        call RemoveLocation(targetloc)
        call RemoveLocation(UnitLoc)
        set targetloc = null
        set UnitLoc = null
        set RandomLoc = null
    endfunction

//===========================================================================
    public function InitTrig takes nothing returns nothing
        local trigger ShockArtillery = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ(ShockArtillery, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(ShockArtillery, Condition(function Conditions))
        call TriggerAddAction( ShockArtillery, function ShockArtilleryActions )
    endfunction

endscope
 

Attachments

  • Spell - Artillery Barrage.w3x
    45.4 KB · Views: 413

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Why uses location?
Try using real?

Why using a PollWait before removing the unit? I didn't download the map and I don't know what happen.
Is it required to wait for 1 sec before the artillery to be removed? Then use timer instead? I doubt that it may conflict with other cast and not MUI.

If there is no need to wait for 1sec, add an expiration timer to the unit and it will be auto removed after the timer.

2. You don't have to run set RandomLoc everytime you destroy the location.
Once is more than enough, and it is at the end of the function. Same as unit.

**Note**: I didn't use method for a long time, correct me if I am wrong. I am using struct as member variable is not needed to be nulled. :p
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
> Why uses location?
Try using real?

Because locations made my job much easier. :p

> add an expiration timer to the unit and it will be auto removed after the timer.

I didn't even think of that. Thanks! :D

> You don't have to run set RandomLoc everytime you destroy the location.

Ok. Thanks for the info.
 

Tinki3

Special Member
Reaction score
418
Cool spell :)

This:
JASS:
set Artillery = CreateUnitAtLoc(Player(GetPlayerId(GetOwningPlayer(GetTriggerUnit()))), ArtilleryUnit, UnitLoc, 0.00)

Can be simply:
JASS:
set Artillery = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), ArtilleryUnit, UnitLoc, 0.00)

Also:
JASS:
call IssuePointOrderLocBJ( Artillery, "attackground", RandomLoc )

... could save you an easy BJ by simply removing BJ from the function name.

In your implementation script, you might want to mention that raw codes need to be changed to, whatever they change to, and how to do so.

Some people just do NOT get how to make JASS spells work because some <spell> does not come with info on how to do this.

I try to think about other people that don't have a clue all the time.

After all, they are usually the type that are interested in importing every spell they can get their hands on IMO.

Nice job FTR.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>I didn't even think of that. Thanks!
If you are using that method, you just need to 1 variable. Just set the var = create unit, then set expiration, then create another unit using the same var.

You know how to use struct? It is easier to maintain those variable using struct.
 

Hatebreeder

So many apples
Reaction score
381
When not using structs in scopes, is it better to use liberaries?
Is there any difference between liberaries and scopes?

Anyways, cool Spell ^^
Since it's kinda simple, how about adding some more Spells or refining your spell so that you mustn't use locations and/or BJs...
Like, Bio-Chemical assult: shoots some missle to a target location, and releases a weird green gass. All units that inhale this gass temporary turn into random critters.

BTW, I would make you some realy cool SFX, and release those SFXes parallel to your Spell(s) ^^
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>When not using structs in scopes
I believe that ghan is pretty new to vJass, it is the starting.
And I doubt that ghan knows struct pretty much.

>> is it better to use liberaries?
Not really, they are totally different thing.

>>Is there any difference between liberaries and scopes?
Ofcourse there are!
Library moves all your functions into the map header and lets you able to call them in anywhere of your map.
Scope is the syntax of allowing you to use public and private in the it.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
> This:
Can be simply:

Ah. Thanks. I went in a circle with that. Thought it needed a player number, then came back to Player. :p

> Just set the var = create unit, then set expiration, then create another unit using the same var.

I think that's what I do now. Once I switched to Expiration Timer, I changed it.

> You know how to use struct? It is easier to maintain those variable using struct.

Yes, I can use them, though probably not very effectively. How would using a struct make it easier?

> refining your spell so that you mustn't use locations and/or BJs

I like locations. Especially when trying to do Point With Polar Offset. :D

> And I doubt that ghan knows struct pretty much.

I know all about what they are, for sure. Application is a different matter.... :rolleyes:

Thanks for all the suggestions! I have an update!
 

Cidzero

Imma firin mah lazer!!!1!1
Reaction score
39
Just don't use the mortar team mdl, get the dummy.mdl one, and set the 4k distance to 10000000.
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
> refining your spell so that you mustn't use locations and/or BJs

I like locations. Especially when trying to do Point With Polar Offset. :D

Reals are generally thought of as better, since you aren't creating a handle when you use them.

To project a coordinate (X,Y) over D distance at A angle (in radians):

JASS:
set X=X+D*Cos(A)
set Y=Y+D*Sin(A)


To get the angle, you can either have the user put the angle in as degrees (for instance, the 'spread' of arrows in a multishot spell) and multiply that by BJ_DEGTORAD, or you can use Atan2 (if you want to find the angle between two points.

For Atan2:

JASS:
set A=Atan2(Y2-Y1,X2-X1)
//It&#039;s Y&#039;s, then X&#039;s.
//(OtherY-CentreY,OtherX-CentreX)


For a dash spell where moves some distance toward the target point:

JASS:
local location t=GetSpellTargetLoc()
local real tx=GetLocationX(t)
local real ty=GetLocationY(t)
local unit u=GetTriggerUnit()
local real x=GetUnitX(u)
local real y=GetUnitY(u)
local real a=Atan2(ty-y,tx-x)

set x=x+Distance*Cos(a)
set y=y+Distance*Sin(a)

call SetUnitX(u,x)
call SetUnitY(u,y)


Hopefully you will switch to reals.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Yes, yes. I do know how to do those things. :p
But thanks for laying it out for me.
And I have switched to reals. I just thought it would be easier to do Offset in this spell with a location.

Anyway, tiny update here.
Units are now hidden. :D
 
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