Spell Death Nova

D.V.D

Make a wish
Reaction score
73
Death Nova
By: D.V.D

First vJass Spell Ever:).

Code Type: vJass
Spell Type: No Target
Damage: 50,100,150
Description: The Caster creates circles of dark power around him that keep getting bigger and bigger dealing damage to units in the way. Deals 50,100,150 damage.

Code:
JASS:
scope DeathNova initializer InitTrig

////////////////////////////////////////////////////////////////////////////////////////
//   Variables:                                                                       //
// 1.atype = AttackType of the damage                                                 //
// 2.dtype = DamageType of the damage                                                 //
// 3.amount = Amount of units created(MUST BE A EVEN NUMBER, NO DECIMAL)              //
// 4.damage = Damage done                                                             //
// 5.distance = Distance from the point                                               //
// 6.radius = Radius the damage is done in                                            //
// 7.X = X of the middle of the nova                                                  //
// 8.Y = Y of the middle of the nova                                                  //
// 9.model = The model name when using CreateNovaDamageAllEffect()                    //
// 10.caster = The Casting Unit of the spell                                          //
////////////////////////////////////////////////////////////////////////////////////////
//   Methods:                                                                         //
// 1.OnDestroy = Nulls everything in the struct and sets it to 0                      //
// 2.CreateNovaDamageEffectAll() = Creates a nova that uses Special Effects and       //
// damages all the units even allies and yours.                                       //
// 3.CreateNovaDamageAllUnit() = Creates a nova made from units that damages all      //
// units including yours and allies.                                                  //
////////////////////////////////////////////////////////////////////////////////////////

globals
private constant attacktype Atype = ATTACK_TYPE_MAGIC
private constant damagetype Dtype = DAMAGE_TYPE_NORMAL
private constant integer ID = 'AHtc'
private constant real Amount = 20.00
private constant real Distance = 100.00
private constant real Radius = 50.00
private constant string ModelId = "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl"
endglobals

private function GetDamage takes unit caster, integer ID returns real
    return(GetUnitAbilityLevel(caster,'AHtc') * 10.00)
endfunction

public struct nova
attacktype atype
damagetype dtype
real amount
real damage
real distance
real radius
real X
real Y
string model
unit caster

method onDestroy takes nothing returns nothing
    set .amount = 0.00
    set .distance = 0.00
    set .radius = 0.00
    set .X = 0.00
    set .Y = 0.00
    set .caster = null
endmethod

method CreateNovaDamageAllEffect takes nothing returns nothing
    local real angle = 0
    local real intervals = 360 / .amount
    local real x
    local real y
    local effect f
    loop
       exitwhen angle > 360
       set x = .X + .distance * Cos(angle * bj_DEGTORAD)
       set y = .Y + .distance * Sin(angle * bj_DEGTORAD)
       set f = AddSpecialEffect(.model, x, y)
       call UnitDamagePoint(.caster, 0.00, .radius, x, y, .damage, true, false, .atype, .dtype, WEAPON_TYPE_WHOKNOWS)
       set angle = angle + intervals
    endloop
    call DestroyEffect(f)
    set f = null
endmethod

endstruct

private function DeathNova takes nothing returns nothing
    local nova d = nova.create()
    local integer i = 1
    local integer e = 10
    set d.caster = GetTriggerUnit()
    set d.X = GetUnitX(d.caster)
    set d.Y = GetUnitY(d.caster)
    set d.model = ModelId
    set d.distance = Distance
    set d.amount = Amount
    set d.damage = GetDamage(d.caster,ID)
    set d.radius = Radius
    set d.atype = Atype
    set d.dtype = Dtype
    loop
       exitwhen i > e
       set d.amount = d.amount + 5.00
       set d.distance = d.distance + 100.00
       set d.radius = d.radius + 10.00
       call d.CreateNovaDamageAllEffect()
       call PolledWait(0.10)
       set i = i + 1
    endloop
endfunction

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction

//===========================================================================
private function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction(t, function DeathNova )
endfunction

endscope


Screenshots:
Untitled-46.jpg

How to Import:
Copy the code from the map and create a new trigger. Convert the trigger into Jass and delete the code. Then paste the code there and create a ability and edit the raw code in the trigger to the raw code of your ability.
 

Attachments

  • Death Nova.w3x
    18.2 KB · Views: 496

Azlier

Old World Ghost
Reaction score
461
JASS:
private function Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == ID ) ) then
        return false
    endif
    return true
endfunction

Eww, gross. GUI style condition.

JASS:
set d.caster = GetTriggerUnit()
    set d.X = GetUnitX(GetTriggerUnit())
    set d.Y = GetUnitY(GetTriggerUnit())

Why call GetTriggerUnit() so much?

JASS:
call PolledWait(0.10)

Inaccurate.

JASS:
set d.model = "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl"
    set d.distance = 100.00
    set d.amount = 20.00
    set d.damage = GetUnitAbilityLevel(d.caster,'AHtc') * 10
    set d.radius = 50.00
    set d.atype = ATTACK_TYPE_MAGIC
    set d.dtype = DAMAGE_TYPE_NORMAL

Constants and configuration functions, please.

JASS:

Don't forget to null it.

JASS:
struct nova

Public, at the very least? Nova is such a common name.

JASS:
method OnDestroy takes nothing returns nothing

Never gets called. onDestroy, not OnDestroy.

JASS:
set .amount = 0.00
set .distance = 0.00
set .radius = 0.00
set .X = 0.00
set .Y = 0.00

Setting things to 0 really does nothing to speed things up or save memory.
 

D.V.D

Make a wish
Reaction score
73
Changed some of the stuff. Polled Wait maybe inacurate but Im too sleepy right now to make timers so Ill do it later. Configuration? Sorry, I don't understand. For the onDestroy, should I just leave the reals alone? Updated code.
 

D.V.D

Make a wish
Reaction score
73
You don't need it for the spell to work but I'll add it. Minmum for GUI wait is 0.10. Look at the code used for polled wait. Rounds of to the nearest 0.10. I'll change it to Timers later. Now my brother hijacked the computer so yea.
 

Flare

Stops copies me!
Reaction score
662
The minimum of at least the GUI wait is 0.2 seconds.

You don't need it for the spell to work but I'll add it. Minmum for GUI wait is 0.10. Look at the code used for polled wait. Rounds of to the nearest 0.10. I'll change it to Timers later. Now my brother hijacked the computer so yea.
There is no set minimum - I tried it before, and the time waited varied between 0.1 and 0.25 (I think, it may have been 0.125 to 0.2, it was some time ago), even though a small wait was specified (was probably 0.05 that I specified, I'll have to test again sometime)

As regards the PolledWait code, PolledWait itself isn't the inaccurate part. TriggerSleepAction is inaccurate and, if you check the PolledWait code, that's what is used to do the actual waiting, and, as such, PolledWait inherets the inaccuracy of TriggerSleepAction
 

Romek

Super Moderator
Reaction score
964
> EVENT_PLAYER_UNIT_SPELL_CAST
EVENT_PLAYER_UNIT_SPELL_EFFECT

JASS:
////////////////////////////////////////////////////////////////////////////////////////////////
endstruct
////////////////////////////////////////////////////////////////////////////////////////////////

Did you think endstruct was that important?

The code is really messy in general, and you definitely need some configurables.
Some of the struct members (atype, etc) are useless too.
 

D.V.D

Make a wish
Reaction score
73
Well if you want the spell to be more easily editable, then you make structs for all the values that need to be set. What if someone wanted 1 ability with attack type normal and another with attack type magic? They would need to create 2 of the same struct to do that. Also, what are configurables?
 

Flare

Stops copies me!
Reaction score
662
Also, what are configurables?
Values that are easily accessible to the end-user and allow them to modify the stats and aesthetics of the spell, without having to dig through code e.g. instead of
JASS:
//Some function way down in the middle of your code, probably
function ... takes ... returns ...
  ...
  local effect e = AddSpecialEffect ("model\\path", x, y)
  ...
endfunction

You would have
JASS:
//This globals block is located at the very top of the code, below documentation/credits/other general comments, so it is easily accessible
globals
  private constant string EFFECT_PATH = "model\\path" //private, assuming you used a scope
endglobals

...
//Some function way down in the middle of your code, probably
function ... takes ... returns ...
  ...
  local effect e = AddSpecialEffect (EFFECT_PATH, x, y)
endfunction


In the first example, the end-user has little choice but to use the current model path, since they would have to dig through the code to find out where to change it. In the second example, they have a nice, easily-accessible, labelled constant that allows them to easily designate their own model path.

obviously, this isn't restricted to things like model paths. Can be used for damage values, durations, spell area of effect, and many other things (which will vary between spells). Take a look at any of the vJASS spells on the forum, and you should see the configuration header

EDIT: Also, I don't think it was mentioned, but you aren't destroying the struct when it's finished - add
JASS:
call d.destroy ()

at the very end of the DeathNova function. Structs have an instance limit, and if you don't destroy old instances, you will reach the instance limit and poof, spell doesn't work
 

D.V.D

Make a wish
Reaction score
73
Well, I have the big box explaining all the struct variables that edit the nova's attributes. I don't see why make them into globals because then ability's will need to recopy all the globals when using thee public struct. So just have them in the public struct and let the people read the box above the whole code. Now adding the globals actually gave me errors. For the global amount, distance, and radius, they cannot be assinged in Death Nova which is the main actions of the spell. Here's the code:
JASS:
scope DeathNova initializer InitTrig

////////////////////////////////////////////////////////////////////////////////////////
//   Variables:                                                                       //
// 1.atype = AttackType of the damage                                                 //
// 2.dtype = DamageType of the damage                                                 //
// 3.damage = Damage done                                                             //
// 4.X = X of the middle of the nova                                                  //
// 5.Y = Y of the middle of the nova                                                  //
// 6.model = The model name when using CreateNovaDamageAllEffect()                    //
// 7.caster = The Casting Unit of the spell                                           //
////////////////////////////////////////////////////////////////////////////////////////
//   Methods:                                                                         //
// 1.OnDestroy = Nulls everything in the struct and sets it to 0                      //
// 2.CreateNovaDamageEffectAll() = Creates a nova that uses Special Effects and       //
// damages all the units even allies and yours.                                       //
// 3.CreateNovaDamageAllUnit() = Creates a nova made from units that damages all      //
// units including yours and allies.                                                  //
////////////////////////////////////////////////////////////////////////////////////////

globals
private constant integer beginloop = 0//This is the loop that begins the amount of novas made until it reaches the amount in endloop variable
private constant integer endLoop = 10//This is the amount of times the novas will be made
private constant integer ID = 'AHtc'//This is the raw code for your ability
private constant real amount = 20.00//This variable indicates the amount of effects amde in one nova. CANNOT BE A DECIAML NUMBER!
private constant real distance = 100.00//This variable sets the distance the nova's are created from the x and y of your choice
private constant real radius = 50.00//This variable indicates the radius of the damage. Radius increases by 10 for all nova's made each time.
private constant real Time = 0.10//This is the time between the next nova is created
private constant timer t = CreateTimer()
endglobals

public struct nova
attacktype atype
damagetype dtype
real damage
real X
real Y
string model
unit caster

method onDestroy takes nothing returns nothing
    set .X = 0.00
    set .Y = 0.00
    set .caster = null
endmethod

method CreateNovaDamageAllEffect takes nothing returns nothing
    local real angle = 0
    local real intervals = 360 / amount
    local real x
    local real y
    local effect f
      loop
         exitwhen angle > 360
         set x = .X + distance * Cos(angle * bj_DEGTORAD)
         set y = .Y + distance * Sin(angle * bj_DEGTORAD)
         set f = AddSpecialEffect(.model, x, y)
         call UnitDamagePoint(.caster, 0.00, radius, x, y, .damage, true, false, .atype, .dtype, WEAPON_TYPE_WHOKNOWS)
         set angle = angle + intervals
      endloop
      call DestroyEffect(f)
      set f = null
endmethod

////////////////////////////////////////////////////////////////////////////////////////////////
endstruct
////////////////////////////////////////////////////////////////////////////////////////////////

private function DeathNova takes nothing returns nothing
    local nova d = nova.create()
      set d.caster = GetTriggerUnit()
      set d.X = GetUnitX(d.caster)
      set d.Y = GetUnitY(d.caster)
      set d.model = "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl"
      set d.damage = GetUnitAbilityLevel(d.caster,'AHtc') * 10
      set d.atype = ATTACK_TYPE_MAGIC
      set d.dtype = DAMAGE_TYPE_NORMAL
      if (beginloop != endLoop) then
         set amount = amount + 5.00
         set distance = distance + 100.00
         set radius = radius + 10.00
           call d.CreateNovaDamageAllEffect()
           call TimerStart(t, Time, false, null)
      endif
endfunction

private function Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == ID ) ) then
        return false
    endif
    return true
endfunction

//===========================================================================
private function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_CAST )  
    call TriggerAddAction(t, function DeathNova )
endfunction

endscope


Pics are gonna be uploded soon.
 

D.V.D

Make a wish
Reaction score
73
Doesn't make a difference. All my globals cannot be assinged to my main actions function. I don't want to add them to my struct because that won't work either.
 

Romek

Super Moderator
Reaction score
964
People are beginning to repeat what others have said now. :rolleyes:
To be frank, the code is a mess, and you don't seem to understand some basic things that apply to making spells in Jass. I suggest you learn [v]Jass properly, before submitting more spells, it'd benefit the community, as well as yourself.
 

D.V.D

Make a wish
Reaction score
73
Find a good tutorial on this site that isn't for begginers because I did all of those. And it worked well until I did what you guys told me. Added more globals which messed up the whole code. Also, I don't see whats bad about the code. Mind telling me finally how to fix it or just tell me to refer to the old tutorials like always?
 

Romek

Super Moderator
Reaction score
964
Could you update the code in the first post.
I suggest you read some beginners ones. If you've 'done all of those', then 'do them' again. Until you learn.

Also, you haven't done what people have told you to.
 

D.V.D

Make a wish
Reaction score
73
Becasuse Im trying to fix my first problem. You guys told me to add more globals and to remove the polled wait so I did and my Jass Helper gives me errors saying cannot initalize the globals:amount,distance,radius,beginloop. Can you please read the posts too? And there's not much to learn from them, they show nothing of ability making. Just display text to player. Thats it.
 

Romek

Super Moderator
Reaction score
964
This has been mentioned numerous times now:
> EVENT_PLAYER_UNIT_SPELL_CAST
EVENT_PLAYER_UNIT_SPELL_EFFECT

JASS:
private function Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == ID ) ) then
        return false
    endif
    return true
endfunction

return GetSpellAbilityID() == ID

Don't make the timer a constant. It's not supposed to be a constant.

atype, dtype, etc struct members aren't needed.
beginloop global is useless. Converted-GUI style much?

Reals don't need to be nulled.
Struct members don't need to be nulled. (Though many argue with this point)

Please use a JASS naming convention to make your code easier to read.

Make the effect a configurable.
Why on earth are you even creating and starting a timer with a null callback? o_O

> set d.damage = GetUnitAbilityLevel(d.caster,'AHtc') * 10
Configurable.

There's a lot more. I'm just getting bored of constantly scrolling up and down. =|
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top