• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Multi Shock (VJASS)

Detail
Status

Forum: http://septimus.invisionplus.net
Coding: VJASS
Current Version: 1.01

Ability Description

Unleash an multiple shockwaves to the targeted enemies. Target this ability far from heroes to cluster the shots.
Target this ability close to heroes to scatter the shots. Each shockwaves deals 75 damage. Number of shockwaves increases with level.

Level 1 - Unleash 3 shockwaves.
Level 2 - Unleash 6 shockwaves.
Level 3 - Unleash 9 shockwaves.

Version 1.01 Update

Fix shockwaves angle (Full credits goes to Dr Super Good).
Change the dummy ability from shockwaves to carrion swarm under the recommendation of the public.




Dark-Dragon - For pointing out a few errors in my coding and gives me a valuable information.
Kingz - For optimize the coding and given me a few helpful tips.
Dr Super Good - Fix the shockwaves angle.

JASS:
library MultiShock initializer Init

globals

    private constant integer ACTIVATOR_RAWCODE = 'A003'

    private constant integer DUMMY_RAWCODE  = 'h000'

    private constant string DUMMY_STRING  = "carrionswarm"

    private constant real TARGET_ARC = 300

    private constant integer WAVE_NUMBER_PER_LEVEL = 3
    private constant integer WAVE_NUMBER_BASE = 0

    private constant real TARGET_ARC_CUTOFF = TARGET_ARC/6.28319

    private constant real TARGET_OFFSET = 150

    private constant real DUMMY_DURATION = 1
endglobals

private function MSCondition takes nothing returns boolean
    return GetSpellAbilityId() == ACTIVATOR_RAWCODE
endfunction

private constant function DummyFilter takes nothing returns boolean
    return true
endfunction

private function MultiShock takes nothing returns nothing
    local unit tu = GetTriggerUnit()
    local location tl = GetSpellTargetLoc()
    local unit lu
    local player p = GetOwningPlayer(tu)
    local integer im = WAVE_NUMBER_BASE + GetUnitAbilityLevel(tu,ACTIVATOR_RAWCODE) * WAVE_NUMBER_PER_LEVEL
    local integer i = 0
    local real x = GetUnitX(tu)
    local real y = GetUnitY(tu)
    local real tx = GetLocationX(tl)
    local real ty = GetLocationY(tl)
    local real distance = SquareRoot((x-tx)*(x-tx)+(y-ty)*(y-ty))
    local real circum
    local real r

    call RemoveLocation(tl)
    set tl = null
    
    
    if distance > TARGET_ARC_CUTOFF then
        set circum = TARGET_ARC/distance
        set r = Atan2(ty-y,tx-x) - circum/2
    else
        set circum = 6.28319
        set r = GetUnitFacing(tu)*bj_DEGTORAD
    endif
    set circum = circum/im
    
    loop
        exitwhen i == im
        set lu = CreateUnit(p,DUMMY_RAWCODE,x,y,r*bj_RADTODEG)
        call UnitApplyTimedLife(lu,'BTLF',DUMMY_DURATION)
        call IssuePointOrder(lu,DUMMY_STRING,x+TARGET_OFFSET*Cos(r),y+TARGET_OFFSET*Sin(r))
        set r = r + circum
        set i = i + 1
    endloop
    
    set tu = null
    set lu = null
    set p = null
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    local filterfunc ff = Filter(function DummyFilter)
    loop
        exitwhen (i >= bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, ff)
        set i = i + 1
    endloop
    call TriggerAddCondition(t,Condition(function MSCondition))
    call TriggerAddAction(t,function MultiShock)
    call DestroyFilter(ff) 
    set ff = null
endfunction
endlibrary
Keywords:
Shock, Multiple, Cluster, Scatter
Contents

Multi Shock Spells (Map)

Reviews
18:52, 3rd Jun 2009 hvo-busterkomo: The spell was pretty good for a first attempt at vJASS. The effect was basic, but well executed. I've attached a script containing a small improvement. You should also be using a constant function with a take and...
Status
Not open for further replies.

Moderator

M

Moderator

18:52, 3rd Jun 2009
hvo-busterkomo:
The spell was pretty good for a first attempt at vJASS. The effect was basic, but well executed. I've attached a script containing a small improvement. You should also be using a constant function with a take and return value instead of WAVE_NUMBER_PER_LEVEL and WAVE_BASE.
JASS:
library MultiShock initializer Init

globals

    private constant integer ACTIVATOR_RAWCODE = 'A003'

    private constant integer DUMMY_RAWCODE  = 'h000'

    private constant string DUMMY_STRING  = "carrionswarm"

    private constant real TARGET_ARC = 300

    private constant integer WAVE_NUMBER_PER_LEVEL = 3
    private constant integer WAVE_NUMBER_BASE = 0

    private constant real TARGET_ARC_CUTOFF = TARGET_ARC/6.28319

    private constant real TARGET_OFFSET = 150

    private constant real DUMMY_DURATION = 1
endglobals

private function MSCondition takes nothing returns boolean
    return GetSpellAbilityId() == ACTIVATOR_RAWCODE
endfunction

private constant function DummyFilter takes nothing returns boolean
    return true
endfunction

private function MultiShock takes nothing returns nothing
    local unit tu = GetTriggerUnit()
    local location tl = GetSpellTargetLoc()
    local unit lu
    local player p = GetOwningPlayer(tu)
    local integer im = WAVE_NUMBER_BASE + GetUnitAbilityLevel(tu,ACTIVATOR_RAWCODE) * WAVE_NUMBER_PER_LEVEL
    local integer i = 0
    local real x = GetUnitX(tu)
    local real y = GetUnitY(tu)
    local real dx = x-GetLocationX(tl)
    local real dy = y-GetLocationY(tl)
    local real distance = SquareRoot(dx*dx+dy*dy)
    local real circum
    local real r

    call RemoveLocation(tl)
    set tl = null
   
   
    if distance > TARGET_ARC_CUTOFF then
        set circum = TARGET_ARC/distance
        set r = Atan2(dy,dx) - circum/2
    else
        set circum = 6.28319
        set r = GetUnitFacing(tu)*bj_DEGTORAD
    endif
    set circum = circum/im
   
    loop
        exitwhen i == im
        set lu = CreateUnit(p,DUMMY_RAWCODE,x,y,r*bj_RADTODEG)
        call UnitApplyTimedLife(lu,'BTLF',DUMMY_DURATION)
        call IssuePointOrder(lu,DUMMY_STRING,x+TARGET_OFFSET*Cos(r),y+TARGET_OFFSET*Sin(r))
        set r = r + circum
        set i = i + 1
    endloop
   
    set tu = null
    set lu = null
    set p = null
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    local filterfunc ff = Filter(function DummyFilter)
    loop
        exitwhen (i >= bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, ff)
        set i = i + 1
    endloop
    call TriggerAddCondition(t,Condition(function MSCondition))
    call TriggerAddAction(t,function MultiShock)
    call DestroyFilter(ff)
    set ff = null
endfunction
endlibrary
 
Level 31
Joined
May 3, 2008
Messages
3,155
This is my first vjass spells which have been view by Dark Dragon and improve by him & Kingz.

It might be rather simple, that was because I make this vjass spells straight after I read 1 tutorial about vjass. You can consider that I jump off from GUI to VJASS without learning JASS.

I still very weak about JASSING :xxd:

P/S : Don't look at me as I was a mad man just because I jump off from GUI to VJASS by barely reading 1 tutorial. I code everything at GUI and convert it to JASS and slowly make it into VJASS, you can try to view the WIP of it. :eekani:
 

Rmx

Rmx

Level 19
Joined
Aug 27, 2007
Messages
1,164
Well think of it that way ........ U cast Shockwave from VJASS and the Shockwave effect or Knockback or push is not nor GUI or vJASS or JASS .. so it's only efficient as GUI...

But if u did Like a Custom shockwave that will be very very very impressive so for now i consider it as a vJASS = GUI trigger ...

Also see me i don't ruch into JASS and i'm now learning it ... going to have my vJASS spell soon :)
 
Level 31
Joined
May 3, 2008
Messages
3,155
Shockwaves are super laggy because of ground shaking. For example when I do more than couple shockwaves sametime in TCO the campaign lags like hell. FPS goes under 5. X_x

Shockwaves are horrible laggy. I suggest change to Carrion Swarm, but shockwave's effect.

lol... just create a carrion swarm ability for dummy unit and change the path of shockwave to carrionswarm at vjass code. It is very simply :p

Another thing is that the spell is simple. Too simple. :p

I could do this type of spell with GUI in 5 mins without any leaks and works as good as JASS or vJASS. X_X_X_X_X_X_X

Hate to say this, but I already done that. :p

Also, it was indeed easy to code in GUI. But how easy it was for people who know nothing about vjass and barely read 1 tutorial about vjass just to make it? :p

well, although I hate GUI and prefer vJass... it's a bad idea rushing into Jass or vJass... dont rush ;)

Why settle for JASS when you could use VJASS :p

My advice to you is to stick a bit longer to GUI before you jump into vJass.

GUI almost have little to no connection with JASS.

Also see me i don't ruch into JASS and i'm now learning it ... going to have my vJASS spell soon :)

lol, I beat you into it. :p

JK, I am curious to know how helpful 1 tutorial could be naturally...
 
Level 15
Joined
Jan 31, 2007
Messages
502
Hmm.. simple.. but simply nice , especially for your first Vjass / Jass Spell

But there are little things which could be optimized:

-Your calculations can be inlined
local real xr = x + dist * Cos(angle * bj_DEGTORAD) return xr

---> return x + dist * Cos(angle * bj_DEGTORAD)

else there can be inlined some other things


-also your use of bj_DEGTORAD and bj_DEGTORAD is quite useless , you could use the Radians directly instead of converting them twice
dont forget to change your set r = (r + 20.00) if you change it


-those PolarProjectionX and PolarProjectionY calculations could be used in the script directly because they are used once , but cuz they are not private its ok


-Youve created a AngleBetweenPoints2 function but in the script your using GetUnitFacing(tu) which could cause some differences because the unit starts casting before it completely faced the target point


-some more constants or spell level related calculations can be moved above to ensure a easy modification
e.g. your local integer im = GetUnitAbilityLevel(tu,Multi_Shock) * 3 can be made into a function which takes the level and returns the number of shockwaves because i can image many would not find where to modificate that
or your "shockwave" order string could be a global string above because the order depends on the used spell (e.g. if its changed to a carrionswarm ability it would bug)


All in all its a decent spell :) these things are minor and its MUI and leakfree
your on a good way
and converting GUI to Jass was also something i made at first, an easy process of learning ;) but possibility to search functions in JNPG (JassCraft) is also a great help
 
Last edited:
Level 15
Joined
Jul 19, 2007
Messages
618
yes yes as -JonNny said very nice for first vJass spell. as well i can see you even coded your own PolarProjection functions which means you learned quite a lot of math (well at least enough for making such a spells like this one). there is as well that thing i agree that you could make global constant string which will hold that string "shockwave" or any other just to be easier for beginners to edit. other then that its really good spell leakless, MUI...

so keep it up!
~Dark Dragon
 
Status
Not open for further replies.
Top