void Threads::Process(const FractalJobHandeler & job) { ProgressInfo statTotal(statusBar); rows = inp_row.GetData(); cols = inp_col.GetData(); densityR = picbox.GetSize().cy / rows; densityC = picbox.GetSize().cx / cols; maxIter = inp_iter.GetData(); logmax= log10((double)maxIter); max_threads = inp_threads.GetData(); statTotal.Set(0,rows*cols); TimeStop startTime; for (int r = 0; r < rows; r++){ for (int c = 0; c < cols; c++) { while(threads >= max_threads) waitforfinish.Wait(); AtomicInc(threads); Thread().Run(callback4(this, &Threads::ThreadRenderJob, r, c, job, 0)); INTERLOCKED_(job_lock) active.Add((r * cols + c), 0); statTotal.Text(Format("Invoking calculations for sector R:%02d C:%02d",r,c)); time.Set(FormatTS(startTime.Elapsed())); picbox.Refresh(); statTotal.Set(r * cols + c,rows*cols); ProcessEvents(); } } while(threads > 0) waitforfinish.Wait(); time.Set(FormatTS(startTime.Elapsed())); picbox.Refresh(); }
int GameCritterObject::skillValue(unsigned int num) { if (num >= _skills.size()) throw Exception("GameCritterObject::skillValue(num) - num out of range:" + std::to_string(num)); int value = 0; switch(num) { case SKILLS_SMALL_GUNS: value += 5 + 4 * statTotal(STATS_AGILITY); if (trait(TRAITS_GOOD_NATURED)) value -= 10; break; case SKILLS_BIG_GUNS: value += 2*statTotal(STATS_AGILITY); if (trait(TRAITS_GOOD_NATURED)) value -= 10; break; case SKILLS_ENERGY_WEAPONS: value += 2*statTotal(STATS_AGILITY); if (trait(TRAITS_GOOD_NATURED)) value -= 10; break; case SKILLS_UNARMED: value += 30 + 2*(statTotal(STATS_AGILITY) + statTotal(STATS_STRENGTH)); if (trait(TRAITS_GOOD_NATURED)) value -= 10; break; case SKILLS_MELEE_WEAPONS: value += 20 + 2*(statTotal(STATS_AGILITY) + statTotal(STATS_STRENGTH)); if (trait(TRAITS_GOOD_NATURED)) value -= 10; break; case SKILLS_THROWING: value += 4*statTotal(STATS_AGILITY); if (trait(TRAITS_GOOD_NATURED)) value -= 10; break; case SKILLS_FIRST_AID: value += 2*(statTotal(STATS_PERCEPTION) + statTotal(STATS_INTELLIGENCE)); if (trait(TRAITS_GOOD_NATURED)) value += 15; break; case SKILLS_DOCTOR: value += 5 + (statTotal(STATS_PERCEPTION) + statTotal(STATS_INTELLIGENCE)); if (trait(TRAITS_GOOD_NATURED)) value += 15; break; case SKILLS_SNEAK: value += 5 + 3*statTotal(STATS_AGILITY); break; case SKILLS_LOCKPICK: value += 10 + (statTotal(STATS_PERCEPTION) + statTotal(STATS_AGILITY)); break; case SKILLS_STEAL: value += 3*statTotal(STATS_AGILITY); break; case SKILLS_TRAPS: value += 10 + (statTotal(STATS_PERCEPTION) + statTotal(STATS_AGILITY)); break; case SKILLS_SCIENCE: value += 4*statTotal(STATS_INTELLIGENCE); break; case SKILLS_REPAIR: value += 3*statTotal(STATS_INTELLIGENCE); break; case SKILLS_SPEECH: value += 5*statTotal(STATS_CHARISMA); if (trait(TRAITS_GOOD_NATURED)) value += 15; break; case SKILLS_BARTER: value += 4*statTotal(STATS_CHARISMA); if (trait(TRAITS_GOOD_NATURED)) value += 15; break; case SKILLS_GAMBLING: value += 5*statTotal(STATS_LUCK); break; case SKILLS_OUTDOORSMAN: value += 2 * (statTotal(STATS_ENDURANCE) + statTotal(STATS_INTELLIGENCE)); break; } if (trait(TRAITS_GIFTED)) { value -= 10; } if (skill(num)) { value += 20; } return value; }
void PlayerCreateState::think() { State::think(); auto player = Game::getInstance()->player(); auto msgEditor = ResourceManager::msgFileType("text/english/game/editor.msg"); _labels.at("name")->setText(player->name()); _labels.at("age")->setText(msgEditor->message(104))->appendText(" ")->appendText(std::to_string(player->age())); _labels.at("gender")->setText(msgEditor->message(player->gender() == 0 ? 107 : 108)); // 0 - male 1 - female _counters.at("statsPoints")->setNumber(player->statsPoints()); _counters.at("skillsPoints")->setNumber(player->skillsPoints()); _labels.at("health_1")->setText(msgEditor->message(300))->appendText(" ")->appendText(std::to_string(player->hitPointsMax()))->appendText("/")->appendText(std::to_string(player->hitPointsMax())); _labels.at("params_1_value")->setText(player->armorClass()); _labels.at("params_2_value")->setText(player->actionPoints()); _labels.at("params_3_value")->setText(player->carryWeightMax()); _labels.at("params_4_value")->setText(player->meleeDamage()); _labels.at("params_5_value")->setText(player->damageResistance())->appendText("%"); _labels.at("params_6_value")->setText(player->poisonResistance())->appendText("%"); _labels.at("params_7_value")->setText(player->radiationResistance())->appendText("%"); _labels.at("params_8_value")->setText(player->sequence()); _labels.at("params_9_value")->setText(player->healingRate()); _labels.at("params_10_value")->setText(player->criticalChance())->appendText("%"); // Stats counters and labels for (unsigned int i = 0; i < 7; i++) { std::stringstream ss; ss << "stats_" << (i+1); unsigned int val = player->statTotal(i); _counters.at(ss.str())->setNumber(val); _counters.at(ss.str())->setColor(BigCounter::COLOR_WHITE); if (val > 10) { val = 10; _counters.at(ss.str())->setColor(BigCounter::COLOR_RED); } _labels.at(ss.str())->setText(msgEditor->message(199 + (val < 1 ? 1 : val))); } // Skills values for (unsigned int i = 0; i != 18; ++i) { std::stringstream ss; ss << "skills_" << (i + 1) << "_value"; _labels.at(ss.str())->setText(player->skillValue(i))->appendText("%"); } // Default labels colors for(auto it = _labels.begin(); it != _labels.end(); ++it) { std::string name = it->first; auto font1_3ff800ff = ResourceManager::font("font1.aaf", 0x3ff800ff); auto font1_a0a0a0ff = ResourceManager::font("font1.aaf", 0xa0a0a0ff); auto font1_183018ff = ResourceManager::font("font1.aaf", 0x183018ff); if (name.find("stats_") == 0 || name.find("params_") == 0) { it->second->setFont(font1_3ff800ff); } if (name.find("traits_") == 0) { unsigned int number = atoi(name.substr(7).c_str()); it->second->setFont(player->trait(number - 1) ? font1_a0a0a0ff : font1_3ff800ff); } if (name.find("skills_") == 0) { unsigned int number = atoi(name.substr(7).c_str()); it->second->setFont(player->skill(number - 1) ? font1_a0a0a0ff : font1_3ff800ff); } if (name.find("health_") == 0) { it->second->setFont(name.compare("health_1") == 0 ? font1_3ff800ff : font1_183018ff); } } // Selected labels colors for(auto it = _labels.begin(); it != _labels.end(); ++it) { if (_selectedLabel != it->second) continue; std::string name = it->first; _title->setText(_titles.at(name)); _description->setText(_descriptions.at(name)); _selectedImage->setTexture(_images.at(name)->texture()); auto font1_ffff7fff = ResourceManager::font("font1.aaf", 0xffff7fff); auto font1_ffffffff = ResourceManager::font("font1.aaf", 0xffffffff); auto font1_707820ff = ResourceManager::font("font1.aaf", 0x707820ff); if (name.find("stats_") == 0) { it->second->setFont(font1_ffff7fff); } if (name.find("params_") == 0) { it->second->setFont(font1_ffff7fff); _labels.at(name+"_value")->setFont(font1_ffff7fff); } if (name.find("traits_") == 0) { unsigned int number = atoi(name.substr(7).c_str()); it->second->setFont(player->trait(number - 1) ? font1_ffffffff : font1_ffff7fff); } if (name.find("skills_") == 0) { unsigned int number = atoi(name.substr(7).c_str()); it->second->setFont(player->skill(number - 1) ? font1_ffffffff : font1_ffff7fff); _labels.at(name+"_value")->setFont(player->skill(number - 1) ? font1_ffffffff : font1_ffff7fff); } if (name.find("health_") == 0) { it->second->setFont(name.compare("health_1") == 0 ? font1_ffff7fff : font1_707820ff); } } }
void Opcode80CA::_run() { auto& debug = Logger::debug("SCRIPT"); debug << "[80CA] [+] int value = get_critter_stat(GameCritterObject* who, int number)" << std::endl; int number = _script->dataStack()->popInteger(); debug << " number = " << number << std::endl; auto object = _script->dataStack()->popObject(); if (!object) { _error("get_critter_stat(who, stat) - who is NULL"); } auto critter = dynamic_cast<Game::CritterObject*>(object); if (!critter) { _error("get_critter_stat(who, stat) - who is not a critter"); } int result = 0; switch (number) { case 0: // ST case 1: // PE case 2: // EN case 3: // CH case 4: // IN case 5: // AG case 6: // LU { result = critter->statTotal((STAT)number); break; } case 7: // max hit points { result = critter->hitPointsMax(); break; } case 8: // max action points { result = critter->actionPointsMax(); break; } case 9: // armor class { result = critter->armorClass(); break; } case 11: // melee damage { result = critter->meleeDamage(); break; } case 12: // carry weight max { result = critter->carryWeightMax(); break; } case 13: // sequence { result = critter->sequence(); break; } case 14: // heal rate { result = critter->healingRate(); break; } case 15: // crit chance { result = critter->criticalChance(); break; } case 16: // better criticals // @TODO break; case 17: // { result = critter->damageThreshold(DAMAGE::NORMAL); break; } case 18: // { result = critter->damageThreshold(DAMAGE::LASER); break; } case 19: // { result = critter->damageThreshold(DAMAGE::FIRE); break; } case 20: // { result = critter->damageThreshold(DAMAGE::PLASMA); break; } case 21: // { result = critter->damageThreshold(DAMAGE::ELECTRICAL); break; } case 22: // { result = critter->damageThreshold(DAMAGE::EMP); break; } case 23: // { result = critter->damageThreshold(DAMAGE::EXPLOSIVE); break; } case 24: // { result = critter->damageResist(DAMAGE::NORMAL); break; } case 25: // { result = critter->damageResist(DAMAGE::LASER); break; } case 26: // { result = critter->damageResist(DAMAGE::FIRE); break; } case 27: // { result = critter->damageResist(DAMAGE::PLASMA); break; } case 28: // { result = critter->damageResist(DAMAGE::ELECTRICAL); break; } case 29: // { result = critter->damageResist(DAMAGE::EMP); break; } case 30: // { result = critter->damageResist(DAMAGE::EXPLOSIVE); break; } case 31: // rad resist { result = critter->damageResist(DAMAGE::RADIATION); break; } case 32: // poison resist { result = critter->damageResist(DAMAGE::POISON); break; } case 33: // age { result = critter->age(); break; } case 34: // gender { result = (unsigned)critter->gender(); break; } case 35: // hit points { result = critter->hitPoints(); break; } case 36: // current poison { result = critter->poisonLevel(); break; } case 37: // current radiation { result = critter->radiationLevel(); break; } default: { _error("VM::opcode80CA - unimplemented number:" + std::to_string(number)); } } _script->dataStack()->push(result); debug << " value = " << result << std::endl; }
int CritterObject::skillBaseValue(SKILL skill) const { if (skill > SKILL::OUTDOORSMAN) throw Exception("CritterObject::skillBaseValue(num) - num out of range:" + std::to_string((unsigned)skill)); int value = 0; switch(skill) { case SKILL::SMALL_GUNS: value += 5 + 4 * statTotal(STAT::AGILITY); if (traitTagged(TRAIT::GOOD_NATURED)) value -= 10; break; case SKILL::BIG_GUNS: value += 2*statTotal(STAT::AGILITY); if (traitTagged(TRAIT::GOOD_NATURED)) value -= 10; break; case SKILL::ENERGY_WEAPONS: value += 2*statTotal(STAT::AGILITY); if (traitTagged(TRAIT::GOOD_NATURED)) value -= 10; break; case SKILL::UNARMED: value += 30 + 2*(statTotal(STAT::AGILITY) + statTotal(STAT::STRENGTH)); if (traitTagged(TRAIT::GOOD_NATURED)) value -= 10; break; case SKILL::MELEE_WEAPONS: value += 20 + 2*(statTotal(STAT::AGILITY) + statTotal(STAT::STRENGTH)); if (traitTagged(TRAIT::GOOD_NATURED)) value -= 10; break; case SKILL::THROWING: value += 4*statTotal(STAT::AGILITY); if (traitTagged(TRAIT::GOOD_NATURED)) value -= 10; break; case SKILL::FIRST_AID: value += 20 + 2*(statTotal(STAT::PERCEPTION) + statTotal(STAT::INTELLIGENCE)); if (traitTagged(TRAIT::GOOD_NATURED)) value += 15; break; case SKILL::DOCTOR: value += 20 + 5 + (statTotal(STAT::PERCEPTION) + statTotal(STAT::INTELLIGENCE)); if (traitTagged(TRAIT::GOOD_NATURED)) value += 15; break; case SKILL::SNEAK: value += 20 + 5 + 3*statTotal(STAT::AGILITY); break; case SKILL::LOCKPICK: value += 20 + 10 + (statTotal(STAT::PERCEPTION) + statTotal(STAT::AGILITY)); break; case SKILL::STEAL: value += 20 + 3*statTotal(STAT::AGILITY); break; case SKILL::TRAPS: value += 20 + 10 + (statTotal(STAT::PERCEPTION) + statTotal(STAT::AGILITY)); break; case SKILL::SCIENCE: value += 20 + 4*statTotal(STAT::INTELLIGENCE); break; case SKILL::REPAIR: value += 20 + 3*statTotal(STAT::INTELLIGENCE); break; case SKILL::SPEECH: value += 20 + 5*statTotal(STAT::CHARISMA); if (traitTagged(TRAIT::GOOD_NATURED)) value += 15; break; case SKILL::BARTER: value += 20 + 4*statTotal(STAT::CHARISMA); if (traitTagged(TRAIT::GOOD_NATURED)) value += 15; break; case SKILL::GAMBLING: value += 20 + 5*statTotal(STAT::LUCK); break; case SKILL::OUTDOORSMAN: value += 20 + 2*(statTotal(STAT::ENDURANCE) + statTotal(STAT::INTELLIGENCE)); break; default: break; } if (traitTagged(TRAIT::GIFTED)) { value -= 10; } if (skillTagged(skill)) { value += 20; } return value; }