Author Topic: reputation of faction increase/decrease based on chosen conversation  (Read 561 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0


               

Well, Here I am again with yet another (probably very easy one but still) script issue I am having with a script that I managed to put together using two tutorials on how to add or decrease the reputation points a pc gains by chosing a certain line in the conversation.


 


so any help or adjustments would be grant.


 


so here is the script:


 


#include "nw_i0_generic"

void main()

{

object oPC = GetPCSpeaker();

object oFacMember = GetObjectByTag("Guard");

int PCCurrFac;

    // Lower the faction of the PC to the guards.

    AdjustReputation(GetPCSpeaker(), OBJECT_SELF, 10);

    // Tell the PC that his/her faction has gone up.

    SendMessageToPC(GetPCSpeaker(), "You have gained 10 point of faction with the guards.");

    // Set the value of PCCurrFac to the PCs current faction with the above group.

    PCCurrFac = GetFactionAverageReputation(oFacMember, oPC);

    // Tell the PC his/her current faction with said group.

    SendMessageToPC(GetPCSpeaker(), "Your current faction with the guards is " + IntToString(PCCurrFac) + ".");

 

problem: I think that I am doing something wrong with the message part here, since it was initially designed to let the player know what the score is with the npc's faction.


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #1 on: April 04, 2015, 01:56:39 pm »


               The comment "lower" should read "raise" if the statement below is correct. Otherwise, what is it doing that you don't expect?


Points of no importance:


If you know that OBJECT_SELF is a guard, it might be simpler and safer to set oFacMember equal to OBJECT_SELF at the outset, then use only the former.


Once you've set oPC, it would be simpler to use it, rather than GetPCSpeaker.


In the messages, "reputation" would make more sense than "faction".
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #2 on: April 04, 2015, 02:41:53 pm »


               Okay in the last line there is a message sent to the player that its current reputation is now (number) in total. So basically letting the player know its current reputation ammount of said faction
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #3 on: April 04, 2015, 02:42:22 pm »


               But it stays at -1
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #4 on: April 04, 2015, 03:06:13 pm »


               

try



PCCurrFac = GetFactionAverageReputation(OBJECT_SELF, oPC);

I suspect the oFacMember is invalid.  Maybe the tag is wrong. But this will be safer anyway.



               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #5 on: April 04, 2015, 06:00:09 pm »


               
#include "nw_i0_generic"

void main()

{

   object oPC = GetPCSpeaker();

   object oFacMember = GetObjectByTag("Guard"); // OBJECT_SELF is better if they're the same

   int PCCurrFac = GetFactionAverageReputation(oFacMember, oPC);

   

   AdjustReputation(oPC, oFacMember, 10);  

   SendMessageToPC(oPC, "Your reputation has raised by 10 points with guards.");   

   SendMessageToPC(oPC, "Your current reputation with guards is " + IntToString(PCCurrFac) + ".");

}

 

As Meaglyn mentioned, if PCCurrFac equals -1, double-check the tag of your guard(s), or, if the owner of the convo is a guard, replace GetObjectByTag("Guard") by OBJECT_SELF on the second line(as suggested by Proleric).

 

 

EDIT: Integrated in the code are the improvements suggested by Proleric and Meaglyn, for convenience.

 

 

Kato 


               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #6 on: April 05, 2015, 03:45:37 pm »


               

awesome thanks! Okay here is another question regarding reputation scripts.


 


What I was planning was that when a certain level of reputation was gained, something unlocks and the player can then advance to the next area.


 


so for example: I want that the player must have gained at least 30 points of reputation with the guards before the gate unlocks and the player can then venture through into the city unhindered, as long as its reputation is at least 30 rep points with the guards or higher.


 


is this possible?



               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #7 on: April 05, 2015, 04:07:33 pm »


               


awesome thanks! Okay here is another question regarding reputation scripts.


 


What I was planning was that when a certain level of reputation was gained, something unlocks and the player can then advance to the next area.


 


so for example: I want that the player must have gained at least 30 points of reputation with the guards before the gate unlocks and the player can then venture through into the city unhindered, as long as its reputation is at least 30 rep points with the guards or higher.


 


is this possible?




Sure, you could prevent players from entering a given area, displaying a short explanation at the same time. The solution would be to integrate the check(s) in the nw_g0_transition script, which handles trigger and door transitions. Is it what you're looking for(just to make sure before attacking the job)?


 


 


Kato


               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #8 on: April 05, 2015, 04:24:33 pm »


               

yeah! That sounds about right in the alley that I wanna go in '<img'> 



               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #9 on: April 05, 2015, 06:46:50 pm »


               

void main()
{
   object oPC = GetClickingObject();
   object oDoor = OBJECT_SELF;
   object oFactionMember = GetObjectByTag("Guard"); // assuming "Guard" as the tag
   int nRep = GetFactionAverageReputation(oFactionMember, oPC);
   int nCheck = GetLocalInt(GetArea( <<linked restricted area door>> ), "req_reputation"); // any variable name set on area, holding the check value

   if(GetIsDM(oPC) || nRep >= nCheck) ExecuteScript("nw_g0_transition", oDoor);
   else
   {
      string sWarning = "<cþ  >I'm not allowed to enter, my reputation with guards is only "+
      IntToString(nRep)+" when it should be at least "+IntToString(nCheck)+".</c>"; // red colored warning message example
      FloatingTextStringOnCreature(sWarning, oPC);
   }
}

Put this script in the OnAreaTransitionClick event handler of the chosen door(s). Then, on the linked, restricted area(s), set an integer variable of the same name as the one in code(can be any name, as long as both are similar, obviously), and give it any value(0-100) you need the reputation check to be.


 


 


Kato



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #10 on: April 06, 2015, 06:15:22 pm »


               



void main()
{
   object oPC = GetClickingObject();
   object oDoor = OBJECT_SELF;
   object oFactionMember = GetObjectByTag("Guard"); // assuming "Guard" as the tag
   int nRep = GetFactionAverageReputation(oFactionMember, oPC);
   int nCheck = GetLocalInt(GetArea( <<linked restricted area door>> ), "req_reputation"); // any variable name set on area, holding the check value

   if(GetIsDM(oPC) || nRep >= nCheck) ExecuteScript("nw_g0_transition", oDoor);
   else
   {
      string sWarning = "<cþ  >I'm not allowed to enter, my reputation with guards is only "+
      IntToString(nRep)+" when it should be at least "+IntToString(nCheck)+".</c>"; // red colored warning message example
      FloatingTextStringOnCreature(sWarning, oPC);
   }
}

Put this script in the OnAreaTransitionClick event handler of the chosen door(s). Then, on the linked, restricted area(s), set an integer variable of the same name as the one in code(can be any name, as long as both are similar, obviously), and give it any value(0-100) you need the reputation check to be.


 


 


Kato


 




 


Okay will see about getting it to work XD 



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #11 on: April 07, 2015, 06:04:59 pm »


               

Okay, just for the sake of me being just extremely stupid, do I need to put the variable on the door that it is going to? (probably yes but felt like asking again) 


 


if so then must I also add the variable in the script?? Seeing that it is giving me an error (which is obvious since there is an opening on line7, like here: int nCheck = GetLocalInt(GetArea( <<Town_rep int 30 ), "req_reputation"); // any variable. )



               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #12 on: April 07, 2015, 06:39:26 pm »


               

Okay sorry, I've been busy. Here is the final code, and the variable should be set on the restricted area itself.



void main()
{
   object oPC = GetClickingObject();
   object oDoor = OBJECT_SELF;
   object oFactionMember = GetObjectByTag("Guard"); // assuming "Guard" as the tag
   int nRep = GetFactionAverageReputation(oFactionMember, oPC);
   int nCheck = GetLocalInt(GetArea(GetTransitionTarget(oDoor)), "req_reputation"); // variable set on area, holding the check value

   if(GetIsDM(oPC) || nRep >= nCheck) ExecuteScript("nw_g0_transition", oDoor);
   else
   {
      string sWarning = "<cþ  >I'm not allowed to enter, my reputation with guards is only "+
      IntToString(nRep)+" when it should be at least "+IntToString(nCheck)+".</c>"; // red colored warning message example
      FloatingTextStringOnCreature(sWarning, oPC);
   }
}

Kato



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #13 on: April 07, 2015, 06:42:21 pm »


               


Okay sorry, I've been busy. Here is the final code, and the variable should be set on the restricted area itself.



void main()
{
   object oPC = GetClickingObject();
   object oDoor = OBJECT_SELF;
   object oFactionMember = GetObjectByTag("Guard"); // assuming "Guard" as the tag
   int nRep = GetFactionAverageReputation(oFactionMember, oPC);
   int nCheck = GetLocalInt(GetArea(GetTransitionTarget(oDoor)), "req_reputation"); // variable set on area, holding the check value

   if(GetIsDM(oPC) || nRep >= nCheck) ExecuteScript("nw_g0_transition", oDoor);
   else
   {
      string sWarning = "<cþ  >I'm not allowed to enter, my reputation with guards is only "+
      IntToString(nRep)+" when it should be at least "+IntToString(nCheck)+".</c>"; // red colored warning message example
      FloatingTextStringOnCreature(sWarning, oPC);
   }
}

 just feeling extremely silly since it took me like a few days before I figured out you ould put variables on items and palceables XD


 


anyways dont worry about it, I am keeping myself busy one way or another but thanks a bunch! 




               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
reputation of faction increase/decrease based on chosen conversation
« Reply #14 on: April 07, 2015, 06:53:51 pm »


               

Excellent then, once the variable is set, you can use the script on any door leading to your area(s), and if you need to alter the difficulty check, simply update that variable and all the doors with adjust accordingly.


 


 


Kato