Jump to content

Scripting help


radovan

Recommended Posts

Hello everyone. I need help with script - I want to place some NPCs after others dead, and I need to put a script into quest stage. Script should wait for 3 days to place them and only when player is far enough from this place (at least 5000). Can anyone help me with this? Thank you for your replies
Link to comment
Share on other sites

So, can I clarify - is this what you want?

 

1. Player kills some NPCs (how many?)

2. Three days later some new NPCs show up in that spot... but only if the player is > 5000 units away.

Link to comment
Share on other sites

For this, you'll need to create two scripts and a quest. For this excercise, I'll call the NPCs that need to be killed the "Old" NPCs and the ones that respawn the "New" NPCs.

 

First, place both the Old and the New NPCs in the game world. Set the New NPCs to "Initially Disabled", make sure they are persistent references and make sure they have editor names. In this example, I've used NewNPC1Ref, NewNPC2Ref for their editor names.

 

Next, create a Quest script (as opposed to an Object or Magic Effect Script) as follows:

 

scriptname NPCRespawnQuestScript

short OldNPCsKilled
short Today
short RespawnDay
short DoOnce

BEGIN GAMEMODE

set Today to GetDayOfWeek 

if ( Today == RespawnDay) && ( DoOnce == 0 )

NewNPC1Ref.enable
NewNPC2Ref.enable
set DoOnce to 1
StopQuest NPCRespawnQuest

endif

END

 

Next, create a quest called NPCRespawnQuest. Make sure you uncheck "Start Game Enabled". Assign NPCRespawnQuestScript to your new quest.

 

Finally, create an Object script as follows and assign it to the base object of each of the Old NPCs.

 

scriptname OldNPCScript

BEGIN ONDEATH

set NPCRespawnQuest.OldNPCsKilled to NPCRespawnQuest.OldNPCsKilled + 1

if ( NPCRespawnQuest.OldNPCsKilled >= 2	)		;Change this to the number of old NPC's that have to die to trigger the respawn.
set NPCRespawnQuest.RespawnDay to GetDayOfWeek + 3
if ( NPCRespawnQuest.RespawnDay > 6 )
	set NPCRespawnQuest.RespawnDay to NPCRespawnQuest.RespawnDay - 7
endif
StartQuest NPCRespawnQuest
endif

END

 

How it works is that every time one of the old NPCs is killed, 1 is added to the variable OldNPCsKilled. Once OldNPCsKilled reaches 2 (or whatever you set it to), it starts the quest script and sets the RespawnDay to 3 days later. Once 3 days have passed, the New NPCs are enabled.

 

Disclaimer: I haven't tested it in-game so it could possibly have a syntax error somewhere.

 

Hope that helps!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...