diff --git a/src/ship/packet/handler/message.rs b/src/ship/packet/handler/message.rs index 5551fb4..9d2725e 100644 --- a/src/ship/packet/handler/message.rs +++ b/src/ship/packet/handler/message.rs @@ -29,20 +29,27 @@ pub async fn request_exp(id: ClientId, let monster = room.maps.enemy_by_id(request_exp.enemy_id as usize)?; let monster_stats = room.monster_stats.get(&monster.monster).unwrap(); + let exp_gain = if request_exp.last_hitter == 1 { + monster_stats.exp + } + else { + ((monster_stats.exp as f32) * 0.8) as u32 + }; + let clients_in_area = client_location.get_clients_in_room(room_id).map_err(|err| -> ClientLocationError { err.into() })?; - let gain_exp_pkt = builder::message::character_gained_exp(area_client, monster_stats.exp); + let gain_exp_pkt = builder::message::character_gained_exp(area_client, exp_gain); let mut exp_pkts: Box + Send> = Box::new(clients_in_area.clone().into_iter() .map(move |c| { (c.client, SendShipPacket::Message(Message::new(GameMessage::GiveCharacterExp(gain_exp_pkt.clone())))) })); let before_level = level_table.get_level_from_exp(client.character.char_class, client.character.exp); - let after_level = level_table.get_level_from_exp(client.character.char_class, client.character.exp + monster_stats.exp); + let after_level = level_table.get_level_from_exp(client.character.char_class, client.character.exp + exp_gain); let level_up = before_level != after_level; if level_up { let (_, before_stats) = level_table.get_stats_from_exp(client.character.char_class, client.character.exp); - let (after_level, after_stats) = level_table.get_stats_from_exp(client.character.char_class, client.character.exp + monster_stats.exp); + let (after_level, after_stats) = level_table.get_stats_from_exp(client.character.char_class, client.character.exp + exp_gain); let level_up_pkt = builder::message::character_leveled_up(area_client, after_level, before_stats, after_stats); exp_pkts = Box::new(exp_pkts.chain(clients_in_area.into_iter() @@ -51,7 +58,7 @@ pub async fn request_exp(id: ClientId, }))) } - client.character.exp += monster_stats.exp; + client.character.exp += exp_gain; entity_gateway.save_character(&client.character).await; Ok(exp_pkts)