81 lines
2.4 KiB
C++
81 lines
2.4 KiB
C++
#include "precompile.h"
|
|
|
|
#include "buff/machine_gun.h"
|
|
|
|
#include "creature.h"
|
|
#include "trigger.h"
|
|
#include "room.h"
|
|
|
|
#include "mt/Buff.h"
|
|
#include "mt/Equip.h"
|
|
#include "mt/Skill.h"
|
|
#include "mt/SkillNumber.h"
|
|
|
|
void MachineGunBuff::Activate()
|
|
{
|
|
SwitchWeapons();
|
|
ProcSkill();
|
|
}
|
|
|
|
void MachineGunBuff::Deactivate()
|
|
{
|
|
owner->GetTrigger()->DispatchEvent(kEndSwitchWeaponBuffEvent, {this});
|
|
RecoverHoldWeapons();
|
|
}
|
|
|
|
void MachineGunBuff::SwitchWeapons()
|
|
{
|
|
hold_curr_weapon_idx_ = caster_.Get()->GetCurrWeapon()->weapon_idx;
|
|
{
|
|
std::vector<std::string> strings;
|
|
a8::Split(meta->buff_param1(), strings, ':');
|
|
for (size_t i = 0; i < strings.size(); ++i) {
|
|
int weapon_id = a8::XValue(strings[i]);
|
|
const mt::Equip* weapon_meta = mt::Equip::GetById(weapon_id);
|
|
if (weapon_meta && i < caster_.Get()->weapons.size()) {
|
|
int weapon_idx = weapon_meta->GetWeaponIdx();
|
|
if (weapon_idx >= 0 && weapon_idx < caster_.Get()->weapons.size()) {
|
|
Weapon* weapon = &caster_.Get()->weapons[weapon_idx];
|
|
hold_weapons_.push_back(*weapon);
|
|
|
|
weapon->weapon_uniid = 0;
|
|
weapon->weapon_id = weapon_meta->id();
|
|
weapon->meta = weapon_meta;
|
|
weapon->skill_meta = skill_meta;
|
|
weapon->Recalc();
|
|
weapon->ammo = weapon->GetClipVolume(owner);
|
|
if (i == 0) {
|
|
caster_.Get()->SetCurrWeapon(weapon);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
caster_.Get()->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
|
|
caster_.Get()->UpdateCharImage(__FILE__, __LINE__, __func__);
|
|
}
|
|
}
|
|
|
|
void MachineGunBuff::ProcSkill()
|
|
{
|
|
if (skill_meta && skill_meta->_number_meta) {
|
|
switch (skill_meta->GetMagicId()) {
|
|
case MAGIC_20201_HX:
|
|
{
|
|
owner->room->xtimer.ModifyTime
|
|
(remover_timer,
|
|
skill_meta->_number_meta->_float_time * 1000 / FRAME_RATE_MS);
|
|
owner->GetTrigger()->DispatchEvent(kStartSwitchWeaponBuffEvent, {this});
|
|
}
|
|
break;
|
|
case MAGIC_20401_MAO:
|
|
{
|
|
}
|
|
break;
|
|
default:
|
|
{
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|