Exemplo n.º 1
0
/*--------------------------------------
 * Checks if sd in on a instance and should be kicked from it
 *--------------------------------------*/
void instance_check_kick(struct map_session_data *sd)
{
	int m = sd->bl.m;

	clif_instance_leave(sd->fd);
	if( map[m].instance_id )
	{ // User was on the instance map
		if( map[m].save.map )
			pc_setpos(sd, map[m].save.map, map[m].save.x, map[m].save.y, CLR_TELEPORT);
		else
			pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
	}
}
Exemplo n.º 2
0
/// Invoked (from char-server) when a party member leaves the party.
int party_member_withdraw(int party_id, uint32 account_id, uint32 char_id)
{
	struct map_session_data* sd = map_id2sd(account_id);
	struct party_data* p = party_search(party_id);

	if( p ) {
		int i;
		ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id );
		if( i < MAX_PARTY ) {
			clif_party_withdraw(p,sd,account_id,p->party.member[i].name,0x0);
			memset(&p->party.member[i], 0, sizeof(p->party.member[0]));
			memset(&p->data[i], 0, sizeof(p->data[0]));
			p->party.count--;
			party_check_state(p);
		}
	}

	if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id ) {
#ifdef BOUND_ITEMS
		int idxlist[MAX_INVENTORY]; //or malloc to reduce consumtion
		int j,i;

		party_trade_bound_cancel(sd);
		j = pc_bound_chk(sd,BOUND_PARTY,idxlist);

		for(i = 0; i < j; i++)
			pc_delitem(sd,idxlist[i],sd->status.inventory[idxlist[i]].amount,0,1,LOG_TYPE_BOUND_REMOVAL);
#endif

		sd->status.party_id = 0;
		clif_charnameupdate(sd); //Update name display [Skotlex]
		//TODO: hp bars should be cleared too

		if( p->instance_id ) {
			int16 m = sd->bl.m;

			if( map[m].instance_id ) { // User was on the instance map
				if( map[m].save.map )
					pc_setpos(sd, map[m].save.map, map[m].save.x, map[m].save.y, CLR_TELEPORT);
				else
					pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
			}
		}
	}

	return 0;
}
Exemplo n.º 3
0
int bg_team_warp(int bg_id, unsigned short mapindex, short x, short y)
{ // Warps a Team
	int i;
	struct battleground_data *bg = bg_team_search(bg_id);
	if( bg == NULL ) return 0;
	for( i = 0; i < MAX_BG_MEMBERS; i++ )
		if( bg->members[i].sd != NULL ) pc_setpos(bg->members[i].sd, mapindex, x, y, CLR_TELEPORT);
	return 1;
}
Exemplo n.º 4
0
/*--------------------------------------
 * Used on instance deleting process.
 * Warps all players on each instance map to its save points.
 *--------------------------------------*/
int instance_del_load(struct map_session_data* sd, va_list args)
{
	int m = va_arg(args,int);
	if( !sd || sd->bl.m != m )
		return 0;

	pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
	return 1;
}
Exemplo n.º 5
0
int bg_member_respawn(struct map_session_data *sd)
{ // Respawn after killed
	struct battleground_data *bg;
	if( sd == NULL || !pc_isdead(sd) || !sd->bg_id || (bg = bg_team_search(sd->bg_id)) == NULL )
		return 0;
	if( bg->mapindex == 0 )
		return 0; // Respawn not handled by Core
	pc_setpos(sd, bg->mapindex, bg->x, bg->y, CLR_OUTSIGHT);
	status_revive(&sd->bl, 1, 100);

	return 1; // Warped
}
Exemplo n.º 6
0
/*==========================================
 * Warp a user into instance
 *------------------------------------------*/
int instance_enter_position(struct map_session_data *sd, const char *name, short x, short y)
{
	struct instance_data *im;
	struct instance_db *db = instance_searchname_db(name);
	struct party_data *p;
	int m;

	nullpo_retr(-1, sd);

	// Character must be in instance party
	if(sd->status.party_id == 0)
		return 1;

	if((p = party_search(sd->status.party_id)) == NULL)
		return 1;

	// Party must have an instance
	if(p->instance_id == 0)
		return 2;

	if(db == NULL)
		return 3;

	im = &instance_data[p->instance_id];
	if(im->party_id != p->party.party_id)
		return 3;

	if(im->state != INSTANCE_BUSY)
		return 3;

	if(im->type != db->id)
		return 3;

	// Does the instance match?
	if((m = instance_mapname2mapid(StringBuf_Value(db->enter.mapname), p->instance_id)) < 0)
		return 3;

	if(pc_setpos(sd, map_id2index(m), x, y, CLR_OUTSIGHT))
		return 3;

	// If there was an idle timer, let's stop it
	instance_stopidletimer(im);

	// Now we start the instance timer
	instance_startkeeptimer(im, p->instance_id);

	return 0;
}
Exemplo n.º 7
0
int bg_send_xy_timer_sub(DBKey key, void *data, va_list ap)
{
	struct battleground_data *bg = (struct battleground_data *)data;
	struct map_session_data *sd;
	char output[128];
	int i, m;

	nullpo_ret(bg);
	m = map_mapindex2mapid(bg->mapindex);
	bg->reveal_flag = !bg->reveal_flag; // Switch

	for( i = 0; i < MAX_BG_MEMBERS; i++ )
	{
		if( (sd = bg->members[i].sd) == NULL )
			continue;
		if( battle_config.bg_idle_autokick && DIFF_TICK(last_tick, sd->idletime) >= battle_config.bg_idle_autokick && bg->g )
		{
			sprintf(output, "- AFK [%s] Kicked -", sd->status.name);
			clif_broadcast2(&sd->bl, output, (int)strlen(output)+1, bg->color, 0x190, 20, 0, 0, BG);

			bg_team_leave(sd,3);
			clif_displaymessage(sd->fd, "You have been kicked from Battleground because of your AFK status.");
			pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,3);
			continue;
		}

		if( sd->bl.x != bg->members[i].x || sd->bl.y != bg->members[i].y )
		{ // xy update
			bg->members[i].x = sd->bl.x;
			bg->members[i].y = sd->bl.y;
			clif_bg_xy(sd);
		}
		if( bg->reveal_pos && bg->reveal_flag && sd->bl.m == m ) // Reveal each 4 seconds
			map_foreachinmap(bg_reveal_pos,m,BL_PC,sd,1,bg->color);
		if( battle_config.bg_idle_announce && !sd->state.bg_afk && DIFF_TICK(last_tick, sd->idletime) >= battle_config.bg_idle_announce && bg->g )
		{ // Idle announces
			sd->state.bg_afk = 1;
			sprintf(output, "%s : %s seens to be away. AFK Warning - Can be kicked out with @reportafk", bg->g->name, sd->status.name);
			clif_bg_message(bg, bg->bg_id, bg->g->name, output, strlen(output) + 1);
		}
	}
	return 0;
}
Exemplo n.º 8
0
int hom_surf(struct map_session_data *sd, int homid)
{
	int d, ny, nx;
	d = unit_getdir(&sd->bl);
	
	switch(d)
		{
			case 0:			//cima   CELL_CHKNOREACH
			ny = (sd->bl.y) +3;
			if(map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH) && map_getcell(sd->bl.m,sd->bl.x,ny-2,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,ny-1,CELL_CHKWATER) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER) && map_getcell(sd->bl.m,sd->bl.x,ny-2,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,ny-1,CELL_CHKREACH) ||
			map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH) && map_getcell(sd->bl.m,sd->bl.x,ny-2,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,ny,CELL_CHKWATER) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER) && map_getcell(sd->bl.m,sd->bl.x,ny-2,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,ny,CELL_CHKREACH)){

			if(pc_readglobalreg(sd,"surf") == 0){
					pc_disguise(sd, homid);
					pc_setglobalreg(sd, "surf", homid);
					pc_setpos(sd,map[sd->bl.m].index,sd->bl.x,ny,CLR_TELEPORT);
					break;
			}else if(pc_readglobalreg(sd,"surf") > 0){
			pc_setglobalreg(sd, "surf", 0);
			pc_disguise(sd, 0);
			pc_setpos(sd,map[sd->bl.m].index,sd->bl.x,ny,CLR_TELEPORT);
			break;
			}
		
		}else{
		clif_displaymessage(sd->fd, "Você não pode usar Surf neste local.");
		break;
		}
		
		//--------------------------------------------------------------------------------------------
		
			case 2:   //esquerda
			nx = (sd->bl.x) -3;
			if(map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH) && map_getcell(sd->bl.m,nx+2,sd->bl.y,CELL_CHKNOREACH) && map_getcell(sd->bl.m,nx+1,sd->bl.y,CELL_CHKWATER) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER) && map_getcell(sd->bl.m,nx+2,sd->bl.y,CELL_CHKNOREACH) && map_getcell(sd->bl.m,nx+1,sd->bl.y,CELL_CHKREACH) ||
			map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH) && map_getcell(sd->bl.m,nx+2,sd->bl.y,CELL_CHKNOREACH) && map_getcell(sd->bl.m,nx,sd->bl.y,CELL_CHKWATER) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER) && map_getcell(sd->bl.m,nx+2,sd->bl.y,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH)){

			if(pc_readglobalreg(sd,"surf")){
					pc_disguise(sd, homid);
					pc_setglobalreg(sd, "surf", homid);
					pc_setpos(sd,map[sd->bl.m].index,nx,sd->bl.y,CLR_TELEPORT);
					break;
			}else if(pc_readglobalreg(sd,"surf") > 0){
			pc_setglobalreg(sd, "surf", 0);
			pc_disguise(sd, 0);
			pc_setpos(sd,map[sd->bl.m].index,nx,sd->bl.y,CLR_TELEPORT);
			break;
			}
		}else{
		clif_displaymessage(sd->fd, "Você não pode usar Surf neste local.");
		break;
		}
		
		//--------------------------------------------------------------------------------------------
		
			case 4:   //baixo
			ny = (sd->bl.y) -3;
			if(map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH) && map_getcell(sd->bl.m,sd->bl.x,ny+2,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,ny+1,CELL_CHKWATER) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER) && map_getcell(sd->bl.m,sd->bl.x,ny+2,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,ny+1,CELL_CHKREACH) ||
			map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH) && map_getcell(sd->bl.m,sd->bl.x,ny+2,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,ny,CELL_CHKWATER) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER) && map_getcell(sd->bl.m,sd->bl.x,ny+2,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,ny,CELL_CHKREACH)){

			if(pc_readglobalreg(sd,"surf") == 0){
					pc_disguise(sd, homid);
					pc_setglobalreg(sd, "surf", homid);
					pc_setpos(sd,map[sd->bl.m].index,sd->bl.x,ny,CLR_TELEPORT);
					break;
			}else if(pc_readglobalreg(sd,"surf") > 0){
			pc_setglobalreg(sd, "surf", 0);
			pc_disguise(sd, 0);
			pc_setpos(sd,map[sd->bl.m].index,sd->bl.x,ny,CLR_TELEPORT);
			break;
			}
		}else{
		clif_displaymessage(sd->fd, "Você não pode usar Surf neste local.");
		break;
		}		
		
		//--------------------------------------------------------------------------------------------
		
			case 6:  //direita
			nx = (sd->bl.x) +3;
			if(map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH) && map_getcell(sd->bl.m,nx-2,sd->bl.y,CELL_CHKNOREACH) && map_getcell(sd->bl.m,nx-1,sd->bl.y,CELL_CHKWATER) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER) && map_getcell(sd->bl.m,nx-2,sd->bl.y,CELL_CHKNOREACH) && map_getcell(sd->bl.m,nx-1,sd->bl.y,CELL_CHKREACH) ||
			map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH) && map_getcell(sd->bl.m,nx-2,sd->bl.y,CELL_CHKNOREACH) && map_getcell(sd->bl.m,nx,sd->bl.y,CELL_CHKWATER) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER) && map_getcell(sd->bl.m,nx-2,sd->bl.y,CELL_CHKNOREACH) && map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKREACH)){

			if(pc_readglobalreg(sd,"surf") == 0){
					pc_disguise(sd, homid);
					pc_setglobalreg(sd, "surf", homid);
					pc_setpos(sd,map[sd->bl.m].index,nx,sd->bl.y,CLR_TELEPORT);
					break;
			}else if(pc_readglobalreg(sd,"surf") > 0){
			pc_setglobalreg(sd, "surf", 0);
			pc_disguise(sd, 0);
			pc_setpos(sd,map[sd->bl.m].index,nx,sd->bl.y,CLR_TELEPORT);
			break;
			}
		}else{
		clif_displaymessage(sd->fd, "Você não pode usar Surf neste local.");
		break;
		}				
		}
			return 0;
		}