Author Topic: How to make NPC and some surrounding placeables only appear after a quest?  (Read 330 times)

Legacy_Primalrose

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0


               Something about setting variables I think? Thanks for any help. 
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
How to make NPC and some surrounding placeables only appear after a quest?
« Reply #1 on: October 23, 2011, 02:48:50 pm »


               Sure is.

You'll want to set a variable at the moment the player moves the quest forward - via a conversation through an NPC, picking up an item, killing a creature. Regardless of the method, the variable is always set through a script.

Personally, I like to set quest variables as the quest moves forward. Thus, the first time a quest is handed to the player and depending on the length, the variable is set to 5 or 10. Try to avoid using 1, 2 and 3 settings because if you go back later with an idea to expand a quest, having variable spaces of 5 allow easy modification without having to go and change every other script. Also, I always store these variables on the module itself.

[/quote]
// PLAYER HAS LEARNED OF THE LOCATION OF THE CAVE
SetLocalInt(GetModule(), "lair_q", 10);
[/quote]

So for the sake of an example, now that the player received the location of the cave by finding a note, the "lair_q" variable is now 10. This number represents to me the advancement of the quest and also matches the increments of the journal entry for this particular quest. This way, when I review the journal and I'm looking at entry TEN, I know that the "lair_q" for this entry must also equal TEN but I'm getting off track here.

Let's say that "lair_q" being equal to 10 spawns in some NPCs and surrounding placeables in a town.

OnEnter script of said area:

Quote

void main()
{

object oPC = GetEnteringObject();
object oSpawn;

// GROUP FROM CAVE QUEST

object oItem1 = GetWaypointByTag("SPAWN_BGH_ITEM1");
object oItem2 = GetWaypointByTag("SPAWN_BGH_ITEM2");
object oItem3 = GetWaypointByTag("SPAWN_BGH_ITEM3");
object oItem4 = GetWaypointByTag("SPAWN_BGH_ITEM4");
object oItem5 = GetWaypointByTag("SPAWN_BGH_ITEM5");
object oItem6 = GetWaypointByTag("SPAWN_BGH_ITEM6");
object oItem7 = GetWaypointByTag("SPAWN_BGH_ITEM7");
object oItem8 = GetWaypointByTag("SPAWN_BGH_ITEM8");
object oItem9 = GetWaypointByTag("SPAWN_BGH_ITEM9");
object oItem10 = GetWaypointByTag("SPAWN_BGH_ITEM10");
object oItem11 = GetWaypointByTag("SPAWN_BGH_ITEM11");
object oItem12 = GetWaypointByTag("SPAWN_BGH_ITEM12");

object oWagon1 = GetWaypointByTag("SPAWN_BGH_WAGON1");
object oWagon2 = GetWaypointByTag("SPAWN_BGH_WAGON2");
object oWagon3 = GetWaypointByTag("SPAWN_BGH_WAGON3");

object oTravelNPC1 = GetWaypointByTag("SPAWN_BGH_TRAVELNPC1");
object oTravelNPC2 = GetWaypointByTag("SPAWN_BGH_TRAVELNPC2");

location lTargetItem1 = GetLocation(oItem1);
location lTargetItem2 = GetLocation(oItem2);
location lTargetItem3 = GetLocation(oItem3);
location lTargetItem4 = GetLocation(oItem4);
location lTargetItem5 = GetLocation(oItem5);
location lTargetItem6 = GetLocation(oItem6);
location lTargetItem7 = GetLocation(oItem7);
location lTargetItem8 = GetLocation(oItem8);
location lTargetItem9 = GetLocation(oItem9);
location lTargetItem10 = GetLocation(oItem10);
location lTargetItem11 = GetLocation(oItem11);
location lTargetItem12 = GetLocation(oItem12);

location lTargetWagon1 = GetLocation(oWagon1);
location lTargetWagon2 = GetLocation(oWagon2);
location lTargetWagon3 = GetLocation(oWagon3);

location lTargetNPC1 = GetLocation(oTravelNPC1);
location lTargetNPC2 = GetLocation(oTravelNPC2);

// FAIL SAFE - MAKE SURE IT'S THE PLAYER!
if (!GetIsPC(oPC)) return;

// DOES LAIR_Q==10? IF SO, SPAWN REQUIRED GOODS
if (GetLocalInt(GetModule(), "lair_q") == 10)
{

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "200a_wagon1", lTargetWagon1);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "200a_wagon2", lTargetWagon2);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "200a_wagon3", lTargetWagon3);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "awningredstri", lTargetItem1);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "awningredstri", lTargetItem2);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "awningbluestr", lTargetItem3);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "awningbluestr", lTargetItem4);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "displaycase3", lTargetItem5);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "armorstand2", lTargetItem6);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "armorstand1", lTargetItem7);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_throwrug", lTargetItem8);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_throwrug", lTargetItem9);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "medium_crate047", lTargetItem10);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_barrel002", lTargetItem11);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "armoire001", lTargetItem12);

oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "travel_npc1", lTargetNPC1); // LAIR_Q NPC1
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "travel_npc2", lTargetNPC2); // LAIR_Q NPC2

// SETS LAIR_Q=100 SO ITEMS DO NOT RESPAWN AND NPCS CAN RESPOND IN KIND
// TO ARRIVAL OF THE PLAYER

// QUEST COMPLETED, UPDATE VARIABLE TO COMPLETED STATUS
SetLocalInt(GetModule(), "lair_q", 100);
// UPDATE JOURNAL TO LET PLAYER KNOW ITEMS/NPCS HAVE ARRIVED
AddJournalQuestEntry("lair_q", 100, oPC, TRUE, TRUE, TRUE);

}
}



You may not want to spawn these on the OnEnter script, which is fine. You can also do this when the player completes the quest in another location, spawning everything in well before the player even reaches the destination.

This should give you a general idea though.

FP!
               
               

               


                     Modifié par Fester Pot, 23 octobre 2011 - 01:56 .
                     
                  


            

Legacy_Vivienne L

  • Full Member
  • ***
  • Posts: 130
  • Karma: +0/-0


               Great! @Fester Pot!  You've really explained things here!