void Player::Respawn() { if (IsDead() == false) { return; } m_position = m_respawnPosition; // Make sure we create a chunk in the respawn position UpdateGridPosition(); m_pChunkManager->CreateNewChunk(GetGridX(), GetGridY(), GetGridZ()); m_health = m_maxHealth; VoxGame::GetInstance()->GetHUD()->UpdatePlayerData(); // Also go through all the equipped items and equip them for (int i = 0; i < EquipSlot_NumSlots; i++) { InventoryItem* pItem = m_pInventoryManager->GetInventoryItemForEquipSlot((EquipSlot)i); if (pItem != NULL) { EquipItem(pItem, true); } } m_dead = false; }
void Character::MoveByDelta ( Real ForwardDelta, Real SideDelta) { if(Health <= 0) { EquipItem(9); return; } Position NewLocation = Location; if(ForwardDelta != 0) { NewLocation.x += ( -ForwardDelta ) * (float)(*m_cos)(Location.Yaw + RADIAN(90)); NewLocation.z += ( ForwardDelta ) * (float)(*m_sin)(Location.Yaw + RADIAN(90)); } if(SideDelta != 0) { NewLocation.x += ( SideDelta ) * (float)(*m_cos)(Location.Yaw ); NewLocation.z += ( -SideDelta ) * (float)(*m_sin)(Location.Yaw ); } if(ForwardDelta !=0 || SideDelta != 0) { TargetVelocity.x = NewLocation.x - Location.x; TargetVelocity.z = NewLocation.z - Location.z; } }
ZCharacterItem::ZCharacterItem() { //memset(&m_Items, 0, sizeof(m_Items)); m_nSelectedWeapon = MMCIP_END; // 우선 임의로 아이템 지급 #ifndef _PUBLISH EquipItem(MMCIP_MELEE, 2); // knife EquipItem(MMCIP_PRIMARY, 4); // rifle EquipItem(MMCIP_SECONDARY, 7); EquipItem(MMCIP_CUSTOM1, 11); // grenade // SelectWeapon(MMCIP_PRIMARY); m_Items[MMCIP_PRIMARY].InitBullet(999, 999); m_Items[MMCIP_SECONDARY].InitBullet(999, 999); m_Items[MMCIP_CUSTOM1].InitBullet(10, 10); #endif }
uint32_t MoveEvent::fireEquip(Player* player, Item* item, slots_t slot, bool boolean) { if (scripted) { if (getEventType() == MOVE_EVENT_EQUIP) { EquipItem(this, player, item, slot, boolean); } else if (getEventType() == MOVE_EVENT_DEEQUIP) { DeEquipItem(this, player, item, slot, boolean); } return executeEquip(player, item, slot); } else { return equipFunction(this, player, item, slot, boolean); } }
void LuaManager::LuaLoadGame() { //PRE: save game data, stored in the luasavegamedata struct //POST: loads this data into the lua script. //get the function name from lua lua_getglobal( VM, "loadgame" ); //call the function, currently with 0 arguments and 19 result lua_call( VM, 0, 19 ); lua_pushnumber(VM, LuaSaveGameData.count ); lua_pushnumber(VM, LuaSaveGameData.getinitialitemscounter ); lua_pushnumber(VM, LuaSaveGameData.flipper ); lua_pushnumber(VM, LuaSaveGameData.sammichcount); lua_pushnumber(VM, LuaSaveGameData.flsammichcount); lua_pushnumber(VM, LuaSaveGameData.gbsammichcount); lua_pushstring( VM, LuaSaveGameData.poesammichtype.c_str()); //lua_pushstring( VM, LuaSaveGameData.head.c_str() ); //lua_pushstring( VM, LuaSaveGameData.chest.c_str() ); //lua_pushstring( VM, LuaSaveGameData.arms.c_str() ); //lua_pushstring( VM, LuaSaveGameData.legs.c_str() ); //lua_pushstring( VM, LuaSaveGameData.feet.c_str() ); //lua_pushstring( VM, LuaSaveGameData.hands.c_str() ); EquipItem(LuaSaveGameData.head.c_str()); EquipItem(LuaSaveGameData.chest.c_str()); EquipItem(LuaSaveGameData.arms.c_str()); EquipItem(LuaSaveGameData.legs.c_str()); EquipItem(LuaSaveGameData.feet.c_str()); EquipItem(LuaSaveGameData.hands.c_str()); lua_pushnumber(VM, LuaSaveGameData.health ); lua_pushnumber(VM, LuaSaveGameData.maxhealth); lua_pushnumber(VM, LuaSaveGameData.attack ); lua_pushnumber(VM, LuaSaveGameData.defense ); lua_pushnumber(VM, LuaSaveGameData.damage ); lua_pushnumber(VM, LuaSaveGameData.armor ); }
void GStateScene::ShopInputEvent(GnInterface* pInterface, GnIInputEvent* pEvent) { if( pEvent->GetEventType() == GnIInputEvent::PUSH ) { if( pInterface->GetTegID() == GInterfaceLayer::LISTITEM_SHOP ) { if( ViewItemExplain( mpCurrentShopItem, pInterface ) ) { if( mpCurrentInvenItem ) mpCurrentInvenItem->SetVisibleExplain( false ); if( mpCurrentEquipItem ) mpCurrentEquipItem->SetVisibleExplain( false ); } } else if( pInterface->GetTegID() == GInterfaceLayer::LISTITEM_INVEN ) { if( ViewItemExplain( mpCurrentInvenItem, pInterface ) ) { if( mpCurrentShopItem ) mpCurrentShopItem->SetVisibleExplain( false ); if( mpCurrentEquipItem ) mpCurrentEquipItem->SetVisibleExplain( false ); } } else { if( ViewItemExplain( mpCurrentEquipItem, pInterface ) ) { if( mpCurrentShopItem ) mpCurrentShopItem->SetVisibleExplain( false ); if( mpCurrentInvenItem ) mpCurrentInvenItem->SetVisibleExplain( false ); } } } else if( pEvent->GetEventType() == GnIInputEvent::PUSHUP ) { GStateUILayer* interfaceLayer = (GStateUILayer*)mpInterfaceLayer; switch( pInterface->GetTegID() ) { case GInterfaceLayer::BT_BUY_ITEM: BuyItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl() , interfaceLayer->GetMoneyLabel(), mpCurrentShopItem ); break; case GInterfaceLayer::BT_SELL_ITEM: if( SellItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl() , interfaceLayer->GetMoneyLabel(), mpCurrentInvenItem ) == 0 ) { if( mpCurrentInvenItem ) { mpCurrentInvenItem->SetVisibleExplain( false ); mpCurrentInvenItem = NULL; } } break; case GInterfaceLayer::BT_EQUIP_ITEM: EquipItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl() , mpCurrentInvenItem ); // if( mpCurrentInvenItem ) // { // mpCurrentInvenItem->SetVisibleExplain( false ); // mpCurrentInvenItem = NULL; // } break; case GInterfaceLayer::BT_UNEQUIP_ITEM: UnEquipItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl() , mpCurrentEquipItem ); if( mpCurrentEquipItem ) { mpCurrentEquipItem->SetVisibleExplain( false ); mpCurrentEquipItem = NULL; } break; } } }
void RPG_InventoryHandler::EquipWeapon(int inventorySlot) { EquipItem(ES_Weapon, inventorySlot); }
void RPG_InventoryHandler::EquipArmor(RPG_EquipmentSlot_e armorSlot, int inventorySlot) { EquipItem(armorSlot, inventorySlot); }
int Inventory::AddSlotItem(CREItem* item, int slot, int slottype) { int twohanded = item->Flags&IE_INV_ITEM_TWOHANDED; if (slot >= 0) { if ((unsigned)slot >= Slots.size()) { InvalidSlot(slot); return ASI_FAILED; } //check for equipping weapons if (WhyCantEquip(slot,twohanded)) { return ASI_FAILED; } if (!Slots[slot]) { item->Flags |= IE_INV_ITEM_ACQUIRED; SetSlotItem(item, slot); EquipItem(slot); return ASI_SUCCESS; } CREItem *myslot = Slots[slot]; if (ItemsAreCompatible( myslot, item )) { //calculate with the max movable stock int chunk = item->Usages[0]; int newamount = myslot->Usages[0]+chunk; if (newamount>myslot->StackAmount) { newamount=myslot->StackAmount; chunk = item->Usages[0]-newamount; } if (!chunk) { return -1; } myslot->Flags |= IE_INV_ITEM_ACQUIRED; myslot->Usages[0] = (ieWord) (myslot->Usages[0] + chunk); item->Usages[0] = (ieWord) (item->Usages[0] - chunk); Changed = true; EquipItem(slot); if (item->Usages[0] == 0) { delete item; return ASI_SUCCESS; } return ASI_PARTIAL; } return ASI_FAILED; } bool which; if (slot==SLOT_AUTOEQUIP) { which=true; } else { which=false; } int res = ASI_FAILED; int max = (int) Slots.size(); for (int i = 0;i<max;i++) { //never autoequip in the magic slot! if (i==SLOT_MAGIC) continue; if ((i<SLOT_INV || i>LAST_INV)!=which) continue; if (!(core->QuerySlotType(i)&slottype)) continue; //the slot has been disabled for this actor if (i>=SLOT_MELEE && i<=LAST_MELEE) { if (Owner->GetQuickSlot(i-SLOT_MELEE)==0xffff) { continue; } } int part_res = AddSlotItem (item, i); if (part_res == ASI_SUCCESS) return ASI_SUCCESS; else if (part_res == ASI_PARTIAL) res = ASI_PARTIAL; } return res; }
void Inventory::KillSlot(unsigned int index) { if (InventoryType==INVENTORY_HEAP) { Slots.erase(Slots.begin()+index); return; } CREItem *item = Slots[index]; if (!item) { return; } //the used up item vanishes from the quickslot bar if (Owner->InParty) { core->SetEventFlag( EF_ACTION ); } Slots[index] = NULL; int effect = core->QuerySlotEffects( index ); if (!effect) { return; } RemoveSlotEffects( index ); Item *itm = gamedata->GetItem(item->ItemResRef); //this cannot happen, but stuff happens! if (!itm) { return; } ItemExcl &= ~itm->ItemExcl; switch (effect) { case SLOT_EFFECT_LEFT: UpdateShieldAnimation(0); break; case SLOT_EFFECT_MISSILE: //getting a new projectile of the same type if (Equipped + SLOT_MELEE == (int) index) { if (Equipped < 0) { //always get the projectile weapon header (this quiver was equipped) ITMExtHeader *header = itm->GetWeaponHeader(true); Equipped = FindRangedProjectile(header->ProjectileQualifier); if (Equipped!=IW_NO_EQUIPPED) { EquipItem(Equipped+SLOT_MELEE); } else { EquipItem(SLOT_FIST); } } } UpdateWeaponAnimation(); break; case SLOT_EFFECT_MELEE: // reset Equipped if it was the removed item if (Equipped+SLOT_MELEE == (int)index) Equipped = IW_NO_EQUIPPED; else if (Equipped < 0) { //always get the projectile weapon header (this is a bow, because Equipped is negative) ITMExtHeader *header = itm->GetWeaponHeader(true); if (header) { //find the equipped type int type = header->ProjectileQualifier; int weaponslot = FindTypedRangedWeapon(type); CREItem *item2 = Slots[weaponslot]; if (item2) { Item *itm2 = gamedata->GetItem(item2->ItemResRef); if (itm2) { if (type == header->ProjectileQualifier) { Equipped = FindRangedProjectile(header->ProjectileQualifier); if (Equipped!=IW_NO_EQUIPPED) { EquipItem(Equipped+SLOT_MELEE); } else { EquipItem(SLOT_FIST); } } gamedata->FreeItem(itm2, item2->ItemResRef, false); } } } } // reset Equipped if it is a ranged weapon slot // but not magic weapon slot! UpdateWeaponAnimation(); break; case SLOT_EFFECT_HEAD: Owner->SetUsedHelmet(""); break; case SLOT_EFFECT_ITEM: //remove the armor type only if this item is responsible for it if ((ieDword) (itm->AnimationType[0]-'1') == Owner->GetBase(IE_ARMOR_TYPE)) { Owner->SetBase(IE_ARMOR_TYPE, 0); } break; } gamedata->FreeItem(itm, item->ItemResRef, false); }
void Inventory::EquipBestWeapon(int flags) { int i; int damage = -1; ieDword best_slot = SLOT_FIST; ITMExtHeader *header; CREItem *Slot; char AnimationType[2]={0,0}; ieWord MeleeAnimation[3]={100,0,0}; //cannot change equipment when holding magic weapons if (Equipped == SLOT_MAGIC-SLOT_MELEE) { return; } if (flags&EQUIP_RANGED) { for(i=SLOT_RANGED;i<LAST_RANGED;i++) { const Item *itm = GetItemPointer(i, Slot); if (!itm) continue; //best ranged int tmp = itm->GetDamagePotential(true, header); if (tmp>damage) { best_slot = i; damage = tmp; memcpy(AnimationType,itm->AnimationType,sizeof(AnimationType) ); memcpy(MeleeAnimation,header->MeleeAnimation,sizeof(MeleeAnimation) ); } gamedata->FreeItem( itm, Slot->ItemResRef, false ); } //ranged melee weapons like throwing daggers (not bows!) for(i=SLOT_MELEE;i<=LAST_MELEE;i++) { const Item *itm = GetItemPointer(i, Slot); if (!itm) continue; //best ranged int tmp = itm->GetDamagePotential(true, header); if (tmp>damage) { best_slot = i; damage = tmp; memcpy(AnimationType,itm->AnimationType,sizeof(AnimationType) ); memcpy(MeleeAnimation,header->MeleeAnimation,sizeof(MeleeAnimation) ); } gamedata->FreeItem( itm, Slot->ItemResRef, false ); } } if (flags&EQUIP_MELEE) { for(i=SLOT_MELEE;i<=LAST_MELEE;i++) { const Item *itm = GetItemPointer(i, Slot); if (!itm) continue; //the Slot flag is enough for this //though we need animation type/damagepotential anyway if (Slot->Flags&IE_INV_ITEM_BOW) continue; //best melee int tmp = itm->GetDamagePotential(false, header); if (tmp>damage) { best_slot = i; damage = tmp; memcpy(AnimationType,itm->AnimationType,sizeof(AnimationType) ); memcpy(MeleeAnimation,header->MeleeAnimation,sizeof(MeleeAnimation) ); } gamedata->FreeItem( itm, Slot->ItemResRef, false ); } } EquipItem(best_slot); UpdateWeaponAnimation(); }
void UAREquipmentComponent::ServerEquipItem_Implementation(FARDragDropInfo ItemIn) { EquipItem(ItemIn); }