Exemplo n.º 1
0
/**
 * Feed a pet and update intimacy.
 * @param sd : playerr requesting
 * @param pd : pet requesting
 * @return 0:success, 1:failure
 */
static int pet_food(struct map_session_data *sd, struct pet_data *pd)
{
	int i,k;

	k = pd->petDB->FoodID;
	i = pc_search_inventory(sd,k);

	if( i < 0 ) {
		clif_pet_food(sd,k,0);

		return 1;
	}

	pc_delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);

	if( pd->pet.hungry > 90 )
		pet_set_intimate(pd, pd->pet.intimate - pd->petDB->r_full);
	else {
		if( battle_config.pet_friendly_rate != 100 )
			k = (pd->petDB->r_hungry * battle_config.pet_friendly_rate) / 100;
		else
			k = pd->petDB->r_hungry;

		if( pd->pet.hungry > 75 ) {
			k = k >> 1;
			if( k <= 0 )
				k = 1;
		}

		pet_set_intimate(pd, pd->pet.intimate + k);
	}
Exemplo n.º 2
0
/**
 * Update pet's hungry value and timer and adjust intimacy based on hunger.
 * @param tid : current timer value
 * @param tick : how often to update
 * @param id : ID of pet owner
 * @return 0
 */
static int pet_hungry(int tid, unsigned int tick, int id, intptr_t data)
{
	struct map_session_data *sd;
	struct pet_data *pd;
	int interval;

	sd = map_id2sd(id);

	if(!sd)
		return 1;

	if(!sd->status.pet_id || !sd->pd)
		return 1;

	pd = sd->pd;

	if(pd->pet_hungry_timer != tid) {
		ShowError("pet_hungry_timer %d != %d\n",pd->pet_hungry_timer,tid);
		return 0;
	}

	pd->pet_hungry_timer = INVALID_TIMER;

	if (pd->pet.intimate <= 0)
		return 1; //You lost the pet already, the rest is irrelevant.

	pd->pet.hungry--;

	if( pd->pet.hungry < 0 ) {
		pet_stop_attack(pd);
		pd->pet.hungry = 0;
		pet_set_intimate(pd, pd->pet.intimate - battle_config.pet_hungry_friendly_decrease);

		if( pd->pet.intimate <= 0 ) {
			pd->pet.intimate = 0;
			pd->status.speed = pd->db->status.speed;
		}

		status_calc_pet(pd,SCO_NONE);
		clif_send_petdata(sd,pd,1,pd->pet.intimate);
	}

	clif_send_petdata(sd,pd,2,pd->pet.hungry);

	if(battle_config.pet_hungry_delay_rate != 100)
		interval = (pd->petDB->hungry_delay*battle_config.pet_hungry_delay_rate)/100;
	else
		interval = pd->petDB->hungry_delay;

	if(interval <= 0)
		interval = 1;

	pd->pet_hungry_timer = add_timer(tick+interval,pet_hungry,sd->bl.id,0);

	return 0;
}
Exemplo n.º 3
0
static int pet_hungry(int tid, unsigned int tick, int id, intptr_t data)
{
	struct map_session_data *sd;
	struct pet_data *pd;
	int interval;
	char mes[100];

	sd=map_id2sd(id);
	if(!sd)
		return 1;

	if(!sd->status.pet_id || !sd->pd)
		return 1;

	pd = sd->pd;
	if(pd->pet_hungry_timer != tid){
		ShowError("pet_hungry_timer %d != %d\n",pd->pet_hungry_timer,tid);
		return 0;
	}
	pd->pet_hungry_timer = INVALID_TIMER;

	switch(pd->pet.hungry) { //Informe de hambre de pet automatico. [Tab]
		case 75:
			snprintf(mes, sizeof mes,msg_txt(907),pd->pet.name);
			clif_message(&pd->bl, mes);
		break;
		case 25:
			snprintf(mes, sizeof mes,msg_txt(906),pd->pet.name);
			clif_message(&pd->bl, mes);
		break;
		case 10:
			snprintf(mes, sizeof mes,msg_txt(905),pd->pet.name);
			clif_message(&pd->bl, mes);
		break;
	}

	if (pd->pet.intimate <= 0)
		return 1; //You lost the pet already, the rest is irrelevant.
	
	pd->pet.hungry--;
	if( pd->pet.hungry < 0 )
	{
		pet_stop_attack(pd);
		pd->pet.hungry = 0;
		pet_set_intimate(pd, pd->pet.intimate - battle_config.pet_hungry_friendly_decrease);
		if( pd->pet.intimate <= 0 )
		{
			pd->pet.intimate = 0;
			pd->status.speed = pd->db->status.speed;
		}
		status_calc_pet(pd, 0);
		clif_send_petdata(sd,pd,1,pd->pet.intimate);
	}
	clif_send_petdata(sd,pd,2,pd->pet.hungry);

	if(battle_config.pet_hungry_delay_rate != 100)
		interval = (pd->petDB->hungry_delay*battle_config.pet_hungry_delay_rate)/100;
	else
		interval = pd->petDB->hungry_delay;
	if(interval <= 0)
		interval = 1;
	pd->pet_hungry_timer = add_timer(tick+interval,pet_hungry,sd->bl.id,0);

	return 0;
}