Wc3C.net (http://www.wc3c.net/forums.php)
-   Scripts (http://www.wc3c.net/forumdisplay.php?f=737)
-   -   OrbStacking (http://www.wc3c.net/showthread.php?t=105449)

Deaod 04-12-2009 10:45 PM

2 Attachment(s)
A library to ease stacking orbs. And to add limitations to stacking orbs.

This uses vJass, DamageEvent, DamageModifiers, AutoIndex, Table and optionally GroupUtils.

In-Game commands

-reset: Spawns some footmen around you.
-level <level>: Sets the level of your hero to the specified level. Note that you cannot decrease your hero's level this way.
-handleid: Creates a location, displays its index - 0x1000001 and destroys it.
-commands: Shows this list.
-credits: Shows the credits.
-clear: Clears all text-messages.


13/04/2009 - Version 1.0.0
- initial release

13/04/2009 - Version 1.0.1
- made removing the buff optional and moved it to the top to prevent recursion

16/04/2009 - Version 1.1.0
- changed internal handling of Item Orbs to Table for a performance gain
- each Orb now has a chance to be run. Refer to the manual for more information

16/04/2009 - Version 1.2.0
- added Category Types (if you have a more logical naming for those types, let me know)
- as a result of that, .AddToCategory()'s interface was changed.

23/04/2009 - Version 1.3.0
- each Category now has an execution limit, which can be adjusted
- backwards compatible

29/04/2009 - Version 1.3.1
- forgot to initialize the string table in the Category struct
- deleted irritating debug messages

29/04/2009 - Version 1.4.0
- reworked the way randomness is handled. 1.4.0 uses Ammorth's ChanceToProc library for that. Due to the severe performance impact i decided to keep 1.3.1 for those who are comfortable with the "spikes" the old way imposes on the chances

08/05/2009 - Version 1.5.0
- reworked the way randomness is handled (again). Removed the chance calculation on my side. The user decides whether the orb was applied or not with his own calculations
- as a result, the function interface was changed. You now have to return a boolean. For compatibility, use the constants provided by this library

22/05/2009 - Version 1.5.1
- deleted the superfluous H2I function
- minor other changes.

07/08/2009 - Version 1.5.2
- Compatibility with 1.24

06/11/2009 - Version 1.5.3
- fixed a few bugs by changing the ability the Generic Orb is based upon.
- Simplified implementation of the library and added a note that you have to add an ability to all units you want to have custom orbs.

06/02/2010 - Version 1.6.0
- Heavily optimized code run when a unit takes damage
- Made LightLeaklessDamageDetect exchangeable with IDDS by implementing an abstraction layer.

10/02/2010 - Version 1.6.1
- dramatically simplified importing this library. Now, you only need to copy over the code, everything else gets done automatically.
- removed the requirement of LightLeaklessDamageDetect, you can still use it, but its not required anymore.
- fixed Orbs for preplaced units.
- fixed destroying Orbs.
- clarified a few things in the documentation.

14/02/2010 - Version 1.6.2
- more bugfixes. Skilling the same ability multiple times no longer creates multiple UnitOrb instances.
- now supports adding Orbs via GUI.

15/02/2010 - Version 1.7.0
- breaks backwards compatibility in order to implement stacking priority. Orbs with higher priority get executed first. Only the interface of Orb.Create was changed.
- Allows changing the damage dealt to the damaged unit with the SetDamage(real new) function.

21/05/2010 - Version 1.8.0
- breaks backwards compatibility again. Ill get into that separately as basically the whole API changed. My aim was to reduce possibility of collision of names (eg. Category was far too general a name for a struct in a public library) (and i wanted to correct past mistakes).
- added missile modificators. Orbs can now change the missile a unit attacks with. Note that it doesnt take the target unit of an attack into account for speed reasons.

New API:
Category --> OrbCategory
Orb_Callback --> OrbCallback
All members of publicly available structs now start with a lower-case-letter.

15/06/2010 - Version 1.8.1
- fixed OrbStacking for unit upgrading.
- did a few optimizations.
- added a few lines warning about using other orbs combined with this library (it just wont work the way you want it to).

Expand Script Code:

I additionally attached a map with two samples.

Vexorian 04-16-2009 02:19 PM

Hmnn, an item based addon for LLDD sounds like a good idea, however:
- Heroes only have 6 items while a map could have like err 20 orbs. In other words, instead of iterating through all the orbs and checking if the hero has such item, iterate through all the items and if the item is an orb, do it.

- Maybe also add randomization into the equation? Most orbs would like to be random and I think it would be better to handle the random stuff inside your script so it doesn't have to call TriggerEvaluate

- Also some stacking is better, a hero could have the same orb multiple times, but for mapmakers just doubling the power of the orb is not that of a great idea, how about running the orb's function once but passing an argument/variable that tells the coder how many of those orbs does he have?

Deaod 04-16-2009 03:17 PM

i could use table, but that would make this thing slow.
Adding the randomization will be a pain in the ass, but ill see what i can do.
Having the same orb twice will not do anything (as long as they share at least one category). The user could still check how many times the unit has that orb.

Vexorian 04-16-2009 03:26 PM


i could use table, but that would make this thing slow.
Definitely faster than this though.

Deaod 04-16-2009 04:40 PM

Version 1.1.0


Version 1.2.0

Deaod 04-23-2009 04:56 PM

Version 1.3.0

Magissia 04-23-2009 07:46 PM

Can you make a demo map with blizzard's orb as sample but using you're system ??? (Ice orb, lightning otb ... etc)

And this line private constant integer AID = 'A005' mean the character have the item A005 or the spell A005 (Learned or on an item) (i think it spell, if it, can we trigger this from an item and not a skill ? (Item without any skill on it all triggered, or item with allready these 4 skills max that i want to add an other effect))

Sorry about my very poor english >_>

Deaod 04-29-2009 06:22 PM

Version 1.3.1

I added a map with two sample orbs created by blizzard initially (you could probably replicate those two orbs with simple object editor work, but they wouldnt stack).

Yes, you can make items have orbs easily, just pass ABILITY_TYPE_ITEM instead of ABILITY_TYPE_SKILL to Orb.Create().
And yes, you technically dont need a separate ability on the item to trigger the orb, but if you, for example, want to modify the missile art of the unit, you have to add one (either you add one, or you find a way to modify the units missile art through scripting).


Version 1.4.0

Deaod 05-08-2009 09:39 PM

Version 1.5.0

Vexorian 05-22-2009 12:38 AM

Approving it.

Deaod 05-22-2009 07:55 PM

Version 1.5.1

Deaod 08-07-2009 02:26 PM

Version 1.5.2

Sinnergy 11-04-2009 08:13 AM

Can you provide more examples for:

We really can't get it clearly if you are only using 1 type for both spells, it would be better if you will create examples for each category type, each ability type and something that uses ORB_NOT_APPLIED as the returned boolean. Or if you are too lazy to create actual spells and items for examples, can you please state them into words? Thank you.

Is CATEGORY_TYPE_READ stacking? or non stacking? I really don't get these category types, and ORB_APPLIED and ORB_NOT_APPLIED are explained before you explained category types, which is really confusing.

Deaod 11-04-2009 08:54 AM

Okay, i will try.

Each category has an execution limit associated to it (which defaults to DEFAULT_CATEGORY_EXEC_LIMIT). Each orb can be associated to multiple categories. For the orb to trigger, its necessary that all categories its associated with (and are of type READ or READWRITE) have not yet reached their respective execution limits.

If the category for an orb is of type READ, that orb ONLY checks if another orb of that category can be executed but does not increase the execution count of that category.

If the category for an orb is of type WRITE, that orb ONLY increases the execution count, but does not check if another orb of that category can be executed.
Given that all preconditions are met, and the callback for that orb is executed, you can return ORB_APPLIED or ORB_NOT_APPLIED from the callback, since you might want to trigger an orb like bash or critical strike (which trigger based on chance).
If you return ORB_NOT_APPLIED, the execution count for all categories (of type WRITE or READWRITE) the orb is associated with will not be increased.
If you return ORB_APPLIED, the execution count for those categories will be increased.

The category type READWRITE combines those two. Meaning, it checks whether the execution limit of that category has been reached, and if the orb is successfully executed (its callback returned ORB_APPLIED) it increases the execution count of the category.

Sinnergy 11-04-2009 09:38 AM

Thanks for the information.
In your life steal spell example, you stated above that it acts like blizzard's life steal spell. Lets say I created an item which also acts like life steal orb in your system, then I want it to stack with the same item, then what types will I use?
Mask of Death item, an orb item that steals 10% of the damage dealt which stacks with another Mask of Death item, meaning if I have two Mask of Death, then I will have 20% life steal per attack.

Edit: Looks like my code isn't working, I imported it right using the same abilities and buffs inside your test map and still using its raw codes in my map, I don't need to calibrate the script because it has the same raw codes used in my map. Heres the code.
Collapse unworking code:
scope Bear initializer init
        private constant integer superBeing = 'A00D'
        private constant integer tr = 'A009'
    private function trash takes nothing returns boolean
        local unit c = GetDamagingUnit()
        local unit t = GetDamagedUnit()
        local xecast xe
        debug call BJDebugMsg("trash is called")
        if(GetUnitAbilityLevel(c,superBeing)>0 and GetUnitAbilityLevel(c, tr) > 0 and GetUnitAbilityLevel(t,'mark') == 0 and IsUnitEnemy(c,GetOwningPlayer(t)) )then
            if GetRandomInt(0,100) <= 30 then
                call UnitDamageTarget(c,t,60.0,true,false,ATTACK_TYPE_MELEE,DAMAGE_TYPE_NORMAL,null)
                set xe = xecast.createA()
                set xe.abilityid = cr
                set xe.orderstring = "cripple"
                set xe.owningplayer = GetOwningPlayer(c)
                call xe.castOnTarget(t)
                debug call BJDebugMsg("with bonus")
        elseif GetUnitAbilityLevel(c,superBeing) == 0 and GetUnitAbilityLevel(c, tr) > 0 and GetUnitAbilityLevel(t,'mark') == 0 and IsUnitEnemy(c,GetOwningPlayer(t))  then
            if GetRandomInt(0,100) <= 20 then
                call UnitDamageTarget(c,t,30.0,true,false,ATTACK_TYPE_MELEE,DAMAGE_TYPE_NORMAL,null)
                debug call BJDebugMsg("without bonus")
                if GetUnitAbilityLevel(c,bb) > 0 then
                    set xe = xecast.createA()
                    set xe.abilityid = cr
                    set xe.orderstring = "cripple"
                    set xe.owningplayer = GetOwningPlayer(c)
                    call xe.castOnTarget(t)
                    debug call BJDebugMsg("buff applied")
        set c = null
        set t = null
        return ORB_APPLIED
    private function init takes nothing returns nothing
        call Orb.Create(tr,ABILITY_TYPE_SKILL,Orb_Callback.trash).AddToCategory("trasher",CATEGORY_TYPE_READWRITE)
none of the debug messages are displayed in testing the map in debug mode

All times are GMT. The time now is 09:05 PM.

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