System SpellStruct

tooltiperror

Super Moderator
Reaction score
231
You could make it so that it sorts out any errors by itself.

I don`t really know, just throwing stuff out there, haven`t read much of the script.
 

Grundy

Ultra Cool Member
Reaction score
35
Here's a function I wrote to go along with SpellStruct, I'm not sure if it should be included in SpellStruct because it's just extra junk that will probably not be used very often, but for people who do want to use it for a couple spells it could come in handy. It checks to see if a widget is between the caster and the target widget or target point +/- a given range. So passing in 128.0 for the real would check to see if a unit is within melee range of the line segment that connects the caster to the target:

JASS:
public method isWidgetBetweenCasterAndTarget takes widget whichWidget, real range returns boolean
    local real x // using local x and y for target loc because the target could
    local real y // have moved since this.targetX and this.targetY were set
    local real distance
    local real a // coefficient in the line equation Ax + By + C = 0
    local real b // coefficient in the line equation Ax + By + C = 0
    local real c // constant in the line equation Ax + By + C = 0
    if this.targetWidget == null then
        set x = this.targetX
        set y = this.targetY
        set distance = this.getDistanceToTargetPoint()
    else
        set x = GetWidgetX(this.targetWidget)
        set y = GetWidgetY(this.targetWidget)
        set distance = this.getDistanceToTargetWidget()
    endif
    set a = this.casterY() - y
    set b = x - this.casterX()
    set c = -(a*x + b*y)
    return ( abs(a*GetWidgetX(whichWidget) + b*GetWidgetY(whichWidget) + c)/distance ) <= range
endmethod


Sorry about variable names, I know they aren't very descriptive. They come form the line equation Ax + By + C = 0 so I didn't know what else to call them.

This could be used in the filter for this.enumUnitsInAoE and could be useful for something like... a channelled lightning spell with a lightning effect between the caster and the target that deals damage to every unit that the lightning passes through. If someone has a more efficient way to do this let me know. And I'm at work right now so I can't check to see if my syntax is all right.
 

Jesus4Lyf

Good Idea™
Reaction score
397
@Grundy:
I think there is a much better (more efficient) way to do that with vectors. I used vector resolution once in a spell of mine to get the distance to a line segment (better than returning whether or not a widget is within range of a line segment ;)) and it was something like ~5 lines, off memory.
 

Grundy

Ultra Cool Member
Reaction score
35
Yea, I guess your right. I just wanted to make a function that would be easy to stick in a SpellStruct and figure out everything for me but to make it more efficient you'd have to figure out the end points yourself and pass them in instead of letting the function figure out what end points you want:
JASS:
public method getWidgetDistanceToLine takes widget whichWidget, real startX, real startY, real endX, real endY returns real
    local real a=startY-endY
    local real b=endX-startX
    return abs(a*GetWidgetX(whichWidget)+b*GetWidgetY(whichWidget)-(a*startX+b*startY))/sqrt(a*a+b*b)
endmethod
but now it's totally irrelevant to SpellStruct haha too bad I can't delete old posts.

And if you really wanted to you could put that all on 1 line, but I wouldn't:
JASS:
public method getWidgetDistanceToLine takes widget whichWidget, real startX, real startY, real endX, real endY returns real
    return abs((startY-endY)*GetWidgetX(whichWidget)+(endX-startX)*GetWidgetY(whichWidget)-((startY-endY)*startX+(endX-startX)*startY))/sqrt((startY-endY)*(startY-endY)+(endX-startX)*(endX-startX))
endmethod
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Just wanted to say this is awesome. It does everything!
 

Kenny

Back for now.
Reaction score
202
Just wanted to say that I scabbed your [ljass].forGroup[/ljass] idea for a [ljass]ForProjectileGroup()[/ljass] function. I know it probably isn't a good idea (at all), but the interface is so much better than [ljass]FirstOfGroup()[/ljass] loops for projectiles.

Anywho, this thing seriously needs a mod review. Too bad all mods have been busy lately, haha.
 

Grundy

Ultra Cool Member
Reaction score
35
Jesus you suggested making
JASS:
module Blockable
    method onChannel takes nothing returns nothing
        if BlockSpell[this.targetUnit] != 0 then
            call BlockSpell[this.targetUnit].destroy()
            call this.destroy()
        endif
    endmethod
endmodule

and having every spell I want to be blockable implement this module.

I was thinking of making another module for Multi-casting, I don't have the code for it but I was going to make a module that would implement the onChannel method and some calculation whatever it may be to decide if multicast should be used on the current cast and then order a dummy unit to cast the same spell again. the method would check the unit type so the dummy unit wouldn't be able to multi cast it. But i'm not sure what I should do if I want a spell to be blockable and multicastable. Right now all I can think of is a module for Blockable and a module for Multicastable and a module for BlockableMulticastable but that is not a good solution because if i come up with something else that I might want to apply to different spells then I'd need to make modules for every combination of effects and it would just get too messy I think.

Do you have any ideas for this?

Maybe a "blockable" text macro and a "multicastable" text macro that i can put inside of the onChannel method and just add text macros for whatever comes in the future, that's the best I can come with, but I don't really like that either.

Maybe multicast should just be coded in a buff and not in spellstruct at all, i don't know.
 

Grundy

Ultra Cool Member
Reaction score
35
if the spell is blocked, it should not be able to multicast.

i was thinking of putting it inside of spellstruct due to the way it would choose targets. some spells might want to be multicast on random allied units only. some might be random enemy units only, some might be the same target multiple times, some might be random units with the possibility of hitting the same one multiple times, some might be random targets without repeating the same target. I was going to make it with some variables that can be set in onInit for target selection.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Mm! Have fun with that one, you might end up just coding it for each spell individually at that rate...

Or get a few algorithms and use textmacros or something. Either way, you should actually run both spell block and multi cast in onEffect, otherwise a spell which is cancelled will proc them. It's a little difficult, I don't know that there's any good vJass features for solving this problem. Textmacros may be the way to go for both (most power over what happens in your code).

On the other hand, you could actually use functions.
JASS:
method onEffect takes nothing returns nothing
    if CheckSpellBlock(targetUnit) then
        call this.destroy()
        return
    endif
    if CheckMulticast(caster) then
        call SomethingToDoWithRecastingTheSpell(some, parameters)
    endif
    // do the spell actions
endmethod
 

Anachron

New Member
Reaction score
53
Dled last version, test it and got a lot of double free errors, also my wc3 crashed.

View attachment 36085

Make sure to test the code before uploading.
Canceling spells cause a lot of errors and bugs too.
 

Jesus4Lyf

Good Idea™
Reaction score
397
I can't seem to find any errors, except by cancelling Life Drain, which displays a T32 error due to a mistake in the example code...

I always test my code before uploading.

Can you explain further how to reproduce the results you're stating? I use this system actively in all my mapping, at the latest version, with debug mode on, and have no such issues.
 

Anachron

New Member
Reaction score
53
I started the testmap.
Selected the ranger.
Skilled lifedrain.
Tested it a few times.
(Hero moved outside of playable map rect because)
Chosed the moon priestess.
Skilled Starfall.
Used starfall once.
Gone around.
Used starfall for about 2-5 times again. (Without delay, instant cast)
Clicked abort.

Then all the errors appeared.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Although there is no "Abort" key, I tried stop, after following all your instructions.
And I am unable to reproduce any errors, except for T32x complaining if you stop casting Life Drain before it starts actually draining.

Edit: FYI I am using the test map downloaded from the first post, upgraded to version 1.0.7 which is also in the first post. :)
 
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

      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