1
This commit is contained in:
parent
01b4b98c4c
commit
503eb03fff
@ -377,21 +377,40 @@ enum ExplosionHit_e
|
|||||||
|
|
||||||
enum CondAddBuff_e
|
enum CondAddBuff_e
|
||||||
{
|
{
|
||||||
kCondBuffTakeonWeaponId = 1,
|
kCondBuffUpdateWeaponId = 1,
|
||||||
kCondBuffTakeonWeaponSlot = 2,
|
kCondBuffUpdateWeaponSlot = 2,
|
||||||
kCondBuffTakeonWeaponType = 3,
|
kCondBuffUpdateWeaponType = 3,
|
||||||
kCondBuffShotWeaponId = 4,
|
kCondBuffShotWeaponId = 4,
|
||||||
kCondBuffShotWeaponSlot = 5,
|
kCondBuffShotWeaponSlot = 5,
|
||||||
kCondBuffShotWeaponType = 6,
|
kCondBuffShotWeaponType = 6,
|
||||||
kCondBuffKillTarget = 7,
|
kCondBuffKillTarget = 7,
|
||||||
kCondBuffDid = 8,
|
kCondBuffDid = 8,
|
||||||
kCondBuffActiveBuff = 9,
|
kCondBuffUpdateBuffId = 9,
|
||||||
kCondBuffHp = 10,
|
kCondBuffUpdateBuffEffect = 10,
|
||||||
kCondBuffDown = 11,
|
kCondBuffHp = 11,
|
||||||
kCondBuffReceiveDmg = 12,
|
kCondBuffDown = 12,
|
||||||
|
kCondBuffReceiveDmg = 13,
|
||||||
|
kCondBuffUseSkill = 14,
|
||||||
|
kCondBuffEatDrug = 15,
|
||||||
kCondBuffEnd
|
kCondBuffEnd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum WeaponOpt_e
|
||||||
|
{
|
||||||
|
kWeaponOptTakeon = 0,
|
||||||
|
kWeaponOptTakeoff = 1,
|
||||||
|
kWeaponOptKeep = 2,
|
||||||
|
kWeaponOptEnd
|
||||||
|
};
|
||||||
|
|
||||||
|
enum BuffOpt_e
|
||||||
|
{
|
||||||
|
kBuffOptActive = 0,
|
||||||
|
kBuffOptDeactive = 1,
|
||||||
|
kBuffOptKeep = 2,
|
||||||
|
kBuffOptEnd
|
||||||
|
};
|
||||||
|
|
||||||
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
||||||
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
||||||
|
|
||||||
|
@ -51,3 +51,13 @@ bool IsValidCondBuff(int cond)
|
|||||||
{
|
{
|
||||||
return cond >= 0 && cond < kCondBuffEnd;
|
return cond >= 0 && cond < kCondBuffEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsValidWeaponOpt(int opt)
|
||||||
|
{
|
||||||
|
return opt >= 0 && opt < kWeaponOptEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsValidBuffOpt(int opt)
|
||||||
|
{
|
||||||
|
return opt >= 0 && opt < kBuffOptEnd;
|
||||||
|
}
|
||||||
|
@ -25,3 +25,5 @@ bool IsValidSlotId(int slot_id);
|
|||||||
bool IsValidBuffEffect(int buff_effect);
|
bool IsValidBuffEffect(int buff_effect);
|
||||||
bool IsValidHumanAttr(int attr_type);
|
bool IsValidHumanAttr(int attr_type);
|
||||||
bool IsValidCondBuff(int cond);
|
bool IsValidCondBuff(int cond);
|
||||||
|
bool IsValidWeaponOpt(int opt);
|
||||||
|
bool IsValidBuffOpt(int opt);
|
||||||
|
@ -3013,6 +3013,7 @@ void Human::ProcUseItemAction()
|
|||||||
{
|
{
|
||||||
AddHp(item_meta->i->heal());
|
AddHp(item_meta->i->heal());
|
||||||
DecInventory(item_meta->i->_inventory_slot(), 1);
|
DecInventory(item_meta->i->_inventory_slot(), 1);
|
||||||
|
GetTrigger()->UseItemAction(action_item_id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IS_PAIN_KILLER:
|
case IS_PAIN_KILLER:
|
||||||
@ -3054,6 +3055,7 @@ void Human::ProcUseItemAction()
|
|||||||
}
|
}
|
||||||
DecInventory(item_meta->i->_inventory_slot(), 1);
|
DecInventory(item_meta->i->_inventory_slot(), 1);
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
|
GetTrigger()->UseItemAction(action_item_id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IS_SHEN_BAO:
|
case IS_SHEN_BAO:
|
||||||
@ -3071,6 +3073,7 @@ void Human::ProcUseItemAction()
|
|||||||
}
|
}
|
||||||
DecInventory(item_meta->i->_inventory_slot(), 1);
|
DecInventory(item_meta->i->_inventory_slot(), 1);
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
|
GetTrigger()->UseItemAction(action_item_id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "trigger.h"
|
#include "trigger.h"
|
||||||
#include "creature.h"
|
#include "creature.h"
|
||||||
|
#include "metamgr.h"
|
||||||
|
#include "skill.h"
|
||||||
|
|
||||||
void Trigger::Init()
|
void Trigger::Init()
|
||||||
{
|
{
|
||||||
@ -21,21 +23,76 @@ void Trigger::TakeonWeapon(Weapon* old_weapon, Weapon* new_weapon)
|
|||||||
|
|
||||||
void Trigger::Shot(MetaData::Equip* weapon_meta)
|
void Trigger::Shot(MetaData::Equip* weapon_meta)
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffShotWeaponId,
|
||||||
|
[this, weapon_meta] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 == weapon_meta->i->id()) {
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffShotWeaponSlot,
|
||||||
|
[this, weapon_meta] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 == weapon_meta->i->_inventory_slot()) {
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffShotWeaponType,
|
||||||
|
[this, weapon_meta] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 == weapon_meta->i->equip_subtype()) {
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::Kill(Creature* target)
|
void Trigger::Kill(Creature* target)
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffKillTarget,
|
||||||
|
[this] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 >= 1) {
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::UseItemAction(int slot_id)
|
void Trigger::UseItemAction(int slot_id)
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffEatDrug,
|
||||||
|
[this, slot_id] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 == slot_id) {
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::UseSkill(Skill* skill)
|
void Trigger::UseSkill(Skill* skill)
|
||||||
{
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffUseSkill,
|
||||||
|
[this, skill] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 == skill->meta->i->skill_id()) {
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::HpChg(float old_hp, float new_hp)
|
void Trigger::HpChg(float old_hp, float new_hp)
|
||||||
@ -45,7 +102,7 @@ void Trigger::HpChg(float old_hp, float new_hp)
|
|||||||
|
|
||||||
void Trigger::Die()
|
void Trigger::Die()
|
||||||
{
|
{
|
||||||
|
TriggeCondBuffAll(kCondBuffDid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> func)
|
void Trigger::TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> func)
|
||||||
@ -76,3 +133,122 @@ void Trigger::TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> fun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Trigger::TriggeCondBuffAll(int cond)
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(cond,
|
||||||
|
[this, cond] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
AddBuff(cond, buff->meta->int_param4);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Trigger::AddBuff(int cond, int buff_id)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
owner_->MustBeAddBuff(owner_, buff_id);
|
||||||
|
#else
|
||||||
|
owner_->TryBeAddBuff(owner_, buff_id);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Trigger::ActiveBuff(MetaData::Buff* buff_meta)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffUpdateBuffId,
|
||||||
|
[this, buff_meta] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 == buff_meta->i->buff_id()) {
|
||||||
|
switch (buff->meta->int_param3) {
|
||||||
|
case kBuffOptActive:
|
||||||
|
case kBuffOptKeep:
|
||||||
|
{
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffUpdateBuffEffect,
|
||||||
|
[this, buff_meta] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 == buff_meta->i->buff_effect()) {
|
||||||
|
switch (buff->meta->int_param3) {
|
||||||
|
case kBuffOptActive:
|
||||||
|
case kBuffOptKeep:
|
||||||
|
{
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Trigger::DeactiveBuff(MetaData::Buff* buff_meta)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffUpdateBuffId,
|
||||||
|
[this, buff_meta] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 == buff_meta->i->buff_id()) {
|
||||||
|
switch (buff->meta->int_param3) {
|
||||||
|
case kBuffOptDeactive:
|
||||||
|
{
|
||||||
|
owner_->RemoveBuffById(buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kBuffOptKeep:
|
||||||
|
{
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
{
|
||||||
|
TraverseCondBuffs
|
||||||
|
(kCondBuffUpdateBuffEffect,
|
||||||
|
[this, buff_meta] (Buff* buff, bool& stop)
|
||||||
|
{
|
||||||
|
if (buff->meta->int_param2 == buff_meta->i->buff_effect()) {
|
||||||
|
switch (buff->meta->int_param3) {
|
||||||
|
case kBuffOptDeactive:
|
||||||
|
{
|
||||||
|
owner_->RemoveBuffById(buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kBuffOptKeep:
|
||||||
|
{
|
||||||
|
AddBuff(buff->meta->int_param1, buff->meta->int_param4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
namespace MetaData
|
||||||
|
{
|
||||||
|
struct Buff;
|
||||||
|
};
|
||||||
|
|
||||||
class Weapon;
|
class Weapon;
|
||||||
class Creature;
|
class Creature;
|
||||||
class Skill;
|
class Skill;
|
||||||
@ -19,9 +24,13 @@ public:
|
|||||||
void UseSkill(Skill* skill);
|
void UseSkill(Skill* skill);
|
||||||
void HpChg(float old_hp, float new_hp);
|
void HpChg(float old_hp, float new_hp);
|
||||||
void Die();
|
void Die();
|
||||||
|
void ActiveBuff(MetaData::Buff* buff_meta);
|
||||||
|
void DeactiveBuff(MetaData::Buff* buff_meta);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> func);
|
void TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> func);
|
||||||
|
void TriggeCondBuffAll(int cond);
|
||||||
|
void AddBuff(int cond, int buff_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Creature* owner_ = nullptr;
|
Creature* owner_ = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user