Jump to content

Question

3 answers to this question

Recommended Posts

  • 0
Posted
BUILDIN_FUNC(mobcount)
{
	const char *mapname,*event;
	int16 m;
	mapname=script_getstr(st,2);
	event=script_getstr(st,3);

	if( strcmp(event, "all") == 0 )
		event = NULL;
	else
		check_event(st, event);

	if( strcmp(mapname, "this") == 0 ) {
		struct map_session_data *sd;
		if( script_rid2sd(sd) )
			m = sd->bl.m;
		else {
			script_pushint(st,-1);
			return SCRIPT_CMD_SUCCESS;
		}
	}
	else if( (m = map_mapname2mapid(mapname)) < 0 ) {
		script_pushint(st,-1);
		return SCRIPT_CMD_SUCCESS;
	}

	script_pushint(st,map_foreachinmap(buildin_mobcount_sub, m, BL_MOB, event));
	return SCRIPT_CMD_SUCCESS;
}

what codes do i need to replace so that the mobcount script will read the mob_id instead of event label?

  • 0
Posted

what you need is rewrite the 

static int buildin_mobcount_sub(struct block_list *bl,va_list ap)

into

static int buildin_mobcount_by_id_sub(struct block_list *bl,va_list ap)	// Added by RoVeRT
{
	unsigned int id = va_arg(ap,unsigned int);
	struct mob_data *md = ((struct mob_data *)bl);
	if (md->status.hp > 0 && md->status.class_ == id)
		return 1;
	return SCRIPT_CMD_SUCCESS;
}
script_pushint(st,map_foreachinmap(buildin_mobcount_by_id_sub, id));

 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...