Aller au contenu

Photo

Simultaneous Potion Cooldown


  • Veuillez vous connecter pour répondre
10 réponses à ce sujet

#1
Bibdy

Bibdy
  • Members
  • 1 455 messages
I'm trying to modify the script in ability_core_h, to put all health potions on cooldown at the same time (for just the character who uses it), but it doesn't appear to work. The code is below.

                               if (!Ability_IsModalAbility(nAbility) && (!bHasProjectile || (GetAbilityType(nAbility) == ABILITY_TYPE_ITEM)))
            {
              
                //---------------------------------------------------
                // Insert code for character-specific potion cooldown
                //---------------------------------------------------
               
                int[] healthPotion;
                healthPotion[0] = ABILITY_ITEM_LESSER_HEALTH_POULTICE;
                healthPotion[1] = ABILITY_ITEM_HEALTH_POULTICE;
                healthPotion[2] = ABILITY_ITEM_GREATER_HEALTH_POULTICE;
                healthPotion[3] = ABILITY_ITEM_POTENT_HEALTH_POULTICE;

                // checks if used ability is any of the above health potions
                if (GetIntArrayIndex(healthPotion,nAbility) != -1) {
                    int nCount = 0;
                    int nMax = GetArraySize(healthPotion);
                    for (nCount = 0; nCount < nMax; nCount++) {
                        nAbility = healthPotion[nCount];
                        Ability_SetCooldown(oCaster, nAbility, oItem);
                    }
                }         
              

               
                else {
                    Ability_SetCooldown(oCaster, nAbility, oItem); // this is normally the only line
                }       


For some reason its not applying the cooldown to anything but the potion I use.

A friend gave me a script which applies a cooldown of each potion, on each party member simultaneously (i.e. if Alistair uses a Lesser Health Poultice, it puts the LHP on cooldown for Morrigan, Dog and me at the same time), and it works fine. I can't figure out what the significant difference is between the two that would cause it not to work. That code is below

if (!Ability_IsModalAbility(nAbility) && (!bHasProjectile || (GetAbilityType(nAbility) == ABILITY_TYPE_ITEM)))
            {
int[] potions;
                potions[0] = ABILITY_ITEM_LESSER_HEALTH_POULTICE;
                potions[1] = ABILITY_ITEM_HEALTH_POULTICE;
                potions[2] = ABILITY_ITEM_GREATER_HEALTH_POULTICE;
                potions[3] = ABILITY_ITEM_POTENT_HEALTH_POULTICE;
                potions[4] = ABILITY_ITEM_LESSER_LYRIUM_POTION;
                potions[5] = ABILITY_ITEM_LYRIUM_POTION;
                potions[6] = ABILITY_ITEM_GREATER_LYRIUM_POTION;
                potions[7] = ABILITY_ITEM_POTENT_LYRIUM_POTION;

                // checks if used ability is any of the above potions
                if (GetIntArrayIndex(potions,nAbility) != -1) {
                    // get party members
                    object[] oParty = GetPartyList(oCaster);

                    // cycle through party members
                    int nCount = 0;
                    int nMax = GetArraySize(oParty);
                    for (nCount = 0; nCount < nMax; nCount++) {
                        Ability_SetCooldown(oParty[nCount], nAbility, oItem);
                    }
                }
                else {
                    Ability_SetCooldown(oCaster, nAbility, oItem); // this is normally the only line
                }





Is there something limiting being able to apply a cooldown to multiple abilities in the same function call?

Modifié par Bibdy, 12 décembre 2009 - 04:21 .


#2
georage

georage
  • Members
  • 247 messages
change oCaster to GetMainControlled() and give it a twirl




#3
Bibdy

Bibdy
  • Members
  • 1 455 messages
I think the problem is that I should be applying the cooldown to the ITEM, not the ABILITY, so I need to get ahold of the different potions as an object...not quite sure how to do that.

#4
georage

georage
  • Members
  • 247 messages
I don't see that script ... i see ability_core and ability_h



Ability_SetCooldown is applied to creatures, not items (per the function in core_h)



I am not exactly clear on what you want, but, if your friend's script works except for the fact is affects everyone and not just the char being used, then i think changing



Ability_SetCooldown(oParty[nCount], nAbility, oItem);



to



Ability_SetCooldown(GetMainControlled(), nAbility, oItem);



might be worth a try

#5
georage

georage
  • Members
  • 247 messages
actually, you need to get rid of that party loop too, else you are applying the cooldown several times.

after reading through your code it seems you want use of a health potion to prevent use of any other type health potion for a while?

Modifié par georage, 12 décembre 2009 - 05:58 .


#6
Bibdy

Bibdy
  • Members
  • 1 455 messages
My friend got back to me. I was right. Had to add some code to get the item by tag, this being the final code if you're interested



//---------------------------------------------------

// Insert code for character-specific potion cooldown

//---------------------------------------------------



int[] healthPotion;

healthPotion[0] = ABILITY_ITEM_LESSER_HEALTH_POULTICE;

healthPotion[1] = ABILITY_ITEM_HEALTH_POULTICE;

healthPotion[2] = ABILITY_ITEM_GREATER_HEALTH_POULTICE;

healthPotion[3] = ABILITY_ITEM_POTENT_HEALTH_POULTICE;



string[] sItemTagHealth;

sItemTagHealth[0] = "gen_im_qck_health_101";

sItemTagHealth[1] = "gen_im_qck_health_201";

sItemTagHealth[2] = "gen_im_qck_health_301";

sItemTagHealth[3] = "gen_im_qck_health_401";





// checks if used ability is any of the above health potions

if (GetIntArrayIndex(healthPotion,nAbility) != -1) {

int nCount = 0;

int nMax = GetArraySize(healthPotion);

for (nCount = 0; nCount < nMax; nCount++) {

Ability_SetCooldown(oCaster, healthPotion[nCount], GetObjectByTag(sItemTagHealth[nCount]));

}

}



#7
georage

georage
  • Members
  • 247 messages
glad you got it working!

but I still don't think you are applying a cooldown to an item, the item is not a valid object ... it disappears on use.

curious!

Modifié par georage, 12 décembre 2009 - 06:10 .


#8
Bibdy

Bibdy
  • Members
  • 1 455 messages

georage wrote...

actually, you need to get rid of that party loop too, else you are applying the cooldown several times.

after reading through your code it seems you want use of a health potion to prevent use of any other type health potion for a while?


Yeah, that's the basic idea. Put all potions on the same cooldown, but only for the character who used it, so you can still blow a potion on each character at the same time, you just can't chain-chug them on the same guy.

I plan to put this together with a mod that bumps the cooldown of all the potions to about 30-60s, so the higher-grade potions become more important, when a lesser potion might not be sufficient for the entire time all the potions are on cooldown.

#9
georage

georage
  • Members
  • 247 messages
I like that sort of change. I plan to just make potions much more rare and sacred in my mod. The endless chugging of potions really detracts from the healing line of spells.


#10
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
In which event do you do this? I'm guessing EVENT_TYPE_ABILITY_CAST_START?

EDIT: Nevermind, it's in EVENT_TYPE_ABILITY_CAST_IMPACT.

Modifié par FalloutBoy, 12 décembre 2009 - 07:53 .


#11
Bibdy

Bibdy
  • Members
  • 1 455 messages
My code is in "EVENT_TYPE_ABILITY_CAST_IMPACT". I think if you put it in ..._START it might instigate the cooldown even if you get interrupted in the middle of the drinking animation, but I'm not wizard at this, so it would probably still work there.

Oh and the mod's done if you're interested :)

http://social.biowar...m/project/1280/

Modifié par Bibdy, 12 décembre 2009 - 07:54 .