IDDDBaseMap - yeelp/Distinct-Damage-Descriptions GitHub Wiki

An IDDDBaseMap is a map with IDDDDamageTypes as keys and floats as values. This is the structure for things like IDamageDistributions. It's basically the same as float[IDDDDamageType]

Importing the package

It might be required for you to import the package if you encounter any issues, (like casting an Array), so better be safe than sorry and add the import

import mods.ddd.lib.IDDDBaseMap;

How to Get One

Currently, the only way to get one is to use the distribute(float) ZenMethod on an IDamageDistribution. You can however, declare one like a standard associative array.

val dist = {
   <dddtype:force> : 0.5,
   <dddtype:poison> : 0.5
} as IDDDBaseMap;

(Technically, since this is a map and not a damage distribution, the float values don't need to add up to 1! However, if you intend to use this to subvert the distribution restrictions, you're on your own!)

What can you do with it?

IDDDBaseMaps are standard ZenScript Associative Arrays, so anything you can do with those, you can do with these! Most importantly, you can iterate over the key-value pairs.

val forceDist = <dddtype:force>.distribution;
for type, weight in forceDist {
    print(type.name ~ " has weight " ~ weight);
}

You can access weights in a DDDBaseMap using standard indexGetters. The memberGetters won't work since the indices aren't strings!

print(<dddtype:force>.name ~ ": distributing 3.14 force damage: " ~ <dddtype:force>.distribution.distribute(3.14)[<dddtype:force>]);

While there are neat things you can do with this, since there isn't many useful ways to get this type, the applications are currently limited.