Hercules icon indicating copy to clipboard operation
Hercules copied to clipboard

Add *duplicate/remove npc script command

Open Emistry opened this issue 5 years ago • 12 comments

Pull Request Prelude

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.

  1. click on the item consume item

  2. create a npc, talk to it, select to consume 1 key or 10 keys. create npc

  3. obtain item 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.

Emistry avatar May 14 '19 17:05 Emistry

This change is Reviewable

HerculesWSAPI avatar May 14 '19 17:05 HerculesWSAPI

Are those treasure chest seen by all players or players who used the item?

dastgirp avatar May 14 '19 22:05 dastgirp

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.

Emistry avatar May 15 '19 02:05 Emistry

@dastgirp @Emistry it's visible to the player only, gravity uses the flag OPTION_CLOAK and sends it to everyone but the player.

Asheraf avatar May 15 '19 03:05 Asheraf

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.

Emistry avatar May 16 '19 14:05 Emistry

@Asheraf

dastgirp avatar Oct 05 '19 17:10 dastgirp

ci still show overflow error

4144 avatar Jul 26 '20 02:07 4144

@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 ?

Emistry avatar Aug 24 '20 07:08 Emistry

@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

4144 avatar Aug 24 '20 07:08 4144

also change strlen(dup_hidden_name) into NAME_LENGTH

4144 avatar Aug 24 '20 07:08 4144

@Emistry If you agree I'd take over this task...

Kenpachi2k13 avatar Nov 14 '20 09:11 Kenpachi2k13

@Emistry If you agree I'd take over this task...

101% agree + support

AnnieRuru avatar Nov 14 '20 09:11 AnnieRuru