add GMAddItem
This commit is contained in:
parent
2751f3ff4d
commit
8d66e35778
@ -3507,3 +3507,81 @@ void Human::UpdateViewObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Human::GMAddItem(int item_id, int item_num)
|
||||||
|
{
|
||||||
|
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(item_id);
|
||||||
|
if (!item_meta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (item_meta->i->_inventory_slot() >= 0 &&
|
||||||
|
item_meta->i->_inventory_slot() < IS_END) {
|
||||||
|
if (GetInventory(item_meta->i->_inventory_slot()) >=
|
||||||
|
GetVolume(item_meta->i->_inventory_slot())
|
||||||
|
) {
|
||||||
|
/*
|
||||||
|
cs::SMPickup notifymsg;
|
||||||
|
notifymsg.set_error_code(1);
|
||||||
|
SendNotifyMsg(notifymsg);
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int add_num = GetVolume(item_meta->i->_inventory_slot()) -
|
||||||
|
GetInventory(item_meta->i->_inventory_slot());
|
||||||
|
add_num = std::min(item_num, add_num);
|
||||||
|
|
||||||
|
AddInventory(item_meta->i->_inventory_slot(), add_num);
|
||||||
|
switch (item_meta->i->_inventory_slot()) {
|
||||||
|
case IS_FRAG:
|
||||||
|
case IS_SMOKE:
|
||||||
|
{
|
||||||
|
Weapon* weapon = &weapons[SPEC1_SLOT_BEGIN +
|
||||||
|
(item_meta->i->_inventory_slot() - SPEC1_IS_BEGIN)
|
||||||
|
];
|
||||||
|
weapon->weapon_id = item_id;
|
||||||
|
weapon->weapon_lv = 1;
|
||||||
|
weapon->ammo += item_num;
|
||||||
|
weapon->meta = item_meta;
|
||||||
|
weapon->Recalc();
|
||||||
|
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IS_1XSCOPE:
|
||||||
|
case IS_2XSCOPE:
|
||||||
|
case IS_4XSCOPE:
|
||||||
|
case IS_8XSCOPE:
|
||||||
|
case IS_15XSCOPE:
|
||||||
|
{
|
||||||
|
if (item_meta->i->_inventory_slot() - IS_1XSCOPE > curr_scope_idx) {
|
||||||
|
curr_scope_idx = item_meta->i->_inventory_slot() - IS_1XSCOPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IS_POSION_GAS_BOMB:
|
||||||
|
case IS_MOLOTOR_COCKTAIL:
|
||||||
|
case IS_TRAP:
|
||||||
|
case IS_MINE:
|
||||||
|
{
|
||||||
|
Weapon* weapon = &weapons[SPEC2_SLOT_BEGIN +
|
||||||
|
(item_meta->i->_inventory_slot() - SPEC2_IS_BEGIN)
|
||||||
|
];
|
||||||
|
weapon->weapon_id = item_id;
|
||||||
|
weapon->weapon_lv = 1;
|
||||||
|
weapon->ammo += item_num;
|
||||||
|
weapon->meta = item_meta;
|
||||||
|
weapon->Recalc();
|
||||||
|
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
abort();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
need_sync_active_player = true;
|
||||||
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
|
}
|
||||||
|
@ -245,6 +245,7 @@ class Human : public Creature
|
|||||||
void DeadDrop();
|
void DeadDrop();
|
||||||
virtual std::string GetName() override { return name;};
|
virtual std::string GetName() override { return name;};
|
||||||
void UpdateViewObjects();
|
void UpdateViewObjects();
|
||||||
|
void GMAddItem(int item_id, int item_num);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _InternalUpdateMove(float speed);
|
void _InternalUpdateMove(float speed);
|
||||||
|
@ -1102,6 +1102,10 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg)
|
|||||||
std::string cmd = cmds[0];
|
std::string cmd = cmds[0];
|
||||||
if (cmd == "gps") {
|
if (cmd == "gps") {
|
||||||
SendDebugMsg(a8::Format("%d %d", {GetPos().x, GetPos().y}));
|
SendDebugMsg(a8::Format("%d %d", {GetPos().x, GetPos().y}));
|
||||||
|
}else if (cmd == "additem" && cmds.size() >= 2) {
|
||||||
|
int item_id = a8::XValue(cmds[1]);
|
||||||
|
int item_num = a8::XValue(cmds[2]);
|
||||||
|
GMAddItem(item_id, item_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user