1
This commit is contained in:
parent
b6a9003514
commit
fab51d4d99
@ -524,11 +524,7 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
} else {
|
} else {
|
||||||
weapons[0].weapon_idx = 0;
|
weapons[0].weapon_idx = 0;
|
||||||
weapons[0].weapon_id = entity->item_id;
|
weapons[0].weapon_id = entity->item_id;
|
||||||
#if 1
|
|
||||||
weapons[0].weapon_lv = std::max(1, entity->item_level);
|
weapons[0].weapon_lv = std::max(1, entity->item_level);
|
||||||
#else
|
|
||||||
weapons[0].weapon_lv = std::max(1, GetWeaponConfigLv(weapons[0].weapon_id));
|
|
||||||
#endif
|
|
||||||
weapons[0].ammo = 0;
|
weapons[0].ammo = 0;
|
||||||
weapons[0].meta = item_meta;
|
weapons[0].meta = item_meta;
|
||||||
weapons[0].Recalc();
|
weapons[0].Recalc();
|
||||||
@ -537,17 +533,18 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
} else {
|
} else {
|
||||||
Weapon* weapon = nullptr;
|
Weapon* weapon = nullptr;
|
||||||
|
bool switch_gun = false;
|
||||||
if (weapons[GUN_SLOT1].weapon_id == 0) {
|
if (weapons[GUN_SLOT1].weapon_id == 0) {
|
||||||
weapon = &weapons[GUN_SLOT1];
|
weapon = &weapons[GUN_SLOT1];
|
||||||
weapon->weapon_idx = GUN_SLOT1;
|
weapon->weapon_idx = GUN_SLOT1;
|
||||||
if (GetCurrWeapon() != &weapons[GUN_SLOT2] && !FreezeOperate()) {
|
if (GetCurrWeapon() != &weapons[GUN_SLOT2] && !FreezeOperate()) {
|
||||||
SetCurrWeapon(&weapons[GUN_SLOT1]);
|
switch_gun = true;
|
||||||
}
|
}
|
||||||
} else if (weapons[GUN_SLOT2].weapon_id == 0) {
|
} else if (weapons[GUN_SLOT2].weapon_id == 0) {
|
||||||
weapon = &weapons[GUN_SLOT2];
|
weapon = &weapons[GUN_SLOT2];
|
||||||
weapon->weapon_idx = GUN_SLOT2;
|
weapon->weapon_idx = GUN_SLOT2;
|
||||||
if (GetCurrWeapon() != &weapons[GUN_SLOT1] && !FreezeOperate()) {
|
if (GetCurrWeapon() != &weapons[GUN_SLOT1] && !FreezeOperate()) {
|
||||||
SetCurrWeapon(&weapons[GUN_SLOT2]);
|
switch_gun = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!weapon) {
|
if (!weapon) {
|
||||||
@ -559,11 +556,7 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
weapon->weapon_id = entity->item_id;
|
weapon->weapon_id = entity->item_id;
|
||||||
#if 1
|
|
||||||
weapon->weapon_lv = std::max(1, entity->item_level);
|
weapon->weapon_lv = std::max(1, entity->item_level);
|
||||||
#else
|
|
||||||
weapon->weapon_lv = std::max(1, GetWeaponConfigLv(weapon->weapon_id));
|
|
||||||
#endif
|
|
||||||
weapon->ammo = 0;
|
weapon->ammo = 0;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = item_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
@ -571,6 +564,9 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
} else {
|
} else {
|
||||||
AutoLoadingBullet();
|
AutoLoadingBullet();
|
||||||
}
|
}
|
||||||
|
if (switch_gun) {
|
||||||
|
SetCurrWeapon(weapon);
|
||||||
|
}
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
|
@ -20,55 +20,59 @@ void Trigger::UnInit()
|
|||||||
void Trigger::TakeonWeapon(Weapon* old_weapon, Weapon* new_weapon)
|
void Trigger::TakeonWeapon(Weapon* old_weapon, Weapon* new_weapon)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
MetaData::Equip* weapon_meta = new_weapon->meta;
|
MetaData::Equip* weapon_meta = old_weapon ? old_weapon->meta : nullptr;
|
||||||
for (int cond = kCondBuffUpdateWeaponId; cond <= kCondBuffUpdateWeaponType; cond++) {
|
if (weapon_meta) {
|
||||||
TraverseCondBuffs
|
for (int cond = kCondBuffUpdateWeaponId; cond <= kCondBuffUpdateWeaponType; cond++) {
|
||||||
(cond,
|
TraverseCondBuffs
|
||||||
[this, cond, weapon_meta] (Buff* buff, bool& stop)
|
(cond,
|
||||||
{
|
[this, cond, weapon_meta] (Buff* buff, bool& stop)
|
||||||
if (weapon_meta->Match((CondAddBuff_e)cond, buff->meta->int_param2)) {
|
{
|
||||||
switch (buff->meta->int_param3) {
|
if (weapon_meta->Match((CondAddBuff_e)cond, buff->meta->int_param3)) {
|
||||||
case kWeaponOptTakeoff:
|
switch (buff->meta->int_param2) {
|
||||||
case kWeaponOptKeep:
|
case kWeaponOptTakeoff:
|
||||||
{
|
case kWeaponOptKeep:
|
||||||
RemoveBuffs(buff->meta->int_param1, buff->meta->param4_int_list);
|
{
|
||||||
|
RemoveBuffs(buff->meta->int_param1, buff->meta->param4_int_list);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
MetaData::Equip* weapon_meta = new_weapon->meta;
|
MetaData::Equip* weapon_meta = new_weapon ? new_weapon->meta : nullptr;
|
||||||
for (int cond = kCondBuffUpdateWeaponId; cond <= kCondBuffUpdateWeaponType; cond++) {
|
if (weapon_meta) {
|
||||||
TraverseCondBuffs
|
for (int cond = kCondBuffUpdateWeaponId; cond <= kCondBuffUpdateWeaponType; cond++) {
|
||||||
(cond,
|
TraverseCondBuffs
|
||||||
[this, cond, weapon_meta] (Buff* buff, bool& stop)
|
(cond,
|
||||||
{
|
[this, cond, weapon_meta] (Buff* buff, bool& stop)
|
||||||
if (weapon_meta->Match((CondAddBuff_e)cond, buff->meta->int_param2)) {
|
{
|
||||||
switch (buff->meta->int_param3) {
|
if (weapon_meta->Match((CondAddBuff_e)cond, buff->meta->int_param3)) {
|
||||||
case kWeaponOptTakeon:
|
switch (buff->meta->int_param2) {
|
||||||
{
|
case kWeaponOptTakeon:
|
||||||
AddBuffs(buff->meta->int_param1, buff->meta->param4_int_list);
|
{
|
||||||
|
AddBuffs(buff->meta->int_param1, buff->meta->param4_int_list);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kWeaponOptKeep:
|
||||||
|
{
|
||||||
|
TryAddBuffs(buff->meta->int_param1, buff->meta->param4_int_list);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case kWeaponOptKeep:
|
|
||||||
{
|
|
||||||
TryAddBuffs(buff->meta->int_param1, buff->meta->param4_int_list);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,8 +218,8 @@ void Trigger::ActiveBuff(MetaData::Buff* buff_meta)
|
|||||||
(cond,
|
(cond,
|
||||||
[this, cond, buff_meta] (Buff* buff, bool& stop)
|
[this, cond, buff_meta] (Buff* buff, bool& stop)
|
||||||
{
|
{
|
||||||
if (buff_meta->Match((CondAddBuff_e)cond, buff->meta->int_param2)) {
|
if (buff_meta->Match((CondAddBuff_e)cond, buff->meta->int_param3)) {
|
||||||
switch (buff->meta->int_param3) {
|
switch (buff->meta->int_param2) {
|
||||||
case kBuffOptActive:
|
case kBuffOptActive:
|
||||||
{
|
{
|
||||||
AddBuffs(buff->meta->int_param1, buff->meta->param4_int_list);
|
AddBuffs(buff->meta->int_param1, buff->meta->param4_int_list);
|
||||||
@ -243,8 +247,8 @@ void Trigger::DeactiveBuff(MetaData::Buff* buff_meta)
|
|||||||
(cond,
|
(cond,
|
||||||
[this, cond, buff_meta] (Buff* buff, bool& stop)
|
[this, cond, buff_meta] (Buff* buff, bool& stop)
|
||||||
{
|
{
|
||||||
if (buff_meta->Match((CondAddBuff_e)cond, buff->meta->int_param2)) {
|
if (buff_meta->Match((CondAddBuff_e)cond, buff->meta->int_param3)) {
|
||||||
switch (buff->meta->int_param3) {
|
switch (buff->meta->int_param2) {
|
||||||
case kBuffOptDeactive:
|
case kBuffOptDeactive:
|
||||||
case kBuffOptKeep:
|
case kBuffOptKeep:
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user