Aller au contenu

Photo

reputation of faction increase/decrease based on chosen conversation


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

#1
Who said that I

Who said that I
  • Members
  • 492 messages

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.


#2
Proleric

Proleric
  • Members
  • 2 354 messages
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".

#3
Who said that I

Who said that I
  • Members
  • 492 messages
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

#4
Who said that I

Who said that I
  • Members
  • 492 messages
But it stays at -1

#5
meaglyn

meaglyn
  • Members
  • 809 messages

try

PCCurrFac = GetFactionAverageReputation(OBJECT_SELF, oPC);

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



#6
Kato -

Kato -
  • Members
  • 392 messages
#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 

  • Who said that I aime ceci

#7
Who said that I

Who said that I
  • Members
  • 492 messages

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?



#8
Kato -

Kato -
  • Members
  • 392 messages

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



#9
Who said that I

Who said that I
  • Members
  • 492 messages

yeah! That sounds about right in the alley that I wanna go in :) 



#10
Kato -

Kato -
  • Members
  • 392 messages
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



#11
Who said that I

Who said that I
  • Members
  • 492 messages
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 



#12
Who said that I

Who said that I
  • Members
  • 492 messages

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. )



#13
Kato -

Kato -
  • Members
  • 392 messages

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



#14
Who said that I

Who said that I
  • Members
  • 492 messages

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! 



#15
Kato -

Kato -
  • Members
  • 392 messages

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



#16
Who said that I

Who said that I
  • Members
  • 492 messages

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

hmmm think I put the variable wrong somehow or it just does not recognize it.....since I gained the required "reputation" as said by the variable but it does not work....

 

given it could be that I made an entirely wrong connection though......

Here is what I put the variable onto: 

 

Alarnian int 10 (as is the tag/name of the faction it is supposed to check)

0door int 10 (as is.....well somewhere I saw in the script)

 

so not sure what I did wrong since it is the first time I used variables like this :S



#17
Kato -

Kato -
  • Members
  • 392 messages

Okay, in the area properties window, advanced tab, variables. In the "Name" textbox, write "req_reputation", without the quotes, then in the type textbox, make sure the type is int, and in the value textbox, put the check value you need(0-100), and there you go. If you need to perform several different faction reputation checks, however, the code will need to be adapted, as I thought you were only checking against guards.

 

EDIT: Make sure you click on "Add" after the variable is set, it will then be displayed in the upper list.

 

 

Kato 



#18
Who said that I

Who said that I
  • Members
  • 492 messages

no not only against guards BUT was planning on having each area required a certain minimum rep level in order for things to unlock so it works great! \\thanks again and sorry for all the hassle XD



#19
Kato -

Kato -
  • Members
  • 392 messages

No problem, I'm glad I could help(if I did).

 

 

Kato



#20
Who said that I

Who said that I
  • Members
  • 492 messages

okay I am not sure what I did wrong here or maybe I have to change something?

 

In any case this is my current issue:

 

The text that should explain to the player what his/her reputation is with the "Dock" Faction and how much reputation the player would need to get through the transition remains the same -1 and ammount needed is 0.

 

now I tried fiddling with it a little buuuut it has not changed, I tried changing the use of variables, no matter nothing seems to work

 

 

so if anyone knows how I can fix it?

 

so It is this section of the script: 

 

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);
}
}



#21
Who said that I

Who said that I
  • Members
  • 492 messages

okay here I have another problem with this script.....and hopefully you are not tired of my rain of questions yet....

 

I figured out how to fix my previous issue but this is the next one:

 

On the ontransition event on the door I have put the tag of the character which it should check, so like this: 

 

void main()
{
object oPC = GetClickingObject();
object oDoor = OBJECT_SELF;
object oFactionMember = GetObjectByTag("docks"); // members of faction DOCKS will recieve this 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);
}
}

 

 

So here is the issue the: 

 

Using the tag on the door makes the rep count on the pc -1 for that faction and it won't go any higher, also it does not seem to recognise the rep count on the door either.

 

So here is the script I use to raise the rep based on quest ending in convo.

 

#include "nw_i0_plotwizard"

void main()
{
    object oItemToTake = GetItemPossessedBy(GetPCSpeaker(), "VillainHead");
    DestroyObject(oItemToTake);
    GiveGoldToCreature(GetPCSpeaker(), 150);
    PWSetMinLocalIntPartyPCSpeaker("p000state_Daisy", 3);
    PWSetMinLocalIntPartyPCSpeaker("p000state", 3);
    PWGiveExperienceParty(GetPCSpeaker(), 250);
    {
   object oPC = GetPCSpeaker();
   object oFacMember = GetObjectByTag("Daisy"); // 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 Dockside");
   SendMessageToPC(oPC, "Your current reputation with Citizens is " + IntToString(PCCurrFac) + ".");
}
 
object oPC = GetPCSpeaker();
 
object oTarget;
oTarget = GetObjectByTag("Door_quest_1");
 
AssignCommand(oTarget, ActionCloseDoor(oTarget));
 
SetLocked(oTarget, TRUE);
 
}
 

 

 
 
well if anyone can help me figure this out? thanks in advance :) 


#22
Who said that I

Who said that I
  • Members
  • 492 messages
Okay got most things to work but here is my next issue with this and I hope someone can help me with this.

I want to try and tie the rep to a group of npc's who give quests (which gives a different faction standing per area)

But the problem I am having is that it is not stacking with each completed quest. I am not able to get the rep up to 200.

so if anyone can help i would really appreciate it.