Reset Cooldowns
#1
Posté 15 janvier 2010 - 07:07
Thanks
#2
Posté 15 janvier 2010 - 11:01
That should help. You will likely have to loop through all spells and abilities and set them all to zero.
#3
Posté 15 janvier 2010 - 11:45
#4
Posté 16 janvier 2010 - 09:15
Craig Graff wrote...
This might work:
[dascript]
object[] arParty = GetPartyList();
object oPartyMember;
int n, m;
int nPartySize = GetArraySize(arParty);
for (n = 0; n < nPartySize; n++)
{
oPartyMember = arParty[n];
for (m = 0; m < 50; m++)
{
Ability_SetCooldown(oPartyMember, GetQuickslot(oPartyMember, m));
}
}
[/dascript]
#5
Posté 16 janvier 2010 - 09:17
Thank you for pointing that out though, very cool of ya.
#6
Posté 06 avril 2010 - 09:09
I propose the following code: it's a bit heavy, but I tried and it looks like it works... Thanks to Anakin, whose message in another thread helped me.
void rna_remove_all_cooldowns_party()
{
object[] aParty = GetPartyList();
int nPartySize = GetArraySize(aParty);
int nCharacter;
object oCharacter;
int nTable;
int nSize;
int i;
int nRow;
int nID;
object[] aItems;
// Remove cooldowns on spells
// We loop on abilities outside the character loop, in order to mimimize M2DA queries.
nTable = TABLE_ABILITIES_SPELLS;
nSize = GetM2DARows(nTable);
for (i = 0; i < nSize; i++)
{
nRow = GetM2DARowIdFromRowIndex(nTable, i);
nID = GetM2DAInt(nTable, "ID", nRow);
for (nCharacter = 0; nCharacter < nPartySize; nCharacter++)
{
oCharacter = aParty[nCharacter];
if (HasAbility(oCharacter, nID))
{
SetCooldown(oCharacter, nID, 0.0);
}
}
}
// Remove cooldowns on talents
// We loop on abilities outside the character loop, in order to mimimize M2DA queries.
nTable = TABLE_ABILITIES_TALENTS;
nSize = GetM2DARows(nTable);
for (i = 0; i < nSize; i++)
{
nRow = GetM2DARowIdFromRowIndex(nTable, i);
nID = GetM2DAInt(nTable, "ID", nRow);
for (nCharacter = 0; nCharacter < nPartySize; nCharacter++)
{
oCharacter = aParty[nCharacter];
if (HasAbility(oCharacter, nID))
{
SetCooldown(oCharacter, nID, 0.0);
}
}
}
// Remove cooldowns on items (health potions, etc.)
for (nCharacter = 0; nCharacter < nPartySize; nCharacter++)
{
oCharacter = aParty[nCharacter];
aItems = GetItemsInInventory(oCharacter);
nSize = GetArraySize(aItems);
for (i = 0; i < nSize; i++)
{
object oItem = aItems[i];
SetCooldown(oCharacter, GetItemAbilityId(oItem), 0.0, GetTag(oItem));
}
}
}
Modifié par FanfanVilperdue, 06 avril 2010 - 09:11 .
#7
Posté 06 avril 2010 - 09:43
void ResetPartyCooldown(object oCreature)
{
int nAbility, nPartyMember;
int[] nAbilities;
object oPartyMember;
// for each member of the party ...
object[] oPartyMembers = GetPartyList(oCreature);
for(nPartyMember = 0; nPartyMember < GetArraySize(oPartyMembers); nPartyMember++)
{
oPartyMember = oPartyMembers[nPartyMember];
// ... get their "hot" abilities ...
nAbilities = GetAbilityList(oPartyMember, ABILITY_INVALID, TRUE);
for(nAbility = 0; nAbility < GetArraySize(nAbilities); nAbility++)
{
// ... and cool them!
SetCooldown(oPartyMember, nAbility, 0.0);
}
}
}
Please not the above is an example to illustrate the new function and which I haven't tested (yet). Also the items might need seperate treatment given the way SetCooldown works.
Modifié par Sunjammer, 06 avril 2010 - 09:49 .
#8
Posté 07 avril 2010 - 09:42
#9
Posté 07 avril 2010 - 10:06
#10
Posté 07 avril 2010 - 10:02
#11
Posté 08 avril 2010 - 12:39
The Lexicon never gets either despite the fact it has it listed as a v1.03 function. Perhaps I need to make the categories day-glow pink or something ...
Modifié par Sunjammer, 08 avril 2010 - 12:41 .
#12
Posté 08 avril 2010 - 03:04
#13
Posté 13 avril 2010 - 03:54
See below my code as it is for the moment. This script works most of times, but
sometimes it doesn't terminate. I guess its execution is quite long and
that happens when the engine is a bit overloaded. As a consequence, the
parent script (in which I call reset_cooldowns on all party members,
amongst other things) doesn't terminate either.
Anybody has an idea about it? Thanks in advance.
void reset_cooldowns(object oCreature)
{
// Non-item abilities
int[] aCoolingDownAbilities = GetAbilityList(oCreature, ABILITY_INVALID, TRUE);
int nSizeAbilities = GetArraySize(aCoolingDownAbilities);
int i;
int nIdAbility;
for (i = 0; i < nSizeAbilities; i++)
{
nIdAbility = aCoolingDownAbilities[i];
SetCooldown(oCreature, nIdAbility, 0.0);
}
// Remove cooldowns on items (health potions, etc.)
object[] aItems = GetItemsInInventory(oCreature);
int nSizeItems = GetArraySize(aItems);
object oItem;
for (i = 0; i < nSizeItems; i++)
{
oItem = aItems[i];
nIdAbility = GetItemAbilityId(oItem);
if (nIdAbility != ABILITY_INVALID)
SetCooldown(oCreature, nIdAbility, 0.0, GetTag(oItem));
}
}
Modifié par FanfanVilperdue, 14 avril 2010 - 08:59 .
#14
Posté 13 avril 2010 - 05:29
#15
Posté 13 avril 2010 - 05:52
That code is also resetting the cooldown regardless of whether or not it requires resetting. Again this may or may not be the cause but it should be addressed. This can be done by adding a GetRemainingCooldown check.
However the biggest issue as I see it is that you are not matching the ability to the item that provides it. The code is resetting the cooldown regardless of whether or the current item actually provided it, i.e. if you have multiple items that can provide abilities with the same ID. This issue is minimised by the previous check (assuming you include the item's tag) however if you have two items with the same tag then there does not seem to be a way to distinguish them.
Incidentally if you know your code doesn't work it is better to post it as a request for assistance rather than offer it up as a potential solution.
Modifié par Sunjammer, 13 avril 2010 - 06:19 .
#16
Posté 14 avril 2010 - 09:21
Thank you for your help.
nSizeAbilities is usually between 0-6, and nSizeItems between 100 et 120. But it is also the case when the script terminates.Magic wrote...
The code looks fine. How much is
nSizeAbilities + nSizeItems when you encounter problems?
Nice idea. Now, for items abilities, I do the loop on items first and then on characters (see code below). According to my tests, it is more than twice faster this way (than the opposite). Theoretically, I guess it's possible that a equipped item has an "cooldownable" ability, so the script doesn't cover every possible cases, but the performance gain is worth it.Sunjammer wrote...
Your item code is iterating over the shared inventory (backpack) for each creature in the party
I had a look on this also... The only case where HasAbility returned FALSE was for nIdAbility = 200000, aka INVALID_ITEM_ABILITY. Dammit! As soon as I replaced ABILITY_INVALID with INVALID_ITEM_ABILITY, it terminated each time!Sunjammer wrote...
I suspect you'll want to add a HasAbility check.
I tried to add a test with GetRemainingCooldown, but with no significally better performance.Sunjammer wrote...
That code is also resetting the cooldown regardless of whether or not it requires resetting. Again this may or may not be the cause but it should be addressed. This can be done by adding a GetRemainingCooldown check.
True, but linked to the syntax of SetCooldown for item abilities (reference by tag only). I don't think it's a problem in practice.Sunjammer wrote...
if you have two items with the same tag then there does not seem to be a way to distinguish them.
You're right, I edited my message.Sunjammer wrote...
Incidentally if you know your code doesn't work it is better to post it as a request for assistance rather than offer it up as a potential solution.
By the way, TimelordDC was right, I didn't know the Lex but just the toolset wiki.
Finally, the code (which works for real, this time
void reset_cooldowns_party()
{
object[] aParty = GetPartyList();
int nPartySize = GetArraySize(aParty);
int iCreature;
object oCreature;
int[] aCoolingDownAbilities;
int nSizeAbilities;
int iAbility;
int nIdAbility;
object[] aItems;
int nSizeItems;
int iItem;
object oItem;
// Non-item abilities
for(iCreature = 0; iCreature < nPartySize; iCreature++)
{
oCreature = aParty[iCreature];
aCoolingDownAbilities = GetAbilityList(oCreature, ABILITY_INVALID, TRUE);
nSizeAbilities = GetArraySize(aCoolingDownAbilities);
for (iAbility = 0; iAbility < nSizeAbilities; iAbility++)
{
nIdAbility = aCoolingDownAbilities[iAbility];
SetCooldown(oCreature, nIdAbility, 0.0);
}
}
// Remove cooldowns on items (health potions, etc.)
// According to tests, it's twice faster to loop on items then on creatures (than the opposite)
aItems = GetItemsInInventory(GetHero(), GET_ITEMS_OPTION_BACKPACK);
nSizeItems = GetArraySize(aItems);
for (iItem = 0; iItem < nSizeItems; iItem++)
{
oItem = aItems[iItem];
nIdAbility = GetItemAbilityId(oItem);
if (nIdAbility != [color="#ff0000"]INVALID_ITEM_ABILITY[/color])
{
for(iCreature = 0; iCreature < nPartySize; iCreature++)
{
oCreature = aParty[iCreature];
SetCooldown(oCreature, nIdAbility, 0.0, GetTag(oItem));
}
}
}
}
Modifié par FanfanVilperdue, 15 avril 2010 - 07:59 .





Retour en haut






