Hercules
Hercules copied to clipboard
Add *duplicate/remove npc script command
Pull Request Prelude
- [x] I have followed proper Hercules code styling.
- [x] I have read and understood the contribution guidelines before making this PR.
- [x] I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.
Changes Proposed
-
npc_duplicate(....)
duplicate any existing npc. -
npc_duplicate_remove(...)
will remove any existing NPC other than itself.
Recently kRO seem like added an item that will create a Treasure Chest NPC nearby player to retrieve item.
-
click on the item
-
create a npc, talk to it, select to consume 1 key or 10 keys.
-
obtain item
Anyway, its a useful script command. Original src : https://github.com/dastgirp/HPM-Plugins/blob/master/src/plugins/npc-duplicate.c
Issues addressed: none
Known Issue: https://github.com/dastgirp/HPM-Plugins/issues/40 Not sure if this issue still persists, cant seem to duplicate this issue for now.
Are those treasure chest seen by all players or players who used the item?
Are those treasure chest seen by all players or players who used the item?
No idea, I am curious too but I didnt found any info regarding this.
@dastgirp @Emistry it's visible to the player only, gravity uses the flag OPTION_CLOAK
and sends it to everyone but the player.
I have no idea how to do the OPTION_CLOAK
trick, maybe I shalll leave it to any of you who familiar to do it in future or push any new commit to this branch.
UPDATE:
seem like can be done using this ancient script command classchange(...)
.
Example:
when create the NPC, give a default sprite ID FAKE_NPC
, then trigger this script command
classchange(4_TREASURE_BOX, 0, getcharid(0));
it will change the sprite into 4_TREASURE_BOX
and only shown for attached player.
Hence, we don't need a new script command for it, nor do any adjustment to current PR since this is already implemented.
@Asheraf
ci still show overflow error
@4144
is there any advise for me to do it? the validation for npc name length has been done prior to this.
append targetname
with \0
?
@4144 is there any advise for me to do it? the validation for npc name length has been done prior to this. append
targetname
with\0
?
look like compiler see issue in this code script.c:13085:3: note: length computed here 13085 | strncat(targetname, dup_hidden_name, strlen(dup_hidden_name)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
try change char targetname[NAME_LENGTH] = "";
into char targetname[NAME_LENGTH * 2 + 2] = "";
and here it should probably works without warnings
also change strlen(dup_hidden_name)
into NAME_LENGTH
@Emistry If you agree I'd take over this task...
@Emistry If you agree I'd take over this task...
101% agree + support