Basically, I would set a variable for completed quests using GetModule() first, or any other choices the player made I found worth keeping along from one module to the next.
At the end of the module, I wrote a script to check the values of those variables stored using GetModule() and if they were a number I expected, such as a quest being completed, or what companion the player decided to bring along with them, I then stored that variable into the Campaign Database.
At the start of the next module, I use a script to read the Campaign Database and pull in all related information and restore it using GetModule(), so the values are carried over into the continuing module.
Almraiven snip at the very end of the module.
void main()
{
// Store selection player made on how they leave the city of Almraiven
SetCampaignInt("Almraiven", "fpfom", 1); // Arrive via Forest of Mir
SetCampaignInt("Almraiven", "syrttaway", 0); // Arrive via the Blood Runner
SetCampaignInt("Almraiven", "misttaway", 0); // Arrive via The Mist
// Player completed Almraiven
SetCampaignInt("Almraiven", "almraiven", 1);
// Important actions player did, including killing important NPCs and quest completion
// Player let Ullip die instead of saving NPC
if (GetLocalInt(GetModule(), "ulipkilled") == 1)
{
SetCampaignInt("Almraiven", "ulipkilled", 1);
}
// Player had Falis Goodmane as a companion but he turned on the player and player killed NPC
if (GetLocalInt(GetModule(), "faliskilled") == 1)
{
SetCampaignInt("Almraiven", "faliskilled", 1);
}
// Player killed Lilly Lynn
if (GetLocalInt(GetModule(), "lillykilled") == 1)
{
SetCampaignInt("Almraiven", "lillykilled", 1);
}
// Player saved three ghosts on Horseshoe Lane and returned them to the Land of the Dead
if (GetLocalInt(GetModule(), "demonqdone") == 1)
{
SetCampaignInt("Almraiven", "demonqdone", 1);
}
// Player released a member of The Hidden back to the Land of the Dead
if (GetLocalInt(GetModule(), "murderquest") == 100)
{
SetCampaignInt("Almraiven", "arbasaved", 1);
}
// Player killed Chelles on Cutback Kat Alley
if (GetLocalInt(GetModule(), "chelleskilled") == 1)
{
SetCampaignInt("Almraiven", "chelleskilled", 1);
}
// Player was ambushed on Horseshoe Lane and killed thief guild members
if (GetLocalInt(GetModule(), "hlambushkilled") == 1)
{
SetCampaignInt("Almraiven", "hlambushkilled", 1);
}
// Player murdered Lady Tolas in her sleep
if (GetLocalInt(GetModule(), "tolaskilled") == 1)
{
SetCampaignInt("Almraiven", "tolaskilled", 1);
}
// Player returned Magnus Magicus spirit back to the Land of the Dead?
if (GetLocalInt(GetModule(), "magnuskilled") == 1)
{
SetCampaignInt("Almraiven", "magnuskilled", 1);
}
// Was the Auren contact Luanu killed by rival mage guilds?
if (GetLocalInt(GetModule(), "luanukilled") == 1)
{
SetCampaignInt("Almraiven", "luanukilled", 1);
}
// Did player kill the Werefolk Captain in the sewers?
if (GetLocalInt(GetModule(), "wereratkilled") == 1)
{
SetCampaignInt("Almraiven", "wereratkilled", 1);
}
// Who did player pick for their laboratory assistant?
if (GetLocalInt(GetModule(), "assist1") == 100)
{
SetCampaignInt("Almraiven", "assist1", 100);
SetCampaignInt("Almraiven", "assist2", 0);
SetCampaignInt("Almraiven", "assist3", 0);
}
if (GetLocalInt(GetModule(), "assist2") == 100)
{
SetCampaignInt("Almraiven", "assist2", 100);
SetCampaignInt("Almraiven", "assist1", 0);
SetCampaignInt("Almraiven", "assist3", 0);
}
if (GetLocalInt(GetModule(), "assist3") == 100)
{
SetCampaignInt("Almraiven", "assist1", 0);
SetCampaignInt("Almraiven", "assist2", 0);
SetCampaignInt("Almraiven", "assist3", 100);
}
// What companion did the player decide on bringing along to next module?
if (GetLocalInt(GetFirstPC(), "annexcomp") == 1)
{
SetCampaignInt("Almraiven", "annexcomp", 1);
SetCampaignInt("Almraiven", "faliscomp", 0);
SetCampaignInt("Almraiven", "shaylacomp", 0);
}
if (GetLocalInt(GetFirstPC(), "faliscomp") == 1)
{
SetCampaignInt("Almraiven", "faliscomp", 1);
SetCampaignInt("Almraiven", "annexcomp", 0);
SetCampaignInt("Almraiven", "shaylacomp", 0);
}
if (GetLocalInt(GetFirstPC(), "shaylacomp") == 1)
{
SetCampaignInt("Almraiven", "shaylacomp", 1);
SetCampaignInt("Almraiven", "faliscomp", 0);
SetCampaignInt("Almraiven", "annexcomp", 0);
}
}
At the start of Shadewood, I read the database values and if they matched, were pulled in and the module events setup for the player, as well as fixed anything noteable.
#include "nw_i0_plot"
void main()
{
// SETTING UP PLAYER FOR FOREST OF MIR
object oTarget = GetWaypointByTag("START_CITYGATE");
location lTarget = GetLocation(oTarget);
object oTarget1 = GetWaypointByTag("START_CITYHARBOR");
location lTarget1 = GetLocation(oTarget1);
object oTarget2 = GetWaypointByTag("START_CITYMIST");
location lTarget2 = GetLocation(oTarget2);
object oTarget3 = GetWaypointByTag("NO_DATABASE");
location lTarget3 = GetLocation(oTarget3);
// CLEANING UP SHADEWOOD DATABASE FILE VARIABLES
SetCampaignInt("Almraiven", "annexgekilled", 0); // ANNEX KILLED AS SPIRIT IN ATTIC
SetCampaignInt("Almraiven", "annexgkilled", 0); // ANNEX KILLED AS SPIRIT
SetCampaignInt("Almraiven", "falisgekilled", 0); // FALIS KILLED AS SPIRIT IN ATTIC
SetCampaignInt("Almraiven", "falisgkilled", 0); // FALIS KILLED AS SPIRIT
SetCampaignInt("Almraiven", "shaygekilled", 0); // SHAY KILLED AS SPIRIT IN ATTIC
SetCampaignInt("Almraiven", "shaykilled", 0); // SHAY KILLED AS SPIRIT
SetCampaignInt("Almraiven", "veslhdone", 0); // VELSHAROON QUEST COMPLETED
SetCampaignInt("Almraiven", "faltainkilled", 0); // FALTAIN KILLED IN SWAMP
SetCampaignInt("Almraiven", "mythalkilled", 0); // MET SPIRIT IN MYTH UNNOHYR
SetCampaignInt("Almraiven", "shadewood", 0); // COMPLETED MODULE
SetCampaignInt("Almraiven", "katkilled", 0); // KAT KILLED (TYNER'S SISTER)
SetCampaignInt("Almraiven", "atalikilled", 0); // KAT & TYNER'S FATHER
SetCampaignInt("Almraiven", "colirkilled", 0); // COLIR LOOMSTALK KILLED
SetCampaignInt("Almraiven", "slingkilled", 0); // MARABA SLINGTOSS KILLED
SetCampaignInt("Almraiven", "zoekilled", 0); // ZOETIA KILLED
SetCampaignInt("Almraiven", "razormkilled", 0); // RAZORMAUL KILLED
SetCampaignInt("Almraiven", "tynerkilled", 0); // TYNER KILLED (KAT'S BROTHER)
// CLEANING UP SHADEWOOD DATABASE FILE VARIABLES
// CHECK TO SEE IF PLAYER COMPLETED ALMRAIVEN
if (GetCampaignInt("Almraiven", "almraiven") == 0)
{
if (GetAreaFromLocation(lTarget3)==OBJECT_INVALID) return;
oTarget3=GetFirstFactionMember(GetFirstPC(), FALSE);
while (GetIsObjectValid(oTarget3))
{
AssignCommand(oTarget3, ClearAllActions());
AssignCommand(oTarget3, ActionJumpToLocation(lTarget3));
oTarget3=GetNextFactionMember(GetFirstPC(), FALSE);
}
return;
}
// END GAME
//START_VARIABLE FOR MODULE...
SetLocalInt(GetFirstPC(), "gamestart", 1);
// CHECK TO SEE IF PLAYER HAS POTION BOOK WILL NEED IT!
if ( !HasItem( GetFirstPC(), "brewpotions"))
{
// SPAWN AUREN POTION BOOK ON PLAYER INCASE PLAYER SOLD IT
// OR LEFT IT BEHIND IN ALMRAIVEN
CreateItemOnObject("brewpotions", GetFirstPC());
}
// CHECK TO SEE IF PLAYER BROUGHT ARIES JOURNAL
if ( !HasItem( GetFirstPC(), "LeatherBoundBook"))
{
CreateItemOnObject("leatherboundbook", GetFirstPC());
}
// CHECK TO SEE IF PLAYER BROUGHT ARIES LETTER
if ( !HasItem( GetFirstPC(), "ariesnote"))
{
CreateItemOnObject("ariesnote", GetFirstPC());
}
// CHECK TO SEE IF PLAYER HAS SPELL BOOK, IF SO REPLACE IT WITH MODIFIED ONE
// IF THEY DID NOT BRING IT, WE CREATE IT.
if ( HasItem( GetFirstPC(), "Spellbook"))
{
object oItemToTake = GetItemPossessedBy(GetFirstPC(), "Spellbook");
if(GetIsObjectValid(oItemToTake) != 0)
DestroyObject(oItemToTake);
CreateItemOnObject("spellbook002", GetFirstPC());
}
else
{
CreateItemOnObject("spellbook002", GetFirstPC());
}
// CHECK TO SEE IF PLAYER HAS NAMING QUILL BECAUSE THEY WON'T NEED IT
if ( HasItem( GetFirstPC(), "NamingQuill"))
{
object oItemToTake = GetItemPossessedBy(GetFirstPC(), "NamingQuill");
if(GetIsObjectValid(oItemToTake) != 0)
DestroyObject(oItemToTake);
}
// CHECK TO SEE IF PLAYER HAS BAD SORCERERS FRIEND AMULET FROM ALMRAIVEN
// QUICK BUG FIX...
if ( HasItem( GetFirstPC(), "SorcerersFriend"))
{
object oItemToTake = GetItemPossessedBy(GetFirstPC(), "SorcerersFriend");
if(GetIsObjectValid(oItemToTake) != 0)
DestroyObject(oItemToTake);
// NOW LET'S SPAWN THE RIGHT ONE
CreateItemOnObject("sorcerersfrien", GetFirstPC());
}
// CHECK TO SEE IF PLAYER BROUGHT LABORATORY ASSISTANT BONES OR NOT
if ( HasItem( GetFirstPC(), "bonesofawoman"))
{
object oBadBones = GetItemPossessedBy(GetFirstPC(), "bonesofawoman");
DestroyObject(oBadBones);
// GIVE PROPER BONES DUE TO BUG IN ALMRAIVEN THAT WAS NOT RESOLVED!
CreateItemOnObject("bonesofoldman", GetFirstPC());
//FloatingTextStringOnCreature("DEBUG: bonesofoldman", GetFirstPC());
SetLocalInt(GetFirstPC(), "labbones", 1);
}
if ( HasItem( GetFirstPC(), "bonesofoldman"))
{
//FloatingTextStringOnCreature("DEBUG: bonesofoldman", GetFirstPC());
SetLocalInt(GetFirstPC(), "labbones", 1);
}
if ( HasItem( GetFirstPC(), "bonesoflady"))
{
//FloatingTextStringOnCreature("DEBUG: bonesoflady", GetFirstPC());
SetLocalInt(GetFirstPC(), "labbones", 1);
}
// SET UP LABORATORY ASSISTANT
if (GetCampaignInt("Almraiven", "assist1") == 100)
{
SetLocalInt(GetModule(), "assist1", 100);
//FloatingTextStringOnCreature("DEBUG: assist1 = 100", GetFirstPC());
}
if (GetCampaignInt("Almraiven", "assist2") == 100)
{
//FloatingTextStringOnCreature("DEBUG: assist2 = 100", GetFirstPC());
SetLocalInt(GetModule(), "assist2", 100);
}
if (GetCampaignInt("Almraiven", "assist3") == 100)
{
//FloatingTextStringOnCreature("DEBUG: assist3 = 100", GetFirstPC());
SetLocalInt(GetModule(), "assist3", 100);
}
// SO HOW DID THE PLAYER ARRIVE TO THIS MODULE?
// THE MIST...
if (GetCampaignInt("Almraiven", "misttaway") == 1)
{
SetLocalInt(GetModule(), "misttaway", 1);
if (GetAreaFromLocation(lTarget2)==OBJECT_INVALID) return;
oTarget2=GetFirstFactionMember(GetFirstPC(), FALSE);
while (GetIsObjectValid(oTarget2))
{
AssignCommand(oTarget2, ClearAllActions());
AssignCommand(oTarget2, ActionJumpToLocation(lTarget2));
oTarget2=GetNextFactionMember(GetFirstPC(), FALSE);
}
}
// THE BLOOD RUNNER...
if (GetCampaignInt("Almraiven", "syrttaway") == 1)
{
SetLocalInt(GetModule(), "syrttaway", 1);
if (GetAreaFromLocation(lTarget1)==OBJECT_INVALID) return;
oTarget1=GetFirstFactionMember(GetFirstPC(), FALSE);
while (GetIsObjectValid(oTarget1))
{
AssignCommand(oTarget1, ClearAllActions());
AssignCommand(oTarget1, ActionJumpToLocation(lTarget1));
oTarget1=GetNextFactionMember(GetFirstPC(), FALSE);
}
}
// THE WILDERNESS...
if (GetCampaignInt("Almraiven", "fpfom") == 1)
{
SetLocalInt(GetModule(), "fpfom", 1);
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
oTarget=GetFirstFactionMember(GetFirstPC(), FALSE);
while (GetIsObjectValid(oTarget))
{
AssignCommand(oTarget, ClearAllActions());
AssignCommand(oTarget, ActionJumpToLocation(lTarget));
oTarget=GetNextFactionMember(GetFirstPC(), FALSE);
}
}
// END
}
All deaths of companions and NPCs through Almraiven and Shadewood are tracked, since the third module in the series takes place in the Land of the Dead and spirits don't easily forget how they were killed and who it was that killed them.
FP!
Modifié par Fester Pot, 25 juin 2012 - 04:05 .