System Damage Struct

dudeim

New Member
Reaction score
22
@Nestharus
Why is it bad that J4L's Damage has additional features in it. As you don't have to use them they are optional you can just as easily use it only for damage detection, you'd never even have to touch blocking damage and whatever if you don't want to. So I'm not getting why there should be a damage library only for detecting it.
Sorry for offtopic btw
 

Laiev

Hey Listen!!
Reaction score
188
@Dudeim
Because you'll need to get it to your map no matter if you will or not use it.
 

dudeim

New Member
Reaction score
22
So how is it bad it´s in there? It's not like it takes up alot of space or anything...
 

Nestharus

o-o
Reaction score
84
Why is it bad that J4L's Damage has additional features in it. As you don't have to use them they are optional you can just as easily use it only for damage detection, you'd never even have to touch blocking damage and whatever if you don't want to. So I'm not getting why there should be a damage library only for detecting it.
Sorry for offtopic btw

It's about modularity. If you say that the damage modification is fine, then why not also add the specific trigger evaluations, and damage for special spells, and spell flags, and etc, and etc, and finally end on damage whenever a green ghost chases down a flying boulder.


A resource should have the bare minimum. The more you add, the more resources are coupled, the harder it is to break things apart (perhaps you want a special type of damage modification?) and modify.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
It seems to bug with high damage, or something along those lines. I set the blademaster's damage to 1.3k and had 1000 damage prevention and it killed the units anyway. Here is the code:
JASS:
struct Tester
    implement DamageData
    static real array count
    private static method onTaken takes nothing returns boolean
        
        //call BJDebugMsg("BONUS DAMAGE: "+R2S(count[GetDamageData()]))
        return false
    endmethod
    private static method onDamage takes nothing returns boolean
        call BJDebugMsg("Before: "+R2S(Damage.dealt))
        call Damage.prevent(1000)
        call BJDebugMsg("After: "+R2S(Damage.dealt))
        return false
    endmethod
    implement DamageStruct
    private static method after takes nothing returns nothing
        call enableDealt(gg_unit_Obla_0001,function thistype.onDamage,0)
        call enableTaken(gg_unit_Obla_0001,function thistype.onTaken,0)
    endmethod
    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(),0,false,function thistype.after)
    endmethod
endstruct


And the test map is attached below. I don't have OVERKILL enabled in the attached test map, but I tried it again with OVERKILL enabled and the problem still occurred.
 

Attachments

  • TESTmap.w3x
    43.2 KB · Views: 428

Dirac

22710180
Reaction score
147
There's no Life Gain Ability Bonus in your map purgeandfire :)

@Nes
Yes i see your point, but IMO damage shouldn't be global at all, and damage systems should focus on damage done by specific units. It's not adding systems to systems, but rather changing how it works.
 

tooltiperror

Super Moderator
Reaction score
231
You made the API a lot worse. The integer argument is stupid, it's like a 2005 Jass way of doing what AIDS does better, you don't need to make it this complicated. Turn it back to the way it was, but keep the names.
 

tommerbob

Minecraft. :D
Reaction score
110
I agree with tooltiperror, the API is not very good. Personally, J4L's Damage/AIDS API is much easier to read and understand.

Forget programming lingo, can you explain to me in simple terms why I should use this instead of J4L's Damage?
 

Dirac

22710180
Reaction score
147
You made the API a lot worse. The integer argument is stupid, it's like a 2005 Jass way of doing what AIDS does better, you don't need to make it this complicated. Turn it back to the way it was, but keep the names.
I don't get it, all i did was change the names, remember that the integer argument is optional and only appears if you implement the Damage Module. I guess you didn't bother to read the code before.

Why you should use this above Damage? Ok a few reasons.
-Instead of coding a bunch of checks in order to know whether you would like to register and change some unit's damage (because of a damage modification ability or something similar) You can just enable the damage recognition for the unit using this system, then disable it after using timers (If approved i'll fix the issue that doesn't let you disable it during damage event firing)
-The event responses variables are now globals and you no longer need to declare them each function as a local. (Damage.dealt, Damage.source, etc.)
-Damage by J4L bugs when trying to prevent AoE damage. (Or any kind of damage done simultaneously
-You don't have to declare triggers in order for the system to function (i really hate this about J4L's damage)
-This (similar to Nestharus's damage library) cleans up the leaks generated by events after a certain amount of units are removed or deindexed. Otherwise unused events would stack and stack over the trigger.

I don't get what is wrong with the API.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Documentation is messy, confusing, and unclear.

Variables should be on the left side of comparisons, and constants on the right, as is the convention in Jass and about every other language.

These are both very valid points, though I'll say that the documentation isn't that messy. The documentation doesn't clearly state what the following do:
MAX_WASTED_UNITS - What is a "wasted unit"? What if I don't want any wasted units? What are the consequences of increasing/decreasing this value?
DamageData vs DamageStruct - What happens if GetDamageData is called on a function using the DamageStruct module?

Ahem, I can't even read the AIDS documentation (super messy, can't find anything in it), but I can read this documentation fairly easily. The random //s all over the place is a little screwy (could be cleaner), but yea >.>.

And i have to agree with nestharus, AIDS is horribly documented, it's almost impossible to look for anything in there, i had to read the code entirely just to discover there were internal public functions such as RegisterOnEnter, as there are many others. If TH standards are as messy as AIDS is, i can't do anything for you guys.

You've got to be kidding me. AIDS clearly tells you everything each function does, separates everything into proper categories (What is this?, How to use?, Public Functions, AIDS structs (with clear points, proper usage documented well)). The categories in this one are... mediocre at best. Also, many functions have a single line to explain them, which is often insufficient (AIDS has a few, but the explanation is enough when combined with the documentation of how the system works (e.g. units are auto-indexed, so "GetUnitIndex" clearly gets the index of the provided unit)).

Dirac: I'm pretty sure those "internal public functions" aren't SUPPOSED to be used by you. It's fine to not document private things.

I don't want to register damage for every single unit that enters my map. Sure this is better in some situations, but it does it in an ugly way. Don't make this as an alternative to Damage, make it a replacement.

tooltiperror has a point here, in that there are many cases in which someone would want to register damage for every unit (or a large majority). Doing this, with a filter function makes things very simple, as you also don't have to worry about units being 'added' multiple times. Using this library makes things much more complicated than they should be.

why is this called "Damage Struct" if the library is Damage?

This is a valid, if minor point. This would also cause the library to conflict with Damage. If this conflict is intended, I suggest that you also implement most, if not all of the features Damage provides.

Remember that Damage is only able to detect damage type if you specify it through triggers, damage done through object editor abilities can't be predicted, so these functions are plainly useless since any jasser can use a global or attach data to the damage using the DamageData module to find a way through this.

Far from being useless, these features allow a spell created by someone else to easily make the damage they deal work with the Damage system. This way I don't have to write all of my spells on my own. Someone else's spells may even be modified very simply (sometimes as little as changing one line) to take advantage of the function.

Also i have to disagree when you say it's useful for only some situations, i can't think of any damage trigger that involves all damage done inside W3 maps without keening on which unit is the one causing the damage or taking it.

The fact that we have to manually add one unit at a time is a problem. It's much easier to filter out anything not in a specific group of units, and should not limit the user so much.

The documentation looks cleaner inside the editor because the [ljass]/*[/ljass] comments aren't green as [ljass]//[/ljass] is.
I think the textmacro part is a bit confusing and might require some explanation, it's somehow hard to explain why is it needed, but i'll try.

In it's current state, there's all kinds of dangling '//' markers in the way (not at the beginning of the line like it should be for easy reading). Also, there has been a modification to TESH that makes /* */ cause its contents to be green. Additionally, I don't think it's all that special to have syntax highlighting on the methods/functions the library provides. It would be much preferable to have it read flue

I have a question:
Why do script resources (Jass2, vJass, Zinc) almost always provide documentation inside the script's text itself?

This is off-topic, but probably because many mappers will open a map they find that isn't protected, and see resources like these. Without the documentation, there is no indication as to who the author is, or even to the fact that there is a giant WC3 resources community behind many of these maps. If you want to continue the discussion, I would recommend a new thread.

Now, I am also saying that j4l's damage event thing is bad too because it couples features together as well... the core should be plain old damage detection (nothing else). Above that core you can code whatever you want easily, like purge's damage mod stuff or your direct trigger eval stuff.

This is probably the first point I'm going to agree with. J4L's damage spell thing should probably be a module.
 

Dirac

22710180
Reaction score
147
That's some good feedback.
These are both very valid points, though I'll say that the documentation isn't that messy. The documentation doesn't clearly state what the following do:
MAX_WASTED_UNITS - What is a "wasted unit"? What if I don't want any wasted units? What are the consequences of increasing/decreasing this value?
DamageData vs DamageStruct - What happens if GetDamageData is called on a function using the DamageStruct module?
The documentation does explain what that constant does, maybe not in the header, but it's there.
Remember that in order to use GetDamageData you must ALSO implement the DamageData module, that means that you have to implement 2 different modules, and this one goes above anywhere you're trying to get the damage's data, while DamageStruct goes below the damage handling method.
Please read the example provided at the header.
Good that this is mentioned. However, this is quite a large problem. It requires the user to go through an extra step to unregister damage (adding to a list of 'to-be-unregistered' units, or something similar). It's not a simple procedure for a new user.
It can't be fixed (unless using trigger evaluations, but that seems really unnecessary :S), however it shouldn't be called "a problem", no other damage system provides a way to deactivate these kind of things, you should just bend to the rules here.
You've got to be kidding me. AIDS clearly tells you everything each function does, separates everything into proper categories (What is this?, How to use?, Public Functions, AIDS structs (with clear points, proper usage documented well)). The categories in this one are... mediocre at best. Also, many functions have a single line to explain them, which is often insufficient (AIDS has a few, but the explanation is enough when combined with the documentation of how the system works (e.g. units are auto-indexed, so "GetUnitIndex" clearly gets the index of the provided unit)).

Dirac: I'm pretty sure those "internal public functions" aren't SUPPOSED to be used by you. It's fine to not document private things.
Well i guess that the thing i hate about AIDS is that you can't find everything at the top of the code. Suppose you forgot the name of one of the functions AIDS has: you have to search it through the entire code.
tooltiperror has a point here, in that there are many cases in which someone would want to register damage for every unit (or a large majority). Doing this, with a filter function makes things very simple, as you also don't have to worry about units being 'added' multiple times. Using this library makes things much more complicated than they should be.
I added an extension for global damage registration.
This is a valid, if minor point. This would also cause the library to conflict with Damage. If this conflict is intended, I suggest that you also implement most, if not all of the features Damage provides.
I'm not sure if it should be called DamageStruct or Damage. I like Damage
Far from being useless, these features allow a spell created by someone else to easily make the damage they deal work with the Damage system. This way I don't have to write all of my spells on my own. Someone else's spells may even be modified very simply (sometimes as little as changing one line) to take advantage of the function.
Well i guess that some damage dealing functions wouldn't harm, but remember: Damage type recognition only works on damage dealt through coding. There are few ways to separate damage done through spells to damage done through attacks, and they're quite buggy (Check Nestharus's AdvDamage library)
The fact that we have to manually add one unit at a time is a problem. It's much easier to filter out anything not in a specific group of units, and should not limit the user so much.
Again, added global damage recognition and damage modding extensions.
In it's current state, there's all kinds of dangling '//' markers in the way (not at the beginning of the line like it should be for easy reading). Also, there has been a modification to TESH that makes /* */ cause its contents to be green. Additionally, I don't think it's all that special to have syntax highlighting on the methods/functions the library provides. It would be much preferable to have it read flue
Where do i find this? My TESH displays "//" green and "/*" with normal JASS colors
 

Dirac

22710180
Reaction score
147
v1.01
-Fixed some encapsulation issues.
-Added global damage registration function
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Dirac said:
JASS:
//What are these operators these texmacros are generating?
        //  Turns out that every time damage events are fired the static variables
        //  change according to the values the event returns (such as GetEventDamage())
        //  so if damage is done when the events are fired the values are set to the new
        //  damage's event responses and aren't properly reverted when the new damage
        //  finishes to the previous values. So i came up with an stack that increases
        //  everytime the events are fired and decreases when the events end.

If I am not mistaken, that is just a problem with recursion. You don't have to create stacks or anything like that. All you need to do is this:
JASS:
globals
    Event myEvent = 0
    integer myEventVariable = 0
endglobals

function Recursive takes nothing returns nothing
    local integer i = myEventVariable
    set myEventVariable = GetUnitUserData(GetTriggerUnit())
    call myEvent.fire()
    set myEventVariable = i
endfunction


This will: use a temporary variable to store the previously-held value of the global, set the global to the new data, fire the event, then revert it back.

http://www.hiveworkshop.com/forums/1809536-post4.html
 

Dirac

22710180
Reaction score
147
Thanks PurgeandFire for clearing that up, changed my confusing array system with yours.

v1.04
-Changed the way variable retrieval for the Damage struct works.
-Added the readonly real last for the Damage struct.

EDIT: currently i'm working on some troubleshooting regarding damage prevention issues, when finished i'll update the system, meanwhile the system is unsafe to use.
 
General chit-chat
Help Users
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top