Aller au contenu

Photo

SetCooldown without "sSourceItemTag" parameter?


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

#1
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
This is what the description says for SetCooldown:

Parameters:

oCreature
- owner of the ability

nAbilityId
- ability to set the cooldown

fCooldownTime
- time that the ability should be inactive (in seconds)

sSourceItemTag
- if an item ability, specify the specific item providing the ability. If an
empty string, the engine will grab the first item with this ability, this may
not be the desired intention if the player has several items with the same
ability.


Now, for the below script, I leave the sSourceItemTag empty because it's a dynamic script and there is no way for me to get the itemtag when I only know the ability which is fired, at least not to my knowledge. Seeing as how the abilities are called  "ABILITY_ITEM_LESSER_HEALTH_POULTICE", etc, I was under the assumption that these abilities would only be tied to one item and so the first item is always the correct one.

However, when using the script, nothing happens (if I use floaty messages, they fire correctly, so the script is working correctly). After some testing I found that if I swap last line of code:

SetCooldown(stEvent.oCaster, 200010 + i, 5.0f);

to

SetCooldown(stEvent.oCaster, 200010 + i, 5.0f, "gen_im_qck_health_201");

Now the last part of the script works, although only on the health poultice, not the lesser/greater/potent, which is as expected.

Now my question is, why won't it work without the ItemTags? Is the description wrong in saying that I can leave it empty or are these abilities actually called by some other items and are the cooldowns wrongly applied on those items instead of the healing poultices?


case ABILITY_ITEM_LESSER_HEALTH_POULTICE:
case ABILITY_ITEM_HEALTH_POULTICE:
case ABILITY_ITEM_GREATER_HEALTH_POULTICE:
case ABILITY_ITEM_POTENT_HEALTH_POULTICE:
{
  object [] arTeam = GetPartyList(stEvent.oCaster)
  int nSize = GetArraySize(arTeam);
  int i;
  object oCurrent;
  float fItemCooldown = Ability_GetCooldown(stEvent.oCaster, stEvent.nAbility);

  for(i = 0; i < nSize; i++)
  {
    oCurrent = arTeam[i];
    if(oCurrent != stEvent.oCaster && 
     FloatToInt(GetRemainingCooldown(oCurrent, stEvent.nAbility)) == 0)
    {
      SetCooldown(oCurrent, stEvent.nAbility, fItemCooldown * 0.25);
    }
  }

  for(i = 0; i < 4; i++)
  {
    if(200010 + i != stEvent.nAbility && 
     FloatToInt(GetRemainingCooldown(stEvent.oCaster, 200010 + i)) == 0)
    {
      SetCooldown(stEvent.oCaster, 200010 + i, 5.0f);
    }
  }
}

Modifié par Joshua Raven, 27 novembre 2009 - 06:47 .


#2
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Well, I worked around it by using an array with the item tags. Still, don't quite understand why omitting the tags didn't work.

#3
AND04

AND04
  • Members
  • 154 messages

Joshua Raven wrote...

Well, I worked around it by using an array with the item tags. Still, don't quite understand why omitting the tags didn't work.


for the script - why not just use GetTag(OBJECT_SELF) - should be the item firing the script shouldn't it be?

Modifié par AND04, 27 novembre 2009 - 07:42 .


#4
Nodrak

Nodrak
  • Members
  • 144 messages
What are you trying to do with that code? Give all health pots a cooldown when one is used? For all party members?  AND04's suggestion is your first step if the function is not getting the correct item by itself.  If you are not intending to make this a mod to the OC, there are many ways to can go about what you want.

Modifié par Nodrak, 27 novembre 2009 - 10:55 .


#5
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Yes, I want all potions to get a CD for the current user and give all same-type potions of the other partymembers a CD as well. And yes I want to use it in the OC. Actually, it's already working with the above method, but I reckon it isn't quite as "clean" as you guys could make it :o)

#6
Nodrak

Nodrak
  • Members
  • 144 messages
No, if you want to make it extend the OC, your way is probably best. The way I was thinking would not have the same effect as you want.

#7
Craig Graff

Craig Graff
  • Members
  • 608 messages
stEvent.oItem should return the item being used, meaning that you can directly access the tag from that if you like. That being said, it is generally best to have a one to one relationship between items and abilities, since there seem to be some gui errors that crop up otherwise. (It may also be the case that I don't fully understand how to work around them.)



I believe the item tag is required for item based abilities, but not for abilities which are not item based.