| 03-15-2009, 11:32 AM | #1 |
i am currently writing a custom buff system ...(for stacking buffs ..) how would you code it ? i am currently have something like this: -one struct buffx, which contains the data for each buff .... -one struct unitbuffs which contains all the buffs for one unit ... (for things like dispel ...for example) Basic Structure:library BuffLib uses TimerUtils, UnitIndexingUtils globals private constant integer MAX_BUFFS = 10 // Maximum ammount of buffs possible per unit private struct ubuffs[8190] readonly unit u readonly integer buffcount readonly buffx array myBuffs[MAX_BUFFS] method getBuffx takes buffx whichBuff returns integer method getBuffxbyAbiId takes integer aid returns integer private method onDestroy takes nothing returns nothing private method refreshBuff takes integer whichIndex, buffx replaceWith returns nothing static method create takes unit u returns ubuffs method removeBuff takes buffx whichBuff returns boolean method addBuff takes buffx whichBuff returns nothing method destroyAllBuffs takes buffx caller returns nothing endstruct globals private ubuffs array unitbuffs endglobals struct buffx integer myindex private unit u // ... static method apply takes unit u, integer adderid, integer auraid, integer level, real dur returns buffx // attaches the buff to the unit (registers it with unitbuffs[GetUnitId(u)].addBuff(this)) // and stores the index of this buffx in the unitbuffs[GetUnitId(u)].myBuffs in this.myindex static method getBuffCount takes unit u returns integer static method unitHasBuffx takes unit u, integer adderid returns boolean method abiLevel takes integer abiId, integer level returns nothing endstruct endlibrary well basically ..what do i need for a custom buff .. ?! -one hidden spellbook adder ability which adds a aura, which gives the buff (and maybe some effects already too) ... -now i thought of having some method for buffx like addEffect takes integer abiId returns nothing which adds additional effects (also auras in a hidden spellbook ..or item abilities without a icon...well basically that would be up to the user) ...those abilitiy-ids would be stored in some array member variable of buffx (a maximum of 5 additional effects should be sufficient ?) What do you think of that ? |
| 03-15-2009, 02:44 PM | #2 |
I'd do it like this. |
| 03-15-2009, 06:38 PM | #3 | |
Quote:
There should be a seperate (optional) module for damage-related stuff for your buff system. |
| 03-15-2009, 06:46 PM | #4 |
I should probably release my buff system sometime. Hrm. Wonder how close it is.. |
| 03-15-2009, 07:07 PM | #5 |
nice suggestions really ... how did you organize your code basically dusk ? ..i am interrested...# EDIT: I think i will implement the additional effects using a Linked list ...seems the best imo ... Also thought about using a linked list for the buffx-list attached to units ... ..but i wont do it, since it would slightly decrease performance ..(or it would stay the same ...unsure 'bout that) |
| 03-15-2009, 07:20 PM | #6 | |
Quote:
JASS:library ADamage //***************************************************************** //* DUMMY ADAMAGE //* //* This is a dummy library that allows the ABuff system to //* function without ADamage. Obviously, if this dummy library //* is used instead of the original ADamage, the ABuff system //* will not be able to use damage events. //* //***************************************************************** public function interface Response takes unit damagedUnit, unit damageSource, real damage, real prevented returns nothing public function AddResponse takes Response r returns nothing endfunction endlibrary |
| 03-15-2009, 07:21 PM | #7 |
JASS:call UnitAddBuff(SourceUnit, TargetUnit, BuffTypeInteger, RealDuration, RealPeriodicity) JASS:call RegisterBuffType(BuffTypeInteger, CallbackFunction) It was really smooth. I just haven't cleaned it up and released it yet. I should, though. |
| 03-15-2009, 07:29 PM | #8 | |
Quote:
But first i will do a minimal buff system ..since such a thing can be easily be done by the users aswell ... (using a periodic timer + check if unit has buff xy..trough a method of the system) @anitarf: Thats really lame 0.o ..but well... ... i really want a friend keyword for libraries ...REALLY ... would make "additional modules" much nicer ... |
