1
This commit is contained in:
parent
4f4a2bacd1
commit
af966614df
@ -103,6 +103,7 @@ const int DEF_WEAPON_ID = 12103;
|
|||||||
const int GAS_INACTIVE_TIME = 30;
|
const int GAS_INACTIVE_TIME = 30;
|
||||||
const int SERVER_FRAME_RATE = 20;
|
const int SERVER_FRAME_RATE = 20;
|
||||||
const int SYNC_FRAME_RATE = 10;
|
const int SYNC_FRAME_RATE = 10;
|
||||||
|
const float FRAME_RATE_MS = 1000.0f / SERVER_FRAME_RATE;
|
||||||
|
|
||||||
const int MAX_INVENTORY_NUM = 17;
|
const int MAX_INVENTORY_NUM = 17;
|
||||||
const int MAX_WEAPON_NUM = 5;
|
const int MAX_WEAPON_NUM = 5;
|
||||||
|
@ -9,6 +9,12 @@ namespace MetaData
|
|||||||
struct Equip;
|
struct Equip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum HumanStatus
|
||||||
|
{
|
||||||
|
HS_PainKiller = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct xtimer_list;
|
||||||
class CircleCollider;
|
class CircleCollider;
|
||||||
class Obstacle;
|
class Obstacle;
|
||||||
class Human : public Entity
|
class Human : public Entity
|
||||||
@ -48,6 +54,7 @@ class Human : public Entity
|
|||||||
long long poisoning_time = 0;
|
long long poisoning_time = 0;
|
||||||
long long dead_frameno = 0;
|
long long dead_frameno = 0;
|
||||||
long long join_frameno = 0;
|
long long join_frameno = 0;
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
Weapon default_weapon;
|
Weapon default_weapon;
|
||||||
std::vector<Weapon> weapons;
|
std::vector<Weapon> weapons;
|
||||||
@ -63,6 +70,9 @@ class Human : public Entity
|
|||||||
|
|
||||||
bool send_gameover = false;
|
bool send_gameover = false;
|
||||||
|
|
||||||
|
int pain_killer_frameno = 0;
|
||||||
|
xtimer_list* pain_killer_timer = nullptr;
|
||||||
|
|
||||||
Human();
|
Human();
|
||||||
virtual ~Human() override;
|
virtual ~Human() override;
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
|
@ -204,15 +204,33 @@ void Player::UpdateAction()
|
|||||||
case IS_PAIN_KILLER:
|
case IS_PAIN_KILLER:
|
||||||
{
|
{
|
||||||
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquipBySlotId(action_item_id);
|
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquipBySlotId(action_item_id);
|
||||||
if (item_meta){
|
if (item_meta && !pain_killer_timer){
|
||||||
if (inventory[item_meta->i->_inventory_slot()] > 0) {
|
if (inventory[item_meta->i->_inventory_slot()] > 0) {
|
||||||
float old_health = health;
|
pain_killer_frameno = room->frame_no;
|
||||||
health += item_meta->i->heal();
|
pain_killer_timer = room->xtimer.AddRepeatTimerAndAttach(
|
||||||
health = std::min(health, GetMaxHP());
|
SERVER_FRAME_RATE,
|
||||||
stats.heal_amount += health - old_health;
|
a8::XParams()
|
||||||
|
.SetSender(this)
|
||||||
|
.SetParam1(item_meta->i->heal())
|
||||||
|
.SetParam2(item_meta->i->time())
|
||||||
|
.SetParam3(0),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Human* hum = (Human*)param.sender.GetUserData();
|
||||||
|
float old_health = hum->health;
|
||||||
|
hum->health += param.param2.GetDouble();
|
||||||
|
hum->health = std::min(hum->health, hum->GetMaxHP());
|
||||||
|
hum->stats.heal_amount += hum->health - old_health;
|
||||||
|
hum->SyncAroundPlayers();
|
||||||
|
if (hum->room->frame_no - hum->pain_killer_frameno > param.param2.GetInt() * SERVER_FRAME_RATE) {
|
||||||
|
hum->room->xtimer.DeleteTimer(hum->pain_killer_timer);
|
||||||
|
hum->pain_killer_timer = nullptr;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&xtimer_attacher.timer_list_
|
||||||
|
);
|
||||||
--inventory[item_meta->i->_inventory_slot()];
|
--inventory[item_meta->i->_inventory_slot()];
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
SyncAroundPlayers();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user