Author Topic: EffectCharmed() and the calling object  (Read 452 times)

Legacy_burma

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
EffectCharmed() and the calling object
« on: February 11, 2015, 08:17:56 am »


               

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.  '<img'>


 


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.


 



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
EffectCharmed() and the calling object
« Reply #1 on: February 12, 2015, 01:55:04 am »


               

Something like this:


 


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



               
               

               
            

Legacy_burma

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
EffectCharmed() and the calling object
« Reply #2 on: February 12, 2015, 04:45:45 am »


               

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.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
EffectCharmed() and the calling object
« Reply #3 on: February 12, 2015, 06:00:30 am »


               


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.


               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
EffectCharmed() and the calling object
« Reply #4 on: February 12, 2015, 01:25:03 pm »


               

^^


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.



               
               

               
            

Legacy_burma

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
EffectCharmed() and the calling object
« Reply #5 on: February 13, 2015, 07:21:13 am »


               


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!