| Author |
Sticky: Post
Working Scripts Here |
| Aeristoch
|
Posted: Sunday, 28 July 03:03PM |
With the help of Kalen27 I was able to
come up with this faction script and I thought I would share it in case
there were some other people out there wanting to use factions. Feel
free to expand upon it and tweak it to your leisure, let me know of any
changes you've made, especially if it optimizes it or combines the 3
major factions into one script. I tried to do this but it just seemed to
get confused and only deducted from the first faction in the script,
Commoners.
What it is: Faction Script
What it does: Adjusts factions based on the faction type you specify. If
you want it to change faction with Merchants, specify Merchants as
OBJECT_SELF and change Commoner to the tag of the source member of your
Commoner faction. I do this by creating a seperate area called "-
Faction" and place NPC's with names that represent my faction names.
How to use it: It should be fairly well commented so that you can easily
figure it out on your own.
NWScript: #include "nw_i0_generic"
void main()
{
object oKiller = GetLastKiller();
object oCommoner = OBJECT_SELF;
object oDefender = GetObjectByTag("Defender");
object oMerchant = GetObjectByTag("Merchant");
int nCommonerRating = GetFactionAverageReputation(oCommoner, oKiller);
int nDefenderRating = GetFactionAverageReputation(oDefender, oKiller);
int nMerchantRating = GetFactionAverageReputation(oMerchant, oKiller);
int nPos1 = 1;
int nPos2 = 2;
int nPos3 = 3;
int nPos4 = 4;
int nPos5 = 5;
int nShift = 1;
string sPos1 = IntToString(nPos1);
string sPos2 = IntToString(nPos2);
string sPos3 = IntToString(nPos3);
string sPos4 = IntToString(nPos4);
string sPos5 = IntToString(nPos5);
string sLose1 = "lost "+ sPos1 +" point(s)";
string sLose2 = "lost "+ sPos2 +" point(s)";
string sLose3 = "lost "+ sPos3 +" point(s)";
string sLose4 = "lost "+ sPos4 +" point(s)";
string sLose5 = "lost "+ sPos5 +" point(s)";
string sAdd1 = "gained "+ sPos1 +" point(s)";
string sAdd2 = "gained "+ sPos2 +" point(s)";
string sAdd3 = "gained "+ sPos3 +" point(s)";
string sAdd4 = "gained "+ sPos4 +" point(s)";
string sAdd5 = "gained "+ sPos5 +" point(s)";
string sCommonerRating = "Your current standing with the Villagers is " + IntToString(nCommonerRating) + ".";
string sDefenderRating = "Your current standing with the Guards is "+ IntToString(nDefenderRating) +".";
string sMerchantRating = "Your current standing with the Merchants is "+ IntToString(nMerchantRating) +".";
int nAlignEvil = ALIGNMENT_EVIL;
int nAlignGood = ALIGNMENT_GOOD;
int nAlignLaw = ALIGNMENT_LAWFUL;
int nAlignChaos = ALIGNMENT_CHAOTIC;
int nAlignNeutral = ALIGNMENT_NEUTRAL;
int nLC = GetAlignmentLawChaos(oKiller);
int nGE = GetAlignmentGoodEvil(oKiller);
AdjustReputation(oKiller, oCommoner, -5);
SendMessageToPC(oKiller, "You have "+ sLose5 +" with the Villagers.");
SendMessageToPC(oKiller, sCommonerRating);
AdjustReputation(oKiller, oDefender, -1);
SendMessageToPC(oKiller, "You have "+ sLose1 +" with the Realm Guards.");
SendMessageToPC(oKiller, sDefenderRating);
AdjustReputation(oKiller, oMerchant, -1);
SendMessageToPC(oKiller, "You have "+ sLose1 +" with the Mercantile Collective.");
SendMessageToPC(oKiller, sMerchantRating);
if(nLC == ALIGNMENT_LAWFUL || ALIGNMENT_CHAOTIC)
{
AdjustAlignment(oKiller, nAlignChaos, nShift);
}
else
if(nGE == ALIGNMENT_GOOD || ALIGNMENT_EVIL)
{
AdjustAlignment(oKiller, nAlignEvil, nShift);
}
else
if(nLC == ALIGNMENT_NEUTRAL && nGE == ALIGNMENT_NEUTRAL)
{
AdjustAlignment(oKiller, nAlignChaos, nShift);
AdjustAlignment(oKiller, nAlignEvil, nShift);
}
{
if(GetSpawnInCondition(NW_FLAG_DEATH_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1007));
}
}
}
Aeristoch
|
|