Aller au contenu

Photo

EffectCharmed() and the calling object


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

#1
burma

burma
  • Members
  • 3 messages

I'm having some problems with a tag-based module script: all the code works except for the charm effect it's supposed to apply.

 

Reading up on EffectCharmed(), I realize that the effect raises the calling object's Personal Reputation with the target by 50 points. In this case, because it's a tag-based script, the calling object is the module, not the player who activated the item whose Unique Power causes the script to fire. So as far as I can tell, any monster 'charmed' by the activation of this item remains hostile to the PC but suddenly has a very high opinion of my module.  :)

 

Obviously, not the effect I was going for.

 

Is there any function, wrapper, or clever workaround that I could use to make this work? Any way to alter what EffectCharmed() thinks is the calling object? (I do need to keep it a tag-based module script.) 

 

If not, is there a way to simulate a charm effect by adjusting personal reputation that doesn't affect the whole faction en masse? 

 

Thanks in advance for any ideas.

 

b.

 



#2
WhiZard

WhiZard
  • Members
  • 1 204 messages

Something like this:

 

AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectCharmed(), oTarget, fTime));



#3
burma

burma
  • Members
  • 3 messages

Thanks. I had tried something similar and it wasn't working. My version was passing in several linked effects, though:

AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, fDuration));

... and that didn't work. Trying it your way, with just EffectCharmed(), worked fine.

 

Not sure why that makes a difference? At any rate, it's working now - thanks!

 

b.



#4
Shadooow

Shadooow
  • Members
  • 4 471 messages

Thanks. I had tried something similar and it wasn't working. My version was passing in several linked effects, though:

AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, fDuration));

... and that didn't work. Trying it your way, with just EffectCharmed(), worked fine.

 

Not sure why that makes a difference? At any rate, it's working now - thanks!

 

b.

 

It makes big difference because creator of the effect is set in the moment of effect declaration. Read Effect Tutorial for more info.



#5
Baaleos

Baaleos
  • Members
  • 1 330 messages

^^

What Shadooow said.

 

If you need to have another creature/object as the creator of an effect, you need to 'delegate' part of your scripted actions to that object.

 

 

Eg:

 

In order to execute a script on player1, to instruct player2 to inflict damage on player 3

 
void DoDamageAgainst(int iAmount, int iType, int iPower, object oTarget)
{
          effect eDamage = EffectDamage(iType,iAmount,iPower);
          ApplyEffectToObject(DURATION_TYPE_INSTANT,eDamage,oTarget);
}
 
void main()
{
 object oPlayer2 = // code to get player 2
 object oPlayer3 = // code to get player 3
 //We ask player 2 to create the damage effect, then apply directly to player 3
 AssignCommand(oPlayer2,DoDamageAgainst(50,DAMAGE_TYPE_FIRE,DAMAGE_POWER_ENERGY,oPlayer3);
 
 
}
 

Note:

In nwnx_funcs for windows - maybe in linux too, you can modify the effect creator without having to assign/delegate actions to other creatures.

Allowing for more linear scripting.



#6
burma

burma
  • Members
  • 3 messages

It makes big difference because creator of the effect is set in the moment of effect declaration. Read Effect Tutorial for more info.

 

Ah, okay. Got it. Thanks!