Aller au contenu

Photo

Custom/Chaining effects, how?


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

#1
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
I am trying to add several effects on the player after a certain event which are all applied at the same time (reduction in stats, etc) but want only one "Effect Icon" to appear on the player's GUI. The effects should all have the same timer so that when the icon disappears, all the negative stats disappear.

The wiki has this to say about chaining effects:

Packages of effects can be constructed by "linking" them in the scripting language before they're applied. Any effects that are linked together will be given the same unique id when they're applied. If any effect in this group is then removed, either through expiry or scripting, then the entire group will go with them. This is most often used to tie a visual effect to a stat modifier. When the modifier expires the visual effect will disappear.


This leaves me with two unanswered questions:

1) How does one go about changing the different effects before applying them?

2) How would I make sure only one Icon is displayed and in which 2da should I set the icon and description for this effect?


Any answer would be appreciated, thanks in advance. ^_^

#2
Hoagsie

Hoagsie
  • Members
  • 101 messages
I could be talking out of my rear, as I haven't really gotten into the toolset and my only toolset experience is modding for Morrowind and Oblivion, but could you just add a new spell that would do all the effects that you want? You could make it either persistent or have a timer but either way set the manna cost to zero so it doesn't affect the player's reserve or give it a cost if that's what you want.

#3
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Well, that would be a "dirty trick" as far as I know. In DA:O, the effects system is used to apply these kind of changes to a characters stats and I already have them working correctly in other places. The only things I don't understand at the moment are chaining and setting a single Icon with its own description to represent the impact the different effects have.

#4
Challseus

Challseus
  • Members
  • 1 032 messages
Here's an example of some code I have written that already does what you're looking for, more or less:

/**
 * This will apply an array of effects to an object.
 */
void ApplyEffectsOnObject(int nDurationType,
                          effect[] eEffects,
                          object oTarget,
                          float fDuration = 0.0f,
                          object oCreator = OBJECT_SELF,
                          int nAbilityID = 0)
{
    int nSize = GetArraySize(eEffects);
    int index;
    for (index = 0; index < nSize; index++)
        ApplyEffectOnObject(nDurationType, eEffects[index], oTarget, fDuration, oCreator, nAbilityID);
}

//////bunch of other stuff before the part that will interest you

effect[] eEffects;
eEffects[0] = EffectEnchantment(ENCHANTMENT_LIGHTNING);
eEffects[1] = EffectVisualEffect(TEMPEST_ELECTRICITY_VFX);
eEffects[2] = EffectModifyProperty(PROPERTY_ATTRIBUTE_ATTACK_SPEED_MODIFIER, -0.5);
eEffects[3] = EffectModifyMovementSpeed(2.0);
ApplyEffectsOnObject(EFFECT_DURATION_TYPE_TEMPORARY, eEffects, oTarget, 100.0, oTarget, ABILITY_TALENT_FLURRY_ATTACK);

******************************************************************

So, I seem to remember effect linking in NWN1, but I haven't used that here. I just make use of arrays, and create an array of various effects. Then I apply that array of effects to the object.

With regards to making an icon pop up, just make sure you specify the ability id at the end of the ApplyEffectOnObject() function. Then you'll see the icon do it's thing as time winds down, and when it's gone, all the effects will be gone as well.

EDIT - I missed one question you had. The icon, description, etc. would be added to ABI_Base.xls. Assuming you're familiar with editing 2DA's, I would make a M2DA version of ABI_Base.xls, and put your stuff in there.

Modifié par Challseus, 02 décembre 2009 - 04:26 .


#5
Challseus

Challseus
  • Members
  • 1 032 messages
I just read the WIKI page on effects, and have to admit, it's all new to me. I've been creating my own effects/spells/etc. using examples I have seen for the implementations of talents/spells in the core ability scripts. I'm going to do some more research on effect linking to see what it's all about...

#6
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Thanks for that example, that's exactly already the way I do things right now. But I don't believe this is what they mean by "Effect linking" is it?

As for the icon, does that mean, if I set each effect with the same ability, it'll only add the icon once? Anyway, I'll test it out once I get home, thanks for the help.

#7
Challseus

Challseus
  • Members
  • 1 032 messages

Joshua Raven wrote...

Thanks for that example, that's exactly already the way I do things right now. But I don't believe this is what they mean by "Effect linking" is it?
As for the icon, does that mean, if I set each effect with the same ability, it'll only add the icon once? Anyway, I'll test it out once I get home, thanks for the help.


Yeah, Effect Linking definitely sounds diferent. Like I said, I seem to remember it from NWN1, but haven't found any reference to it in any core DA scripts yet. Still searching.

As for the icon, you will definitely only see one appear. I'm not sure how the engine handles Engine_ApplyEffectOnObject internally when it is called multiple times with different effects and the same ability, but the end result is that you'll only see one icon appear for the specified length.

#8
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
I don't have toolset access right now but in NWN there was a specific function for linking effects called EffectLinkEffects. I found no such function or any close incarnation to it documented in the wiki, but you might find something like that if you look at the in-toolset reference.

Modifié par Axe_Murderer, 02 décembre 2009 - 05:47 .


#9
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
I already tried searching for a link or chain reference in the Toolset but have yet to find anything. Could be that the Wiki page refers to something that was discussed internally but was never implemented though...

#10
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
I would not be surprised to learn that they decided to use arrays to implement the linking so if you pass in an array of effects you get one linked effect applied. Would be trivial to test that hypothesis since the text you pointed out earlier says that when linked, they all get the same unique ID number when applied and if you remove one of them, all will go away. However, I am also seeing this bit:

"Packages of effects can be constructed by 'linking' them in the scripting language before they're applied..."

I read this as implying (strongly) there is indeed a separate function you need to use before the application of the effects in order to link them up. Since that's how NWN did it, I expect there is a function somewhere but they've renamed it.

If you can dig into the core files and find where the vulnerability hex spell is implemented, you may see it done for that one since there is a visual effect that accompanies the penalty effect throughout the spell's duration. Of course they might just apply them separately for the same duration. They did that quite often in NWN even though they could have used the linking feature. But any spell or talent with multiple effects would be a good candidate to check out...might stumble across it.

Modifié par Axe_Murderer, 02 décembre 2009 - 06:32 .


#11
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Challseus,



about the icon/description usage. I just can't seem to get the icon and description I set to appear ingame. I added a new line in my ABI_base m2da file (abi_base_np_items):



ID 10181001

label LYRIUM_ADDICTION_LVL1

namestrref 610910881

descstrref 610910882

tooltipstrref 610910882

icon ico_greater_lyrium_potion

etc..



I added the Strings "610910881" and "610910882" with the String Editor, exporter the Talk Table, converted the m2da to .gda (and opened it up in the gda tool due to the high integer bug, which I fixed that way). I compiled my custom script that adds the effect and...



The effect gets added (negative effects are applied, cooldown is started and an "icon" appears on the GUI. However, the icon is completely gray and no tooltip descriptions are given. Somehow the m2da isn't properly reading my new entry but it IS readin the gda file correctly because the gda triggers some custom scripts for items, which fire correctly.



Any idea what could be going on here? Thanks.

#12
Challseus

Challseus
  • Members
  • 1 032 messages

Joshua Raven wrote...

Challseus,

about the icon/description usage. I just can't seem to get the icon and description I set to appear ingame. I added a new line in my ABI_base m2da file (abi_base_np_items):

ID 10181001
label LYRIUM_ADDICTION_LVL1
namestrref 610910881
descstrref 610910882
tooltipstrref 610910882
icon ico_greater_lyrium_potion
etc..

I added the Strings "610910881" and "610910882" with the String Editor, exporter the Talk Table, converted the m2da to .gda (and opened it up in the gda tool due to the high integer bug, which I fixed that way). I compiled my custom script that adds the effect and...

The effect gets added (negative effects are applied, cooldown is started and an "icon" appears on the GUI. However, the icon is completely gray and no tooltip descriptions are given. Somehow the m2da isn't properly reading my new entry but it IS readin the gda file correctly because the gda triggers some custom scripts for items, which fire correctly.

Any idea what could be going on here? Thanks.


First off, I actually haven't gotten any names/descriptions of any custom abilities to show up in game. I know there is something up with the String Editor and the ID's it creates (as you pointed out in your post), but I just haven't gotten around to fixing it. So I don't know much about that.

As for the icon, that is definitely weird. For the record, when creating custom abilities, I have been using existing icons from existing abilities (i.e. Shield Bash), and haven't had any issues... It looks like you are doing the same... Hmm... Perhaps try to just copy an entire line from the original AB_BASE.xls that matches the type of custom ability you have (spell, sustained, whatever). Obviously make sure it's pointing to your custom script that adds the effects, and see if you see the icon pop up. If so, perhaps just work backwards, and change things one at a time to see what the culprit is.

Sorry I don't have a better answer, because honestly, you look like you're doing exactly what you should be.

P.S. Maybe clear out all of your .GDA's, and export them all again?

#13
Challseus

Challseus
  • Members
  • 1 032 messages

Axe_Murderer wrote...

I would not be surprised to learn that they decided to use arrays to implement the linking so if you pass in an array of effects you get one linked effect applied. Would be trivial to test that hypothesis since the text you pointed out earlier says that when linked, they all get the same unique ID number when applied and if you remove one of them, all will go away. However, I am also seeing this bit:


"Packages of effects can be constructed by 'linking' them in the scripting language before they're applied..."

I read this as implying (strongly) there is indeed a separate function you need to use before the application of the effects in order to link them up. Since that's how NWN did it, I expect there is a function somewhere but they've renamed it.

If you can dig into the core files and find where the vulnerability hex spell is implemented, you may see it done for that one since there is a visual effect that accompanies the penalty effect throughout the spell's duration. Of course they might just apply them separately for the same duration. They did that quite often in NWN even though they could have used the linking feature. But any spell or talent with multiple effects would be a good candidate to check out...might stumble across it.


After looking through all the core ability scripts again, I definitely don't see anything with regards to effect linking. For most sustained abilities, they use effect arrays, and apply them with the ability ID. When the sustained ability is deactivated, for the most part, they are removing them all by using the ability ID as the filter.

With some regular single target abilities, they simply apply each effect one after another, like as you say, they did in NWN1.