Esempio n. 1
0
void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &class_, bool preserveProgress)
{
    int base = getSkill (skillIndex).getBase();

    if (base >= 100)
        return;

    base += 1;

    const MWWorld::Store<ESM::GameSetting> &gmst =
        MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

    // is this a minor or major skill?
    int increase = gmst.find("iLevelupMiscMultAttriubte")->getInt(); // Note: GMST has a typo
    for (int k=0; k<5; ++k)
    {
        if (class_.mData.mSkills[k][0] == skillIndex)
        {
            mLevelProgress += gmst.find("iLevelUpMinorMult")->getInt();
            increase = gmst.find("iLevelUpMajorMultAttribute")->getInt();
        }
    }
    for (int k=0; k<5; ++k)
    {
        if (class_.mData.mSkills[k][1] == skillIndex)
        {
            mLevelProgress += gmst.find("iLevelUpMajorMult")->getInt();
            increase = gmst.find("iLevelUpMinorMultAttribute")->getInt();
        }
    }

    const ESM::Skill* skill =
        MWBase::Environment::get().getWorld ()->getStore ().get<ESM::Skill>().find(skillIndex);
    mSkillIncreases[skill->mData.mAttribute] += increase;

    // Play sound & skill progress notification
    /// \todo check if character is the player, if levelling is ever implemented for NPCs
    MWBase::Environment::get().getSoundManager ()->playSound ("skillraise", 1, 1);

    std::vector <std::string> noButtons;

    std::stringstream message;
    message << boost::format(MWBase::Environment::get().getWindowManager ()->getGameSettingString ("sNotifyMessage39", ""))
               % std::string("#{" + ESM::Skill::sSkillNameIds[skillIndex] + "}")
               % static_cast<int> (base);
    MWBase::Environment::get().getWindowManager ()->messageBox(message.str(), noButtons, MWGui::ShowInDialogueMode_Never);

    if (mLevelProgress >= gmst.find("iLevelUpTotal")->getInt())
    {
        // levelup is possible now
        MWBase::Environment::get().getWindowManager ()->messageBox ("#{sLevelUpMsg}", noButtons, MWGui::ShowInDialogueMode_Never);
    }

    getSkill (skillIndex).setBase (base);
    if (!preserveProgress)
        getSkill(skillIndex).setProgress(0);
}
Esempio n. 2
0
void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType)
{
    float base = getSkill (skillIndex).getBase();

    int level = static_cast<int> (base);

    base += getSkillGain (skillIndex, class_, usageType);

    if (static_cast<int> (base)!=level)
        base = level+1;

    getSkill (skillIndex).setBase (base);
}
Esempio n. 3
0
void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &class_, bool preserveProgress)
{
    float base = getSkill (skillIndex).getBase();

    int level = static_cast<int> (base);

    if (level >= 100)
        return;

    if (preserveProgress)
        base += 1;
    else
        base = level+1;

    // if this is a major or minor skill of the class, increase level progress
    bool levelProgress = false;
    for (int i=0; i<2; ++i)
        for (int j=0; j<5; ++j)
        {
            int skill = class_.mData.mSkills[j][i];
            if (skill == skillIndex)
                levelProgress = true;
        }

    mLevelProgress += levelProgress;

    // check the attribute this skill belongs to
    const ESM::Skill* skill =
        MWBase::Environment::get().getWorld ()->getStore ().get<ESM::Skill>().find(skillIndex);
    ++mSkillIncreases[skill->mData.mAttribute];

    // Play sound & skill progress notification
    /// \todo check if character is the player, if levelling is ever implemented for NPCs
    MWBase::Environment::get().getSoundManager ()->playSound ("skillraise", 1, 1);

    std::stringstream message;
    message << boost::format(MWBase::Environment::get().getWindowManager ()->getGameSettingString ("sNotifyMessage39", ""))
               % std::string("#{" + ESM::Skill::sSkillNameIds[skillIndex] + "}")
               % static_cast<int> (base);
    MWBase::Environment::get().getWindowManager ()->messageBox(message.str());

    if (mLevelProgress >= 10)
    {
        // levelup is possible now
        MWBase::Environment::get().getWindowManager ()->messageBox ("#{sLevelUpMsg}");
    }

    getSkill (skillIndex).setBase (base);
}
Esempio n. 4
0
DECLARE_EXPORT ResourceSkill::ResourceSkill(Skill* s, Resource* r, int u)
{
  setSkill(s);
  setResource(r);
  setPriority(u);
  initType(metadata);
  try { validate(ADD); }
  catch (...)
  {
    if (getSkill()) getSkill()->resources.erase(this);
    if (getResource()) getResource()->skills.erase(this);
    resetReferenceCount();
    throw;
  }
}
Esempio n. 5
0
void MWMechanics::NpcStats::setWerewolf (bool set)
{
    if(set != false)
    {
        const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

        for(size_t i = 0;i < ESM::Attribute::Length;i++)
        {
            mWerewolfAttributes[i] = getAttribute(i);
            // Oh, Bethesda. It's "Intelligence".
            std::string name = "fWerewolf"+((i==ESM::Attribute::Intelligence) ? std::string("Intellegence") :
                                            ESM::Attribute::sAttributeNames[i]);
            mWerewolfAttributes[i].setBase(int(gmst.find(name)->getFloat()));
        }

        for(size_t i = 0;i < ESM::Skill::Length;i++)
        {
            mWerewolfSkill[i] = getSkill(i);

            // Acrobatics is set separately for some reason.
            if(i == ESM::Skill::Acrobatics)
                continue;

            // "Mercantile"! >_<
            std::string name = "fWerewolf"+((i==ESM::Skill::Mercantile) ? std::string("Merchantile") :
                                            ESM::Skill::sSkillNames[i]);
            mWerewolfSkill[i].setBase(int(gmst.find(name)->getFloat()));
        }
    }
    mIsWerewolf = set;
}
Esempio n. 6
0
int CmdUseSkill::execute()
{
  int turns(0);

  if ( SkillPtr skill = getSkill() )
  {
    Engine::instance().render();
    Engine::instance().flush();
    ActorPtr player = Engine::instance().getPlayer();

    TargetSelectorPtr selector( TargetSelector::create( skill->getTargetType() ) );
    if ( selector )
    {
      selector->setRadius( skill->getRadius() );
      MapPtr map = Engine::instance().getWorld().getCurrentMap();
      ActorActionPtr action(
            new UseSkillAction(skill, selector->select([&](ActorPtr a){
                                 return map->isInFov(a->getX(), a->getY());
                               })) );
      if ( player->performAction( action ) != ActorActionResult::Ok )
      {
        gui::msgBox(skill->getName() + " failed!", gui::MsgType::Warning);
      }
      ++turns;
    }
  }

  return turns;
}
Esempio n. 7
0
bool MWMechanics::NpcStats::hasSkillsForRank (const std::string& factionId, int rank) const
{
    if (rank<0 || rank>=10)
        throw std::runtime_error ("rank index out of range");

    const ESM::Faction& faction =
        *MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);

    std::vector<int> skills;

    for (int i=0; i<7; ++i)
    {
        if (faction.mData.mSkills[i] != -1)
            skills.push_back (static_cast<int> (getSkill (faction.mData.mSkills[i]).getBase()));
    }

    if (skills.empty())
        return true;

    std::sort (skills.begin(), skills.end());

    std::vector<int>::const_reverse_iterator iter = skills.rbegin();

    const ESM::RankData& rankData = faction.mData.mRankData[rank];

    if (*iter<rankData.mSkill1)
        return false;

    if (skills.size() < 2)
        return true;

    return *++iter>=rankData.mSkill2;
}
Esempio n. 8
0
int main() {
	std::bitset<2> bit;

	try {
		bit.set(getSkill(3, true));
		std::cerr << "succeed" << std::endl;
	} catch (std::out_of_range& e) {
		std::cerr << "out_of_range" << std::endl;
		std::cerr << e.what() << std::endl;
	} catch (std::invalid_argument& e) {
		std::cerr << "invalid" << std::endl;
		std::cerr << e.what() << std::endl;
	} catch (std::length_error& e) {
		std::cerr << "length" << std::endl;
	} catch (std::bad_exception& e) {
		std::cerr << "bad_exception" << std::endl;
	} catch (std::logic_error& e) {
		std::cerr << "logic_error" << std::endl;
	} catch (std::runtime_error& e) {
		std::cerr << "runtime_error" << std::endl;
	} catch (std::exception& e) {
		std::cerr << e.what() << std::endl;
	}
	std::cerr << typeid((3, true)).name() << std::endl;
}
Esempio n. 9
0
void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType, float extraFactor)
{
    const ESM::Skill *skill =
        MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find (skillIndex);
    float skillGain = 1;
    if (usageType>=4)
        throw std::runtime_error ("skill usage type out of range");
    if (usageType>=0)
    {
        skillGain = skill->mData.mUseValue[usageType];
        if (skillGain<0)
            throw std::runtime_error ("invalid skill gain factor");
    }
    skillGain *= extraFactor;

    MWMechanics::SkillValue& value = getSkill (skillIndex);

    value.setProgress(value.getProgress() + skillGain);

    if (int(value.getProgress())>=int(getSkillProgressRequirement(skillIndex, class_)))
    {
        // skill levelled up
        increaseSkill(skillIndex, class_, false);
    }
}
Esempio n. 10
0
DECLARE_EXPORT void ResourceSkill::writeElement(XMLOutput *o, const Keyword& tag, mode m) const
{
  // If the resourceskill has already been saved, no need to repeat it again
  // A 'reference' to a load is not useful to be saved.
  if (m == REFERENCE) return;
  assert(m != NOHEAD && m != NOHEADTAIL);

  o->BeginObject(tag);

  // If the resourceskill is defined inside of a resource tag, we don't need to save
  // the resource. Otherwise we do save it...
  if (!dynamic_cast<Resource*>(o->getPreviousObject()))
    o->writeElement(Tags::tag_resource, getResource());

  // If the resourceskill is defined inside of a skill tag, we don't need to save
  // the skill. Otherwise we do save it...
  if (!dynamic_cast<Skill*>(o->getPreviousObject()))
    o->writeElement(Tags::tag_skill, getSkill());

  // Write the priority and effective daterange
  if (getPriority()!=1) o->writeElement(Tags::tag_priority, getPriority());
  if (getEffective().getStart() != Date::infinitePast)
    o->writeElement(Tags::tag_effective_start, getEffective().getStart());
  if (getEffective().getEnd() != Date::infiniteFuture)
    o->writeElement(Tags::tag_effective_end, getEffective().getEnd());

  // Write the tail
  if (m != NOHEADTAIL && m != NOTAIL) o->EndObject(tag);
}
Esempio n. 11
0
float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& class_, int usageType,
    int level) const
{
    if (level<0)
        level = static_cast<int> (getSkill (skillIndex).getBase());

    const ESM::Skill *skill =
        MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find (skillIndex);

    float skillFactor = 1;

    if (usageType>=4)
        throw std::runtime_error ("skill usage type out of range");

    if (usageType>=0)
    {
        skillFactor = skill->mData.mUseValue[usageType];

        if (skillFactor<0)
            throw std::runtime_error ("invalid skill gain factor");

        if (skillFactor==0)
            return 0;
    }

    const MWWorld::Store<ESM::GameSetting> &gmst =
        MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

    float typeFactor = gmst.find ("fMiscSkillBonus")->getFloat();

    for (int i=0; i<5; ++i)
        if (class_.mData.mSkills[i][0]==skillIndex)
        {
            typeFactor = gmst.find ("fMinorSkillBonus")->getFloat();

            break;
        }

    for (int i=0; i<5; ++i)
        if (class_.mData.mSkills[i][1]==skillIndex)
        {
            typeFactor = gmst.find ("fMajorSkillBonus")->getFloat();

            break;
        }

    if (typeFactor<=0)
        throw std::runtime_error ("invalid skill type factor");

    float specialisationFactor = 1;

    if (skill->mData.mSpecialization==class_.mData.mSpecialization)
    {
        specialisationFactor = gmst.find ("fSpecialSkillBonus")->getFloat();

        if (specialisationFactor<=0)
            throw std::runtime_error ("invalid skill specialisation factor");
    }
    return 1.0 / ((level+1) * (1.0/skillFactor) * typeFactor * specialisationFactor);
}
Esempio n. 12
0
void BTPc::updateSkills()
{
 BTJobList &jobList = BTGame::getGame()->getJobList();
 for (int i = 0; i < jobList[job]->skill.size(); ++i)
 {
  int value = jobList[job]->skill[i]->value;
  if ((jobList[job]->skill[i]->modifier >= 0) && (stat[jobList[job]->skill[i]->modifier] > 14))
   value += stat[jobList[job]->skill[i]->modifier] - 14;
  if (getSkill(jobList[job]->skill[i]->skill) == 0)
  {
   setSkill(jobList[job]->skill[i]->skill, value, value);
   if (jobList[job]->skill[i]->improve > 0)
   {
    for (int sk = 0; sk < skill.size(); ++sk)
    {
     if (skill[sk]->skill == jobList[job]->skill[i]->skill)
     {
      for (int k = 2; k <= level; ++k)
      {
       if ((k % jobList[job]->skill[i]->improveLevel) == 0)
       {
        unsigned int increase = BTDice(1, jobList[job]->skill[i]->improve).roll();
        if ((jobList[job]->skill[i]->modifier >= 0) && (stat[jobList[job]->skill[i]->modifier] > 14))
         increase += stat[jobList[job]->skill[i]->modifier] - 14;
        skill[sk]->value += increase;
        skill[sk]->history.push_back(increase);
       }
      }
      break;
     }
    }
   }
  }
 }
}
Esempio n. 13
0
bool Character::CanPractice( Weave* weave )
{
	if( weave->isWeave() )
	{
		std::string sAir = weave->getAttribute("Air"),
					sEarth = weave->getAttribute("Earth"),
					sFire = weave->getAttribute("Fire"),
					sSpirit = weave->getAttribute("Spirit"),
					sWater = weave->getAttribute("Water");

		//Has the channeler yet to unlock the weave with the required elements?
		if( getSkill(WeaveManager::GetManager().GetWeaveVnum("Fire")) < MiscUtil::convert<int>(sFire)    ||
			getSkill(WeaveManager::GetManager().GetWeaveVnum("Earth")) < MiscUtil::convert<int>(sEarth)  ||
			getSkill(WeaveManager::GetManager().GetWeaveVnum("Spirit")) < MiscUtil::convert<int>(sSpirit)   ||
			getSkill(WeaveManager::GetManager().GetWeaveVnum("Air")) < MiscUtil::convert<int>(sAir) ||
			getSkill(WeaveManager::GetManager().GetWeaveVnum("Water")) < MiscUtil::convert<int>(sWater)
		)
		{
			return false;
		}
	}
	//All race/class based restrictions are to be hard coded.
	if( weave->disabled() )
		return false;
	if( !this->ChannelingAbility() && (weave->isWeave() || weave->isElement()) )
		return false;
	if( !IS_FADE(this) && (weave->getName() == "Fade" || weave->getName() == "Fear" || weave->getName() == "Compel" || weave->getName() == "Shadow Rage") )
		return false;
	if( !IS_GREYMAN(this) && weave->getName() == "Effusion" )
		return false;
	if( !IS_BLADEMASTER(this) && (weave->getName() == "Hamstring" || weave->getName() == "Whirlwind"))
		return false;
	if( !IS_OGIER(this) && weave->getName() == "Pulverize" )
		return false;
	if( !CAN_RIDE(this) && weave->getName() == "Charge" )
		return false;
	if( CAN_RIDE(this) && weave->getName() == "Skewer" )
		return false;
	if( !this->AES_SEDAI() && weave->getName() == "Bond" )
		return false;
	return true;
}
Esempio n. 14
0
void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType)
{
    // Don't increase skills as a werewolf
    if(mIsWerewolf)
        return;

    float base = getSkill (skillIndex).getBase();

    int level = static_cast<int> (base);

    base += getSkillGain (skillIndex, class_, usageType);

    if (static_cast<int> (base)!=level)
    {
        // skill leveled up
        increaseSkill(skillIndex, class_, false);
    }
    else
        getSkill (skillIndex).setBase (base);
}
Esempio n. 15
0
DECLARE_EXPORT void ResourceSkill::validate(Action action)
{
  // Catch null operation and resource pointers
  Skill *skill = getSkill();
  Resource *res = getResource();
  if (!skill || !res)
  {
    // Invalid load model
    if (!skill && !res)
      throw DataException("Missing resource and kill on a resourceskill");
    else if (!skill)
      throw DataException("Missing skill on a resourceskill on resource '"
          + res->getName() + "'");
    else if (!res)
      throw DataException("Missing resource on a resourceskill on skill '"
          + skill->getName() + "'");
  }

  // Check if a resourceskill with 1) identical resource, 2) identical skill and
  // 3) overlapping effectivity dates already exists
  Skill::resourcelist::const_iterator i = skill->getResources().begin();
  for (; i != skill->getResources().end(); ++i)
    if (i->getResource() == res
        && i->getEffective().overlap(getEffective())
        && &*i != this)
      break;

  // Apply the appropriate action
  switch (action)
  {
    case ADD:
      if (i != skill->getResources().end())
      {
        throw DataException("Resourceskill of '" + res->getName() + "' and '"
            + skill->getName() + "' already exists");
      }
      break;
    case CHANGE:
      throw DataException("Can't update a resourceskill");
    case ADD_CHANGE:
      // ADD is handled in the code after the switch statement
      if (i == skill->getResources().end()) break;
      throw DataException("Can't update a resourceskill");
    case REMOVE:
      // This resourceskill was only used temporarily during the reading process
      delete this;
      if (i == skill->getResources().end())
        // Nothing to delete
        throw DataException("Can't remove nonexistent resourceskill of '"
            + res->getName() + "' and '" + skill->getName() + "'");
      delete &*i;
      return;
  }
}
Esempio n. 16
0
VSkill *VEffectManager::createSkill(const VString &skillName)
{
	VSkill *tempSkill = getSkill(skillName);

	VSkill *skill = VNULL;
	if (tempSkill != VNULL)
	{
		skill = new VSkill(skillName);
		*skill = *tempSkill;
	}

	return skill;
}
Esempio n. 17
0
DECLARE_EXPORT PyObject* ResourceSkill::getattro(const Attribute& attr)
{
  if (attr.isA(Tags::tag_resource))
    return PythonObject(getResource());
  if (attr.isA(Tags::tag_skill))
    return PythonObject(getSkill());
  if (attr.isA(Tags::tag_priority))
    return PythonObject(getPriority());
  if (attr.isA(Tags::tag_effective_end))
    return PythonObject(getEffective().getEnd());
  if (attr.isA(Tags::tag_effective_start))
    return PythonObject(getEffective().getStart());
  return NULL;
}
Esempio n. 18
0
void FightLayer::combatAction(int index){
    
    if(index>=_combatVec.size()){
        
        runAction(Sequence::create(DelayTime::create(0.6),CallFunc::create(CC_CALLBACK_0(FightLayer::combatEnd, this)) ,NULL));
        return;
    }
 
    auto cb = _combatVec.at(index);
    
    auto attacker = getCardByHash(cb->getAttacker());
    auto beattacked = getCardByHash(cb->getBeattacked());
    
    if(!attacker||!beattacked){
        return;
    }
    
    auto delay =2;

    if (cb->getSkill()>0) {
        
        attacker->attack(cb->getSkill());

        beattacked->runAction(Sequence::create(DelayTime::create(1.4),CallFunc::create([beattacked](){beattacked->hurt(1, true);}),NULL));
        delay = 2.5;
    }else{
        
        attacker->attack(0);
        auto ba = Sequence::create(DelayTime::create(delay),
                                   CallFunc::create([&](){beattacked->hurt(cb->getDamage(), false);}),NULL);
        beattacked->runAction(ba);
    }
    
    auto action = Sequence::create(DelayTime::create(delay),CallFunc::create([index, this](){auto ni = index+1; combatAction(ni);}), NULL);
    
    runAction(action);
}
Esempio n. 19
0
void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType)
{
    // Don't increase skills as a werewolf
    if(mIsWerewolf)
        return;

    MWMechanics::SkillValue& value = getSkill (skillIndex);

    value.setProgress(value.getProgress() + getSkillGain (skillIndex, class_, usageType));

    if (value.getProgress()>=1)
    {
        // skill leveled up
        increaseSkill(skillIndex, class_, false);
    }
}
Esempio n. 20
0
float MWMechanics::NpcStats::getSkillProgressRequirement (int skillIndex, const ESM::Class& class_) const
{
    float progressRequirement = static_cast<float>(1 + getSkill(skillIndex).getBase());

    const MWWorld::Store<ESM::GameSetting> &gmst =
        MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

    float typeFactor = gmst.find ("fMiscSkillBonus")->getFloat();

    for (int i=0; i<5; ++i)
        if (class_.mData.mSkills[i][0]==skillIndex)
        {
            typeFactor = gmst.find ("fMinorSkillBonus")->getFloat();

            break;
        }

    for (int i=0; i<5; ++i)
        if (class_.mData.mSkills[i][1]==skillIndex)
        {
            typeFactor = gmst.find ("fMajorSkillBonus")->getFloat();

            break;
        }

    progressRequirement *= typeFactor;

    if (typeFactor<=0)
        throw std::runtime_error ("invalid skill type factor");

    float specialisationFactor = 1;

    const ESM::Skill *skill =
        MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find (skillIndex);
    if (skill->mData.mSpecialization==class_.mData.mSpecialization)
    {
        specialisationFactor = gmst.find ("fSpecialSkillBonus")->getFloat();

        if (specialisationFactor<=0)
            throw std::runtime_error ("invalid skill specialisation factor");
    }
    progressRequirement *= specialisationFactor;

    return progressRequirement;
}
Esempio n. 21
0
void SkillController::updateRun()
{
	skill_info* run_skill = getSkill("n_run");

	if (run_skill != nullptr)
	{
		if (onRun)
		{
			unsigned int delta_time = run_end_time - run_start_time;
			unsigned int run_duration = run_skill->power_percentage * 1000;

			if (run_elapsed_time > run_duration)
			{
				run_start_time = get_ms_onSystem();
				run_end_time = get_ms_onSystem();
				run_elapsed_time = 0;

				game_obj_info->move_speed /= 2.f;
				onRun = false;
			}
			else
			{
				if (delta_time > 0)
				{
					if (run_elapsed_time > 0)
						run_elapsed_time += delta_time;
					else
						run_elapsed_time = delta_time;
				}
				else
					run_end_time = get_ms_onSystem();
			}
		}
		else
		{
			run_start_time = get_ms_onSystem();
			run_end_time = get_ms_onSystem();
		}
	}
}
Esempio n. 22
0
void SkillController::updateHide()
{
	skill_info* hide_skill = getSkill("n_hide");

	if (hide_skill != nullptr)
	{
		if (onPrepareHide)
		{
			unsigned int delta_time = hide_end_time - hide_start_time;
			unsigned int hide_duration = hide_skill->power_percentage * 1000;

			unsigned int spr_opacity = g_ctrl->getAlphaValue();
			if (spr_opacity >= (opacity_limit * hide_opacity_limit))
			{
				spr_opacity -= hide_opacity_speed;
				g_ctrl->setAlphaValue(spr_opacity);

				hide_start_time = get_ms_onSystem();
				hide_end_time = get_ms_onSystem();
			}
			else
			{
				if (delta_time > 0)
				{
					if (hide_elapsed_time > hide_duration)
					{
						hide_start_time = get_ms_onSystem();
						hide_end_time = get_ms_onSystem();
						hide_elapsed_time = 0;

						onPrepareHide = false;
						onHide = false;
					}
					else
					{
						if (hide_elapsed_time > 0)
							hide_elapsed_time += delta_time;
						else
							hide_elapsed_time = delta_time;

						hide_skill->isSkillUsed = true;
						onHide = true;
					}
				}
				else
					hide_end_time = get_ms_onSystem();
			}
		}
		else
		{
			if (*game_obj_ev != DEAD)
			{
				unsigned int spr_opacity = g_ctrl->getAlphaValue();
				if (spr_opacity < opacity_limit)
				{
					spr_opacity += hide_opacity_speed;
					if (spr_opacity >= opacity_limit)
						spr_opacity = 255;
				}

				g_ctrl->setAlphaValue(spr_opacity);
			}

			hide_start_time = get_ms_onSystem();
			hide_end_time = get_ms_onSystem();
		}
	}
}
Esempio n. 23
0
std::string BTPc::attack(BTCombatant *defender, int weapon, int &numAttacksLeft, int &activeNum)
{
 BTGame *game = BTGame::getGame();
 BTFactory<BTItem> &itemList = game->getItemList();
 BTFactory<BTMonster> &monList = game->getMonsterList();
 BTDice damageDice(1, 2);
 IShort chanceXSpecial(0);
 IShort xSpecial(BTEXTRADAMAGE_NONE);
 bool melee = true;
 if (-1 == weapon)
 {
  if (BTMONSTER_NONE != monster)
  {
   damageDice = monList[monster].getMeleeDamage();
   chanceXSpecial = 100;
   xSpecial = monList[monster].getMeleeExtra();
  }
  else
  {
   XMLVector<BTSkill*> &skill = game->getSkillList();
   for (int i = 0; i < skill.size(); ++i)
   {
    if ((skill[i]->special == BTSKILLSPECIAL_BAREHANDS) && (hasSkillUse(i)))
    {
     BTDice *skillDice = skill[i]->getRoll(getSkill(i));
     if (skillDice)
      damageDice = *skillDice;
     break;
    }
   }
  }
 }
 else
 {
  BTItem &itemWeapon = itemList[weapon];
  damageDice = itemWeapon.getDamage();
  chanceXSpecial = itemWeapon.getChanceXSpecial();
  xSpecial = itemWeapon.getXSpecial();
  if ((BTITEM_ARROW == itemWeapon.getType()) || (BTITEM_THROWNWEAPON == itemWeapon.getType()))
   melee = false;
 }
 if (stat[BTSTAT_ST] > 14)
  damageDice.setModifier(damageDice.getModifier() + stat[BTSTAT_ST] - 14);
 std::string cause;
 std::string effect;
 if (-1 == weapon)
 {
  if (BTMONSTER_NONE == monster)
  {
   cause = "punches at";
   effect = "and strikes";
  }
  else
  {
   cause = monList[monster].getMeleeMessage();
   effect = "and hits";
  }
 }
 else
 {
  BTItem &itemWeapon = itemList[weapon];
  cause = itemWeapon.getCause();
  effect = itemWeapon.getEffect();
  if ((effect.length() >= 4) && (0 == strcmp(effect.c_str() + effect.length() - 4, " for")))
   effect.resize(effect.length() - 4);
 }
 return BTCombatant::attack(defender, melee, cause, effect, damageDice, chanceXSpecial, xSpecial, numAttacksLeft, activeNum);
}
Esempio n. 24
0
            connect(cp, &CircleOfPower::notifyDesactive, this, &FormGame::circleOfPowerDesactive);
        }
        object->initObject();
    }

    _tank = _tanks.at(index_of_this_player);

    foreach (ITank* tank, _tanks) {
        tank->setPrincipalReference(_tank);
        tank->initTank();
    }

    _ui->_l_preview_tank->setPixmap(_tank->getPreview());

    _preview_skill_1 = _tank->getSkill(1)->getPreview();
    _preview_skill_2 = _tank->getSkill(2)->getPreview();
    _preview_skill_3 = _tank->getSkill(3)->getPreview();

    _no_active_skill_1 = getNoActiveSkill(_preview_skill_1);
    _no_active_skill_2 = getNoActiveSkill(_preview_skill_2);
    _no_active_skill_3 = getNoActiveSkill(_preview_skill_3);

    _skill_locked = QPixmap(":/icons/skill_locked.png");

    _ui->_l_tank_name->setText(_tank->getName());

    _ui->_l_preview_skill_1->setPixmap(QPixmap());
    _ui->_l_preview_skill_2->setPixmap(QPixmap());
    _ui->_l_preview_skill_3->setPixmap(QPixmap());