Adding NPCs - SWG-Source/swg-main GitHub Wiki
Adding_npcs
Last edited by Cekis a year ago
Useful Sources of Information
Let's Play SWG - 87 Playthroughs (https://www.youtube.com/playlist?list=PL485CDF01E8993C3A)
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:
- 0 object/tangible/npc/tatooine/lady_valarian.iff 0 865.623 80 1845.21 0.283795 0 0.921845 0