void PlayerInst::pickup_item(GameState* gs, const GameAction& action) { const int PICKUP_RATE = 10; GameInst* inst = gs->get_instance(action.use_id); if (!inst) { return; } ItemInst* iteminst = dynamic_cast<ItemInst*>(inst); LANARTS_ASSERT(iteminst); const Item& type = iteminst->item_type(); int amnt = iteminst->item_quantity(); bool inventory_full = false; if (type.id == get_item_by_name("Gold")) { gold() += amnt; } else { itemslot_t slot = inventory().add(type); if (slot == -1) { inventory_full = true; } else if (projectile_should_autowield(equipment(), type, this->last_chosen_weaponclass)) { projectile_smart_equip(inventory(), slot); } } if (!inventory_full) { cooldowns().reset_pickup_cooldown(PICKUP_RATE); gs->remove_instance(iteminst); } }
void BtTreeModel::copySelected(QList< QPair<QModelIndex, QString> > toBeCopied) { while ( ! toBeCopied.isEmpty() ) { QPair<QModelIndex,QString> thisPair = toBeCopied.takeFirst(); QModelIndex ndx = thisPair.first; QString name = thisPair.second; switch ( type(ndx) ) { case BtTreeItem::EQUIPMENT: Equipment *copyKit, *oldKit; oldKit = equipment(ndx); copyKit = Database::instance().newEquipment(oldKit); // Create a deep copy. copyKit->setName(name); break; case BtTreeItem::FERMENTABLE: Fermentable *copyFerm, *oldFerm; oldFerm = fermentable(ndx); copyFerm = Database::instance().newFermentable(oldFerm); // Create a deep copy. copyFerm->setName(name); break; case BtTreeItem::HOP: Hop *copyHop, *oldHop; oldHop = hop(ndx); copyHop = Database::instance().newHop(oldHop); // Create a deep copy. copyHop->setName(name); break; case BtTreeItem::MISC: Misc *copyMisc, *oldMisc; oldMisc = misc(ndx); copyMisc = Database::instance().newMisc(oldMisc); // Create a deep copy. copyMisc->setName(name); break; case BtTreeItem::RECIPE: Recipe *copyRec, *oldRec; oldRec = recipe(ndx); copyRec = Database::instance().newRecipe(oldRec); // Create a deep copy. copyRec->setName(name); break; case BtTreeItem::STYLE: Style *copyStyle, *oldStyle; oldStyle = style(ndx); copyStyle = Database::instance().newStyle(oldStyle); // Create a deep copy. copyStyle->setName(name); break; case BtTreeItem::YEAST: Yeast *copyYeast, *oldYeast; oldYeast = yeast(ndx); copyYeast = Database::instance().newYeast(oldYeast); // Create a deep copy. copyYeast->setName(name); break; default: Brewtarget::logW(QString("deleteSelected:: unknown type %1").arg(type(ndx))); } } }
void ahelpkey() { int x,i,lgscr,page; byte ch; if (vstate(0)==4) smallscr(NO); if (equipment(0)==7) { page =0; smallscr(NO); } else { page =3; } vpage(page); crttim=0; lgscr = (tvmaxc==39) ? TRUE:FALSE; for (i=0; i<10; ++i) { helptop(page); for (x=0;;++x) { ch=*(helpkey[i]+x); if (ch==0) break; if (ch=='_') { if (lgscr) rprints(foreg,page,"\n \t \t "); else rputcinc(' ',0,foreg,NO,page); } else rputcinc(ch,0,foreg,NO,page); if ((ch==LF) && (lgscr)) putch(LF); /* 2nd LF */ } curset(23,5,page); if (i<9) { rprints(foreg,page,"Do you want the next page (Y/N) ? "); x=getyn(); if (x==NO) break; } else { rprints(foreg,page,"Hit any key to return "); getkey(); } } bright; /* Restore page 0 */ if (page==0) { if (SMALLMSK(maskp)) smallscr(NO); else largescr(NO); dspmsk(); } }
bool pawsCharacterPickerWindow::CheckLoadStatus() { if(!loaded) { csRef<iMeshFactoryWrapper> factory = psengine->GetLoader()->LoadFactory(models[selectedCharacter].factName); if (factory.IsValid()) { psengine->UnregisterDelayedLoader(this); view->View(factory); iMeshWrapper * mesh = view->GetObject(); if (!mesh) { PawsManager::GetSingleton().CreateWarningBox("Couldn't find mesh! Please run the updater"); return true; } charApp->ClearEquipment(); charApp->SetMesh(mesh); csRef<iSpriteCal3DState> spstate = scfQueryInterface<iSpriteCal3DState> (mesh->GetMeshObject()); if (spstate) { // Setup cal3d to select random 0 velocity anims spstate->SetVelocity(0.0,&psengine->GetRandomGen()); csString traits(models[selectedCharacter].traits); csString equipment( models[selectedCharacter].equipment ); //psengine->BuildAppearance( mesh, traits ); charApp->ApplyTraits(traits); //csPDelArray<Trait> dummy; //psengine->BuildEquipment(mesh, equipment, dummy); charApp->ApplyEquipment(equipment); } loaded = true; return true; } else { psengine->RegisterDelayedLoader(this); } } return false; }
void BtTreeModel::deleteSelected(QModelIndexList victims) { QModelIndexList toBeDeleted = victims; // trust me while ( ! toBeDeleted.isEmpty() ) { QModelIndex ndx = toBeDeleted.takeFirst(); switch ( type(ndx) ) { case BtTreeItem::EQUIPMENT: Database::instance().remove( equipment(ndx) ); break; case BtTreeItem::FERMENTABLE: Database::instance().remove( fermentable(ndx) ); break; case BtTreeItem::HOP: Database::instance().remove( hop(ndx) ); break; case BtTreeItem::MISC: Database::instance().remove( misc(ndx) ); break; case BtTreeItem::RECIPE: Database::instance().remove( recipe(ndx) ); break; case BtTreeItem::STYLE: Database::instance().remove( style(ndx) ); break; case BtTreeItem::YEAST: Database::instance().remove( yeast(ndx) ); break; case BtTreeItem::BREWNOTE: Database::instance().remove( brewNote(ndx) ); break; case BtTreeItem::FOLDER: // This one is weird. toBeDeleted += allChildren(ndx); removeFolder(ndx); break; default: Brewtarget::logW(QString("deleteSelected:: unknown type %1").arg(type(ndx))); } } }
bool pawsCharacterPickerWindow::CheckLoadStatus() { if(!loaded) { if(view->View(models[selectedCharacter].factName)) { psengine->UnregisterDelayedLoader(this); iMeshWrapper* mesh = view->GetObject(); if (!mesh) { PawsManager::GetSingleton().CreateWarningBox("Couldn't find mesh! Please run the updater"); return true; } charApp->SetMesh(mesh); csRef<iSpriteCal3DState> spstate = scfQueryInterface<iSpriteCal3DState> (mesh->GetMeshObject()); if (spstate) { // Setup cal3d to select random 0 velocity anims spstate->SetVelocity(0.0,&psengine->GetRandomGen()); csString traits(models[selectedCharacter].traits); csString equipment( models[selectedCharacter].equipment ); charApp->ApplyTraits(traits); charApp->ApplyEquipment(equipment); psengine->GetLoader()->ContinueLoading(true); // make sure everything is loaded *now* } loaded = true; return true; } else { psengine->RegisterDelayedLoader(this); } } return false; }
void PlayerInst::perform_action(GameState* gs, const GameAction& action) { event_log("Player id=%d performing act=%d, xy=(%d,%d), frame=%d, origin=%d, room=%d, use_id=%d, use_id2=%d\n", this->player_entry(gs).net_id, action.act, action.action_x, action.action_y, action.frame, action.origin, action.room, action.use_id, action.use_id2); switch (action.act) { case GameAction::MOVE: return use_move(gs, action); case GameAction::USE_WEAPON: return use_weapon(gs, action); case GameAction::USE_SPELL: return use_spell(gs, action); case GameAction::USE_REST: return use_rest(gs, action); case GameAction::USE_PORTAL: return use_dngn_portal(gs, action); case GameAction::USE_ITEM: return use_item(gs, action); case GameAction::PICKUP_ITEM: return pickup_item(gs, action); case GameAction::DROP_ITEM: return drop_item(gs, action); case GameAction::DEEQUIP_ITEM: return equipment().deequip_type(action.use_id); case GameAction::REPOSITION_ITEM: return reposition_item(gs, action); case GameAction::CHOSE_SPELL: spellselect = action.use_id; return; case GameAction::PURCHASE_FROM_STORE: return purchase_from_store(gs, action); default: printf("PlayerInst::perform_action() error: Invalid action id %d!\n", action.act); break; } }
void CombatGameInst::equip(item_id item, int amnt) { equipment().equip(item, amnt); }
void PlayerInst::use_weapon(GameState* gs, const GameAction& action) { WeaponEntry& wentry = weapon().weapon_entry(); MTwist& mt = gs->rng(); const int MAX_MELEE_HITS = 10; EffectiveStats& estats = effective_stats(); if (!cooldowns().can_doaction()) { return; } Pos start(x, y); Pos actpos(action.action_x, action.action_y); if (wentry.uses_projectile && !equipment().has_projectile()) { return; } int cooldown = 0; if (equipment().has_projectile()) { const Projectile& projectile = equipment().projectile; ProjectileEntry& pentry = projectile.projectile_entry(); item_id item = get_item_by_name(pentry.name.c_str()); int weaprange = std::max(wentry.range, pentry.range); AttackStats weaponattack(weapon()); bool wallbounce = false; int nbounces = 0; float movespeed = pentry.speed; cooldown = std::max(wentry.cooldown, pentry.cooldown); //XXX: Horrible hack REMOVE THIS LATER if (class_stats().class_type().name == "Archer" && pentry.weapon_class == "bows") { int xplevel = class_stats().xplevel; float movebonus = class_stats().xplevel / 4.0f; if (movebonus > 2) { movebonus = 2; } float cooldown_mult = 1.0f - (class_stats().xplevel - 1) / 20.0f; if (cooldown_mult <= 0.85) { cooldown_mult = 0.85; } cooldown *= cooldown_mult; movespeed += movebonus; if (xplevel >= 3 && core_stats().mp >= 5) { nbounces = 2; core_stats().mp -= 5; } } GameInst* bullet = new ProjectileInst(projectile, effective_atk_stats(mt, weaponattack), id, start, actpos, movespeed, weaprange, NONE, wallbounce, nbounces); gs->add_instance(bullet); equipment().use_ammo(); } else { int weaprange = wentry.range + this->radius + TILE_SIZE / 2; float mag = distance_between(actpos, Pos(x, y)); if (mag > weaprange) { float dx = actpos.x - x, dy = actpos.y - y; actpos = Pos(x + dx / mag * weaprange, y + dy / mag * weaprange); } GameInst* enemies[MAX_MELEE_HITS]; int max_targets = std::min(MAX_MELEE_HITS, wentry.max_targets); int numhit = get_targets(gs, this, actpos.x, actpos.y, wentry.dmgradius, enemies, max_targets); if (numhit == 0) { return; } for (int i = 0; i < numhit; i++) { EnemyInst* e = (EnemyInst*)enemies[i]; lua_hit_callback(gs->get_luastate(), wentry.on_hit_func, this, e); if (attack(gs, e, AttackStats(equipment().weapon))) { PlayerData& pc = gs->player_data(); signal_killed_enemy(); char buffstr[32]; int amnt = round( double(e->xpworth()) / pc.all_players().size()); players_gain_xp(gs, amnt); snprintf(buffstr, 32, "%d XP", amnt); gs->add_instance( new AnimatedInst(Pos(e->x - 5, e->y - 5), -1, 25, Posf(), Posf(), AnimatedInst::DEPTH, buffstr, Colour(255, 215, 11))); } } cooldown = wentry.cooldown; } cooldowns().reset_action_cooldown(cooldown * estats.cooldown_mult); reset_rest_cooldown(); }
// dx & dy indicates moving direction, useful for choosing melee attack targets bool PlayerInst::enqueue_io_spell_and_attack_actions(GameState* gs, float dx, float dy) { GameView& view = gs->view(); WeaponEntry& wentry = weapon().weapon_entry(); bool mouse_within = gs->mouse_x() < gs->view().width; int rmx = view.x + gs->mouse_x(), rmy = view.y + gs->mouse_y(); int level = gs->get_level()->id(), frame = gs->frame(); bool is_moving = (dx != 0.0f || dy != 0.0f); IOController& io = gs->io_controller(); bool attack_used = enqueue_io_spell_actions(gs); bool autotarget = io.query_event(IOEvent::AUTOTARGET_CURRENT_ACTION) || io.query_event(IOEvent::ACTIVATE_SPELL_N); bool mousetarget = io.query_event(IOEvent::MOUSETARGET_CURRENT_ACTION); bool weaponuse = spell_selected() == -1; // choose & use weapon if (io.query_event(IOEvent::USE_WEAPON)) { queued_actions.push_back( game_action(gs, this, GameAction::CHOSE_SPELL, -1)); autotarget = true; weaponuse = true; } if (spell_selected() >= 0 && spells_known().get_entry(spell_selected()).mp_cost > core_stats().mp) { weaponuse = true; } // weapon use if (!attack_used && weaponuse && (autotarget || mousetarget)) { bool is_projectile = wentry.uses_projectile || equipment().has_projectile(); MonsterController& mc = gs->monster_controller(); GameInst* curr_target = gs->get_instance(current_target); GameInst* target = NULL; Pos targ_pos; if (is_projectile) { if (mousetarget) { targ_pos = Pos(rmx, rmy); } else if (autotarget && curr_target) { targ_pos = curr_target->pos(); } } else { if (mousetarget) { dx = rmx - x, dy = rmy - y; } target = get_weapon_autotarget(gs, this, curr_target, dx, dy); if (target) { targ_pos = Pos(target->x, target->y); } if (!is_moving && !target && !mousetarget && spell_selected() == -1 && curr_target && !is_projectile) { int vx, vy; GameInst* closest = get_closest_monster(gs, this); if (closest && decide_attack_movement(pos(), closest->pos(), TILE_SIZE / 4, vx, vy)) { queued_actions.push_back( game_action(gs, this, GameAction::MOVE, spellselect, round(vx), round(vy))); } } } if (target || (is_projectile && (mousetarget || curr_target))) { queued_actions.push_back( game_action(gs, this, GameAction::USE_WEAPON, spellselect, targ_pos.x, targ_pos.y)); attack_used = true; } } return attack_used; }
void BtTreeModel::copySelected(QList< QPair<QModelIndex, QString> > toBeCopied) { bool failed = false; while ( ! toBeCopied.isEmpty() ) { QPair<QModelIndex,QString> thisPair = toBeCopied.takeFirst(); QModelIndex ndx = thisPair.first; QString name = thisPair.second; switch ( type(ndx) ) { case BtTreeItem::EQUIPMENT: Equipment *copyKit, *oldKit; oldKit = equipment(ndx); copyKit = Database::instance().newEquipment(oldKit); // Create a deep copy. if ( copyKit) copyKit->setName(name); else failed = true; break; case BtTreeItem::FERMENTABLE: Fermentable *copyFerm, *oldFerm; oldFerm = fermentable(ndx); copyFerm = Database::instance().newFermentable(oldFerm); // Create a deep copy. if ( copyFerm ) copyFerm->setName(name); else failed = true; break; case BtTreeItem::HOP: Hop *copyHop, *oldHop; oldHop = hop(ndx); copyHop = Database::instance().newHop(oldHop); // Create a deep copy. if ( copyHop ) copyHop->setName(name); else failed = true; break; case BtTreeItem::MISC: Misc *copyMisc, *oldMisc; oldMisc = misc(ndx); copyMisc = Database::instance().newMisc(oldMisc); // Create a deep copy. if ( copyMisc ) copyMisc->setName(name); else failed = true; break; case BtTreeItem::RECIPE: Recipe *copyRec, *oldRec; oldRec = recipe(ndx); copyRec = Database::instance().newRecipe(oldRec); // Create a deep copy. if ( copyRec ) copyRec->setName(name); else failed = true; break; case BtTreeItem::STYLE: Style *copyStyle, *oldStyle; oldStyle = style(ndx); copyStyle = Database::instance().newStyle(oldStyle); // Create a deep copy. if ( copyStyle ) copyStyle->setName(name); else failed = true; break; case BtTreeItem::YEAST: Yeast *copyYeast, *oldYeast; oldYeast = yeast(ndx); copyYeast = Database::instance().newYeast(oldYeast); // Create a deep copy. if ( copyYeast ) copyYeast->setName(name); else failed = true; break; default: Brewtarget::logW(QString("copySelected:: unknown type %1").arg(type(ndx))); } if ( failed ) { QMessageBox::warning(0, tr("Could not copy"), tr("There was an unexpected error creating %1").arg(name)); return; } } }
WorldPackets::Character::EnumCharactersResult::CharacterInfo::CharacterInfo(Field* fields) { // 0 1 2 3 4 5 6 7 // "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.skin, characters.face, characters.hairStyle, " // 8 9 10 11 12 13 // "characters.hairColor, characters.facialStyle, characters.customDisplay1, characters.customDisplay2, characters.customDisplay3, characters.level, " // 14 15 16 17 18 // "characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z, " // 19 20 21 22 23 24 25 // "guild_member.guildid, characters.playerFlags, characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache, " // 26 27 28 29 30 // "character_banned.guid, characters.slot, characters.logout_time, characters.activeTalentGroup, character_declinedname.genitive" Guid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64()); Name = fields[1].GetString(); Race = fields[2].GetUInt8(); Class = fields[3].GetUInt8(); Sex = fields[4].GetUInt8(); Skin = fields[5].GetUInt8(); Face = fields[6].GetUInt8(); HairStyle = fields[7].GetUInt8(); HairColor = fields[8].GetUInt8(); FacialHair = fields[9].GetUInt8(); CustomDisplay[0] = fields[10].GetUInt8(); CustomDisplay[1] = fields[11].GetUInt8(); CustomDisplay[2] = fields[12].GetUInt8(); Level = fields[13].GetUInt8(); ZoneId = int32(fields[14].GetUInt16()); MapId = int32(fields[15].GetUInt16()); PreLoadPosition = Position(fields[16].GetFloat(), fields[17].GetFloat(), fields[18].GetFloat()); if (ObjectGuid::LowType guildId = fields[19].GetUInt64()) GuildGuid = ObjectGuid::Create<HighGuid::Guild>(guildId); uint32 playerFlags = fields[20].GetUInt32(); uint32 atLoginFlags = fields[21].GetUInt16(); if (atLoginFlags & AT_LOGIN_RESURRECT) playerFlags &= ~PLAYER_FLAGS_GHOST; if (playerFlags & PLAYER_FLAGS_HIDE_HELM) Flags |= CHARACTER_FLAG_HIDE_HELM; if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK) Flags |= CHARACTER_FLAG_HIDE_CLOAK; if (playerFlags & PLAYER_FLAGS_GHOST) Flags |= CHARACTER_FLAG_GHOST; if (atLoginFlags & AT_LOGIN_RENAME) Flags |= CHARACTER_FLAG_RENAME; if (fields[26].GetUInt64()) Flags |= CHARACTER_FLAG_LOCKED_BY_BILLING; if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED) && !fields[30].GetString().empty()) Flags |= CHARACTER_FLAG_DECLINED; if (atLoginFlags & AT_LOGIN_CUSTOMIZE) CustomizationFlag = CHAR_CUSTOMIZE_FLAG_CUSTOMIZE; else if (atLoginFlags & AT_LOGIN_CHANGE_FACTION) CustomizationFlag = CHAR_CUSTOMIZE_FLAG_FACTION; else if (atLoginFlags & AT_LOGIN_CHANGE_RACE) CustomizationFlag = CHAR_CUSTOMIZE_FLAG_RACE; Flags3 = 0; Flags4 = 0; FirstLogin = (atLoginFlags & AT_LOGIN_FIRST) != 0; // show pet at selection character in character list only for non-ghost character if (!(playerFlags & PLAYER_FLAGS_GHOST) && (Class == CLASS_WARLOCK || Class == CLASS_HUNTER || Class == CLASS_DEATH_KNIGHT)) { if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(fields[22].GetUInt32())) { Pet.CreatureDisplayId = fields[23].GetUInt32(); Pet.Level = fields[24].GetUInt16(); Pet.CreatureFamily = creatureInfo->family; } } BoostInProgress = false; ProfessionIds[0] = 0; ProfessionIds[1] = 0; Tokenizer equipment(fields[25].GetString(), ' '); ListPosition = fields[27].GetUInt8(); LastPlayedTime = fields[28].GetUInt32(); if (ChrSpecializationEntry const* spec = sDB2Manager.GetChrSpecializationByIndex(Class, fields[29].GetUInt8())) SpecID = spec->ID; for (uint8 slot = 0; slot < INVENTORY_SLOT_BAG_END; ++slot) { uint32 visualBase = slot * 3; VisualItems[slot].InventoryType = Player::GetUInt32ValueFromArray(equipment, visualBase); VisualItems[slot].DisplayId = Player::GetUInt32ValueFromArray(equipment, visualBase + 1); VisualItems[slot].DisplayEnchantId = Player::GetUInt32ValueFromArray(equipment, visualBase + 2); } }
void mitk::FiberBundleDicomWriter::Write() { try { mitk::FiberBundle::ConstPointer fib = dynamic_cast<const mitk::FiberBundle*>(this->GetInput()); vtkPolyData* poly = fib->GetFiberPolyData(); mitk::PropertyList* p_list = fib->GetPropertyList(); std::string patient_id = ""; if (!p_list->GetStringProperty("DICOM.patient_id", patient_id)) patient_id = "-"; std::string patient_name = ""; if (!p_list->GetStringProperty("DICOM.patient_name", patient_name)) patient_name = "-"; std::string study_instance_uid = ""; if (!p_list->GetStringProperty("DICOM.study_instance_uid", study_instance_uid)) study_instance_uid = "-"; std::string series_instance_uid = ""; if (!p_list->GetStringProperty("DICOM.series_instance_uid", series_instance_uid)) series_instance_uid = "-"; std::string sop_instance_uid = ""; if (!p_list->GetStringProperty("DICOM.sop_instance_uid", sop_instance_uid)) sop_instance_uid = "-"; std::string frame_of_reference_uid = ""; if (!p_list->GetStringProperty("DICOM.frame_of_reference_uid", frame_of_reference_uid)) frame_of_reference_uid = "-"; std::string algo_code_value = ""; if (!p_list->GetStringProperty("DICOM.algo_code.value", algo_code_value)) algo_code_value = "-"; std::string algo_code_meaning = ""; if (!p_list->GetStringProperty("DICOM.algo_code.meaning", algo_code_meaning)) algo_code_meaning = "-"; std::string model_code_value = ""; if (!p_list->GetStringProperty("DICOM.model_code.value", model_code_value)) model_code_value = "-"; std::string model_code_meaning = ""; if (!p_list->GetStringProperty("DICOM.model_code.meaning", model_code_meaning)) model_code_meaning = "-"; std::string anatomy_value = ""; if (!p_list->GetStringProperty("DICOM.anatomy.value", anatomy_value)) anatomy_value = "-"; std::string anatomy_meaning = ""; if (!p_list->GetStringProperty("DICOM.anatomy.meaning", anatomy_meaning)) anatomy_meaning = "-"; const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, nullptr ); setlocale(LC_ALL, locale.c_str()); // Instance Number, Label, Description, Creator's Name ContentIdentificationMacro id("1", "TRACTOGRAM", "Tractogram processed with MITK Diffusion", "MIC@DKFZ"); // Manufacturer, model name, serial number, software version(s) IODEnhGeneralEquipmentModule::EquipmentInfo equipment("MIC@DKFZ", "dcmtract library", "0815", OFFIS_DCMTK_VERSION_STRING); IODReferences refs; // We need at least one image reference this Tractography Results object is based on. // We provide: Patient ID, Study Instance UID, Series Instance UID, SOP Instance UID, SOP Class UID IODImageReference* ref = new IODImageReference(patient_id.c_str(), study_instance_uid.c_str(), series_instance_uid.c_str(), sop_instance_uid.c_str(), UID_MRImageStorage); refs.add(ref); std::time_t t = std::time(nullptr); char date_buffer[20]; std::strftime(date_buffer, sizeof(date_buffer), "%Y%m%d", std::gmtime(&t)); char time_buffer[20]; std::strftime(time_buffer, sizeof(time_buffer), "%H%M%S", std::gmtime(&t)); OFString contentDate(date_buffer); OFString contentTime(time_buffer); OFString val = "-"; TrcTractographyResults *trc = nullptr; TrcTractographyResults::create(id, contentDate, contentTime, equipment, refs, trc); trc->getStudy().setStudyInstanceUID(study_instance_uid.c_str()); trc->getSeries().setSeriesInstanceUID(series_instance_uid.c_str()); trc->getSOPCommon().setSOPInstanceUID(sop_instance_uid.c_str()); trc->getSeries().getSeriesInstanceUID(val); // Create track set CodeWithModifiers anatomy(""); anatomy.set(anatomy_value.c_str(), "SRT", anatomy_meaning.c_str()); // Every CodeSequenceMacro has: Code Value, Coding Scheme Designator, Code Meaning CodeSequenceMacro diffusionModel(model_code_value.c_str(), "DCM", model_code_meaning.c_str()); CodeSequenceMacro algorithmId(algo_code_value.c_str(), "DCM", algo_code_meaning.c_str()); TrcTrackSet *set = nullptr; trc->addTrackSet("TRACTOGRAM", "Tractogram processed with MITK Diffusion", anatomy, diffusionModel, algorithmId, set); // Create trackset Uint16 cieLabColor[3]; // color the whole track with this color; we use some blue cieLabColor[0] = 30000; // L cieLabColor[1] = 0 ; // a cieLabColor[2] = 0 ; // b std::vector< Float32* > tracts; for (unsigned int i=0; i<fib->GetNumFibers(); i++) { vtkCell* cell = poly->GetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); Float32* pointData = new Float32[numPoints*3]; for(int i=0; i<numPoints ;i++) { double* p = points->GetPoint(i); pointData[i*3] = p[0]; pointData[i*3+1] = p[1]; pointData[i*3+2] = p[2]; } tracts.push_back(pointData); TrcTrack* track = nullptr; set->addTrack(pointData, numPoints, cieLabColor, 1 /* numColors */, track); } // Frame of Reference is required; could be the same as from related MR series trc->getFrameOfReference().setFrameOfReferenceUID(frame_of_reference_uid.c_str()); // Set some optional data trc->getPatient().setPatientID(patient_id.c_str()); trc->getPatient().setPatientName(patient_name.c_str()); trc->getSeries().setSeriesDescription("Tractogram processed with MITK Diffusion"); // Save file OFCondition result = trc->saveFile(this->GetOutputLocation().c_str()); delete trc; if (result.bad()) mitkThrow() << "Unable to save tractography as DICOM file: " << result.text(); for (Float32* tract : tracts) delete [] tract; setlocale(LC_ALL, currLocale.c_str()); MITK_INFO << "DICOM Fiber bundle written to " << this->GetOutputLocation(); } catch(...) { throw; } }
void PlayerInst::use_item(GameState* gs, const GameAction& action) { if (!effective_stats().allowed_actions.can_use_items) { return; } itemslot_t slot = action.use_id; ItemSlot& itemslot = inventory().get(slot); Item& item = itemslot.item; ItemEntry& type = itemslot.item_entry(); lua_State* L = gs->luastate(); if (item.amount > 0) { if (item.is_equipment()) { if (itemslot.is_equipped()) { inventory().deequip(slot); } else { if (item.is_projectile()) { // Best-effort to equip, may not be possible: projectile_smart_equip(inventory(), slot); } else if (item.is_weapon()) { const Projectile& p = equipment().projectile(); if (!p.empty()) { if (!p.projectile_entry().is_standalone()) { inventory().deequip_type( EquipmentEntry::AMMO); } } equipment().equip(slot); // Try and equip a projectile WeaponEntry& wentry = item.weapon_entry(); if (wentry.uses_projectile) { const Projectile& p = equipment().projectile(); if (p.empty()) { projectile_smart_equip(inventory(), wentry.weapon_class); } } } else { equipment().equip(slot); } if (item.is_weapon() || item.is_projectile()) { last_chosen_weaponclass = weapon().weapon_entry().weapon_class; } } } else if (equipment().valid_to_use(item) && item_check_lua_prereq(L, type, this)) { item_do_lua_action(L, type, this, Pos(action.action_x, action.action_y), item.amount); if (is_local_player() && !type.inventory_use_message().empty()) { gs->game_chat().add_message(type.inventory_use_message(), Colour(100, 100, 255)); } if (item.is_projectile()) itemslot.clear(); else item.remove_copies(1); reset_rest_cooldown(); } } }
void PlayerInst::enqueue_io_equipment_actions(GameState* gs, bool do_stopaction) { GameView& view = gs->view(); bool mouse_within = gs->mouse_x() < gs->view().width; int rmx = view.x + gs->mouse_x(), rmy = view.y + gs->mouse_y(); int level = gs->get_level()->id(); int frame = gs->frame(); bool item_used = false; IOController& io = gs->io_controller(); Pos p(gs->mouse_x() + view.x, gs->mouse_y() + view.y); obj_id target = this->current_target; GameInst* targetted = gs->get_instance(target); if (targetted) p = Pos(targetted->x, targetted->y); // We may have already used an item eg due to auto-use of items bool used_item = false; //Item use for (int i = 0; i < 9 && !used_item; i++) { if (io.query_event(IOEvent(IOEvent::USE_ITEM_N, i))) { if (inventory().get(i).amount() > 0) { item_used = true; queued_actions.push_back( GameAction(id, GameAction::USE_ITEM, frame, level, i, p.x, p.y)); } } } if (!used_item && gs->game_settings().autouse_health_potions && core_stats().hp < AUTOUSE_HEALTH_POTION_THRESHOLD) { int item_slot = inventory().find_slot( get_item_by_name("Health Potion")); if (item_slot > -1) { queued_actions.push_back( game_action(gs, this, GameAction::USE_ITEM, item_slot)); used_item = true; } } //Item pickup GameInst* inst = NULL; if (cooldowns().can_pickup() && gs->object_radius_test(this, &inst, 1, &item_colfilter)) { ItemInst* iteminst = (ItemInst*)inst; Item& item = iteminst->item_type(); bool was_dropper = iteminst->last_held_by() == id; bool dropper_autopickup = iteminst->autopickup_held(); bool autopickup = (item.is_normal_item() && !was_dropper && !dropper_autopickup) || (was_dropper && dropper_autopickup); bool wieldable_projectile = projectile_should_autowield(equipment(), item, this->last_chosen_weaponclass); bool pickup_io = gs->key_down_state(SDLK_LSHIFT) || gs->key_down_state(SDLK_RSHIFT); if (do_stopaction || wieldable_projectile || pickup_io || autopickup) queued_actions.push_back( GameAction(id, GameAction::PICKUP_ITEM, frame, level, iteminst->id)); } }