Exemple #1
0
//Retrieve and load sc_data for a player. [Skotlex]
int chrif_load_scdata(int fd)
{	
#ifdef ENABLE_SC_SAVING
	struct map_session_data *sd;
	struct status_change_data *data;
	int aid, cid, i, count;

	aid = RFIFOL(fd,4); //Player Account ID
	cid = RFIFOL(fd,8); //Player Char ID
	
	sd = map_id2sd(aid);
	if (!sd)
	{
		ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid);
		return -1;
	}
	if (sd->status.char_id != cid)
	{
		ShowError("chrif_load_scdata: Receiving data for account %d, char id does not matches (%d != %d)!\n", aid, sd->status.char_id, cid);
		return -1;
	}
	count = RFIFOW(fd,12); //sc_count
	for (i = 0; i < count; i++)
	{
		data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
		status_change_start(&sd->bl, data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
	}
#endif
	return 0;
}
Exemple #2
0
//Retrieve and load sc_data for a player. [Skotlex]
int chrif_load_scdata(int fd)
{	
#ifdef ENABLE_SC_SAVING
	struct map_session_data *sd;
	struct status_change_data *data;
	int aid, cid, i, count;

	aid = RFIFOL(fd,4); //Player Account ID
	cid = RFIFOL(fd,8); //Player Char ID
	
	sd = map_id2sd(aid);
	if (!sd)
	{
		ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid);
		return -1;
	}
	if (sd->status.char_id != cid)
	{
		ShowError("chrif_load_scdata: Receiving data for account %d, char id does not matches (%d != %d)!\n", aid, sd->status.char_id, cid);
		return -1;
	}
	count = RFIFOW(fd,12); //sc_count
	for (i = 0; i < count; i++)
	{
		data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
		if (data->tick < 1)
		{	//Protection against invalid tick values. [Skotlex]
			ShowWarning("chrif_load_scdata: Received invalid duration (%d ms) for status change %d (character %s)\n", data->tick, data->type, sd->status.name);
			continue;
		}
		status_change_start(&sd->bl, data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
	}
#endif
	return 0;
}
Exemple #3
0
//Retrieve and load sc_data for a player. [Skotlex]
int chrif_load_scdata(int fd)
{	
#ifdef ENABLE_SC_SAVING
	struct map_session_data *sd;
	struct status_change_data *data;
	int aid, cid, i, count;

	aid = RFIFOL(fd,4); //Player Account ID
	cid = RFIFOL(fd,8); //Player Char ID
	
	sd = map_id2sd(aid);
	if (!sd)
	{
		ShowError("chrif_load_scdata: Personagem de ID %d nao encontrado!\n", aid);
		return -1;
	}
	if (sd->status.char_id != cid)
	{
		ShowError("chrif_load_scdata: Recebendo dados da conta %d, ID do personagem nao corresponde (%d != %d)!\n", aid, sd->status.char_id, cid);
		return -1;
	}
	count = RFIFOW(fd,12); //sc_count
	for (i = 0; i < count; i++)
	{
		data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
		status_change_start(&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
	}
#endif
	return 0;
}
Exemple #4
0
int mercenary_killbonus(struct mercenary_data *md)
{
	const enum sc_type scs[] = { SC_MERC_FLEEUP, SC_MERC_ATKUP, SC_MERC_HPUP, SC_MERC_SPUP, SC_MERC_HITUP };
	int index = rand() % ARRAYLENGTH(scs);

	status_change_start(&md->bl, scs[index], 10000, rand()%5, 0, 0, 0, 600000, 0);
	return 0;
}
Exemple #5
0
int party_skill_check(struct map_session_data *sd, int party_id, int skillid, int skilllv)
{
	struct party *p;
	struct map_session_data *p_sd;
	int i;

	if(!party_id || (p=party_search(party_id))==NULL)
		return 0;
	for(i=0;i<MAX_PARTY;i++){
		if ((p_sd = p->member[i].sd) == NULL)
			continue;
		switch(skillid) {
			case TK_COUNTER: //Increase Triple Attack rate of Monks.
				if((p_sd->class_&MAPID_UPPERMASK) == MAPID_MONK
					&& sd->bl.m == p_sd->bl.m
					&& pc_checkskill(p_sd,MO_TRIPLEATTACK)) {
					int rate = 50 +50*skilllv; //+100/150/200% success rate
					status_change_start(&p_sd->bl,SC_SKILLRATE_UP,MO_TRIPLEATTACK,rate,0,0,skill_get_time(SG_FRIEND, 1),0);
				}
				break;
			case MO_TRIPLEATTACK: //Increase Counter rate of Star Gladiators
				if((p_sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR
					&& sd->bl.m == p_sd->bl.m
					&& pc_checkskill(p_sd,TK_COUNTER)) {
					int rate = 50 +50*pc_checkskill(p_sd,TK_COUNTER); //+100/150/200% success rate
					status_change_start(&p_sd->bl,SC_SKILLRATE_UP,TK_COUNTER,rate,0,0,skill_get_time(SG_FRIEND, 1),0);
				}
				break;
			case AM_TWILIGHT2: //Twilight Pharmacy, requires Super Novice
				if ((p_sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE
					&& sd->bl.m == p_sd->bl.m)
					return 1;
				break;
			case AM_TWILIGHT3: //Twilight Pharmacy, Requires Taekwon
				if ((p_sd->class_&MAPID_NOVICE) == MAPID_TAEKWON
					&& sd->bl.m == p_sd->bl.m)
					return 1;
				break;
		}
	}
	return 0;
}
int charsave_load_scdata(int account_id, int char_id)
{	//Loads character's sc_data
	struct map_session_data *sd;
	
	sd = map_id2sd(account_id);
	if (!sd)
	{
		ShowError("charsave_load_scdata: Player of AID %d not found!\n", account_id);
		return -1;
	}
	if (sd->status.char_id != char_id)
	{
		ShowError("charsave_load_scdata: Receiving data for account %d, char id does not matches (%d != %d)!\n", account_id, sd->status.char_id, char_id);
		return -1;
	}
	sprintf(tmp_sql, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` FROM `sc_data`"
		"WHERE `account_id`='%d' AND `char_id`='%d'", account_id, char_id);
	
	if(mysql_query(&charsql_handle, tmp_sql)){
		ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
		ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
		return -1;
	}

	sql_res = mysql_store_result(&charsql_handle);
	if(sql_res)
	{
		while ((sql_row = mysql_fetch_row(sql_res)))
		{
			if (atoi(sql_row[1]) < 1)
			{	//Protection against invalid tick values. [Skotlex]
				ShowWarning("charsave_load_scdata: Received invalid duration (%d ms) for status change %d (character %s)\n", atoi(sql_row[1]), sd->status.name);
				continue;
			}

			status_change_start(&sd->bl, atoi(sql_row[0]), atoi(sql_row[2]), atoi(sql_row[3]),
				atoi(sql_row[4]), atoi(sql_row[5]), atoi(sql_row[1]), 7);
		}
	}

	//Once loaded, sc_data must be disposed.
	sprintf(tmp_sql, "DELETE FROM `sc_data` WHERE `account_id`='%d' AND `char_id`='%d'", account_id, char_id);
	if(mysql_query(&charsql_handle, tmp_sql)){
		ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
		ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
	}
	return 0;
}