Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
While populating zones with new NPCs I ran into a few issues, this PR aims to solve them and improve workflow using the
#npcspawn
and#npcedit
commands.This PR adds a new argument to the npcspawn command, "clone", which references an already existing but unused function that copies an NPC including spawngroup, only creating a spawn2 entry.
After making this command I found that
#npcspawn remove
was no longer functioning as intended, as it simply removed the first spawn2 entry it found - not necessarily the targeted NPC's entry. I fixed this and also made an optional parameter to remove spawngroups or not (as using the command on a bunch of cloned NPCs would remove all of them if it also kills the spawngroup).I've also modified
#npcspawn create
to set all of the NPCs stats based on the target NPC. This allows you to for example#dbspawn
an existing NPC you want to work off of as a base, use#npcspawn create
on it, and then work from there.Also included in this PR is a tweak to
#npcedit set_grid
- allowing setting a grid of 0 (clearing the grid) and adding a zone shortname check to the query to ensure only the currently selected npc in the current zone will be edited in the database.Type of change
Testing
I've been using these changes to populate a zone with NPCs and have been crosschecking the database to ensure everything is being added/removed/updated as it should be. I have tested the following:
#npcspawn create
copying stats properly to the new npc_types entry#npcspawn create
properly naming the spawngroup with appended timestamp to avoid duplicate spawngroup entries#npcspawn create/add/clone
#npcspawn clone
properly creating a new spawn2 entry with the same spawngroup as the targeted NPC#npcspawn help
properly printing the help text and returning#npcspawn remove
optional param properly removing the spawngroup of the targeted NPC if set#npcspawn create/add/clone
all use the clients current position/heading instead of the targeted NPCs position for better ease of placing NPC spawns#npcedit set_grid
allowing values of 0 and properly applying it, and the query checking for which zone the NPC is in to avoid unintended row changesClients tested: RoF2
Checklist