117 lines
5.6 KiB
Plaintext
117 lines
5.6 KiB
Plaintext
// Script created by Crashed
|
|
|
|
// Used as a series of 11 spawnpoints to simulate 10 outposts and 1 master spawn
|
|
|
|
// This script allows a particular custom monster to "respawn" every so often
|
|
// in a static place. X seconds after the monster is killed, it will reappear
|
|
// at its "spawn point."
|
|
// HOW TO USE:
|
|
// Step 1 - Install the script into your module by copying and pasting this
|
|
// code into a new script. Save the script as "staticspawn" -- it should
|
|
// compile with no errors.
|
|
//
|
|
// STEP 2 (IMPORTANT) - In any area where you wish to use this script, you
|
|
// must have a static object on the map with the tag "spawnmaster". I prefer
|
|
// a barrel or a crate in a place where the players can never get, but it
|
|
// can be any object, as long as that object has an action queue. NOTE:
|
|
// If/when the spawnmaster is destroyed, monsters will stop spawning. You
|
|
// can use this to create e.g. an altar the PCs must destroy to stop the
|
|
// flow of monsters, if you wish.
|
|
//
|
|
// Step 3 - For every monster type you want to be able to spawn using this
|
|
// script, you must create a monster BLUEPRINT representing that monster.
|
|
// That blueprint must have its OnDeath event set to "staticspawn" (the name
|
|
// of this script)
|
|
// Example:
|
|
// Suppose I wanted to have an Orc-infested area where orcs respawn every
|
|
// 30 seconds or so after they are killed. I would create a new blueprint
|
|
// using Creature Wizard, picking the appropriate stats for my orcs. I
|
|
// would call this blueprint, for example, "respawning_orc".
|
|
//
|
|
// Step 4 - For every position within your area where you want a monster to
|
|
// spawn you must create a waypoint using the Waypoint type on the palette.
|
|
// The Tag of this waypoint can be anything you wish, but it must be unique.
|
|
// I call mine 'spawnpoint1', 'spawnpoint2', and so forth. The Name of this
|
|
// waypoint must be very specially formatted. The first three characters
|
|
// of the name must be a number representing the spawn time, e.g. how many
|
|
// seconds should pass after one monster dies before another one appears. The
|
|
// fourth character must be an underscore ('_'). The rest of the string is the
|
|
// name of the BLUEPRINT of the monsters which are to be spawned here, in other
|
|
// words, the blueprint you made in step 3.
|
|
// Example:
|
|
// I made a monster blueprint "respawning_orc" in step 3, and I now want
|
|
// a spawn point that would spawn an orc every 5 seconds. I would create
|
|
// a waypoint with the tag "spawnpoint1" and name "005_respawning_orc"
|
|
//
|
|
// Step 5 - For every spawn point within your area, you must create an "initial
|
|
// creature" for that spawn point. The initial creature should belong to the
|
|
// blueprint that you created in step 3, and it should be placed very close to
|
|
// the spawn point. The initial creature must be assigned a tag of a certain
|
|
// format. The first three characters of the tag should be "ms_" and the rest
|
|
// of the tag should be the TAG of the waypoint you created in step 4.
|
|
// Example:
|
|
// For my example, I would paint a "respawning_orc" monster on top of
|
|
// the "spawnpoint1" waypoint that I created. I would then open Creature
|
|
// Properties for the monster I just created on the map and set the tag to
|
|
// "ms_spawnpoint1".
|
|
//
|
|
// Step 6 - Just kidding, there is no Step 6. You're done. Save your module
|
|
// and you should have a respawning monster.
|
|
// Declarations
|
|
// StaticSpawn - Summon the monster with the given tag at the given spot.
|
|
// Set the local variable ms_info to the given value
|
|
void StaticSpawn(string szClass, location lWhere, string info);
|
|
// The main event handler.
|
|
void main()
|
|
{
|
|
// VARIABLES
|
|
// The Spawnmaster object
|
|
object oSpawnMaster4;
|
|
// The tag for this monster
|
|
string szMonsterTag = GetTag(OBJECT_SELF);
|
|
int nLength = 0;
|
|
string szSpawnPointTag = "";
|
|
string szSpawnPointInfo;
|
|
string szMonsterClass;
|
|
object oSpawnPoint;
|
|
float fSpawnTime;
|
|
location lSpawnPoint;
|
|
// Check to see if we are an "ms_" monster
|
|
if( GetSubString(szMonsterTag, 0, 3) == "ms_" ) {
|
|
nLength = GetStringLength(szMonsterTag);
|
|
// Get the Spawn Point for this monster
|
|
szSpawnPointTag = GetSubString(szMonsterTag, 3, (nLength - 3));
|
|
} else {
|
|
// Check to see if we have an ms_info local variable
|
|
szSpawnPointTag = GetLocalString(OBJECT_SELF, "ms_info");
|
|
}
|
|
// If this creature has a spawn point...
|
|
if(szSpawnPointTag != "") {
|
|
// ActionSpeakString("I was a MSMonster with SpawnPointTag " + szSpawnPointTag, TALKVOLUME_SHOUT);
|
|
// Get the waypoint and info
|
|
oSpawnPoint = GetWaypointByTag(szSpawnPointTag);
|
|
szSpawnPointInfo = GetName(oSpawnPoint);
|
|
// ActionSpeakString("SpawnpointInfo is "+szSpawnPointInfo, TALKVOLUME_SHOUT);
|
|
nLength = GetStringLength(szSpawnPointInfo);
|
|
// Spawn time is the first 3 characters
|
|
fSpawnTime = StringToFloat( GetSubString(szSpawnPointInfo, 0, 3) + ".0" );
|
|
// Monster class to spawn is the 4th char onward
|
|
szMonsterClass = GetSubString(szSpawnPointInfo, 4, (nLength - 4));
|
|
// Location to spawn is the loc. of the spawnpoint...
|
|
lSpawnPoint = GetLocation(oSpawnPoint);
|
|
// Get the spawn master
|
|
oSpawnMaster4 = GetObjectByTag("spawnmaster4");
|
|
// Dispatch the command to the spawn master.
|
|
AssignCommand(
|
|
oSpawnMaster4,
|
|
DelayCommand(fSpawnTime, StaticSpawn(szMonsterClass, lSpawnPoint, szSpawnPointTag))
|
|
);
|
|
}
|
|
}
|
|
// SummonMonster
|
|
// Conjure a monster with the given class at the given point.
|
|
void StaticSpawn(string szClass, location lWhere, string info) {
|
|
object oNewMonster = CreateObject(OBJECT_TYPE_CREATURE, szClass, lWhere);
|
|
SetLocalString(oNewMonster, "ms_info", info);
|
|
}
|