-
Notifications
You must be signed in to change notification settings - Fork 88
NPC Factory
The NPC Factory is a 2x2 tiles structure that is a part of a Settlement. It periodically creates new NPCs that will work in a certain radius around the Factory. The NPCs spawned by the factory are bound to its Settlement, and will generally be hostile to foreign NPCs (This feature has not yet been implemented). Regular NPCs will not go more than 3 worlds away from the Settlement.
Units with a ComPort are able to upload data to the factory so that the next spawned NPC becomes a Hacked NPC. This gives the player the opportunity to control more than one unit.
The Factory starts accepting data sent by the ComPort as soon as it has received the password for this Settlement (See Settlement). Attempts to send messages to the Factory while it is locked will fail (the COMPORT_FRONT_PORT_OUT
command will return 0
). The factory has a buffer of 2048
words, attempts to send data beyond this will fail.
Example:
to_upload:
; This is the code that will be uploaded to the Hacked NPC
mov a, 3
mov b, 0x100
hwi 0x9
brk
password: dw "12345678"
.text
; Send password
mov a, 2 ; COMPORT_FRONT_PORT_OUT
mov x, password
hwi 0x000D ; ComPort
; Send first 8 words of the program
mov a, 2 ; COMPORT_FRONT_PORT_OUT
mov x, to_upload
hwi 0x000D ; ComPort
Currently, the Factory will create a new NPC every NPC_LIFETIME / MAX_NPC_COUNT
ticks.
Lifetime for all types of NPCs is 1024
ticks and the maximum NPC count is 16
. The factory will not create an NPC if all adjacent tiles are blocked.