Hercules icon indicating copy to clipboard operation
Hercules copied to clipboard

[ Offer ] Get GID of playerattached homunculus

Open AcidMarco opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. I've asked myself, how to get GID of playerattached homunculus to manipulate it via scripts directly? Not class (it shows monster ID), not unique ID (it shows 1/2/3/etc), but GID. I cannot get it via 'gethominfo()'. I was using getmapxy & getunits to find and get homunculus GID which is located close to the player within several cells, BUT it would be perfect to get the GID directly.

Describe the solution you'd like To get homunculus GID directly via 'gethominfo()'.

Additional context I've changed src a bit and it works, by adding type 'HOMINFO_GID' as PETINFO has. Might be it would be helpful for some people using Herc and working with homunclus. Can you check it and implement to Herc, or might be don't something?

Add to script.c [ field: static BUILDIN(unitattack) {...} ] :

	switch(type) {
	case HOMINFO_ID:
		script_pushint(st, sd->hd->homunculus.hom_id);
		break;
	case HOMINFO_CLASS:
		script_pushint(st, sd->hd->homunculus.class_);
		break;
	case HOMINFO_NAME:
		script_pushstrcopy(st, sd->hd->homunculus.name);
		break;
	case HOMINFO_INTIMACY:
		script_pushint(st, sd->hd->homunculus.intimacy);
		break;
	case HOMINFO_HUNGRY:
		script_pushint(st, sd->hd->homunculus.hunger);
		break;
	case HOMINFO_RENAME:
		script_pushint(st, sd->hd->homunculus.rename_flag);
		break;
	case HOMINFO_LEVEL:
		script_pushint(st, sd->hd->homunculus.level);
		break;
	case HOMINFO_GID:                        // Hom GID
		script_pushint(st, sd->hd->bl.id);
		break;
	default:
		script_pushint(st, 0);
		break;
	}
  • and add line to 'script->constdb_comment("gethominfo types");' script->set_constant("HOMINFO_GID", HOMINFO_GID, false, false); // Hom GID

Add to script.h [enum script_hominfo_types {...} ] :

enum script_hominfo_types {
	HOMINFO_ID = 0,
	HOMINFO_CLASS,
	HOMINFO_NAME,
	HOMINFO_INTIMACY,
	HOMINFO_HUNGRY,
	HOMINFO_RENAME,
	HOMINFO_LEVEL,
	HOMINFO_GID, // Hom GID
	HOMINFO_MAX
};

AcidMarco avatar May 21 '23 18:05 AcidMarco

I consider this a pretty good solution. Could you submit a PR for it? That way the staff has better visibility and can be merged easily.

csnv avatar Aug 14 '23 20:08 csnv