Jump to content
  • 0

Instance NoNPC: treu


Onairda

Question


  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  181
  • Reputation:   9
  • Joined:  12/30/16
  • Last Seen:  

Hello Everyone,

I have created an instance with the setting NoNPC: true. This prevents copying NPCs from the source map.

How can I enable my custom NPC inside the instance? Even though I have set NoNPC, the script I am using (see below) is not enabling the NPC inside the instance.

 

// Instance Controller NPC (Triggers OnInstanceInit)
moc_fild17,37,289,0	script	InstanceSpawner#DD	1001,{
	end;

OnInstanceInit:
	// Broadcast to the instance map
	mapannounce instance_mapname("moc_fild17"), "[System]: The monsters have arrived!", bc_map;

	// Spawn mobs in the instance
	monster instance_mapname("moc_fild17"), 50, 50, "Phreeoni Minion", 1002, 10;
	monster instance_mapname("moc_fild17"), 53, 53, "Phreeoni", 1159, 1;

	// Enable the instance NPC
	enablenpc instance_npcname("PhreeoniHelper#DD");
	end;
}

// Instance-Only NPC (initially hidden)
moc_fild17,42,292,0	script	PhreeoniHelper#DD	100,{

	mes "Hello!";
	mes "Welcome to the Phreeoni Instance.";
	close;

OnInit:
	// Hide globally — needed due to NoNpc: true
	hideonnpc strnpcinfo(0);
	end;
}

Thank you!!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  236
  • Reputation:   105
  • Joined:  06/02/12
  • Last Seen:  

Hello. Using NoNPC: true will block the copying of all NPCs on the map moc_fild17, including custom ones or those with the OnInstanceInit label (e.g., InstanceSpawner#DD).

To enable your custom NPC inside the instance, you must duplicate them manually after the instance is created.

*duplicate "<NPC name>","<map>",<x>,<y>{,"<Duplicate NPC name>"{,<sprite>{,<dir>{,<xs>{,<xy>}}}}};

This command will duplicate the NPC with the given <NPC name> on <map> at <x>/<y>.
If <Duplicate NPC name>, <sprite>, <dir>, <xs> or <ys> is not provided the value of the original NPC will be used.
The Unique name of the new duplicated NPC is returned on success. An empty string is returned on failure.

NOTE:
	Duplicates will always have the same NPC variables as the original NPC.
	Editing a NPC variable in a duplicate or the original NPC will change it for the others.

Example:

	.@md_name$ = "Phreeoni";
	.@id = instance_create(.@md_name$);
	if (.@id < 0) {
		mes "Party Name: "+ getpartyname(.@party_id);
		mes "Party Leader: "+strcharinfo(0);
		mes "^0000ff"+.@md_name$+" ^000000- Reservation Failed!";
		close;
	}

	//NPC to duplicate
	setarray .@npc_name$,"Phreeoni Helper#DD", "InstanceSpawner#DD";

	.@m$ = instance_mapname(instance_info(.@md_name$,IIT_ENTER_MAP), .@id);
	for ( .@i = 0; .@i < getarraysize(.@npc_name$); .@i++ ) {
		if (getmapxy(.@mapname$, .@mapx, .@mapy, BL_NPC, .@npc_name$[.@i]) == 0) {
			if (duplicate(.@npc_name$[.@i], .@m$, .@mapx, .@mapy) == "")
				debugmes "NPC: " + .@npc_name$[.@i] + " not found for duplication.";
		}
	}


// Instance Controller NPC (Triggers OnInstanceInit)
moc_fild17,37,289,0	script	InstanceSpawner#DD	1001,10,10,{
	end;

OnInit:
	// Hide if outside instance — needed due to NoNpc: true
	if (countstr(strnpcinfo(4), "#") == 0)
		disablenpc;
	end;

OnTouch:
	// Do nothing if outside instance — needed due to NoNpc: true
	if (countstr(strnpcinfo(4), "#") == 0)
		end;

	disablenpc; //disable itself so that it triggers only once
	// Broadcast to the instance map
	mapannounce strnpcinfo(4), "[System]: The monsters have arrived!", bc_map;

	// Spawn mobs in the instance
	monster strnpcinfo(4), 75, 265, "Phreeoni Minion", 1002, 10;
	monster strnpcinfo(4), 78, 268, "Phreeoni", 1159, 1;
	
	end;
}

// Instance-Only NPC (initially hidden)
moc_fild17,42,292,0	script	Phreeoni Helper#DD	100,{

	mes "Hello!";
	mes "Welcome to the Phreeoni Instance.";
	close;

OnInit:
	// Hide if not inside instance — needed due to NoNpc: true
	if (countstr(strnpcinfo(4), "#") == 0)
		disablenpc;
	end;
}

 

⚠️ NPCs created using the duplicate command will not trigger OnInstanceInit.
✅ It's recommended to use strnpcinfo(3) instead of instance_npcname, and strnpcinfo(4) instead of instance_mapname.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...