1. Script Name - NPC Brawl
2. What it does:
The inspiration for this script came from this topic:
Switching factions
Click Here
The idea was to take a group of NPC's and based upon an action, have them
take sides and start fighting amongst each other.
3. Notes:
This script will support any number of NPC's (and/or monsters) and any
number of factions. In this script, I have three custom factions (A,B,C) and
also include the Commoner faction. I had the custom factions hostile to each
other, while neutral to everyone else. Out of 16 NPC's, some still remained
part of the commoner faction and so became innocent bystanders.
I also included the option to have rally points. So when the script is
executed, the NPC's will attempt to make it to the rally points before the
actual faction change takes effect. This makes things a bit more
interesting.
I chose to use a die roll so that the brawl could be different each time.
However it wouldn't be difficult to modify this by hardcoding NPC tags and
calling functions.
4. The Script itself
NWScript:
void main()
{
string sNPCTagPrefix = "NPC";
int nMaxFaction = 16;
int nUseRallyPoints = 1;
int nUseTauntAnimation = 1;
float fDelay = 5.0;
object oNPC, oFaction_FlagA, oFaction_FlagB, oFaction_FlagC;
int i, nRoll, nFaction;
string sNPCTag;
if (nUseRallyPoints == 1)
{
oFaction_FlagA = GetObjectByTag("Flag_FactionA",0);
oFaction_FlagB = GetObjectByTag("Flag_FactionB",0);
oFaction_FlagC = GetObjectByTag("Flag_FactionC",0);
}
for (i=1; i < nMaxFaction; i++)
{
if (i < 10) {sNPCTag = sNPCTagPrefix + "00" + IntToString(i);}
else if (i < 100) {sNPCTag = sNPCTagPrefix + "0" + IntToString(i);}
else {sNPCTag = sNPCTagPrefix + IntToString(i);}
oNPC = GetObjectByTag(sNPCTag,0);
nRoll = d4(1);
if (GetIsObjectValid(oNPC))
{
if (nRoll == 1)
{
nFaction = 5;
if (nUseRallyPoints == 1)
{
AssignCommand(oNPC,ActionMoveToObject(oFaction_FlagA,1,1.5));
}
}
else if (nRoll == 2)
{
nFaction = 6;
if (nUseRallyPoints == 1)
{
AssignCommand(oNPC,ActionMoveToObject(oFaction_FlagB,1,1.5));
}
}
else if (nRoll == 3)
{
nFaction = 7;
if (nUseRallyPoints == 1)
{
AssignCommand(oNPC,ActionMoveToObject(oFaction_FlagC,1,1.5));
}
}
else if (nRoll == 4)
{
nFaction = 1;
}
AssignCommand(oNPC,ActionRandomWalk());
if (nUseTauntAnimation == 1 && nFaction != 1 && d2() == 2)
{
AssignCommand(oNPC,DelayCommand(fDelay,ActionPlayAnimation(ANIMATION_FIREFORGET_TAUNT,1.0,0.0)));
}
DelayCommand((fDelay+1.0),ChangeToStandardFaction(oNPC, nFaction));
}
}
}
[ Edited By crashdv: Thursday, 04 July 10:15AM (GMT) ]
|