//Script Name: Reward RolePlaying
//
//What it does: Assigns rewards (XP and alignment points) for playing in character.
//
//Notes: The function RewardRolePlay is large enough to deserve its own file. Just #include that file in any script that needs it. Generally, the scripts that //use this file are attached to PC responses in a conversation tree. An example, I include a script that rewards a character for giving an 'evil' response. //Note that not all rewards are beneficial.
//
//p.s. If you are not used to using #include files, they will not usually compile as written (they don't need to). Just save them. They are compiled when the //script that 'includes' them is compiled.

//::///////////////////////////////////////////////
//:: Conversation Reward Functions
//:: aa_conv_rewards
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Assigns various rewards based on conversation
responses. Rewards may include
alignment shifts, XP, gold, items
*/
//:://////////////////////////////////////////////
//:: Created By: Keith Voss (fendis_khan)
//:: Created On: 2 Jul 2002
//:://////////////////////////////////////////////

//PRIVATE FUNCTION DECLARATIONS
// Assigns alignment shift and XP based on PC response
// - returns level of misalignment between alignment and response
// - returns negative value if Reward fails to be awarded
// nResponse: Alignment of response
// nAlignmentAxis: Alignment axis (ALIGNMENT_GOOD or ALIGNMENT_LAWFUL)
// nXPReward: XP reward for answering in character
// nAlignReward: Alignment shift toward that of response
int RewardRolePlay( object oPC, int nResponse, int nAlignmentAxis=ALIGNMENT_GOOD, int nXPReward=20, int nAlignReward=1 );
//::///////////////////////////////////////////////
//:: RewardRolePlay Functions
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Assigns alignment shift and XP based on PC
response. XP given for correct roleplay;
alignment shift given to all
*/
//:://////////////////////////////////////////////
//:: Created By: Keith Voss (fendis_khan)
//:: Created On: 2 Jul 2002
//:://////////////////////////////////////////////
int RewardRolePlay( object oPC, int nResponse, int nAlignmentAxis=ALIGNMENT_GOOD, int nXPReward=20, int nAlignReward=1 )
{
int nAlignmentValue;
int nAlignment;
int nAlignUp;
int nAlignDown;
int nMisAligned = -1; // 0 indicates match, 1 or 2 indicate difference in alignment, -1 invalid call
if ( (!GetIsPC( oPC )) || (nXPReward < 0) || (nAlignReward < 0) )
{
return -1; // signal reward failure
}
if ( (nAlignmentAxis == ALIGNMENT_GOOD) || (nAlignmentAxis == ALIGNMENT_EVIL) )
{
nAlignmentValue = GetGoodEvilValue( oPC );
nAlignment = GetAlignmentGoodEvil( oPC );
nAlignUp = ALIGNMENT_GOOD;
nAlignDown = ALIGNMENT_EVIL;
}
else if ( (nAlignmentAxis == ALIGNMENT_LAWFUL) || (nAlignmentAxis == ALIGNMENT_CHAOTIC) )
{
nAlignmentValue = GetLawChaosValue( oPC );
nAlignment = GetAlignmentLawChaos( oPC );
nAlignUp = ALIGNMENT_LAWFUL;
nAlignDown = ALIGNMENT_CHAOTIC;
}
else return -1; // signal reward failure
// reward PC for answering in character
if ( nAlignment == nResponse )
{
nMisAligned = 0;
GiveXPToCreature( oPC, nXPReward ); // no misalignment
}
else
// no match, neutral cannot differ by more than one alignment
if ( (nAlignment == ALIGNMENT_NEUTRAL) || (nResponse == ALIGNMENT_NEUTRAL) )
{
nMisAligned = 1; // slight misalignment
}
else
{
nMisAligned = 2; // complete misalignment
}
// shift alignment toward that of response
if ( nResponse != ALIGNMENT_NEUTRAL )
{
// if alignment and response opposed, double penalty
AdjustAlignment( oPC, nResponse, nAlignReward*(1+nMisAligned/2) );
}
else
{
if ( nAlignmentValue > 50 ) // high side of neutral
{
AdjustAlignment( oPC, nAlignDown, nAlignReward );
}
else if ( nAlignmentValue < 50 ) // low side of neutral
{
AdjustAlignment( oPC, nAlignUp, nAlignReward );
}
}
return nMisAligned;
}
//::///////////////////////////////////////////////
//:: Reward for Evil dialogue
//:: lr_reward_evil
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Cause PC alignment to shift toward Evil;
and give Evil PC some XP for answering in character
*/
//:://////////////////////////////////////////////
//:: Created By: Keith Voss (fendis_khan)
//:: Created On: 30 Jun 2002
//:://////////////////////////////////////////////
#include "aa_conv_rewards"
void main()
{
int nResponse = ALIGNMENT_EVIL; // alignment of response
int nAlignmentAxis = ALIGNMENT_GOOD; // alignment axis (GOOD/EVIL or LAW/CHAOS)
int nXPReward = 20; // XP reward for answering in character
int nAlignReward = 1; // Alignment shift in direction of response
int nMisAligned = 0; // Assume alignment matches response
object oPC = GetPCSpeaker(); // assign reward to conversation speaker
if ( GetLocalInt( oPC, "lr_reward" ) == FALSE )
{
nMisAligned = RewardRolePlay( oPC, nResponse, nAlignmentAxis, nXPReward, nAlignReward );
if ( nMisAligned >= 0 )
{
// Remember the correlation between PC alignment and response
SetLocalInt( oPC, "lr_reward", TRUE + nMisAligned );
}
else
{
SendMessageToPC( oPC, "Response Reward System Failed" );
}
}
}