Added and fixed some pet features (#5040)
Fixes #5019 Thanks to @alisonrag
This commit is contained in:
parent
ddd8fb2fde
commit
02c5b8c8d8
103
sql-files/upgrades/upgrade_20200703.sql
Normal file
103
sql-files/upgrades/upgrade_20200703.sql
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
-- Fix rename flag and intimacy in inventories
|
||||||
|
update `inventory` `i`
|
||||||
|
inner join `pet` `p`
|
||||||
|
on
|
||||||
|
`i`.`card0` = 256
|
||||||
|
and
|
||||||
|
( `i`.`card1` | ( `i`.`card2` << 16 ) ) = `p`.`pet_id`
|
||||||
|
set
|
||||||
|
`i`.`card3` =
|
||||||
|
(
|
||||||
|
CASE
|
||||||
|
WHEN `p`.`intimate` < 100 THEN
|
||||||
|
1 -- awkward
|
||||||
|
WHEN `p`.`intimate` < 250 THEN
|
||||||
|
2 -- shy
|
||||||
|
WHEN `p`.`intimate` < 750 THEN
|
||||||
|
3 -- neutral
|
||||||
|
WHEN `p`.`intimate` < 910 THEN
|
||||||
|
4 -- cordial
|
||||||
|
WHEN `p`.`intimate` <= 1000 THEN
|
||||||
|
5 -- loyal
|
||||||
|
ELSE 0 -- unrecognized
|
||||||
|
END << 1
|
||||||
|
) | `p`.`rename_flag`
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Fix rename flag and intimacy in carts
|
||||||
|
update `cart_inventory` `i`
|
||||||
|
inner join `pet` `p`
|
||||||
|
on
|
||||||
|
`i`.`card0` = 256
|
||||||
|
and
|
||||||
|
( `i`.`card1` | ( `i`.`card2` << 16 ) ) = `p`.`pet_id`
|
||||||
|
set
|
||||||
|
`i`.`card3` =
|
||||||
|
(
|
||||||
|
CASE
|
||||||
|
WHEN `p`.`intimate` < 100 THEN
|
||||||
|
1 -- awkward
|
||||||
|
WHEN `p`.`intimate` < 250 THEN
|
||||||
|
2 -- shy
|
||||||
|
WHEN `p`.`intimate` < 750 THEN
|
||||||
|
3 -- neutral
|
||||||
|
WHEN `p`.`intimate` < 910 THEN
|
||||||
|
4 -- cordial
|
||||||
|
WHEN `p`.`intimate` <= 1000 THEN
|
||||||
|
5 -- loyal
|
||||||
|
ELSE 0 -- unrecognized
|
||||||
|
END << 1
|
||||||
|
) | `p`.`rename_flag`
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Fix rename flag and intimacy in storages
|
||||||
|
update `storage` `i`
|
||||||
|
inner join `pet` `p`
|
||||||
|
on
|
||||||
|
`i`.`card0` = 256
|
||||||
|
and
|
||||||
|
( `i`.`card1` | ( `i`.`card2` << 16 ) ) = `p`.`pet_id`
|
||||||
|
set
|
||||||
|
`i`.`card3` =
|
||||||
|
(
|
||||||
|
CASE
|
||||||
|
WHEN `p`.`intimate` < 100 THEN
|
||||||
|
1 -- awkward
|
||||||
|
WHEN `p`.`intimate` < 250 THEN
|
||||||
|
2 -- shy
|
||||||
|
WHEN `p`.`intimate` < 750 THEN
|
||||||
|
3 -- neutral
|
||||||
|
WHEN `p`.`intimate` < 910 THEN
|
||||||
|
4 -- cordial
|
||||||
|
WHEN `p`.`intimate` <= 1000 THEN
|
||||||
|
5 -- loyal
|
||||||
|
ELSE 0 -- unrecognized
|
||||||
|
END << 1
|
||||||
|
) | `p`.`rename_flag`
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Fix rename flag and intimacy in guild storages
|
||||||
|
update `guild_storage` `i`
|
||||||
|
inner join `pet` `p`
|
||||||
|
on
|
||||||
|
`i`.`card0` = 256
|
||||||
|
and
|
||||||
|
( `i`.`card1` | ( `i`.`card2` << 16 ) ) = `p`.`pet_id`
|
||||||
|
set
|
||||||
|
`i`.`card3` =
|
||||||
|
(
|
||||||
|
CASE
|
||||||
|
WHEN `p`.`intimate` < 100 THEN
|
||||||
|
1 -- awkward
|
||||||
|
WHEN `p`.`intimate` < 250 THEN
|
||||||
|
2 -- shy
|
||||||
|
WHEN `p`.`intimate` < 750 THEN
|
||||||
|
3 -- neutral
|
||||||
|
WHEN `p`.`intimate` < 910 THEN
|
||||||
|
4 -- cordial
|
||||||
|
WHEN `p`.`intimate` <= 1000 THEN
|
||||||
|
5 -- loyal
|
||||||
|
ELSE 0 -- unrecognized
|
||||||
|
END << 1
|
||||||
|
) | `p`.`rename_flag`
|
||||||
|
;
|
@ -5968,7 +5968,7 @@ void getring (struct map_session_data* sd)
|
|||||||
memset(&item_tmp, 0, sizeof(item_tmp));
|
memset(&item_tmp, 0, sizeof(item_tmp));
|
||||||
item_tmp.nameid = item_id;
|
item_tmp.nameid = item_id;
|
||||||
item_tmp.identify = 1;
|
item_tmp.identify = 1;
|
||||||
item_tmp.card[0] = 255;
|
item_tmp.card[0] = CARD0_FORGE;
|
||||||
item_tmp.card[2] = sd->status.partner_id;
|
item_tmp.card[2] = sd->status.partner_id;
|
||||||
item_tmp.card[3] = sd->status.partner_id >> 16;
|
item_tmp.card[3] = sd->status.partner_id >> 16;
|
||||||
|
|
||||||
@ -8957,7 +8957,7 @@ ACMD_FUNC(itemlist)
|
|||||||
StringBuf_Clear(&buf);
|
StringBuf_Clear(&buf);
|
||||||
|
|
||||||
if( it->card[0] == CARD0_PET ) { // pet egg
|
if( it->card[0] == CARD0_PET ) { // pet egg
|
||||||
if (it->card[3])
|
if (it->card[3]&1)
|
||||||
StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
|
StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
|
||||||
else
|
else
|
||||||
StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
|
StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
|
||||||
|
@ -2575,8 +2575,11 @@ static void clif_addcards( struct EQUIPSLOTINFO* buf, struct item* item ){
|
|||||||
if( item->card[0] == CARD0_PET ){
|
if( item->card[0] == CARD0_PET ){
|
||||||
buf->card[0] = 0;
|
buf->card[0] = 0;
|
||||||
buf->card[1] = 0;
|
buf->card[1] = 0;
|
||||||
buf->card[2] = 0;
|
// Pet intimacy
|
||||||
buf->card[3] = item->card[3]; //Pet renamed flag.
|
// No idea when this was added exactly, but older clients have no problem if we send it anyway
|
||||||
|
buf->card[2] = item->card[3] >> 1;
|
||||||
|
// Pet renamed flag
|
||||||
|
buf->card[3] = item->card[3] & 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,6 +593,28 @@ int pet_hungry_val(struct pet_data *pd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16 pet_get_card3_intimacy( int intimacy ){
|
||||||
|
if( intimacy < PET_INTIMATE_SHY ){
|
||||||
|
// Awkward
|
||||||
|
return ( 1 << 1 );
|
||||||
|
}else if( intimacy < PET_INTIMATE_NEUTRAL ){
|
||||||
|
// Shy
|
||||||
|
return ( 2 << 1 );
|
||||||
|
}else if( intimacy < PET_INTIMATE_CORDIAL ){
|
||||||
|
// Neutral
|
||||||
|
return ( 3 << 1 );
|
||||||
|
}else if( intimacy < PET_INTIMATE_LOYAL ){
|
||||||
|
// Cordial
|
||||||
|
return ( 4 << 1 );
|
||||||
|
}else if( intimacy <= PET_INTIMATE_MAX ){
|
||||||
|
// Loyal
|
||||||
|
return ( 5 << 1 );
|
||||||
|
}else{
|
||||||
|
// Unknown
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of the pet's intimacy.
|
* Set the value of the pet's intimacy.
|
||||||
* @param pd : pet requesting
|
* @param pd : pet requesting
|
||||||
@ -606,8 +628,16 @@ void pet_set_intimate(struct pet_data *pd, int value)
|
|||||||
|
|
||||||
struct map_session_data *sd = pd->master;
|
struct map_session_data *sd = pd->master;
|
||||||
|
|
||||||
if(pd->pet.intimate <= PET_INTIMATE_NONE)
|
int index = pet_egg_search( sd, pd->pet.pet_id );
|
||||||
pc_delitem(sd, pet_egg_search(sd, pd->pet.pet_id), 1, 0, 0, LOG_TYPE_OTHER);
|
|
||||||
|
if( pd->pet.intimate <= PET_INTIMATE_NONE ){
|
||||||
|
pc_delitem( sd, index, 1, 0, 0, LOG_TYPE_OTHER );
|
||||||
|
}else{
|
||||||
|
// Remove everything except the rename flag
|
||||||
|
sd->inventory.u.items_inventory[index].card[3] &= 1;
|
||||||
|
|
||||||
|
sd->inventory.u.items_inventory[index].card[3] |= pet_get_card3_intimacy( pd->pet.intimate );
|
||||||
|
}
|
||||||
|
|
||||||
if (sd)
|
if (sd)
|
||||||
status_calc_pc(sd,SCO_NONE);
|
status_calc_pc(sd,SCO_NONE);
|
||||||
@ -1297,6 +1327,7 @@ bool pet_get_egg(uint32 account_id, short pet_class, int pet_id ) {
|
|||||||
tmp_item.card[1] = GetWord(pet_id,0);
|
tmp_item.card[1] = GetWord(pet_id,0);
|
||||||
tmp_item.card[2] = GetWord(pet_id,1);
|
tmp_item.card[2] = GetWord(pet_id,1);
|
||||||
tmp_item.card[3] = 0; //New pets are not named.
|
tmp_item.card[3] = 0; //New pets are not named.
|
||||||
|
tmp_item.card[3] |= pet_get_card3_intimacy( pet->intimate ); // Store intimacy status based on initial intimacy
|
||||||
|
|
||||||
if((ret = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER))) {
|
if((ret = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER))) {
|
||||||
clif_additem(sd,0,0,ret);
|
clif_additem(sd,0,0,ret);
|
||||||
@ -1401,6 +1432,12 @@ int pet_change_name_ack(struct map_session_data *sd, char* name, int flag)
|
|||||||
clif_pet_equip_area(pd);
|
clif_pet_equip_area(pd);
|
||||||
clif_send_petstatus(sd);
|
clif_send_petstatus(sd);
|
||||||
|
|
||||||
|
int index = pet_egg_search( sd, pd->pet.pet_id );
|
||||||
|
|
||||||
|
if( index >= 0 ){
|
||||||
|
sd->inventory.u.items_inventory[index].card[3] |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user