Player Owned NPCs - P3pp3rF1y/AncientWarfare2 GitHub Wiki

Ancient Warfare Player Owned NPCs

All NPCs are spawned from spawning items, which can be crafted in Survival in the Engineering Table with the proper Research. Use JEI/NEI for the recipes. By default, the NPCs home position is the same block that it was spawned on. It will always return to this point during night time, or when it comes under attack.

NPCs fall into three major categories: Worker, Combat, and Utility. Worker NPCs are meant to be used on the Machines, and fall into configurable roles: Farmer, Lumberjack, Miner, Craftsman, and Researcher. Combat NPCs are meant to be used for defense and offense, and also split into configurable roles: Soldier, Archer, Commander, Medic, Siege Engineer, and Engineer. Utility NPCs fulfill various other jobs, and split into Courier, Trader, Priest, and Bard.

All NPCs have a Interaction GUI accessible by right clicking on the NPC. In this GUI, the NPCs have main hand, off-hand, armor, and order slots, all of which can be customized by the Player. The GUI also includes a name entry, and a skin entry, which allow you to customize the name and skin of the NPC. The other buttons in the GUI are for utility and logistical purposes. “Toggle Follow”, which causes the NPC to follow the Player, which can also be accomplished by sneak-right clicking on the NPC. “Set Home” which sets the NPCs home point to wherever it is standing. “Clear Home” which completely removes the NPC’s home point. “Repack”, which allows you to return the NPC back to its spawning item with any customization saved, and then can be placed back down wherever the player likes. And finally, “Creative GUI”, which as the name implies, is only accessible by a player when in creative, and contains advanced options.

Upkeep Mechanics

All Player-Owned NPCs require upkeep in the form of food. If they are not fed, they will cease doing their duties; workers and utility NPCs will wander about, and Combat NPCs will only attack in self-defense. They will also cease to automatically heal as long as they are hungry. If they have an assigned upkeep point, they will wait near that point until fed. The specific food values withdrawn at every upkeep period is configurable through the Upkeep Orders item. If no Upkeep Orders are equipped, the NPC will attempt to withdraw enough food for five minutes (real-time). The specific food value granted by an item and which items are considered food are completely configurable through the “AncientWarfareNpcFood.cfg” configuration file. NPCs without an Upkeep Orders item equipped will attempt to withdraw their upkeep from the nearest available Town Hall block. A player may also manually specify the upkeep location for an NPC by using the Command Baton, but this does not allow for setting how much food will be withdrawn at every upkeep cycle.

Upkeep Orders

To use a Upkeep Order, press the “z” key with the Upkeep Order in your hand while looking at the inventory block you want to have the NPC to draw from. You can only select one inventory per Upkeep Order. Once you have the inventory the NPC should draw from selected, right click to open the order. The GUI that opens will display that point, what it is, where it is, and a side-specific inventory option (for chests, this does not matter). Next to these options will be an entry for the minimum amount of time between food pickups in minutes. Place the Upkeep order in the Upkeep Order slot of an NPC to have it begin to follow that order.

Townhall

The Town Hall block functions as an auto-assignable upkeep point for its owner’s NPCs. NPCs in range will automatically select the closest Town Hall as their upkeep point if no Upkeep Orders are present. This will also override an upkeep point assigned by command baton. The Town Hall has a modest sized inventory for storing food for NPC upkeep.

The Town Hall additionally serves as a death tracker for any NPCs that died within its range. Players may view this list by pressing the ‘Death List’ button in the Town Hall GUI. The list may be cleared out manually by pressing the ‘Clear List’ button in the death list GUI. Priests use this death list to track potential resurrection targets, so do not clear the list if you want to resurrect any of the NPCs on it.

Command Baton

The Command Baton gives a player the means to issue orders to owned or same-team NPCs. Each Command Baton stores its own list of NPC targets; multiple Batons may be used for ‘command groups’. The Command Baton also functions as a sword, doing damage equivalent to a same-material sword. The list of commanded NPCs is displayed in the upper-left of the screen. The current target is displayed in the upper-right of the screen. To add or remove an NPC from the list of commanded NPCs, right click while targeting that NPC. Orders are issued with the currently highlighted block or entity as the target. Orders are issued to the entire list of commanded NPCs for that Baton. To issue an order press the “Z” key. To cycle between commands, hold sneak and scroll the mouse wheel, the commands will pop up and the last one to show up is the selected Command. The available commands are as follows:

  • Clear Command will clear the current command.
  • Attack/Move-Attack will have the NPC target the selected Entity, or move to the target position while attacking any sighted enemies.
  • Move/Guard/Mount will have the NPCs move to target position, or follow/guard the target Entity, or Mount target Horse
  • Set Home will set the selected block to be the NPC’s home point.
  • Clear Home will clear the NPC home point.
  • Set Upkeep will set the selected block to be the NPC’s upkeep point, this would have no proper effect if the selected block is not an inventory block with food.
  • Clear Upkeep will clear the NPC’s upkeep point.

Worker NPC

The Worker NPC is the generic survival spawned NPC. Without any equipped tools, the NPC does not have any role or job. They must be given a tool to give them a job and the ability to work at the appropriate Machines. The only thing this NPC does is eat your food, so make sure to give them a job as soon as possible.

For all Workers, the material quality of the equipment will contribute to the worker’s effectiveness and work output. A workers level will also contribute to his effectiveness at his current task. Workers will automatically return to their home point at night or whenever it is raining. If a Worker NPC spots a hostile entity they will broadcast an alert and begin moving towards the nearest Town Hall/home point while attempting to evade the enemy. If no Town Hall is present, or home point set, they will continue working like normal. Other nearby NPCs may respond to this broadcast in different manners – other nearby Workers and Utility NPCs will begin to flee as well, while nearby Combat NPCs may move to attack the enemy.

Work Orders

NPC Workers will automatically seek the nearest active worksite that has work to begin working at. If no worksites have work to be done, they will begin to wander around. Automatic selection of worksite can be overridden by placing a properly configured ‘Work Order’ item in the workers ‘Orders’ slot. To use a Work Order, press the “z” key with the work order in your hand while looking at the machine you want to have the NPC work on. You can do this for multiple machines. Once you have the machine(s) the NPC should work at selected, right click to open the order. The GUI that opens will have a list of the points, what it is, where it is, a plus sign to raise it in the list, a minus sign to lower it in the list, and a remove button. Next to these options will be an entry for the minimum amount of time you want the worker to work at that point in seconds. For most cases, this can actually be left to zero, which will tell the NPC to spend as much time as it needs to work at that point. Above the whole list is two buttons, the top one is options for what the NPC should do at each point in the list, the bottom one determines if the NPC is the day shift or the night shift.

Farmer

The Farmer works at the Crop Farm, Fruit Farm, Animal Farm, and Fish Farm Machines. The Worker NPC requires a hoe of any material level placed in the main hand to become a Farmer. You should see the skin of the Worker change to the Farmer skin, and if this change does not occur, then the Worker is not a Farmer. Offhand, armor slots, and order slots can be set up however you like.

Lumberjack

The Lumberjack works at the Tree Farm Machine. The Worker NPC requires an axe of any material level placed in the main hand to become a Lumberjack. You should see the skin of the Worker change to the Lumberjack skin, and if this change does not occur, then the Worker is not a Lumberjack. Offhand, armor slots, and order slots can be set up however you like.

Miner

The Miner works at the Quarry Machine. The Worker NPC requires a pickaxe of any material level placed in the main hand to become a Miner. You should see the skin of the Worker change to the Miner skin, and if this change does not occur, then the Worker is not a Miner. Offhand, armor slots, and order slots can be set up however you like.

Craftsman

The Craftsman works at the Autocrafting Table and the Warehouse Machines, as well as the Hand-Cranked Generator and any Survival Structure Builder. The Worker NPC requires a hammer of any material level placed in the main hand to become a Craftsman. You should see the skin of the Worker change to the Craftsman skin, and if this change does not occur, then the Worker is not a Craftsman. Offhand, armor slots, and order slots can be set up however you like.

Researcher

The Researcher works at Research Stations, to enable continual research progress without player interaction. Required equipment is a Quill, of any material level, in the main-hand slot. Offhand and armor may be configured as desired. Under default configs, the Researcher serves no real purpose, since researches do not require large amounts of power, and the player can easily supply it quickly. However, config options exist to make the researches’ power consumption greater, thus making the Researcher worthwhile.

Combat NPC

The Combat NPCs, like Workers, do not have a job when first spawned, and must be given one. You must equip them properly for whatever their intended job will be. Damage output is determined by NPC level and the material level of the items equipped. Like workers, Combat NPCs track experience and level per-role. If a Combat NPC spots a hostile entity they will broadcast an alert and begin moving towards attack distance from that enemy. Other nearby NPCs may respond to this broadcast in different manners –nearby Workers and Utility NPCs will begin to flee, while other nearby Combat NPCs may move to attack the enemy. If a Combat NPC has a home point set he will attempt to stay within a set distance of this home point even when pursuing enemies. If he strays too far, he will abandon his current task/target and begin moving back within a set distance from his home point. Combat NPCs may be assigned patrol routes by equipping them with a properly setup Combat Orders item in their Orders slot.

Combat Orders

Combat Orders function the same as Work Orders when picking points, simply hold the order in your hand, and press the “z” key. Open the Order by right-clicking, which will display a GUI similar to the Work Order. However, the Combat Order simply states the coordinates of the points, and a plus sign for moving up points, a minus sign for moving down points, and an x for removing the points. Place the Combat Order in the Orders slot in a Combat NPC, and it will begin to patrol these points. A single point order can be used to have the NPC guard that point.

Soldier

Equipping a Combat NPC with a Sword of any material level will turn him into a Soldier. The Combat NPC’s skin will change to the Soldier’s Skin, and if this does not happen, then the Combat NPC is not a Soldier. His damage output is determined by the material level of the sword equipped. Offhand, armor slots, and order slots can be set up however you like. Placing another sword in the Soldier’s offhand will allow the Soldier to dual wield, and the offhand sword will do half as much damage as a sword in the main hand.

Archer

Equipping a Combat NPC with a Bow will turn him into an Archer. The Combat NPC’s skin will change to the Archer’s Skin, and if this does not happen, then the Combat NPC is not an Archer. In the Archer NPC’s menu is a checkbox marked “Stand Ground”, which can be used to prevent the Archer from moving closer to their target when engaging with one. His range is the same as a vanilla Skeleton Mob. Offhand, armor slots, and order slots can be set up however you like.

Commander

Equipping a Combat NPC with a Command Baton of any material level will turn him into a Commander. The Combat NPC’s skin will change to the Commander’s Skin, and if this does not happen, then the Combat NPC is not a Commander. His damage output is determined by the material level of the Baton equipped. The Commander provides boosts in damage and armor to nearby same team NPCs. Offhand, armor slots, and order slots can be set up however you like. Placing another Baton in the Commander’s offhand will allow the Commander to dual wield, and the offhand baton will do half as much damage as a baton in the main hand.

Medic

Equipping a Combat NPC with an Axe of any material level will turn him into a Medic. The Combat NPC’s skin will change to the Medic’s Skin, and if this does not happen, then the Combat NPC is not a Medic. His damage output is determined by the material level of the Axe equipped. The Medic attempts to heal Players and nearby same team NPCs. Offhand, armor slots, and order slots can be set up however you like.

Siege Engineer

The Siege Engineer is spawned from its own type of spawner item, which can be crafted in the Engineering Station. The Siege Engineer will automatically pilot nearby Siege Vehicles. It does not need anything in its main hand to perform its function. Offhand, armor slots, and order slots can be set up however you like.

Utility NPCs

Each of the Utility NPCs have their own individual spawning item, all of which can be crafted at the Engineering Station with the proper research. The role of these individual NPCs cannot be changed, but some still require certain items in their mainhand to function correctly.

Courier

The Courier provides an automated means of transferring items between inventories. The Courier must be equipped with a Backpack in his main-hand for inventory space. Offhand, armor slots, and order slots can be set up however you like. The type of Backpack determines how much room the Courier has for storing items. Items that the Courier is moving are stored in the backpack; you may remove it at any time and view or manipulate the contents. A Courier must also be equipped with a Routing Order in his orders slot. The Routing Order specifies what blocks the Courier will be transferring items to and from, and what items he will be moving at each stop. Please see the Routings Orders section for more details regarding the Routing Order setup and functioning.

Routing Orders

The Routing Order is used by Courier NPCs to denote the route they will travel, and what items should be transferred at each stop. Similarly to the Work Order and the Combat Order, adding points to the Routing Order is done by holding the Order in your hand, and pressing the “z” key while looking at the inventory you want to access. For Machines, recall that their inventories are side specific, and it is very important to be looking at the right side for the inventory you wish to access when adding points to the Order. Right-click the Routing Order to adjust the inventory side, items to be transferred, or to change the route-point ordering. To change the target side, open the Routing Orders GUI and click the button labeled with the current side (it will say on of: North, South, East, West, Up, or Down). The selected side will scroll through the side-list with each press of the button. Each point on the route is allowed a single type of item-transfer. The same block/inventory may be specified multiple times for more complex interactions. Add items to the filter bar by simply placing them as if it was a slot in a chest, you can specify numbers larger than a stack by continuing to click on the same slot. To decrease amounts, left click with the item in your hand. Different stack sizes increase and reduce appropriately. To change the route-type, press the button labeled with the current transfer type. The types of item transfers available are:

  • Fill Upto: The Courier will try and Fill the target inventory To these amounts. Courier will not deposit anything if the inventory already has these stack sizes, or more.
  • Take Upto: The Courier will try and Take these amounts From the target inventory. Courier will not take anything if they are already carrying the specified amounts, or more in their inventory.
  • Put Any: The Courier will try to Put Any matches in the filter bar To the target inventory. Stack Sizes are ignored, the Courier will fill until the inventory is full, or the Courier no longer holds those items.
  • Take Any: The Courier will try to Take Any matches in the filter bar From the target inventory. Stack Sizes are ignored, the courier will take all matches until its backpack is full, or the inventory no longer has any.
  • Put Except: The Courier will try and Put All items EXCEPT the matches in the filter bar To the target inventory. Stack Sizes are ignored, the courier will fill target with the non-matches until it is full or the Courier no longer has any.
  • Take Except: The Courier will try to Take All items EXCEPT the matches in the filter bar From the target inventory. Stack Sizes are ignored, the courier will take all non-matches until its backpack is full or the inventory no longer has any.
  • Put Ratio: The Courier will try to Put a specified ratio of items in To the target inventory. Item stack size in the filter bar determines the ratio, where a stack size of 2 is half, 3 is a third, etc.
  • Take Ratio: The Courier will try and Take a specified ratio From the target inventory. Item stack size in the filter bar determines the ratio, where a stack size of 2 is half, 3 is a third, etc.
  • Put Exact: The Courier will try to Put the EXACT amount specified in the filter bar To the target inventory. If the Courier does not have EXACTLY the correct amount, or it does not COMPLETELY fit in the destination, it will not transfer.
  • Take Exact: The Courier will try to Take the EXACT amount specified in the filter bar from the target inventory. If the inventory does not have EXACTLY the correct amount, or the Courier cannot COMPLETELY hold it, it will not transfer.
  • Fill Minimum: The Courier will try and Fill a minimum of the amount specified in the filter bar To the target inventory. This is the same as “Fill Upto” but it will only transfer items if the target will result in having AT LEAST this amount.
  • Take Minimum: The Courier will try to Take an minimum of the amount in the filter bar From the target inventory. This is the same as “Take Upto” but it will only transfer items if it results in the Courier having AT LEAST this amount.

Trader

The Trader is a player-configurable mobile bartering station. The trader must be equipped with a Backpack in his main-hand for item storage. Any items to be traded, and proceeds from trades, are stored in this backpack. A Trader must also be equipped with a Trade Orders item in his Orders slot. Through this you may assign him a withdraw and deposit point for his traded goods, assign the specific trades he will have available, the route he should take for trading, and how long he should linger at each stop on his route. The Trader will seek shelter at night or in the rain, he will seek shelter at the nearest waypoint specified in his trade orders item. If a Trader is not equipped with a trade orders item he will fall back to default AI regarding upkeep and night/rain. As an owner of the NPC, right-clicking the Trader will open its usual GUI, so, to see the trades of a trader as another player would see it, use the “Adv. Options” button.

Trade Orders

The Trade Order is used by the Trader NPC to determine its route, its trades, and its restock options. Similarly to previous orders, adding points to the route of the Trade Order can be done by holding the Order in your hand, and clicking the “z” key. Adding points to the Deposit/Withdraw list in the Restock can be done using the “x” key and the “c” key, respectively. To set these points up correctly, right click to open the GUI. Along the top of this GUI are three tabs, Trade, Route, and Restock.

To start in the Trade tab, click on the “Add New Trade”, and now two 3x3 grids will pop up, with an arrow point from the left one to the right one, and next to these, there are up, delete, and down buttons, which can manipulate the place of the trade in the order or remove it. To set up the trade, place what you want to sell in the right grid, and what should be traded for it in the left one.

Moving on to the Route tab, here you can see all the points added by the “z” key, and the same up, delete, and down buttons to manipulate the order. Next to these buttons is a upkeep checkbox and a Delay time entry box. The upkeep checkbox tells the Trader to go get its upkeep after it finishes at that point, and perform any Restock options it might have set up. This should be used for the first or last order in the list, since the Trader will then repeat its route again. The Delay entry box is the amount of seconds the Trader should spend waiting at this point in the route. Finally the Restock tab, where the points for the withdrawal of the items for the trade, and the deposit of the goods gained through this trade, are stored. There can only be one point for each of these options, and the side specific withdrawal, if necessary, can be manipulated here. To add a item to either option, click on either the Add Deposit/Withdraw Entry button, and put an item in the filter slot that appears. Next to this slot is the type of transfer you want to occur, and next to this is the delete button to remove that item filter. To add more items, simply add more entries.

Priest

The Priest NPC is used to resurrect other NPCs that have died. In order to be eligible for resurrection, the slain NPC must have died within range of a Town Hall. Resurrected NPCs return unequipped – their equipment was dropped when they were slain, and must be manually retrieved and/or replaced.

Bard

The Bard is a ‘flavor’ NPC – he has no real use aside from playing music. The music to be played, play frequency, and volume may all be configured from his advanced controls GUI. These controls may be accessed by pressing the ‘Advanced Controls’ button in his inventory/interaction GUI. To add a new song to the bards’ play-list, click on the ‘Add Tune’ button. A blank entry will be created at the bottom of the list for you to fill in. Input the length of the song (in minutes, decimal format) into the length box. Any sound loaded and registered in Minecraft may be played through the bard; you may need to consult external documentation to locate the registered name and play-length of the sound. A bard may be configured to only begin playing when a player first enters his range. Check the ‘Play on Player Entry’ checkbox at the top of the GUI to enable this feature. Once enabled he will only play a single song when the first player comes within his range; he will not play again when a second player enters range unless the first had already left –and- the song was over. The bard will continue to play songs until there are no more players within range. Song play-order may be randomized by checking the ‘Random’ checkbox at the top of the GUI. The min and max delay settings at the top of the GUI determine the random pause that will occur between playing of each song. This setting is given in game-ticks (20 ticks per second).

NPC Experience, Leveling, and Miscellaneous

All NPC types maintain experience and level stats. Player-Owned NPC types track level and experience separately per available role. Higher levels result in higher damage and work output and higher maximum health. Experience is gained by doing whatever action is appropriate for the NPC; workers gain experience by working, soldiers gain experience by attacking and killing enemies, and utility NPCs gain experience by performing their specific roles. NPC levels are tracked independently per role; changing role will result in the NPC using his level for the new role for efficiency calculations, and any experience gained will contribute to his level for that role only. NPC Level is determined by the amount of experience gained. After gaining a set amount of experience (value increases per level) the NPC will gain one level in his current role. NPCs achieve a maximum of ten levels (configurable in configuration file). All NPCs will 'heal' over time on their own, slowly. The time delay between heals is customizable via configuration file.