void DropShortcut::dropItems(int cnt) { if (!player_node) return; if (player_node->isServerBuggy()) { dropItem(player_node->getQuickDropCounter()); return; } int n = 0; for (int f = 0; f < 9; f++) { for (int i = 0; i < player_node->getQuickDropCounter(); i++) { if (!Client::limitPackets(PACKET_DROP)) return; if (dropItem()) n++; } if (n >= cnt) break; } }
void qtractorFileListView::dropEvent ( QDropEvent *pDropEvent ) { QTreeWidgetItem *pDropItem = dragDropItem(pDropEvent->pos()); if (!canDropItem(pDropItem)) { dragLeaveEvent(NULL); m_pDragItem = NULL; return; } // Not quite parent, but the exact drop target... qtractorFileGroupItem *pParentItem = static_cast<qtractorFileGroupItem *> (pDropItem); const bool bOutdent = (pDropEvent->pos().x() < QTreeWidget::indentation()); // Get access to the pertinent drop data... int iUpdate = 0; const QMimeData *pMimeData = pDropEvent->mimeData(); // Let's see how many files there are... if (pMimeData->hasUrls()) { QListIterator<QUrl> iter(pMimeData->urls()); iter.toBack(); while (iter.hasPrevious()) { const QString& sPath = iter.previous().toLocalFile(); // Is it one from ourselves (file item) ?... if (m_pDragItem && m_pDragItem->type() == FileItem) { if (dropItem(pDropItem, findItem(sPath, FileItem), bOutdent)) ++iUpdate; } else if (addFileItem(sPath, pParentItem)) ++iUpdate; } } else if (pMimeData->hasText()) { // Maybe its just a new convenience group... const QString& sText = pMimeData->text(); // Is it one from ourselves (group item) ?... if (m_pDragItem && m_pDragItem->type() == GroupItem) { if (dropItem(pDropItem, findItem(sText, GroupItem), bOutdent)) ++iUpdate; } else if (addGroupItem(sText, pParentItem)) ++iUpdate; } // Teke care of change modification... if (iUpdate > 0) { // Make parent open, anyway... qtractorFileGroupItem *pGroupItem = groupItem(pDropItem); if (pGroupItem) pGroupItem->setOpen(true); // Notify that we've changed something. emit contentsChanged(); } dragLeaveEvent(NULL); m_pDragItem = NULL; }
void EntitySkeleton::dropFewItems() { int i = rand.nextInt(3); for(int j = 0; j < i; j++) { dropItem(Item.arrow.shiftedIndex, 1); } i = rand.nextInt(3); for(int k = 0; k < i; k++) { dropItem(Item.bone.shiftedIndex, 1); } }
/* * Sets entry->curItem to new found heap item pointer for one * entry of one scan key */ static bool entryGetItem(Relation index, GinScanEntry entry) { if (entry->master) { entry->isFinished = entry->master->isFinished; entry->curItem = entry->master->curItem; } else if (!BufferIsValid(entry->buffer)) { entry->offset++; if (entry->offset <= entry->nlist) entry->curItem = entry->list[entry->offset - 1]; else { ItemPointerSet(&entry->curItem, InvalidBlockNumber, InvalidOffsetNumber); entry->isFinished = TRUE; } } else { do { entryGetNextItem(index, entry); } while (entry->isFinished == FALSE && entry->reduceResult == TRUE && dropItem(entry)); } return entry->isFinished; }
bool GameLevel::dropItemClosestEmptyTile(Item& item, const Actor& actor, const Misc::Point& position, Misc::Direction direction) { auto tryDrop = [&](const Misc::Point& pos) { bool res = false; if (isPassable(pos, &actor) && !mItemMap->getItemAt(pos)) res = dropItem(std::unique_ptr<Item>{new Item(item)}, actor, FAWorld::Tile(pos)); return res; }; if (direction == Misc::Direction::none) { if (tryDrop(position)) return true; direction = Misc::Direction::south; } constexpr auto directionCnt = 8; for (auto diff : {0, -1, 1}) { auto dir = static_cast<Misc::Direction>((static_cast<int32_t>(direction) + diff + directionCnt) % directionCnt); auto pos = Misc::getNextPosByDir(position, dir); if (tryDrop(pos)) return true; } return tryDrop(position); }
void EntityChicken::onLivingUpdate() { super.onLivingUpdate(); field_756_e = field_752_b; field_757_d = destPos; destPos += (double)(onGround ? -1 : 4) * 0.29999999999999999; if(destPos < 0.0F) { destPos = 0.0F; } if(destPos > 1.0F) { destPos = 1.0F; } if(!onGround && field_755_h < 1.0F) { field_755_h = 1.0F; } field_755_h *= 0.90000000000000002; if(!onGround && motionY < 0.0D) { motionY *= 0.59999999999999998; } field_752_b += field_755_h * 2.0F; if(!worldObj.multiplayerWorld && --timeUntilNextEgg <= 0) { worldObj.playSoundAtEntity(this, "mob.chickenplop", 1.0F, (rand.nextFloat() - rand.nextFloat()) * 0.2 + 1.0F); dropItem(Item.egg.shiftedIndex, 1); timeUntilNextEgg = rand.nextInt(6000) + 6000; } }
void ContainerWindow::onItemSelected(int index) { if (mDragAndDrop->mIsOnDragAndDrop) { dropItem(); return; } const ItemStack& item = mSortModel->getItem(index); // We can't take a conjured item from a container (some NPC we're pickpocketing, a box, etc) if (item.mFlags & ItemStack::Flag_Bound) { MWBase::Environment::get().getWindowManager()->messageBox("#{sContentsMessage1}"); return; } MWWorld::Ptr object = item.mBase; int count = item.mCount; bool shift = MyGUI::InputManager::getInstance().isShiftPressed(); if (MyGUI::InputManager::getInstance().isControlPressed()) count = 1; mSelectedItem = mSortModel->mapToSource(index); if (count > 1 && !shift) { CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog(); dialog->openCountDialog(object.getClass().getName(object), "#{sTake}", count); dialog->eventOkClicked.clear(); dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem); } else dragItem (NULL, count); }
void ContainerWindow::onItemSelected(int index) { if (mDragAndDrop->mIsOnDragAndDrop) { if (!dynamic_cast<PickpocketItemModel*>(mModel)) dropItem(); return; } const ItemStack& item = mSortModel->getItem(index); MWWorld::Ptr object = item.mBase; int count = item.mCount; bool shift = MyGUI::InputManager::getInstance().isShiftPressed(); if (MyGUI::InputManager::getInstance().isControlPressed()) count = 1; mSelectedItem = mSortModel->mapToSource(index); if (count > 1 && !shift) { CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog(); dialog->open(MWWorld::Class::get(object).getName(object), "#{sTake}", count); dialog->eventOkClicked.clear(); dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem); } else dragItem (NULL, count); }
void SnakeEntity::drop() { if (!invocated) { if (rand() % 5 == 0) { dropItem(ItemCopperCoin); } if (game().getPlayer()->isEquiped(EQUIP_LUCK) && rand() % 5 == 0) { dropItem(ItemCopperCoin); } if (rand() % 25 == 0) { dropItem(ItemHealthVerySmallPoison); } } }
void pickUpItem(character *actor, item *itm) { item *itmPtr; if (itm->itemFlags & IS_WEAPON) { itmPtr = actorGetItemWithFlag(actor, IS_WEAPON); if (itmPtr) { dropItem(actor, itmPtr); } } else if ((itm->itemFlags & (IS_ARMOR | ARE_BOOTS)) == (IS_ARMOR | ARE_BOOTS)) { itmPtr = actorGetItemWithFlag(actor, IS_ARMOR | ARE_BOOTS); if (itmPtr) { dropItem(actor, itmPtr); } } else if ((itm->itemFlags & (IS_ARMOR | IS_CHEST_ARMOR)) == (IS_ARMOR | IS_CHEST_ARMOR)) { itmPtr = actorGetItemWithFlag(actor, IS_ARMOR | IS_CHEST_ARMOR); if (itmPtr) { dropItem(actor, itmPtr); } } else if ((itm->itemFlags & (IS_ARMOR | IS_AMULET)) == (IS_ARMOR | IS_AMULET)) { itmPtr = actorGetItemWithFlag(actor, IS_ARMOR | IS_AMULET); if (itmPtr) { dropItem(actor, itmPtr); } } itm->owner = actor; actor->inventory[actor->numberOfItems] = itm; actor->numberOfItems ++; if (actor == getPlayer()) { showMessage(10, "You pick up <", itm->name, ">", NULL); } }
void KyraEngine_LoK::processInput(int xpos, int ypos) { if (processInputHelper(xpos, ypos)) return; uint8 item = findItemAtPos(xpos, ypos); if (item == 0xFF) { _changedScene = false; int handled = clickEventHandler(xpos, ypos); if (_changedScene || handled) return; } // XXX _deathHandler specific if (ypos <= 158) { uint16 exit = 0xFFFF; if (xpos < 12) exit = _walkBlockWest; else if (xpos >= 308) exit = _walkBlockEast; else if (ypos >= 136) exit = _walkBlockSouth; else if (ypos < 12) exit = _walkBlockNorth; if (exit != 0xFFFF) { handleSceneChange(xpos, ypos, 1, 1); return; } else { int script = checkForNPCScriptRun(xpos, ypos); if (script >= 0) { runNpcScript(script); return; } if (_itemInHand != kItemNone) { if (ypos < 155) { if (hasClickedOnExit(xpos, ypos)) { handleSceneChange(xpos, ypos, 1, 1); return; } dropItem(0, _itemInHand, xpos, ypos, 1); } } else { if (ypos <= 155) handleSceneChange(xpos, ypos, 1, 1); } } } }
bool CDropManager::doDropOnceSelect(CPC* _pPC, CNPC* _pNPC , CDropInfo* _pDrop, const int _pos, bool _bPreferenceIndex) { if( _pDrop->getItemCount() == 0 ) return false; int pos = -1; if( _pos < 0 || _pos >= _pDrop->getItemCount() ) pos = GetRandom(0, _pDrop->getItemCount()-1); else pos = _pos; // if( !checkJob(_pDrop->getItemData(i)->getJobFlag(), _pPC->m_job ) ) // return false; if( !dropItem(_pPC, _pNPC, _pDrop->getItemData(pos), _bPreferenceIndex) ) return false; return true; }
void Enemy03::update(){ move(); hitCircleUpdate(); collision = active = isActive(); if(active){ shot(); } needDelete = ! isAlive(); if(life <= 0.0f){ ScoreMng.addScore(1000); PlaySound(SoundMng.get(SE_EXPLOSION02)); dropItem(); ObjectMng.set(ENEMY_EXPLOSION, new EnemyExplosion(ImageMng.get(EE_01), position)); } privActive = active; }
bool CDropManager::doDropRandom(CPC* _pPC, CNPC* _pNPC , CDropInfo* _pDrop, bool _bPreferenceIndex) { if( _pDrop->getItemCount() == 0 ) return false; int i=0; int itemCount = _pDrop->getItemCount(); for(i=0; i<itemCount; i++ ) { if( !checkJob(_pDrop->getItemData(i)->getJobFlag(), _pPC->m_job ) ) continue; if( !checkProbPerLevel(_pDrop->getItemData(i)->getProb(), _pPC->m_level-_pNPC->m_level, _pDrop->getProbPerLevel()) ) continue; if( !dropItem(_pPC, _pNPC, _pDrop->getItemData(i), _bPreferenceIndex) ) continue; } return true; }
void AscentApp::onKeyDown_Inventory(SDL_KeyboardEvent * keyEvent) { // If is an alphanumeric char, use char anchar = getalphanumeric(keyEvent); if (anchar != '\0') if (userInputRequested == InputType::InventoryItemToDrop) { dropItem(anchar); return; } // When implementing InventoryItemToView, need something here // Other key input types switch (keyEvent->keysym.sym) { case SDLK_F11: togglefullscreen(); break; case SDLK_ESCAPE: currentlyDisplaying = windowType::Map; userInputRequested = InputType::Standard; break; default: break; } }
bool CDropManager::doDropOnceRandom(CPC* _pPC, CNPC* _pNPC , CDropInfo* _pDrop,const int _prob, bool _bPreferenceIndex) { if( _pDrop->getItemCount() == 0 ) return false; int probPerLevel = getProbPerLevel( _pPC->m_level-_pNPC->m_level, _pDrop->getProbPerLevel() ); int prob = -1; if( _prob < 0 || _prob > 10000 ) prob = getRandom() - probPerLevel; else prob = _prob - probPerLevel; if( prob < 0 ) return false; int totalProb = 0; int i=0; int itemCount = _pDrop->getItemCount(); for(i=0; i<itemCount; i++ ) { totalProb += _pDrop->getItemData(i)->getProb(); // if( !checkJob(_pDrop->getItemData(i)->getJobFlag(), _pPC->m_job ) ) // continue; if( prob > totalProb ) continue; if( !dropItem(_pPC, _pNPC, _pDrop->getItemData(i), _bPreferenceIndex) ) return false; return true; } return true; }
void Menu::dropMenu() { dropItem(play); dropItem(playN); dropItem(quit); dropItem(option); dropItem(load); dropItem(cancelN); dropItem(cancelP); dropItem(one); dropItem(two); dropItem(three); dropItem(ia); }
void KyraEngine_HoF::handleInput(int x, int y) { setNextIdleAnimTimer(); if (_unk5) { _unk5 = 0; return; } if (!_screen->isMouseVisible()) return; if (_savedMouseState == -2) { snd_playSoundEffect(13); return; } setNextIdleAnimTimer(); if (x <= 6 || x >= 312 || y <= 6 || y >= 135) { bool exitOk = false; assert(_savedMouseState + 6 >= 0); switch (_savedMouseState + 6) { case 0: if (_sceneExit1 != 0xFFFF) exitOk = true; break; case 1: if (_sceneExit2 != 0xFFFF) exitOk = true; break; case 2: if (_sceneExit3 != 0xFFFF) exitOk = true; break; case 3: if (_sceneExit4 != 0xFFFF) exitOk = true; break; default: break; } if (exitOk) { inputSceneChange(x, y, 1, 1); return; } } if (checkCharCollision(x, y) && _savedMouseState >= -1) { runSceneScript2(); return; } else if (pickUpItem(x, y)) { return; } else { int skipHandling = 0; if (checkItemCollision(x, y) == -1) { resetGameFlag(0x1EF); skipHandling = handleInputUnkSub(x, y) ? 1 : 0; if (queryGameFlag(0x1EF)) { resetGameFlag(0x1EF); return; } if (_unk5) { _unk5 = 0; return; } } if (_deathHandler > -1) skipHandling = 1; if (skipHandling) return; if (checkCharCollision(x, y)) { runSceneScript2(); return; } if (_itemInHand >= 0) { if (y > 136) return; dropItem(0, _itemInHand, x, y, 1); } else { if (_savedMouseState == -2 || y > 135) return; if (!_unk5) { inputSceneChange(x, y, 1, 1); return; } _unk5 = 0; } } }
void consoleCommand(char *command_str) { node_t *node; Entity *entity; char name[64]; int c; if( !command_str ) return; if( !strncmp(command_str,"/ping",5) ) { if( multiplayer != CLIENT ) { messagePlayer(clientnum,language[1117],0); } else { strcpy((char *)net_packet->data,"PING"); net_packet->data[4] = clientnum; net_packet->address.host = net_server.host; net_packet->address.port = net_server.port; net_packet->len = 5; sendPacketSafe(net_sock, -1, net_packet, 0); pingtime = SDL_GetTicks(); } } else if (!strncmp(command_str, "/fov", 4)) { fov = atoi(&command_str[5]); fov = std::min(std::max<Uint32>(40,fov),100u); } else if (!strncmp(command_str, "/svflags ", 9)) { if( multiplayer==CLIENT ) { messagePlayer(clientnum,language[275]); } else { svFlags = atoi(&command_str[9]); messagePlayer(clientnum,language[276]); if( multiplayer==SERVER ) { // update client flags strcpy((char *)net_packet->data,"SVFL"); SDLNet_Write32(svFlags,&net_packet->data[4]); net_packet->len = 8; int c; for( c=1; c<MAXPLAYERS; c++ ) { if( client_disconnected[c] ) continue; net_packet->address.host = net_clients[c-1].host; net_packet->address.port = net_clients[c-1].port; sendPacketSafe(net_sock, -1, net_packet, c-1); messagePlayer(c,language[276]); } } } } else if( !strncmp(command_str,"/spawnitem ",11) ) { if( !(svFlags&SV_FLAG_CHEATS) ) { messagePlayer(clientnum,language[277]); return; } strcpy(name,command_str+11); for( c=0; c<NUMITEMS; c++ ) { if( strstr(items[c].name_identified, name) ) { dropItem(newItem(static_cast<ItemType>(c),EXCELLENT,0,1,rand(),TRUE,&stats[clientnum].inventory),0); break; } } if( c==NUMITEMS ) { messagePlayer(clientnum,language[278],name); } } else if( !strncmp(command_str,"/spawncursed ",13) ) { if( !(svFlags&SV_FLAG_CHEATS) ) { messagePlayer(clientnum,language[277]); return; } strcpy(name,command_str+13); for( c=0; c<NUMITEMS; c++ ) { if( strstr(items[c].name_identified, name) ) { dropItem(newItem(static_cast<ItemType>(c),WORN,-2,1,rand(),FALSE,&stats[clientnum].inventory),0); break; } } if( c==NUMITEMS ) { messagePlayer(clientnum,language[278],name); } } else if( !strncmp(command_str,"/kick ",6) ) { strcpy(name,command_str+6); if( multiplayer==SERVER ) { for( c=1; c<MAXPLAYERS; c++ ) { if( !client_disconnected[c] && !strncmp(name,stats[c].name,128) ) { client_disconnected[c] = TRUE; strcpy((char *)net_packet->data,"KICK"); net_packet->address.host = net_clients[c-1].host; net_packet->address.port = net_clients[c-1].port; net_packet->len = 4; sendPacketSafe(net_sock, -1, net_packet, c-1); int i; for( i=0; i<MAXPLAYERS; i++ ) { messagePlayer(i,language[279],c,stats[c].name); } break; } } if( c==MAXPLAYERS ) { messagePlayer(clientnum,language[280]); } } else if( multiplayer==CLIENT ) { messagePlayer(clientnum,language[281]); } else { messagePlayer(clientnum,language[282]); } } else if( !strncmp(command_str,"/spawnbook ",11) ) { if( !(svFlags&SV_FLAG_CHEATS) ) { messagePlayer(clientnum,language[277]); return; } strcpy(name,command_str+11); dropItem(newItem(READABLE_BOOK,EXCELLENT,0,1,getBook(name),TRUE,&stats[clientnum].inventory),0); } else if( !strncmp(command_str,"/savemap ",9) ) { if( command_str[9]!=0 ) { saveMap(command_str+9); messagePlayer(clientnum,language[283],command_str+9); } } else if( !strncmp(command_str,"/nextlevel",10) ) { if( !(svFlags&SV_FLAG_CHEATS) ) { messagePlayer(clientnum,language[277]); return; } if( multiplayer==CLIENT ) { messagePlayer(clientnum,language[284]); } else { messagePlayer(clientnum,language[285]); loadnextlevel=TRUE; } } else if( !strncmp(command_str,"/pos",4) ) { if( !(svFlags&SV_FLAG_CHEATS) ) { messagePlayer(clientnum,language[277]); return; } messagePlayer(clientnum,language[286],(int)camera.x,(int)camera.y,(int)camera.z,camera.ang,camera.vang); } else if( !strncmp(command_str,"/pathmap",4) ) { if( !(svFlags&SV_FLAG_CHEATS) ) { messagePlayer(clientnum,language[277]); return; } if( players[clientnum] ) { int x = std::min<int>(std::max(0.0,floor(players[clientnum]->x/16)),map.width-1); int y = std::min<int>(std::max(0.0,floor(players[clientnum]->y/16)),map.height-1); messagePlayer(clientnum,"pathMapGrounded value: %d",pathMapGrounded[y+x*map.height]); messagePlayer(clientnum,"pathMapFlying value: %d",pathMapFlying[y+x*map.height]); } } else if( !strncmp(command_str,"/exit",5) ) { mainloop=0; } else if( !strncmp(command_str,"/showfps",8) ) { showfps=(showfps==FALSE); } else if( !strncmp(command_str,"/noclip",7) ) { if( multiplayer!=SINGLE ) { messagePlayer(clientnum,language[287]); } else { noclip=(noclip==FALSE); if( noclip ) messagePlayer(clientnum,language[288]); else messagePlayer(clientnum,language[289]); } } else if( !strncmp(command_str,"/god",4) ) { if( multiplayer!=SINGLE ) { messagePlayer(clientnum,language[290]); } else { godmode=(godmode==FALSE); if( godmode ) messagePlayer(clientnum,language[291]); else messagePlayer(clientnum,language[292]); } } else if( !strncmp(command_str,"/buddha",7) ) { if( multiplayer!=SINGLE ) { messagePlayer(clientnum,language[293]); } else { buddhamode=(buddhamode==FALSE); if( buddhamode ) messagePlayer(clientnum,language[294]); else messagePlayer(clientnum,language[295]); } } else if( !strncmp(command_str,"/friendly",9) ) { if( !(svFlags&SV_FLAG_CHEATS) ) { messagePlayer(clientnum,language[277]); return; } if( multiplayer==CLIENT ) { messagePlayer(clientnum,language[284]); return; } everybodyfriendly=(everybodyfriendly==FALSE); if( everybodyfriendly ) messagePlayer(clientnum,language[296]); else messagePlayer(clientnum,language[297]); } else if( !strncmp(command_str,"/dowse",6) ) { if( !(svFlags&SV_FLAG_CHEATS) ) { messagePlayer(clientnum,language[277]); return; } for( node=map.entities->first; node!=NULL; node=node->next ) { entity = (Entity *)node->element; if( entity->behavior == &actLadder ) messagePlayer(clientnum,language[298],(int)(entity->x/16),(int)(entity->y/16)); } } else if( !strncmp(command_str,"/thirdperson",12) ) { if( !(svFlags&SV_FLAG_CHEATS) ) { messagePlayer(clientnum,language[277]); return; } if( players[clientnum] != NULL ) { players[clientnum]->skill[3]=(players[clientnum]->skill[3]==0); if( players[clientnum]->skill[3]==1 ) messagePlayer(clientnum,"thirdperson ON"); else messagePlayer(clientnum,"thirdperson OFF"); } } else if( !strncmp(command_str,"/res ",5) ) { xres = atoi(&command_str[5]); for( c=0; c<strlen(command_str); c++ ) { if( command_str[c] == 'x' ) { yres = atoi(&command_str[c+1]); break; } } } else if( !strncmp(command_str,"/rscale",7) ) { rscale = atoi(&command_str[8]); } else if( !strncmp(command_str,"/smoothlighting",15) ) { smoothlighting = (smoothlighting==0); } else if( !strncmp(command_str,"/fullscreen",11) ) { fullscreen = (fullscreen==0); } else if( !strncmp(command_str,"/shaking",8) ) { shaking = (shaking==0); } else if( !strncmp(command_str,"/bobbing",8) ) { bobbing = (bobbing==0); } else if( !strncmp(command_str,"/sfxvolume",10) ) { sfxvolume = atoi(&command_str[11]); } else if( !strncmp(command_str,"/musvolume",10) ) { musvolume = atoi(&command_str[11]); } else if( !strncmp(command_str,"/bind",5) ) { if( strstr(command_str,"IN_FORWARD") ) { impulses[IN_FORWARD] = atoi(&command_str[6]); printlog("Bound IN_FORWARD: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_LEFT") ) { impulses[IN_LEFT] = atoi(&command_str[6]); printlog("Bound IN_LEFT: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_BACK") ) { impulses[IN_BACK] = atoi(&command_str[6]); printlog("Bound IN_BACK: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_RIGHT") ) { impulses[IN_RIGHT] = atoi(&command_str[6]); printlog("Bound IN_RIGHT: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_TURNL") ) { impulses[IN_TURNL] = atoi(&command_str[6]); printlog("Bound IN_TURNL: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_TURNR") ) { impulses[IN_TURNR] = atoi(&command_str[6]); printlog("Bound IN_TURNR: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_UP") ) { impulses[IN_UP] = atoi(&command_str[6]); printlog("Bound IN_UP: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_DOWN") ) { impulses[IN_DOWN] = atoi(&command_str[6]); printlog("Bound IN_DOWN: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_CHAT") ) { impulses[IN_CHAT] = atoi(&command_str[6]); printlog("Bound IN_CHAT: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_COMMAND") ) { impulses[IN_COMMAND] = atoi(&command_str[6]); printlog("Bound IN_COMMAND: %d\n",atoi(&command_str[6])); } else if( strstr(command_str,"IN_STATUS") ) { impulses[IN_STATUS] = atoi(&command_str[6]); printlog("Bound IN_STATUS: %d\n",atoi(&command_str[6])); } else if (strstr(command_str, "IN_SPELL_LIST")) { impulses[IN_SPELL_LIST] = atoi(&command_str[6]); printlog( "Bound IN_SPELL_LIST: %d\n", atoi(&command_str[6])); } else if (strstr(command_str, "IN_CAST_SPELL")) { impulses[IN_CAST_SPELL] = atoi(&command_str[6]); printlog( "Bound IN_CAST_SPELL: %d\n", atoi(&command_str[6])); } else if (strstr(command_str, "IN_DEFEND")) { impulses[IN_DEFEND] = atoi(&command_str[6]); printlog( "Bound IN_DEFEND: %d\n", atoi(&command_str[6])); } else if (strstr(command_str, "IN_ATTACK")) { impulses[IN_ATTACK] = atoi(&command_str[6]); printlog( "Bound IN_ATTACK: %d\n", atoi(&command_str[6])); } else if (strstr(command_str, "IN_USE")) { impulses[IN_USE] = atoi(&command_str[6]); printlog( "Bound IN_USE: %d\n", atoi(&command_str[6])); } else { messagePlayer(clientnum,"Invalid binding."); } } else if( !strncmp(command_str,"/mousespeed",11) ) { mousespeed = atoi(&command_str[12]); } else if( !strncmp(command_str,"/reversemouse",13) ) { reversemouse = (reversemouse==0); } else if( !strncmp(command_str,"/smoothmouse",12) ) { smoothmouse = (smoothmouse==FALSE); } else if( !strncmp(command_str,"/mana", 4) ) { if( multiplayer == SINGLE ) { stats[clientnum].MP = stats[clientnum].MAXMP; } else { messagePlayer(clientnum,language[299]); } } else if( !strncmp(command_str,"/heal", 4) ) { if( multiplayer == SINGLE ) { stats[clientnum].HP = stats[clientnum].MAXHP; } else { messagePlayer(clientnum,language[299]); } } else if (!strncmp(command_str, "/ip ", 4)) { if( command_str[4]!=0 ) { strcpy(last_ip, command_str + 4); last_ip[strlen(last_ip)-1]=0; } } else if (!strncmp(command_str, "/port ", 6)) { if (command_str[6] != 0) { strcpy(last_port, command_str + 6); last_port[strlen(last_port)-1]=0; } } else if (!strncmp(command_str, "/noblood", 8)) { spawn_blood = (spawn_blood==FALSE); } else if(!strncmp(command_str, "/colorblind", 11)) { colorblind = (colorblind==FALSE); } else if (!strncmp(command_str, "/gamma", 6)) { std::stringstream ss; ss << command_str + 7; ss >> vidgamma; }
void ContainerWindow::onBackgroundSelected() { if (mDragAndDrop->mIsOnDragAndDrop && mModel && mModel->allowedToInsertItems()) dropItem(); }
void FileOrganiserWidget::addFile(const QString &pFileName, QStandardItem *pDropItem, const QAbstractItemView::DropIndicatorPosition &pDropPosition) { if (!pDropItem) // pDropItem is not valid, so... return; // Check that we are indeed dealing with a file QFileInfo fileInfo = pFileName; if (!fileInfo.isFile()) // We are not dealing with a file, so... return; // Check whether we are dropping a symbolic link QString fileName = pFileName; if (fileInfo.isSymLink()) // We are dropping a symbolic link, so retrieve its target fileName = fileInfo.symLinkTarget(); // Check whether the file exists if (QFileInfo(fileName).exists()) { // The target file exists, so add it above/on/below pDropItem, depending // on the drop position and only if the file isn't already present // First, determine the item that will own the file QStandardItem *newParentItem = parentItem(pDropItem, pDropPosition); // Second, if the file is not already owned, then add it to // newParentItem and this to the right place, depending on the value of // pDropPosition if (!ownedBy(fileName, newParentItem)) { QStandardItem *newFileItem = new QStandardItem(QIcon(FileIcon), QFileInfo(fileName).fileName()); newFileItem->setData(fileName, Item::Path); dropItem(pDropItem, pDropPosition, newParentItem, newFileItem); // Add the file to our file manager // Note: it doesn't matter whether or not the file is already being // monitored, since if that's the case then the current // instance will be ignored mFileManager->manage(fileName); // Resize the widget, just in case the new file takes more space // than is visible resizeToContents(); } else { // The file is already owned by newParentItem, so just repaint the // widget to make sure that the dragging & dropping overlay // disappears repaint(); } } }
void CyclopsEntity::drop() { dropItem(ItemBossHeart); }
void HoldBuildUI::LoadFinish() { m_TiledIdx = m_LoadPram.asInt(); TiledMapUI::getInstance()->SetTouchEnabled(false); MsgListNode::getInstance()->LoadMsg(m_RootWidget); auto layout_Bottom = m_RootWidget->getChildByName<Layout*>("Layout_Bottom"); auto btn_Close = layout_Bottom->getChildByName<Button*>("Btn_Close"); auto langId = (int)LanguageIdEnum::CloseLangId; auto langText = MultiLanguage::getInstance()->GetText(langId); btn_Close->setTitleText(langText); auto btn_Collect = layout_Bottom->getChildByName<Button*>("Btn_Collect"); langId = (int)LanguageIdEnum::PickUpAllLangId; langText = MultiLanguage::getInstance()->GetText(langId); btn_Collect->setTitleText(langText); btn_Close->addClickEventListener([this](Ref* sender) { SaveBagItem(); UnLoad(); MapUI::getInstance()->ShowBreadNum(); TiledMapUI::getInstance()->UpdateBuildStatus(m_TiledIdx, TiledMapUI::BuildStatus::Visit); }); btn_Collect->addClickEventListener([this](Ref* sender) { auto nowNum = GetBagItemNum(); auto bag_maxNum = UserData::getInstance()->GetUserData(UserDataEnum::BackPackMaxNum)->asInt(); auto saveItemNum = bag_maxNum - nowNum; auto iter = m_DropItem->begin(); while (iter != m_DropItem->end()) { int cfgId = iter->first; if (cfgId == (int)CfgIdEnum::GoldId) { SaveGold(); continue; } CfgDataRow dropItem(cfgId); // 是否占据背包格子,1:占据 bool isOcy = dropItem.GetValue(CfgField::NonSpace)->asInt() == 1; if (saveItemNum <= 0 && isOcy) { auto langId = (int)LanguageIdEnum::BakcPackSpaceNotEnoughId; auto langText = MultiLanguage::getInstance()->GetText(langId); //背包 空间不够 MoveText::getInstance()->AddDefaultTextData(m_RootWidget, langText); break; } auto bag_Iter = m_BagItem->begin(); while (bag_Iter != m_BagItem->end()) { if (bag_Iter->first == cfgId) { break; } bag_Iter++; } if (bag_Iter == m_BagItem->end()) { //背包里没有这种物品 if (!isOcy) { m_BagItem->push_back(pair<int, int>(cfgId, iter->second)); iter = m_DropItem->erase(iter); } else { if (iter->second <= saveItemNum) { saveItemNum -= iter->second; //背包空间不够保存一部分物品 m_BagItem->push_back(pair<int, int>(cfgId, iter->second)); iter = m_DropItem->erase(iter); }else { m_BagItem->push_back(pair<int, int>(cfgId, saveItemNum)); iter->second -= saveItemNum; saveItemNum = 0; } } }else { //背包里有这种物品 if (!isOcy) { bag_Iter->second += iter->second; iter = m_DropItem->erase(iter); } else { if (iter->second <= saveItemNum) { saveItemNum -= iter->second; bag_Iter->second += iter->second; iter = m_DropItem->erase(iter); }else { bag_Iter->second += saveItemNum; //背包空间不够保存一部分物品保存一部分到背包 iter->second -= saveItemNum; saveItemNum = 0; } } } } ShowItemList(m_BagItem, true); ShowItemList(m_DropItem, false); }); }
void KingRatEntity::drop() { dropItem(ItemBossHeart); }
void KyraEngine_MR::handleInput(int x, int y) { if (_inventoryState) return; setNextIdleAnimTimer(); if (_unk5) { _unk5 = 0; return; } if (!_screen->isMouseVisible()) return; if (_savedMouseState == -3) { snd_playSoundEffect(0x0D, 0x80); return; } setNextIdleAnimTimer(); int skip = 0; if (checkCharCollision(x, y) && _savedMouseState >= -1 && runSceneScript2()) { return; } else if (_itemInHand != 27 && pickUpItem(x, y, 1)) { return; } else if (checkItemCollision(x, y) == -1) { resetGameFlag(1); skip = runSceneScript1(x, y); if (queryGameFlag(1)) { resetGameFlag(1); return; } else if (_unk5) { _unk5 = 0; return; } } if (_deathHandler >= 0) skip = 1; if (skip) return; if (checkCharCollision(x, y)) { if (runSceneScript2()) return; } else if (_itemInHand >= 0 && _savedMouseState >= 0) { if (_itemInHand == 27) { makeCharFacingMouse(); } else if (y <= 187) { if (_itemInHand == 43) removeHandItem(); else dropItem(0, _itemInHand, x, y, 1); } return; } else if (_savedMouseState == -3) { return; } else { if (y > 187 && _savedMouseState > -4) return; if (_unk5) { _unk5 = 0; return; } } inputSceneChange(x, y, 1, 1); }
void ChestEntity::open() { isOpen = true; if (chestType >= ChestFairy) SoundManager::getInstance().playSound(SOUND_GLASS); else SoundManager::getInstance().playSound(SOUND_CHEST_OPENING); if (chestType == ChestBasic) { int r = rand()% 50; if (r == 0 && !game().getPlayer()->isEquiped(EQUIP_FLOOR_MAP)) dropItem(ItemFloorMap); else if (r == 1 && !game().getPlayer()->isEquiped(EQUIP_ALCOHOL)) dropItem(ItemAlcohol); else if (r == 2 && !game().getPlayer()->isEquiped(EQUIP_LUCK)) dropItem(ItemLuck); else if (r == 3 && !game().getPlayer()->isEquiped(EQUIP_FAIRY_POWDER) && game().getPlayer()->getFairieNumber() > 0) dropItem(ItemFairyPowder); else if (r < 10) { // consumable if (rand() % 3 == 0) { // scroll dropItem(ItemScrollRevelation); } else { // potion dropItem((enumItemType)(ItemPotion01 + rand() % NUMBER_UNIDENTIFIED)); } } else { // gold int r = 2 + rand() % 6; if (game().getPlayer()->isEquiped(EQUIP_LUCK)) r += 1 + rand() % 5; for (int i = 0; i < r; i++) { dropItem(ItemCopperCoin); } } // trap ! if (game().getLevel() >= 2 && !game().getPlayer()->isEquiped(EQUIP_DISPLACEMENT_GLOVES)) { if (rand() % 5 == 0) // trap { SoundManager::getInstance().playSound(SOUND_TRAP); int r; // no "earthquake" trap in insel rooms if (game().getCurrentMap()->isWalkable(1, 1)) r = rand() % 3; else r = 1 + rand() % 2; if (r == 1) { timer = 1.0f; trap = TrapExplosion; } else if (r == 2) { timer = 1.0f; trap = TrapSnakes; } else { timer = 0.5f; trap = TrapStones; } } } } else if (chestType >= ChestFairy) { enumItemType itemType = ItemFairy; switch (chestType - ChestFairy) { case FamiliarFairy: itemType = ItemFairy; break; case FamiliarFairyIce: itemType = ItemFairyIce; break; case FamiliarFairyFire: itemType = ItemFairyFire; break; case FamiliarFairyTarget: itemType = ItemFairyTarget; break; case FamiliarFairyPoison: itemType = ItemFairyPoison; break; case FamiliarFairyStone: itemType = ItemFairyStone; break; } ItemEntity* newItem = new ItemEntity(itemType, x, y); newItem->setVelocity(Vector2D(50.0f + rand()% 150)); newItem->setViscosity(0.96f); } else if (chestType == ChestExit) { // Multiplayer bonus game().gainMultiplayerPower(); int r = rand() % 3; if (r == 0) { for (int i = 0; i < (game().getPlayer()->isEquiped(EQUIP_LUCK) ? 6 : 5); i++) { dropItem(ItemSilverCoin); } } else if (r == 1) { for (int i = 0; i < (game().getPlayer()->isEquiped(EQUIP_LUCK) ? 4 : 3); i++) { dropItem(ItemSilverCoin); } dropItem(ItemHealth); } else { int bonusType = game().getRandomEquipItem(false, true); if (game().getPlayer()->isEquiped(bonusType)) dropItem(ItemBonusHealth); else dropItem((enumItemType)(FirstEquipItem + bonusType)); } } else if (chestType == ChestChallenge) { game().generateChallengeBonus(x, y); } }
int main(int argc, char *argv[]) { char *fname; // name of dictionary file FILE *wordf; // handle for dictionary file Item word; // current word from file int size = 7919; // default size of hash table HashTable htab; // the hash table int nwords; // # words read and stored int nfound; // # words found during search tests // set up parameters switch (argc) { case 2: fname = argv[1]; break; case 3: fname = argv[1]; size = atoi(argv[2]); break; default: fname = NULL; usage(argv[0]); break; } // access the word file if (eq(fname,"-")) { wordf = stdin; printf("Reading words from stdin\n"); } else { wordf = fopen(fname,"r"); if (wordf == NULL) { printf("Can't open %s\n",fname); exit(1); } printf("Reading words from %s\n",fname); } // build hash table, containing all words from file nwords = 0; nfound = 0; htab = newHashTable(size); while ((word = ItemGet(wordf)) != NULL) { if (eq(word,"")) { dropItem(word); continue; } HashTableInsert(htab,word); nwords++; if (HashTableSearch(htab,word) != NULL) nfound++; dropItem(word); } // examine hash table HashTableStats(htab); // tests // warning: we are assuming that "!aaaaaa!" etc. // do not occur in the input; this is not guaranteed assert(nfound == nwords); assert(HashTableSearch(htab,"!aaaaaa!") == NULL) ; assert(HashTableSearch(htab,"!xxxxxx!") == NULL) ; assert(HashTableSearch(htab,"!yyyyyy!") == NULL) ; assert(HashTableSearch(htab,"!zzzzzz!") == NULL) ; printf("Testing completed OK\n"); // clean up fclose(wordf); dropHashTable(htab); return 0; }
void Square::dropItems(vector<PItem> items) { for (PItem& it : items) dropItem(std::move(it)); }
void ContainerWindow::onBackgroundSelected() { if (mDragAndDrop->mIsOnDragAndDrop && !dynamic_cast<PickpocketItemModel*>(mModel)) dropItem(); }
void Actor::dropAllItems() { for (int i(0); i < inventory.getSlots(); i++) { dropItem(i); } }