wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Systems
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 06-20-2011, 08:26 PM   #211
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by XCLD
I'm sorry if this is a noob question, but is there a way to register when a unit gains a buff using this system? Without having to use ABuff.Create, because I'm trying to register the exact moment a unit gains a buff from Phoenix Fire.
This is a framework for creating triggered buffs. When it is used as a wrapper for ingame buffs, it is up to the user to apply the aBuff whenever an ingame buff is applied. In the case of phoenix fire, you would likely need a damage detection system like DamageEvent, provided that the phoenix fire buff is already applied on the damaged unit by the time the damage event occurs. If that's the case, it's a simple matter of checking for the buff on all damage events caused by damage sources with the phoenix fire ability. Once a buff is found you know that the damage event was caused by phoenix fire, after that you need to either remove the buff so other damage events from non-phoenix-fire sources don't also count, or, if you need the buff since it prevents phoenix fire from hitting the unit again for a duration, you need to tag it for that duration so it doesn't get counted again. For this latter purpose, this library could be used.
__________________
Anitarf is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 07-28-2011, 09:38 PM   #212
BBQ
User
 
Join Date: May 2011
Posts: 85

Submissions (2)

BBQ will become famous soon enough (30)BBQ will become famous soon enough (30)

Default

Okay, I've really come to like this thing, but anyway, here are some particular things that I'd change:
  • ABuff
    1. I really don't see use for the isDying boolean that is found in the aBuffUnit struct.
    2. I think that you should add a private keyword firstBuff, as that shouldn't be used anywhere outside of the library (or should it?).
    3. The name olddata is kind of unlikable, at least in my eyes. How about previousData?
    4. Why the need of three data variables? Just leave one, and change its name to customData or something.
    5. Wouldn't .evaluate() make more sense for the event responses than .execute() ?
    6. I really dislike the .target.u syntax for getting the buffs target. Adding the following method operator in the aBuff struct seems much neater to me:
      Expand targetUnit:

      You could also change the name of caster to sourceUnit, in order to match the above suggestion.
  • ABuffDispel
    1. I think that this add-on wouldn't even work, due to the fact that you have an uninitialized global variable:
      Expand ABuffDispel:
  • ABuffStruct
    1. Perhaps you should include the functions from all the other add-ons inside the ABuffStruct module.
As for add-ons, how about including something like ABuffTransfer, which would support automatic transferring the buffs from one unit to another. You can also supply the users with a configurable textmacro of ObjectMerger calls to ease the creation of 'Aasl' abilities needed for the ABuffDisplay add-on.

Last edited by BBQ : 07-28-2011 at 09:39 PM.
BBQ is offline   Reply With Quote
Old 07-29-2011, 01:59 PM   #213
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Thanks for the feedback.

Quote:
Originally Posted by BBQ
3. The name olddata is kind of unlikable, at least in my eyes. How about previousData?
4. Why the need of three data variables? Just leave one, and change its name to customData or something.
Well, many features of ABuff are results of bad design decisions that remain there in order to maintain backwards compatibility. For example, the data value was initially created to allow custom data to be passed to and stored on an aBuff. As it turns out, doing both those things with the same value is a shitty idea. Custom data should have been passed to the aBuff using an extra argument for the create and refresh event responses, rather than automatically overwriting the data value. I couldn't really change the event function interfaces if I wanted to keep backwards compatibility, but I could add additional data values that wouldn't get overwritten automatically, so I added data1, data2 and data3. As it turns out, that too was a poor decision since users could easily attach data to buffs by typecasting the aBuff to integer and using it as an array index (or just use the new aBuffStruct), so the whole data1/2/3 thing turned out to be a useless feature but again, I have to keep it for backwards compatibility. As noted, you don't really have to use these features, there are better ways to do what they do.

Quote:
I really don't see use for the isDying boolean that is found in the aBuffUnit struct.
It should be used to prevent new aBuffs from being applied on a dying unit, but that somehow got lost during one of the many code updates. Thanks for pointing it out, I'll make it work again in the next version.

Quote:
I think that you should add a private keyword firstBuff, as that shouldn't be used anywhere outside of the library (or should it?).
Yeah, I wrote the first version of the system before we had keyword, so a lot of things that should be private had to be public at the time, I'll fix it in the next version.

Quote:
Wouldn't .evaluate() make more sense for the event responses than .execute() ?
I prefer it if errors in users' code can't crash the whole system, although I suppose it would be possible to make it so event responses are always the last thing that is run so that even if they crash the thread, the functioning of the system is unaffected. I'll look into changing this.

Quote:
I really dislike the .target.u syntax for getting the buffs target. Adding the following method operator in the aBuff struct seems much neater to me:

You could also change the name of caster to sourceUnit, in order to match the above suggestion.
This is another relic from the first version of the system (I don't think we had operators back then). I'm not too fond of adding new syntax on top just because the old one is weird, though, if I did that I'd end up with a new API with each new version. I don't wish to repeat the data1/2/3 fiasco.

Quote:
I think that this add-on wouldn't even work, due to the fact that you have an uninitialized global variable:
I didn't think I could mess up on such a simple piece of code. I was wrong. Fixed it in the next version.

Quote:
Perhaps you should include the functions from all the other add-ons inside the ABuffStruct module.
That seems like a lot of needless code duplication. The API of the modules is not that terrible.

Quote:
As for add-ons, how about including something like ABuffTransfer, which would support automatic transferring the buffs from one unit to another.
If you want to transfer a buff, you can just destroy it on one unit and create a buff of the same type on the other one.

Quote:
You can also supply the users with a configurable textmacro of ObjectMerger calls to ease the creation of 'Aasl' abilities needed for the ABuffDisplay add-on.
Would that really make things easier? Wouldn't it be faster to just copy the abilities in the object editor rather than writing the textmacro call, saving, closing and reopening the map and then deleting the call again?
__________________
Anitarf is offline   Reply With Quote
Old 08-01-2011, 07:31 AM   #214
vuongkkk
User
 
vuongkkk's Avatar
 
Join Date: May 2010
Posts: 5

vuongkkk has little to show at this moment (0)

Default

First, thanks for your work. I really like this sys.However, I have some problems with your system. Fortunately, you still develope this.

ABuffAura and ABuffHeroSkill do NOT work with abilities which unit added by Object Editor. If a unit have a aura ability(use ABuff to handle) by creating or upgrading at runtime or placed at WE (not added by learning) , your system can NOT handle this issue.

May you fix this issue with next version ?

I guest the system needs to add 3 triggers more:
  • one to enum units which placed by WE
  • one has event upgrade finish
  • one has event unit enter map
then check if that unit has a ability .... then add ABuff

Last edited by vuongkkk : 08-01-2011 at 08:17 AM.
vuongkkk is offline   Reply With Quote
Old 08-01-2011, 10:34 AM   #215
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

ABuff was never meant to handle all those situations automatically. ABuffHeroSkill was written specifically to address hero skills, not regular abilities. If you want to apply an aBuff on units as they enter the map, you can easily do it with the onIndex event of AutoIndex so I see no need to provide a special module for it.
__________________
Anitarf is offline   Reply With Quote
Old 11-19-2011, 04:56 AM   #216
watermelon_1234
User
 
Join Date: Oct 2007
Posts: 9

watermelon_1234 has little to show at this moment (4)

Default

I have some questions on using this system:

How do you know when a stacking ABuff is completely gone from a unit?
I need to know since I want to remove a buff only when the unit does not have any of the ABuff type on it.

What would be the best way you would suggest coding ABuffs to make the target immune to other ABuffs?
I have something like this, and I'm wondering if it can be improved:
Collapse JASS:
struct Immune_Stun
    private static constant integer CATEGORY = ABuff_REFCOUNT
    private static constant boolean COUNTS_AS_BUFF = false
    private static constant boolean IGNORE_AS_BUFF = true
            
    method onCreate takes nothing returns nothing
        local aBuff b = .getABuffByType(Stun_Buff.id) // Basically same as the function you defined for normal use but for ABuff structs
        if b != 0 then
            call ABuffRemove(b)
        endif
    endmethod
            
    implement ABuffStruct
endstruct

struct Stun_Buff
    private static constant integer CATEGORY = ABuff_STANDARD
    private static constant boolean COUNTS_AS_BUFF = true
    private static constant boolean IGNORE_AS_BUFF = false
        
    method onCreate takes nothing returns nothing
        local aBuff b = .getABuffByType(Immune_Stun.id) 
        if b == 0 then // Don't want the target to get interrupted if it's immune
            call xecast.createBasicA(SPELL_ID, ORDER_ID, GetOwningPlayer(.caster)).castOnTarget(.target)
        else
            call .remove()
        endif    
    endmethod

    // Etc code

Last edited by watermelon_1234 : 11-19-2011 at 04:57 AM.
watermelon_1234 is offline   Reply With Quote
Old 11-19-2011, 12:34 PM   #217
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by watermelon_1234
I have some questions on using this system:

How do you know when a stacking ABuff is completely gone from a unit?
I need to know since I want to remove a buff only when the unit does not have any of the ABuff type on it.
I'd use a refcount buff in such a situation. If you must also have the stacking functionality, I'd use two buffs: a stacking buff which applies a refcount buff in its onCreate method and removes it in its onRemove method.

Quote:
What would be the best way you would suggest coding ABuffs to make the target immune to other ABuffs?
I have something like this, and I'm wondering if it can be improved:
Your code is okay, the only think I'd do differently is make a wrapper function for applying the stun buff and check for the immunity buff in there and if it is present, not create the stun buff in the first place.
__________________
Anitarf is offline   Reply With Quote
Old 11-19-2011, 03:22 PM   #218
watermelon_1234
User
 
Join Date: Oct 2007
Posts: 9

watermelon_1234 has little to show at this moment (4)

Default

Thanks for the quick answers. The only thing I couldn't do was remove the refcount buff in the onRemove method of the stacking buff, though it worked fine in onCleanup.
watermelon_1234 is offline   Reply With Quote
Old 11-19-2011, 03:39 PM   #219
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Oh, right, my mistake, onRemove only runs if the buff is removed by the ABuffRemove function. I meant the onCleanup method, which runs every time the buff is removed.
__________________
Anitarf is offline   Reply With Quote
Old 01-03-2012, 04:16 AM   #220
codart
User
 
Join Date: Jan 2011
Posts: 15

codart has little to show at this moment (0)

Default

if i create a buff called "Stun" and ABuff_STANDARD category, and apply an instace of it on an unit with 4s as duration, after 1s, unit take another one with 2s as duration.
What is the remaining duration, 2 or 3 s ???
codart is offline   Reply With Quote
Old 01-03-2012, 09:23 AM   #221
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by codart
if i create a buff called "Stun" and ABuff_STANDARD category, and apply an instace of it on an unit with 4s as duration, after 1s, unit take another one with 2s as duration.
What is the remaining duration, 2 or 3 s ???
Quote:
Originally Posted by ABuff documentation
If the constant boolean REFRESH_NEVER_REDUCE_DURATION is true, then refreshing
a buff will never be able to reduce its duration. If the new duration would
be shorter than the buff's current remaining duration, then the remaining
duration of the buff is not changed in this case. This is how normal Warcraft
buffs function as well, if you stun a unit for 6 seconds and 1 second later,
it is stunned by bash for 2 seconds, the stun will end 5 seconds later, not 2.
__________________
Anitarf is offline   Reply With Quote
Old 01-13-2012, 02:51 PM   #222
watermelon_1234
User
 
Join Date: Oct 2007
Posts: 9

watermelon_1234 has little to show at this moment (4)

Default

I have an ABuff that gets dispelled when the target unit gets damaged. The problem is, if the damage dealt kills the unit, the system tries to destroy the ABuff again, resulting in a double free. Could you fix this or is there a way to code the ABuff to prevent this?

Right now I've edited the system a bit to have this check:
Collapse JASS:
if aBuffUnit.check(killed) and not a.beingDestroyed then
watermelon_1234 is offline   Reply With Quote
Old 01-15-2012, 02:52 AM   #223
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

That is not a correct way to fix this, at that point the variable a is still pointing to a buff from the killing unit as the loop for the killed unit has not yet started. Here is a proper fix:
Expand JASS:
__________________
Anitarf is offline   Reply With Quote
Old 01-15-2012, 03:08 AM   #224
watermelon_1234
User
 
Join Date: Oct 2007
Posts: 9

watermelon_1234 has little to show at this moment (4)

Default

Ah that was a careless mistake of me but I didn't notice since it seemed like it worked.
Thanks again for helping. From the looks of that new constant, OPTIMIZE_EVENTS, you will eventually update the system, right?
watermelon_1234 is offline   Reply With Quote
Old 01-15-2012, 09:57 AM   #225
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

I might eventually update it, yes. Not sure why that new constant would indicate that, though.
__________________
Anitarf is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 06:12 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services