Jump to content
  • 0

npc_parse_mob map random


misterM

Question


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   1
  • Joined:  01/05/14
  • Last Seen:  

Hello folks I was wanting to add more maps in the parse of mob, I even got it though he does the random only once, I always wanted the monster to appear he does a random of maps.

Here is the code below the modified part, I think it's because the txt file is read only once, could anyone help me how can I make the maps stay random?

static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
{
	int num, class_, i, j, mob_lv = -1, ai = -1, size = -1, w1count;
	short m,x,y,xs = -1, ys = -1;
	char mobname[NAME_LENGTH];
	struct spawn_data mob, *data;
	struct mob_db* db;
	int mp;
	

	memset(&mob, 0, sizeof(struct spawn_data));

	mob.state.boss = !strcmpi(w2,"boss_monster");

	// w1=<map name>,<x>,<y>{,<xs>{,<ys>}}
	// w3=<mob name>{,<mob level>}
	// w4=<mob id>,<amount>{,<delay1>{,<delay2>{,<event>{,<mob size>{,<mob ai>}}}}}
	if( ( w1count = sscanf(w1, "%15[^,],%15[^,],%15[^,],%6hd,%6hd,%6hd,%6hd", mob.parse[0].map, mob.parse[1].map, mob.parse[2].map, &x, &y, &xs, &ys) ) < 3
	||	sscanf(w3, "%23[^,],%11d", mobname, &mob_lv) < 1
	||	sscanf(w4, "%11d,%11d,%11u,%11u,%77[^,],%11d,%11d[^\t\r\n]", &class_, &num, &mob.delay1, &mob.delay2, mob.eventname, &size, &ai) < 2 )
	{
		ShowError("npc_parse_mob: Invalid mob definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
		return strchr(start,'\n');// skip and continue
	}
	if( mapindex_name2id(mob.parse[0].map) == 0 || mapindex_name2id(mob.parse[1].map) == 0 || mapindex_name2id(mob.parse[2].map) == 0)
	{
		ShowError("npc_parse_mob: Unknown map1 '%s', map2 '%s', map3 '%s' in file '%s', line '%d'.\n", mob.parse[0].map, mob.parse[2].map, mob.parse[3].map, filepath, strline(buffer,start-buffer));
		return strchr(start,'\n');// skip and continue
	}
	for(mp = 0; mp < 4; mp++) {
		m =  map_mapname2mapid(mob.parse[mp].map);
		if( m < 0 )//Not loaded on this map-server instance.
			return strchr(start,'\n');// skip and continue
	}
	
	mob.m = (unsigned short)m;
	
	

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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...