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: 228

Romek

Super Moderator
Reaction score
963
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.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      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