System SpellStruct

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.
 
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.
 
@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.
 
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
 
Just wanted to say this is awesome. It does everything!
 
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.
 
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.
 
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.
 
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
 
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.
 
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.
 
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.
 
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:
    A probate is usually done with a will, yes? If so I am sorry for your loss
    +1
  • The Helper The Helper:
    Yeah Tom, me too sorry for your loss buddy my mom told me she finds out her olds friend died from Google searching them. She had not talked to one of her old friends in a year and found out she died from Google. Also another one in the same session. RIP all of them my sincere condolences Tom
    +1
  • Varine Varine:
    We have some elderly guests that regularly come hang out at the bar at the end of the night, and every once in a while we don't see someone for a few weeks and then someone shows up with their obituary.
  • Varine Varine:
    We usually let them do their memorials there in the morning if they want to and I'll make them some snacks and drinks. There was one guy named Tom that came in like every night and would sit by himself and get a bunch of soup and a glass of wine. idk why but he LOVED our fucking soup, like he would order a fucking quart of it at a time and would always get so sad when we stop doing it for the summer.
    +1
  • Varine Varine:
    But he also loved our calamari, which is another thing I hate but it sells super well so I can't change it. There was one day he came in and was asking me how to make it, because he tried to at home once in the off season when we stop running it and he really wanted it lol
  • Varine Varine:
    I think he's one of the only people I've made recipes for for free because he really wanted a broccoli cheddar, and it was like dude I don't have a recipe, it's just whatever I have, but here, this is how you do it
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?
  • The Helper The Helper:
    I am doing my first Vibe Coding project. In installed the environment and tools according to instructions but it is all chat doing this for me at my direction. It is fun really and holy shit I might finish in 2 hours what it would have taken a day to in my Access and this would be an electron app complete new
  • Ghan Ghan:
    Good stuff.
  • Ghan Ghan:
    Just make sure it is secure. :)
  • The Helper The Helper:
    It will only be on internal network

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top