StellaBellum Adding NPCs - SWG-Source/swg-main GitHub Wiki

Adding NPCs

Useful Sources of Information

Creature Definitions

Creatures are defined and identified by their names in datatables/mob/creatures.tab, with their associated scripts, conversations, and mobile templates, amongst other parameters listed in their row. Adding a creature that is missing entirely starts here, if the mobiletemplate and conversation scripts are already in existence, otherwise you have to create those first.

Static Spawns

Static spawns can be defined/created in several ways. Some are spawned purely using scripts, such as those found in the masterspawner.script files. Otherwise, those that use spawn_tables, or poi_spawner tables, or any of the other datatables in datatables/spawning generally are used in conjunction with theme_park.dungeon.generic_spawner. However, some NPC's can be spawned by directly referencing their object/tangible file as well in which case all objvars and scripts are already referenced making spawning a simple matter of direct reference with X,Y,Z and Quaternion information added.

To add a static spawn, first make sure that the worldsnapshot tab you are editing has all of the cells for it's buildings (if any) properly defined. If not, open the worldsnapshot in treexplorer and manually enter each cell below it's parent container's line.

Once done, attach the theme_park.dungeon.generic_spawner script to the parent object, if spawning in a building, or to a spawn_egg or area_spawner object if spawning in the world (TODO: make sure that bit about world spawns is accurate).

Then, under the objvars column, add the following for the spawn table:

spawn_table|4|relpath/to/table.iff

Make sure that the end of line character is there with separators ( |$| )

** Note: If you are spawning within a structure that registers on the map or map index, you must call a secondary script called "planet_map.map_loc" in order to register the structure with the map. To execute multiple scripts, separate each script with a colon (:) between them. The following is a real-world example taken from the Imperial Military Outpost on Dantooine's Cantina spawn:

1365875	0	object/building/military/military_base_shed_imperial_style_cantina_s01.iff	0	1937	3	1666	1	0	0	0	planet_map.map_loc:theme_park.dungeon.generic_spawner	spawn_table|4|datatables/spawning/building_spawns/dant_imperial_outpost_cantina.iff|planetMap.category|4|cantina|portalLayoutCrc|0|-242217168|healing.canhealshock|0|1|safeLogout|0|1|$|

Areaspawner

Areaspawners can be used outside/inside buildings in the buildout Files to directly load NPCs from the creatures.tab File, for an outside spawn you need to add an object

-objectid	0	object/tangible/ground_spawning/area_spawner.iff px	py	pz	qw	qx	qy	qz systems.spawning.spawner_area	fltMaxSpawnTime|2|1.000000|fltMinSpawnTime|2|0.000000|fltRadius|2|0.000000|intDefaultBehavior|0|1|intGoodLocationSpawner|0|0|intSpawnCount|0|1|intSpawnSystem|0|1|registerWithController|0|1|strName|4|area_spawnerName|strSpawnerType|4|area|strSpawns|4|creatureName|$|

to your .tab File. The Coordinates are relative to the Tile you are working in. Or with Inside Spawns, relative to the Parent cells's Building (see datatable coordinates explained in this wiki).

The Areaspawner name is pure cosmetic, the NPCs that can be spawned can be found directly in the creatures.tab Table.

In my Tests it seemed to make no difference if spawned in various ways, example:

strName|4|tatooine_knives_valarian|strSpawnerType|4|area|strSpawns|4|tatooine/lady_valarian
strName|4|lady_valarian|strSpawnerType|4|area|strSpawns|4|lady_valarian
strName|4|tatooine_knives_valarian|strSpawnerType|4|area|strSpawns|4|lady_valarian

All three spawned the same NPC.

Full Examples:

-1899966199	0	object/tangible/ground_spawning/area_spawner.iff	0	865.623	80	1833.21	0.283795	0	0.921845	0	systems.spawning.spawner_area	fltMaxSpawnTime|2|5.000000|fltMinSpawnTime|2|0.000000|fltRadius|2|0.000000|intDefaultBehavior|0|1|intGoodLocationSpawner|0|0|intSpawnCount|0|1|intSpawnSystem|0|1|registerWithController|0|1|strName|4|clone_relics_darth_vader|strSpawnerType|4|area|strSpawns|4|clone_relics_darth_vader|$|
-1899966200	0	object/tangible/ground_spawning/area_spawner.iff	0	865.623	80	1836.21	0.283795	0	0.921845	0	systems.spawning.spawner_area	fltRespawnTime|2|30.000000|fltRadius|2|0.000000|intDefaultBehavior|0|1|intGoodLocationSpawner|0|0|intSpawnCount|0|1|intSpawnSystem|0|1|registerWithController|0|1|strName|4|clone_relics_han_solo|strSpawnerType|4|area|strSpawns|4|clone_relics_han_solo|$|
-1899966201	0	object/tangible/ground_spawning/area_spawner.iff	0	865.623	80	1842.21	0.283795	0	0.921845	0	systems.spawning.spawner_area	fltRespawnTime|2|45.000000|fltRadius|2|0.000000|intDefaultBehavior|0|1|intGoodLocationSpawner|0|0|intSpawnCount|0|1|intSpawnSystem|0|1|registerWithController|0|1|strName|4|luke_skywalker|strSpawnerType|4|area|strSpawns|4|luke_skywalker|$|
-1899966202	0	object/tangible/ground_spawning/area_spawner.iff	0	865.623	80	1845.21	0.283795	0	0.921845	0	systems.spawning.spawner_area	fltMaxSpawnTime|2|8.000000|fltMinSpawnTime|2|0.000000|fltRadius|2|0.000000|intDefaultBehavior|0|1|intGoodLocationSpawner|0|0|intSpawnCount|0|1|intSpawnSystem|0|1|registerWithController|0|1|strName|4|rtp_leia_organa_summoned|strSpawnerType|4|area|strSpawns|4|rtp_leia_organa_summoned|$|

NOTE: Either fltRespawnTime (how long it takes to spawn and to respawn when initialized or when an NPC dies) or fltMinSpawnTime and fltMaxSpawnTime can be specified to indicate how long between spawns. If fltMinSpawnTime and fltMaxSpawnTime are specified, the spawner gets a random value between the two numbers and sets that as the fltRespawnTime object var.

Spawning NPC's or Objects Directly

NPC's, Creatures and Objects may be spawned directly if you know the template file for that particular NPC, creature or object. This spawning method handles many things auto-magically saving the developer time in creating the spawn, but other aspects such as respawn time or behavior are not added, but may exist in the template file itself (.tpf is the uncompiled version). You may add specific obj vars to an object (such as NPC behavior), but the NPC is not respawned if destroyed.

Another example of spawning directly can be done by calling the NPC's template file directly (if one exists). The folder that contains the template file is located in a different location depending on where the NPC is supposed to be spawned (i.e. what planet). Check this location when spawning NPC's to determine if they are there or not. In most cases they seem to be located in their respective folders:

-<objid>	0	object/tangible/npc/tatooine/lady_valarian.iff	0	865.623	80	1845.21	0.283795	0	0.921845	0		$|

Such spawns can be placed in the buildout files to spawn named or special NPC's. The way to call a spawner is much like the areaspawner above, but the extra object vars are NOT needed as they most likely exist in the template (tpf) file. Below is an example of the lady valarian spawner shown above. Keep in mind not all NPC's have (or need even) spawner scripts:

-<objid>	0	object/tangible/npc/lady_valarian_spawner.iff	0	865.623	80	1845.21	0.283795	0	0.921845	0		$|

Space.content_tools.npc_spawner Script

Adding NPCs/Items with the space.content_tools.npc_spawner scripts begins in the following way, first look into the

datatables/space_content/npc_spawners.tab

for the NPC you want to add and note the OID of the NPC.

Then you have to add an Spawnegg to the buildout File with the OID of the NPC you want to add, for example:

3795724    1076952    object/tangible/space/content_infrastructure/ground_npc_spawner.iff    11    -3.61827    0.00999999    -8.8941    0.11057    0    0.993868    0        $| 

Here 3795724 is the OID of the NPC we want to add(this OID has to exist in npc_spawners.tab), 1076952 is a cell.iff, because the NPC in the example was spawned inside a building. (The cell.iff is a child of a building object)

What if we need to spawn the NPC outside? Just change the child OID of the ground_npc_spawner to 0

3795724    0    object/tangible/space/content_infrastructure/ground_npc_spawner.iff

Interior Spawner Script

The interior spawner script allows you to spawn NPC's in a structure (or cell), but not until the player enters that cell. This allows delayed (only when necessary) spawning of cave NPC's and lessens the load on the server to spawn the creatures. The spawnegg spawns creatures immediately that are in the root location of the datatables/spawning/poi_spawner directory. Please note, subfolders in this location are NOT of the same layout or type as the files in the root location and because of this you cannot mix file formats between the various spawners.

To use the interior spawner script, you must add the compiled template of the interior_spawnegg to your datatable in the following manner with the Object ID of the creature you wish to spawn found in the datatables reference above:

3273733   0    object/tangible/poi/spawnegg/interior_spawnegg.iff

Be sure to add positional (x,y,z) and rotational (qw,qx,qy,qz) data to the spawn egg as well.

NEW

Exterior Spawner Script

The exterior_spawner script behaves much the same way as the interior_spawner script, but the spawner spawns NPC's/Creatures immediately and allows you to spawn creatures in the world if they are referenced in the datatables/spawning/poi_spawner/ root folder (note: subfolders located in the poi_spawner folder are not referenced by the exterior spawner). The benefit to this method is that it allows reading of the same files the interior_spawner script reads (the layout is the same). To create an Exterior Spawn, get the Object ID of the creature/NPC you wish to spawn and add the spawnegg template. The template contains a reference to the spawner script:

3273733   0    object/tangible/poi/spawnegg/exterior_spawnegg.iff

Be sure to add coordinate and quaternion data for the script. No obj vars are needed. Dynamic World Spawns

TODO

Instance Spawns

TODO: may be spawned by the scripts?

⚠️ **GitHub.com Fallback** ⚠️