Sgqvur
FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
- Reaction score
- 62
LightningRecycle allowes efficient usage of [ljass]lightning[/ljass]s and moving from destroying them to recycling.
Can be configured to precache only the types of [ljass]lightning[/ljass]s that the map is using.
There is also a picture of how the different types of lightnings look like (for fast refference).
API:
Exported constants mapped with human readable names to the Blizzards internal "code names" for lightnings:
[ljass]constant string LIGHTNING_CHAIN_LIGHTNING_PRIMARY = "CLPB"[/ljass]
[ljass]constant integer LIGHTNING_CHAIN_LIGHTNING_PRIMARY_ID = 0[/ljass]
[ljass]constant string LIGHTNING_CHAIN_LIGHTNING_SECONDARY = "CLSB"[/ljass]
[ljass]constant integer LIGHTNING_CHAIN_LIGHTNING_SECONDARY_ID = 1[/ljass]
[ljass]constant string LIGHTNING_DRAIN = "DRAB"[/ljass]
[ljass]constant integer LIGHTNING_DRAIN_ID = 2[/ljass]
[ljass]constant string LIGHTNING_DRAIN_LIFE = "DRAL"[/ljass]
[ljass]constant integer LIGHTNING_DRAIN_LIFE_ID = 3[/ljass]
[ljass]constant string LIGHTNING_DRAIN_MANA = "DRAM"[/ljass]
[ljass]constant integer LIGHTNING_DRAIN_MANA_ID = 4[/ljass]
[ljass]constant string LIGHTNING_FINGER_OF_DEATH = "AFOD"[/ljass]
[ljass]constant integer LIGHTNING_FINGER_OF_DEATH_ID = 5[/ljass]
[ljass]constant string LIGHTNING_FORKED_LIGHTNING = "FORK"[/ljass]
[ljass]constant integer LIGHTNING_FORKED_LIGHTNING_ID = 6[/ljass]
[ljass]constant string LIGHTNING_HEALING_WAVE_PRIMARY = "HWPB"[/ljass]
[ljass]constant integer LIGHTNING_HEALING_WAVE_PRIMARY_ID = 7[/ljass]
[ljass]constant string LIGHTNING_HEALING_WAVE_SECONDARY = "HWSB"[/ljass]
[ljass]constant integer LIGHTNING_HEALING_WAVE_SECONDARY_ID = 8[/ljass]
[ljass]constant string LIGHTNING_LIGHTNING_ATTACK = "CHIM"[/ljass]
[ljass]constant integer LIGHTNING_LIGHTNING_ATTACK_ID = 9[/ljass]
[ljass]constant string LIGHTNING_MAGIC_LEASH = "LEAS"[/ljass]
[ljass]constant integer LIGHTNING_MAGIC_LEASH_ID = 10[/ljass]
[ljass]constant string LIGHTNING_MANA_BURN = "MBUR"[/ljass]
[ljass]constant integer LIGHTNING_MANA_BURN_ID = 11[/ljass]
[ljass]constant string LIGHTNING_MANA_FLARE = "MFPB"[/ljass]
[ljass]constant integer LIGHTNING_MANA_FLARE_ID = 12[/ljass]
[ljass]constant string LIGHTNING_SPIRIT_LINK = "SPLK"[/ljass]
[ljass]constant integer LIGHTNING_SPIRIT_LINK_ID = 13[/ljass]
[ljass]constant integer LIGHTNING_COUNT = 14[/ljass]
[ljass]function GetLightning takes integer lightning_id returns lightning[/ljass]
[ljass]function RecycleLightning takes lightning l, integer lightning_id returns nothing[/ljass]
[ljass]function GetLightningCodeNameById takes integer lightning_id returns string[/ljass]
[ljass]function GetLightningIdByCodeName takes string code_name returns integer[/ljass]
Can be configured to precache only the types of [ljass]lightning[/ljass]s that the map is using.
There is also a picture of how the different types of lightnings look like (for fast refference).
API:
Exported constants mapped with human readable names to the Blizzards internal "code names" for lightnings:
[ljass]constant string LIGHTNING_CHAIN_LIGHTNING_PRIMARY = "CLPB"[/ljass]
[ljass]constant integer LIGHTNING_CHAIN_LIGHTNING_PRIMARY_ID = 0[/ljass]
[ljass]constant string LIGHTNING_CHAIN_LIGHTNING_SECONDARY = "CLSB"[/ljass]
[ljass]constant integer LIGHTNING_CHAIN_LIGHTNING_SECONDARY_ID = 1[/ljass]
[ljass]constant string LIGHTNING_DRAIN = "DRAB"[/ljass]
[ljass]constant integer LIGHTNING_DRAIN_ID = 2[/ljass]
[ljass]constant string LIGHTNING_DRAIN_LIFE = "DRAL"[/ljass]
[ljass]constant integer LIGHTNING_DRAIN_LIFE_ID = 3[/ljass]
[ljass]constant string LIGHTNING_DRAIN_MANA = "DRAM"[/ljass]
[ljass]constant integer LIGHTNING_DRAIN_MANA_ID = 4[/ljass]
[ljass]constant string LIGHTNING_FINGER_OF_DEATH = "AFOD"[/ljass]
[ljass]constant integer LIGHTNING_FINGER_OF_DEATH_ID = 5[/ljass]
[ljass]constant string LIGHTNING_FORKED_LIGHTNING = "FORK"[/ljass]
[ljass]constant integer LIGHTNING_FORKED_LIGHTNING_ID = 6[/ljass]
[ljass]constant string LIGHTNING_HEALING_WAVE_PRIMARY = "HWPB"[/ljass]
[ljass]constant integer LIGHTNING_HEALING_WAVE_PRIMARY_ID = 7[/ljass]
[ljass]constant string LIGHTNING_HEALING_WAVE_SECONDARY = "HWSB"[/ljass]
[ljass]constant integer LIGHTNING_HEALING_WAVE_SECONDARY_ID = 8[/ljass]
[ljass]constant string LIGHTNING_LIGHTNING_ATTACK = "CHIM"[/ljass]
[ljass]constant integer LIGHTNING_LIGHTNING_ATTACK_ID = 9[/ljass]
[ljass]constant string LIGHTNING_MAGIC_LEASH = "LEAS"[/ljass]
[ljass]constant integer LIGHTNING_MAGIC_LEASH_ID = 10[/ljass]
[ljass]constant string LIGHTNING_MANA_BURN = "MBUR"[/ljass]
[ljass]constant integer LIGHTNING_MANA_BURN_ID = 11[/ljass]
[ljass]constant string LIGHTNING_MANA_FLARE = "MFPB"[/ljass]
[ljass]constant integer LIGHTNING_MANA_FLARE_ID = 12[/ljass]
[ljass]constant string LIGHTNING_SPIRIT_LINK = "SPLK"[/ljass]
[ljass]constant integer LIGHTNING_SPIRIT_LINK_ID = 13[/ljass]
[ljass]constant integer LIGHTNING_COUNT = 14[/ljass]
[ljass]function GetLightning takes integer lightning_id returns lightning[/ljass]
[ljass]function RecycleLightning takes lightning l, integer lightning_id returns nothing[/ljass]
[ljass]function GetLightningCodeNameById takes integer lightning_id returns string[/ljass]
[ljass]function GetLightningIdByCodeName takes string code_name returns integer[/ljass]
JASS:
//! zinc
library LightningRecycle
{
public
{
constant string LIGHTNING_CHAIN_LIGHTNING_PRIMARY = "CLPB";
constant integer LIGHTNING_CHAIN_LIGHTNING_PRIMARY_ID = 0;
constant string LIGHTNING_CHAIN_LIGHTNING_SECONDARY = "CLSB";
constant integer LIGHTNING_CHAIN_LIGHTNING_SECONDARY_ID = 1;
constant string LIGHTNING_DRAIN = "DRAB";
constant integer LIGHTNING_DRAIN_ID = 2;
constant string LIGHTNING_DRAIN_LIFE = "DRAL";
constant integer LIGHTNING_DRAIN_LIFE_ID = 3;
constant string LIGHTNING_DRAIN_MANA = "DRAM";
constant integer LIGHTNING_DRAIN_MANA_ID = 4;
constant string LIGHTNING_FINGER_OF_DEATH = "AFOD";
constant integer LIGHTNING_FINGER_OF_DEATH_ID = 5;
constant string LIGHTNING_FORKED_LIGHTNING = "FORK";
constant integer LIGHTNING_FORKED_LIGHTNING_ID = 6;
constant string LIGHTNING_HEALING_WAVE_PRIMARY = "HWPB";
constant integer LIGHTNING_HEALING_WAVE_PRIMARY_ID = 7;
constant string LIGHTNING_HEALING_WAVE_SECONDARY = "HWSB";
constant integer LIGHTNING_HEALING_WAVE_SECONDARY_ID = 8;
constant string LIGHTNING_LIGHTNING_ATTACK = "CHIM";
constant integer LIGHTNING_LIGHTNING_ATTACK_ID = 9;
constant string LIGHTNING_MAGIC_LEASH = "LEAS";
constant integer LIGHTNING_MAGIC_LEASH_ID = 10;
constant string LIGHTNING_MANA_BURN = "MBUR";
constant integer LIGHTNING_MANA_BURN_ID = 11;
constant string LIGHTNING_MANA_FLARE = "MFPB";
constant integer LIGHTNING_MANA_FLARE_ID = 12;
constant string LIGHTNING_SPIRIT_LINK = "SPLK";
constant integer LIGHTNING_SPIRIT_LINK_ID = 13;
constant integer LIGHTNING_COUNT = 14;
function GetLightningCodeNameById(integer id) -> string
{
if (id == LIGHTNING_CHAIN_LIGHTNING_PRIMARY_ID) return LIGHTNING_CHAIN_LIGHTNING_PRIMARY;
else if (id == LIGHTNING_CHAIN_LIGHTNING_SECONDARY_ID) return LIGHTNING_CHAIN_LIGHTNING_SECONDARY;
else if (id == LIGHTNING_DRAIN_ID) return LIGHTNING_DRAIN;
else if (id == LIGHTNING_DRAIN_LIFE_ID) return LIGHTNING_DRAIN_LIFE;
else if (id == LIGHTNING_DRAIN_MANA_ID) return LIGHTNING_DRAIN_MANA;
else if (id == LIGHTNING_FINGER_OF_DEATH_ID) return LIGHTNING_FINGER_OF_DEATH;
else if (id == LIGHTNING_FORKED_LIGHTNING_ID) return LIGHTNING_FORKED_LIGHTNING;
else if (id == LIGHTNING_HEALING_WAVE_PRIMARY_ID) return LIGHTNING_HEALING_WAVE_PRIMARY;
else if (id == LIGHTNING_HEALING_WAVE_SECONDARY_ID) return LIGHTNING_HEALING_WAVE_SECONDARY;
else if (id == LIGHTNING_LIGHTNING_ATTACK_ID) return LIGHTNING_LIGHTNING_ATTACK;
else if (id == LIGHTNING_MAGIC_LEASH_ID) return LIGHTNING_MAGIC_LEASH;
else if (id == LIGHTNING_MANA_BURN_ID) return LIGHTNING_MANA_BURN;
else if (id == LIGHTNING_MANA_FLARE_ID) return LIGHTNING_MANA_FLARE;
else if (id == LIGHTNING_SPIRIT_LINK_ID) return LIGHTNING_SPIRIT_LINK;
return "";
}
function GetLightningIdByCodeName(string code_name) -> integer
{
if (code_name == LIGHTNING_CHAIN_LIGHTNING_PRIMARY) return LIGHTNING_CHAIN_LIGHTNING_PRIMARY_ID;
else if (code_name == LIGHTNING_CHAIN_LIGHTNING_SECONDARY) return LIGHTNING_CHAIN_LIGHTNING_SECONDARY_ID;
else if (code_name == LIGHTNING_DRAIN) return LIGHTNING_DRAIN_ID;
else if (code_name == LIGHTNING_DRAIN_LIFE) return LIGHTNING_DRAIN_LIFE_ID;
else if (code_name == LIGHTNING_DRAIN_MANA) return LIGHTNING_DRAIN_MANA_ID;
else if (code_name == LIGHTNING_FINGER_OF_DEATH) return LIGHTNING_FINGER_OF_DEATH_ID;
else if (code_name == LIGHTNING_FORKED_LIGHTNING) return LIGHTNING_FORKED_LIGHTNING_ID;
else if (code_name == LIGHTNING_HEALING_WAVE_PRIMARY) return LIGHTNING_HEALING_WAVE_PRIMARY_ID;
else if (code_name == LIGHTNING_HEALING_WAVE_SECONDARY) return LIGHTNING_HEALING_WAVE_SECONDARY_ID;
else if (code_name == LIGHTNING_LIGHTNING_ATTACK) return LIGHTNING_LIGHTNING_ATTACK_ID;
else if (code_name == LIGHTNING_MAGIC_LEASH) return LIGHTNING_MAGIC_LEASH_ID;
else if (code_name == LIGHTNING_MANA_BURN) return LIGHTNING_MANA_BURN_ID;
else if (code_name == LIGHTNING_MANA_FLARE) return LIGHTNING_MANA_FLARE_ID;
else if (code_name == LIGHTNING_SPIRIT_LINK) return LIGHTNING_SPIRIT_LINK_ID;
return -1;
}
}
// configure the constants to your map's requirments
// example numbers
constant integer LIGHTNING_CHAIN_LIGHTNING_PRIMARY_PRECACHE_COUNT = 100;
constant integer LIGHTNING_CHAIN_LIGHTNING_SECONDARY_PRECACHE_COUNT = 21;
constant integer LIGHTNING_DRAIN_PRECACHE_COUNT = 34;
constant integer LIGHTNING_DRAIN_LIFE_PRECACHE_COUNT = 40;
constant integer LIGHTNING_DRAIN_MANA_PRECACHE_COUNT = 32;
constant integer LIGHTNING_FINGER_OF_DEATH_PRECACHE_COUNT = 1;
constant integer LIGHTNING_FORKED_LIGHTNING_PRECACHE_COUNT = 2;
constant integer LIGHTNING_HEALING_WAVE_PRIMARY_PRECACHE_COUNT = 67;
constant integer LIGHTNING_HEALING_WAVE_SECONDARY_PRECACHE_COUNT = 123;
constant integer LIGHTNING_LIGHTNING_ATTACK_PRECACHE_COUNT = 0;
constant integer LIGHTNING_MAGIC_LEASH_PRECACHE_COUNT = 0xF;
constant integer LIGHTNING_MANA_BURN_PRECACHE_COUNT = 'A';
constant integer LIGHTNING_MANA_FLARE_PRECACHE_COUNT = 1;
constant integer LIGHTNING_SPIRIT_LINK_PRECACHE_COUNT = 2;
// set this constant to the biggest number from the above (123 for the example configuration)
//
constant integer LIGHTNING_PRECACHE_COUNT_MAX = LIGHTNING_HEALING_WAVE_SECONDARY_PRECACHE_COUNT;
lightning stack[LIGHTNING_COUNT][LIGHTNING_PRECACHE_COUNT_MAX];
integer top[LIGHTNING_COUNT];
function init_lightnings()
{
integer i;
for (0 <= i < LIGHTNING_CHAIN_LIGHTNING_PRIMARY_PRECACHE_COUNT)
{
stack[LIGHTNING_CHAIN_LIGHTNING_PRIMARY_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_CHAIN_LIGHTNING_PRIMARY_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_CHAIN_LIGHTNING_PRIMARY_ID] = LIGHTNING_CHAIN_LIGHTNING_PRIMARY_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_DRAIN_PRECACHE_COUNT)
{
stack[LIGHTNING_CHAIN_LIGHTNING_SECONDARY_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_CHAIN_LIGHTNING_SECONDARY_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_CHAIN_LIGHTNING_SECONDARY_ID] = LIGHTNING_CHAIN_LIGHTNING_SECONDARY_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_DRAIN_PRECACHE_COUNT)
{
stack[LIGHTNING_DRAIN_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_DRAIN_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_DRAIN_ID] = LIGHTNING_DRAIN_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_DRAIN_LIFE_PRECACHE_COUNT)
{
stack[LIGHTNING_DRAIN_LIFE_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_DRAIN_LIFE_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_DRAIN_LIFE_ID] = LIGHTNING_DRAIN_LIFE_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_DRAIN_MANA_PRECACHE_COUNT)
{
stack[LIGHTNING_DRAIN_MANA_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_DRAIN_MANA_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_DRAIN_MANA_ID] = LIGHTNING_DRAIN_MANA_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_FINGER_OF_DEATH_PRECACHE_COUNT)
{
stack[LIGHTNING_FINGER_OF_DEATH_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_FINGER_OF_DEATH_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_FINGER_OF_DEATH_ID] = LIGHTNING_FINGER_OF_DEATH_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_FORKED_LIGHTNING_PRECACHE_COUNT)
{
stack[LIGHTNING_FORKED_LIGHTNING_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_FORKED_LIGHTNING_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_FORKED_LIGHTNING_ID] = LIGHTNING_FORKED_LIGHTNING_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_HEALING_WAVE_PRIMARY_PRECACHE_COUNT)
{
stack[LIGHTNING_HEALING_WAVE_PRIMARY_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_HEALING_WAVE_PRIMARY_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_HEALING_WAVE_PRIMARY_ID] = LIGHTNING_HEALING_WAVE_PRIMARY_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_HEALING_WAVE_SECONDARY_PRECACHE_COUNT)
{
stack[LIGHTNING_HEALING_WAVE_SECONDARY_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_HEALING_WAVE_SECONDARY_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_HEALING_WAVE_SECONDARY_ID] = LIGHTNING_HEALING_WAVE_SECONDARY_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_LIGHTNING_ATTACK_PRECACHE_COUNT)
{
stack[LIGHTNING_LIGHTNING_ATTACK_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_LIGHTNING_ATTACK_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_LIGHTNING_ATTACK_ID] = LIGHTNING_LIGHTNING_ATTACK_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_MAGIC_LEASH_PRECACHE_COUNT)
{
stack[LIGHTNING_MAGIC_LEASH_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_MAGIC_LEASH_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_MAGIC_LEASH_ID] = LIGHTNING_MAGIC_LEASH_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_MANA_BURN_PRECACHE_COUNT)
{
stack[LIGHTNING_MANA_BURN_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_MANA_BURN_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_MANA_BURN_ID] = LIGHTNING_MANA_BURN_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_MANA_FLARE_PRECACHE_COUNT)
{
stack[LIGHTNING_MANA_FLARE_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_MANA_FLARE_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_MANA_FLARE_ID] = LIGHTNING_MANA_FLARE_PRECACHE_COUNT;
for (0 <= i < LIGHTNING_SPIRIT_LINK_PRECACHE_COUNT)
{
stack[LIGHTNING_SPIRIT_LINK_ID]<i> = AddLightning(GetLightningCodeNameById(LIGHTNING_SPIRIT_LINK_ID), false, 0, 0, 0, 0);
}
top[LIGHTNING_SPIRIT_LINK_ID] = LIGHTNING_SPIRIT_LINK_PRECACHE_COUNT;
}
public function GetLightning(integer lightning_id) -> lightning
{
top[lightning_id] = top[lightning_id] - 1;
debug
{
if (top[lightning_id] < 0)
{
BJDebugMsg("LightningRecycle error: no more lightnings of type \"" + /*
*/ GetLightningCodeNameById(lightning_id) + "\", maybe you are not recycling them or you need to precache more");
}
}
return stack[lightning_id][top[lightning_id]];
}
public function RecycleLightning(lightning l, integer lightning_id)
{
MoveLightningEx(l, false, 0, 0, 0, 0, 0, 0);
stack[lightning_id][top[lightning_id]] = l;
top[lightning_id] = top[lightning_id] + 1;
}
function onInit()
{
init_lightnings();
}
}
//! endzinc
</i></i></i></i></i></i></i></i></i></i></i></i></i></i>
Attachments
-
437.4 KB Views: 419