Spell Fire Geysers

Lightstalker

New Member
Reaction score
55
Fire Geysers v1.5

FIRE GEYSERS​

My first spell... :p
Go nuts on the critique but also tell me what to change & improve this is my first vJASS spell...

vJASS, MUI, Leakless, & Lagless

''Technical' description'': creates X amount of fire special effects at random points around the caster, dealing Y damage to all units within range of any of those effects. Every Z seconds for A times, random fire effects will be created at random points around the caster, damaging all units within range.
X, Y, Z, A are all configurable variables.

Screenshots:
FireGeysers.jpg
Could probably look a lot better with more fire effects, but now you can configure that, too.

Code:
JASS:
scope FireGeysers initializer Init

globals
    private constant integer SPELLID = 'A000' //ABILITY RAWCODE
    private constant string EFFECT = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl" //FIRE EFFECT

    private constant integer EFFECTAMOUNT = 3 //HOW MANY FIRE GEYSERS ARE CREATED DURING A PERIOD
    private constant integer AMOUNT = 3 //HOW MANY TIMES THE EFFECT OCCURS IN TOTAL. TO FIND OUT HOW LONG THE SPELL WILL LAST IN SECONDS: AMOUNT * PERIOD
    
    private constant real PERIOD = 2.0 //HOW OFTEN THE EFFECT OCCURS
    private constant real DAMAGE = 50.0 //DAMAGE DONE BY EACH FIRE GEYSER PER LEVEL
    private constant real RNDMIN = 300.0 //MINIMUM DISTANCE THE EFFECT WILL OCCUR FROM THE CASTER
    private constant real RNDMAX = 600.0 //MINIMUM DISTANCE THE EFFECT WILL OCCUR FROM THE CASTER
    
    private constant attacktype ATTACKTYPE = ATTACK_TYPE_MAGIC //THE TYPE OF ATTACK (MAGIC, HERO, CHAOS, ETC.)
    private constant damagetype DAMAGETYPE = DAMAGE_TYPE_FIRE //THE TYPE OF DAMAGE.
    private constant weapontype WEAPONTYPE = WEAPON_TYPE_WHOKNOWS //FOR DIFFERENT TYPES OF WEAPONS. DON'T RECOMMAND YOU CHANGE IT.
    
    //DON'T CHANGE ANYTHING AFTER THIS POINT UNLESS YOU KNOW WHAT YOU'RE DOING!
    private group TEMPGROUP = CreateGroup()
endglobals

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

private struct data
    unit u = null
    real ux = 0.0
    real uy = 0.0
    integer lvl = 0
    integer count = 0

    static method create takes unit u returns data
        local data d = data.allocate()
        set d.u = u
        set d.ux = GetUnitX(u)
        set d.uy = GetUnitY(u)
        set d.lvl = GetUnitAbilityLevel(u, SPELLID)
        return d
    endmethod
endstruct

globals
    private data TEMPSTRUCT
endglobals

private function Damage takes nothing returns boolean
    call UnitDamageTarget(TEMPSTRUCT.u, GetFilterUnit(), DAMAGE * TEMPSTRUCT.lvl, false, false, ATTACKTYPE, DAMAGETYPE, WEAPONTYPE)
    return false
endfunction

private function Periodic takes nothing returns nothing
    local data d = data(GetTimerData(GetExpiredTimer()))
    local real rndx = 0.0
    local real rndy = 0.0
    local real angle = 0.0
    local integer i = 0

    if d.count < AMOUNT then
        loop
            set rndx = d.ux + GetRandomReal(RNDMIN, RNDMAX) * Cos(GetRandomReal(0.00,57.29))
            set rndy = d.uy + GetRandomReal(RNDMIN, RNDMAX) * Sin(GetRandomReal(0.00,57.29))
            call DestroyEffect(AddSpecialEffect(EFFECT, rndx, rndy))
            call GroupEnumUnitsInRange(TEMPGROUP, rndx, rndy, 200.0, Condition(function Damage))
        set i = i + 1
        exitwhen i == EFFECTAMOUNT
        endloop
        set d.count = d.count + 1
    else
        call ReleaseTimer(GetExpiredTimer())
        call d.destroy()
    endif
endfunction

private function Actions takes nothing returns nothing
    local timer t = NewTimer()
    call SetTimerData(t, data.create(GetTriggerUnit()))
    call TimerStart(t, PERIOD, true, function Periodic)
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 Conditions))
    call TriggerAddAction(t, function Actions)
endfunction
endscope


Changelog:
v1.5
- Fixed a bug where incorrect units would be damaged.
- Further randomized effects.
v1.4
- Added weapontype, damagetype, and attacktype configurables.
- Made code easier to read.
- Optimized code.
v1.3
- Inlined damage.
v1.2
- Further optimized code.
v1.1
- Optimized code.
- Damage, amount of fire effects, amount of times the spell will run for can now all be easily modified.
 

Attachments

  • Fire Geysers v1.5 by THUNDERPOWER.w3x
    63.1 KB · Views: 233

Romek

Super Moderator
Reaction score
964
You don't need to null 'trigger t' nor 'timer t'.

JASS:
    local data d = data.create(GetTriggerUnit())
    local timer t = NewTimer()
    call SetTimerData(t, d)

Could be:
JASS:
    local timer t = NewTimer()
    call SetTimerData(t, data.create(GetTriggerUnit()))

On a somewhat related note, you should just inline that create method.

In 'Damage', just use tempstruct directly.

Globals could do with some nice comments. :)

'Evaluation' should be constant, and at the top of the script.
 

Viikuna

No Marlo no game.
Reaction score
265


You need to release your timer, thats the whole point of timer recycling.

Otherwise this looks pretty good. Its a nice start.

edit. Also, you dont need to null neither that trigger t in init function than that timer t in Actions function.

Trigger is never destroyed, so its handle index wont be recycled anyways, which means that theres no need to null it. Its the same thing with those timers when you recycle them properly.
 

Igor_Z

You can change this now in User CP.
Reaction score
61
Upload a demo map plz... To see how it looks like
 

Lightstalker

New Member
Reaction score
55
@Romek

>>>You don't need to null 'trigger t' nor 'timer t'.
So I heard... Any reason why AceHart is doing it here? http://www.thehelper.net/forums/showthread.php?t=105146
(Just curious. :p)

>>>
JASS:
    local data d = data.create(GetTriggerUnit())
    local timer t = NewTimer()
    call SetTimerData(t, d)

Could be:
JASS:
    local timer t = NewTimer()
    call SetTimerData(t, data.create(GetTriggerUnit()))


Cool & fixed. :)

>>>On a somewhat related note, you should just inline that create method.
What's inlining mean? Using "Tab" to indent it?

>>>In 'Damage', just use tempstruct directly.
Not 100% sure what you mean.

>>>Globals could do with some nice comments. :)
Done. :)

>>>'Evaluation' should be constant, and at the top of the script.
How can I make a function constant? Assign it to a variable?
Also, I just thought of something. Instead of doing this:

JASS:
private function Evaluation takes integer lvl returns real
    return 50.0 * lvl
endfunction

private function Damage takes nothing returns boolean
    local data d = tempstruct
    call UnitDamageTarget(d.u, GetFilterUnit(), Evaluation(d.lvl), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
    return false
endfunction


Couldn't I just do this? (It compiles fine.)

JASS:
private function Damage takes nothing returns boolean
    local data d = tempstruct
    call UnitDamageTarget(d.u, GetFilterUnit(), 50 * d.lvl, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
    return false
endfunction


@Viikuna

>>>You need to release your timer, thats the whole point of timer recycling.

I thought DestroyTimer was the same as ReleaseTimer :confused:
 

Lightstalker

New Member
Reaction score
55
Stil not testmap. :thdown:

Sorry was working on it. I was trying to find a template so I wouldn't have to make my own.

Anyway, the test map is up.

I will post screenshot as soon as I can fix the problem except I have no idea how to. :banghead:
Basically, when you test the map, you'll notice the the fire effects are always grouped close together at same location. They're suppose to randomly spawn from the ground every 2 seconds. :(
 

Kenny

Back for now.
Reaction score
202
So I heard... Any reason why AceHart is doing it here? http://www.thehelper.net/forums/showthread.php?t=105146
(Just curious. )

It is good coding practice to null local handles. Lots of people do it. Except in the trigger and timer circumstances, there is no need, as explained by Viikuna.

>>>In 'Damage', just use tempstruct directly.
Not 100% sure what you mean.

He means use the tempstruct directly instead of allocating it to a local variable.

Example:

tempstruct.u instead of d.u.

>>>'Evaluation' should be constant, and at the top of the script.
How can I make a function constant? Assign it to a variable?

Like this:

JASS:
private constant function Evaluation takes integer lvl returns real
    return 50.00 * lvl
endfunction


Notice the constant keyword BEFORE then function keyword.

I thought DestroyTimer was the same as ReleaseTimer

No. DestroyTimer() destroys the timer while ReleaseTimer() frees the timer for later use.

Now the only problem with it is that the special effects are always created around the same location during a cast. If someone can tell me how to make it so that special effects are created at different locations during a single cast, that would be great.

You need to offset the coordinates using angles, for example:

JASS:
call DestroyEffect(AddSpecialEffect(EFFECT, d.ux + rndx * Cos(GetRandomReal(0.00,57.29)), d.uy + rndy * Sin(GetRandomReal(0.00,57.29))))
// Notice the Cos() and Sin() parts in the above line, they -should- offset the coordinates randomly.
// Do that for the damage group thing as well
 

Tom Jones

N/A
Reaction score
437
Now the only problem with it is that the special effects are always created around the same location during a cast. If someone can tell me how to make it so that special effects are created at different locations during a single cast, that would be great.
You probably have fixed seeds turned on, to turn it off:
Main editor window -> File -> Preferences -> Test Map -> Untick "Use Fixed Random Seed".
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Basically, when you test the map, you'll notice the the fire effects are always grouped close together at same location.
That's because your X/Y coordinates are being generated not as polar coordinates, but a random value between the minimum and maximum "distances"
JASS:
private constant real RNDMIN = 300.0 //MINIMUM DISTANCE THE EFFECT WILL OCCUR FROM THE CASTER
private constant real RNDMAX = 600.0 //MAXIMUM .........
...
set rndx = GetRandomReal(RNDMIN, RNDMAX)
set rndy = GetRandomReal(RNDMIN, RNDMAX)

so they'll always be within a square located up and right of the caster, with lower left corner <300, 300> from the caster, and upper right corner <600, 600> from the caster.
 

Lightstalker

New Member
Reaction score
55
Fixed everything said by everyone. :)

Still, one more concern of mine: in the trigger, I am doing this:

JASS:
private function Evaluation takes integer lvl returns real
    return 50.0 * lvl
endfunction

private function Damage takes nothing returns boolean
    call UnitDamageTarget(TEMPSTRUCT.u, GetFilterUnit(), Evaluation(TEMPSTRUCT.lvl), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
    return false
endfunction


Couldn't I just do this instead?

JASS:
private function Damage takes nothing returns boolean
    call UnitDamageTarget(TEMPSTRUCT.u, GetFilterUnit(), 50 * TEMPSTRUCT.lvl, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
    return false
endfunction


And what is inlining???
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
That would make it harder for someone who uses the spell to modify the damage. What if he wanted to use a different value than 50?
 

Lightstalker

New Member
Reaction score
55
That would make it harder for someone who uses the spell to modify the damage. What if he wanted to use a different value than 50?

Well no... I meant for ME. I use the spell too, you know. :p And I have no need of all these comments and configurables. Anyway, I can just set "50" to a global variable (which I have done in v1.1 :)).

Anyway, would it be better for me to do it that way:

JASS:
private function Damage takes nothing returns boolean
    call UnitDamageTarget(TEMPSTRUCT.u, GetFilterUnit(), DAMAGE * TEMPSTRUCT.lvl, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
    return false
endfunction
 

Viikuna

No Marlo no game.
Reaction score
265
JASS:
private function Evaluation takes integer lvl returns real
    return 50.0 * lvl
endfunction


You should use this instead, like you were using before.

Inlining means that for example this:


JASS:
private function Evaluation takes integer lvl returns real
    return 50.0 * lvl
endfunction

private function Damage takes nothing returns boolean
    call UnitDamageTarget(TEMPSTRUCT.u, GetFilterUnit(), Evaluation(TEMPSTRUCT.lvl), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
    return false
endfunction


is shortened to this:

JASS:
private function Damage takes nothing returns boolean
    call UnitDamageTarget(TEMPSTRUCT.u, GetFilterUnit(), 50 * TEMPSTRUCT.lvl, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
    return false
endfunction


Luckily JassHelper does some inlining for us, so removing that function Evaluation wont make your code any faster ( It should get inlined by JassHelper ). And even without JassHelper, its still worth of one function call to have more readable code.

You can find more about Jasshelper features, such as inlining from JassHelper manual.
 

Kenny

Back for now.
Reaction score
202
JASS:
static method create takes unit u returns data
        local data d = data.allocate()
        set d.u = GetTriggerUnit()
        set d.ux = GetUnitX(u)
        set d.uy = GetUnitY(u)
        set d.lvl = GetUnitAbilityLevel(u, SPELLID)
        set d.p = GetOwningPlayer(u)
        return d
    endmethod


set d.u = GetTriggerUnit()

Should be:

set d.u = u

JASS:
call UnitDamageTarget(TEMPSTRUCT.u, GetFilterUnit(), Evaluation(TEMPSTRUCT.lvl), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)


Attacktype, damagetype and weapontype should all be configurable options.

JASS:
set angle = GetRandomReal(0.0, 359.9999)
            call DestroyEffect(AddSpecialEffect(EFFECT, d.ux + rndx * Cos(angle * bj_DEGTORAD), d.uy + rndy * Sin(angle * bj_DEGTORAD)))


If you want it too be truely random do something like this:

JASS:
call DestroyEffect(AddSpecialEffect(EFFECT, d.ux + rndx * Cos(GetRandomReal(0.00,57.29)), d.uy + rndy * Sin(GetRandomReal(0.00,57.29))))


That gets rid of the need for the local variable for the angle as well.

Also you need to do the same for the GroupEnum function, so I suggest you do something like this:

JASS:
set rndx = d.ux + GetRandomReal(RNDMIN, RNDMAX) * Cos(GetRandomReal(0.00,57.29))
set rndy = d.uy + GetRandomReal(RNDMIN, RNDMAX) * Sin(GetRandomReal(0.00,57.29))
call DestroyEffect(AddSpecialEffect(EFFECT,rndx,rndy)
call GroupEnumUnitsInRange(TEMPGROUP,rndx,rndy,200.0,Condition(function Damage))


That should work.

Also, this spell would be much better if it was written to last X amount of seconds, instead of AMOUNT * PERIOD seconds.

You should also add a configurable fuction (like you Evaluation function) for the amount of effects created per interval, and the duration.
 

Lightstalker

New Member
Reaction score
55
JASS:

static method create takes unit u returns data
        local data d = data.allocate()
        set d.u = GetTriggerUnit()
        set d.ux = GetUnitX(u)
        set d.uy = GetUnitY(u)
        set d.lvl = GetUnitAbilityLevel(u, SPELLID)
        set d.p = GetOwningPlayer(u)
        return d
    endmethod


set d.u = GetTriggerUnit()

Should be:

set d.u = u

JASS:

call UnitDamageTarget(TEMPSTRUCT.u, GetFilterUnit(), Evaluation(TEMPSTRUCT.lvl), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)

Will WC3 automatically assume 'u' is the triggering unit?

>>>Attacktype, damagetype and weapontype should all be configurable options.
They are now. :)

JASS:

set angle = GetRandomReal(0.0, 359.9999)
            call DestroyEffect(AddSpecialEffect(EFFECT, d.ux + rndx * Cos(angle * bj_DEGTORAD), d.uy + rndy * Sin(angle * bj_DEGTORAD)))


If you want it too be truely random do something like this:

JASS:

call DestroyEffect(AddSpecialEffect(EFFECT, d.ux + rndx * Cos(GetRandomReal(0.00,57.29)), d.uy + rndy * Sin(GetRandomReal(0.00,57.29))))


Also you need to do the same for the GroupEnum function, so I suggest you do something like this:

JASS:

set rndx = d.ux + GetRandomReal(RNDMIN, RNDMAX) * Cos(GetRandomReal(0.00,57.29))
set rndy = d.uy + GetRandomReal(RNDMIN, RNDMAX) * Sin(GetRandomReal(0.00,57.29))
call DestroyEffect(AddSpecialEffect(EFFECT,rndx,rndy)
call GroupEnumUnitsInRange(TEMPGROUP,rndx,rndy,200.0,Condition(function Damage))

Done! :)

>>>Also, this spell would be much better if it was written to last X amount of seconds, instead of AMOUNT * PERIOD seconds.
Don't think it would make much of a difference. But anyway, I'm not rewriting it just for that. It's the same spell that is in one of the maps I'm working on right now so I didn't make it for no reason. ;)

>>>You should also add a configurable fuction (like you Evaluation function) for the amount of effects created per interval, and the duration.
Was already done since v1.2.
If you want to create more/less effects, change the value of "EFFECTAMOUNT". The duration is controlled by "PERIOD".

Anyway, thanks a lot. I gave you +REP :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top