you can learn how to do that by looking at the nova system...
basically for a movement spell you create a real struct member which will determine the distance travelled every loop, now set it to the max distance upon create and reduce it by the distance travelled per loop, now if it become <= 0.00, the spell is finished
static method looper takes nothing returns nothing
local integer i
exitwhen i > .TOTAL
set data = .INDEX[.TOTAL]
set data.distance = data.distance - .dpl
if data.distance <= 0.00 then
to index it just create an integer array and an integer variable global or static struct members
static thistype data
static integer TOTAL
static integer array INDEX
static method create takes nothing returns sample
//we allocate an instance
set data = allocate()
//we increase the number of instances in use
set .TOTAL = .TOTAL + 1
//we set the struct instance into the array
set .INDEX[.TOTAL] = data
for unit movement, there are some of that in the spells section...
basically you make a periodic loop which moves the unit...
yup, basically the struct instance is an integer... but you cannot directly use it effectively... because allocation of structs are a bit random from my experience.
example: I have missile spells, then I added debug messages which gave me the instance of each missile created, it gives something like, [1,2,3,5] or [1,4,2,10] so its pretty hard to use the instances as an index directly... well you can loop from 1-8190 but it would be inefficient...
so we use an indexing system instead to loop only the in-use struct instances.
I do it this way:
-I decide how much min and max damage the unit will have
-then initialize it at the library
-then on the OE, I calculate the correct amount of base damage, number die, sides per die to achieve the min and max that I want so that the unit's UI show the correct amount... ^_^
Min damage -> Base + NumberOfDie
Max damage ->Base + NumberOfDie*SidesPerDie
The indexing is to loop thru all the instances of the struct... Remember that structs are just a collection of arrays so that indexing is the same as the normal recycling indexing methods used on GUI triggers.
I have an update for Arzachel. you might want to check it out on the map dev... ^_^
unit's have a min and max damage right? the one you see on the UI... ex: 1-10
-This is an example which I used in my map-
well since the DDS will fire off when a unit is damaged you need to somehow add a condition.
On my case, I use a dummy unit to cause the "real damage"(the triggered one) whenever a unit gets damaged by a unit(B) (and on my case damage done by other units is 0.00 because of the settings)
So the DDS checks if the UnitId that caused the damage is the same as the Id of the dummy unit, and if not (meaning the damage is not yet the calculated) the DDS will run its actions
-Get the damage of the unit (via a library that saves a unit's min and max damage)
-Apply reduction calculations on the damage value
-Make the dummy unit owned by the player which owns the unit(B) deal the calculated damage amount to the damaged unit.
On the gamelay constants:
I've set the damage dealt by all attack-types to 0.00 except for attack-type Chaos
-basically Chaos would still deal 100% for all armor types while the others deal 0.00 so dont give attack-type chaos to any unit in the map
Then I made a library which stores every UnitIds min and max damage value.
Then made a dummy unit that will be the one that will cause the "real damage".
Then create one dummy per player
Then made a DDS which checks if the damager's unitId is the not equal to the dummy unit.
-If not then we will calculate damage by getting a random real between the unit's saved min and max damage
-then reduce it by the value of the damaged unit's reduction...
-and make the dummy of the damager's owner to deal the calculated damage (using ATTACK_TYPE_CHAOS, DAMAGE_TYPE_DIVINE)
-And basically all damages will have to be made custom, especially spells, so no default spells-
your suggestion is fine, but that would result to more code rather than the user just initializing every unit... mainly because I would then need to have two libraries, one will have the armor value for every unitId, and then DRT...
while if the user wil just do it, another library isnt really needed... the user can do it on map init
Pick - every unit
Unit-Type is equal to blahblah
Then - actions
now that would be shorter than if I make a new library and will take less map space since you dont need to save the armor value per UnitId anymore...
basically, its more efficient if the user himself initializes every unit rather than me providing another library that would "automize" it a little bit.
This sets the reduction value of units, when you initialize them. Basically you need to initialize EACH individual unit that will use the system. And you can dynamically change the reduction values of each individual unit in-game. Instructions included on the code.
I have another one on my comp which is easier to use (uses UnitIds rather than units, so you only need to initialize each unitId and it will affect all units with that Id). BUT since it uses a common reduction per UnitId, you cannot change a single unit's reduction without affecting similar units.
And that's why I have uploaded the Per Unit DRT, rather than the Per UnitId...
Yup, though the system doesn't support armor types... and it must be used in a custom damage system...
And the ItemTable is only useful if you will use the normal wc3 inventory or an ordinary bag system...
Anyway if you can use an FSI or any other inventory, it wont be a problem integrating the ReductionTable. (I managed to integrate it with The_Witcher's Inventory system)
Well, DamageReductionTable isnt a Damage system, its just a reduction table. Its meant to be used in a SIMPLE custom damage system since its kinda lacking advanced features (like different armor types, but the user can do that in their damage system themselves... ^_^)...
ItemTable lets you set the reduction values of an Item type and automatically updates a unit's reduction values when it picks/drop/pawn an item...