Ejemplo n.º 1
0
bool Robot::movesNamesCb(robot_white::get_moves_srv::Request &req,
		robot_white::get_moves_srv::Response &res)
{
	res.move1.data = getAttack(1)->getName();
	res.move2.data = getAttack(2)->getName();
	res.move3.data = getAttack(3)->getName();
	res.move4.data = getAttack(4)->getName();
	return true;
}
Ejemplo n.º 2
0
Archivo: fight.cpp Proyecto: q4a/attal
void Fight::updateUnits( void )
{

	updateLordUnits( getAttack() , FIGHTER_ATTACK );
	updateLordUnits( getDefense() , FIGHTER_DEFENSE	);

}
Ejemplo n.º 3
0
void Monster::getMonsterStats()
{
    cout << "[[ " << monsterName << " - level: " << getLevel() << " || "
         << "Health: " << getHealth() << " HP || "
         << "Attack: " << getAttack() << " || "
         << "Strength: " << getStrength() << " || "
         << "Defence: " << getDefence() << " ]] \n";
}
Ejemplo n.º 4
0
void Hero::printStats()
{
	cout << "Hero's stats:\n";
	cout << "Level: \t" << getLevel() << "\n";
	cout << "Health: \t" << getHealth() << "\n";
	cout << "Attack: \t" << getAttack() << "\n";
	cout << "Defense: \t" << getDefense() << "\n";
	cout << "Perception: \t" << perception << "\n";
	cout << "Experience: \t" << experience << "/" << requiredXp << "\n";
}
Ejemplo n.º 5
0
//////////////////////////////////////////////////////////////////////////////
//风魔龙技能 闪电云
//////////////////////////////////////////////////////////////////////////////
void CDragon::skillLight(float time)
{
    T_SkillDragonLighing* tpSkilllight = (T_SkillDragonLighing*)m_pRandSkill->m_pSkill;
    
    //------------------------------------------------
    if (tpSkilllight->state == 2)
    {
        //log("skill attick");
        return;
    }
    
    tpSkilllight->m_fCount += time;
    if (tpSkilllight->m_fCount >= 1)
    {
        if (m_refSp->hasSkillLightCountTime())
        {
            tpSkilllight->buffer++;
            if (tpSkilllight->buffer > 3)
            {
                //减伤 ,释放闪电,消失云彩  

                CEventDispatcher::getInstrance()->dispatchEvent(EVENT_BOSSSKILL_LIIGHTATTICAK, 0);

                m_refSp->attiack(getAttack(), this);
                //skillLightEnd();
                tpSkilllight->state = 2;
            }
        }
        else
        {
            tpSkilllight->buffer--;
            if (tpSkilllight->buffer <= 0)
            {
                tpSkilllight->buffer = 0;
            }
        }
        
        CEventDispatcher::getInstrance()->dispatchEvent(EVENT_BOSSSKILL_LIGHTCOUNT, new int(tpSkilllight->buffer));
        tpSkilllight->m_fCount = 0;
    }

    //----------------------------------------------

    if (tpSkilllight->m_fTime < m_fCount)
    {       
        m_fCount = 0;
        skillLightEnd();        
    }
}
Ejemplo n.º 6
0
void Robot::getMove(const std_msgs::UInt8 & move_number)
{
	if (this->getNewturnFlag())
	{
		this->setAttackToLaunch(move_number.data);
		this->setNewturnFlag(false);

		std_msgs::UInt8 speed_msg;
		speed_msg.data = this->getSpeed() + 100 * (int) getAttack(getAttackToLaunch())->getPriority();
		myspeed_pub.publish(speed_msg);
		
		sendLogMsg("ho scelto il mio attack e comunicata la mia velocita... ti distruggo!",0);
	}	

}
Ejemplo n.º 7
0
void Player::showStats()
{
	std::cout << "----  STATS OF ---" << name << std::endl;
	std::cout << "Level :" << getLevel() << std::endl;
	std::cout << "Experience :" << getExperience() << std::endl;
	std::cout << "Health :" << getHealth() << std::endl;
	std::cout << "Attack :" << getAttack() << std::endl;
	std::cout << "Defence :" << getDefence() << std::endl;
	std::cout << "Awareness :" << getAwarenes() << std::endl << std::endl;
	std::cout << "Inventory :" << getAwarenes() << std::endl << std::endl;
	for (int i = 0; i < inventory.size(); i++)
	{
		std::cout << i << ": " << inventory.at(i).getName() << std::endl;
	}
	std::cout << std::endl;
}
Ejemplo n.º 8
0
bool Entity::attack(){

	if (Victim == NULL)
		return false;
	

	// Don't attack dead or hurt people
	if (Victim->Action == CHAR_DIE || Victim->Action == CHAR_HURT)
		return false;

	// Set attacker and victim
	Victim->Attacker = this;
	this->Victim = Victim;
	notify(*this, EVENT_ATTACK);

	// Return if hit missed
	if ((rand() % 1000) > getToHit(Victim)) {
		
		std::string miss_msg = getEntityType().c_str() + std::string(" missed!");
		log_message->setString(miss_msg);
		log_message->setColor(sf::Color::Yellow);
		addMessage(miss_msg.c_str(), 1000, sf::Color::Yellow);
		return false;
	}
	
	// Return if hit dodged
	if ((rand() % 1000) <= getAgility(Victim)) {
		std::string dodge_msg = getEntityType().c_str() + std::string(" dodged!");
		log_message->setString(dodge_msg);
		log_message->setColor(sf::Color::Yellow);
		addMessage(dodge_msg.c_str(), 1000, sf::Color::Yellow);
		return false;
	}

	// If this is asleep, randomly wake them up (50% chance)
	if (Victim->Ailments & AILMENT_SLEEP) {
		if ((rand() % 100) < 50)
			Victim->Ailments &= ~AILMENT_SLEEP;
	}

	// Attack landed, apply damage
	damage(Victim, true, getAttack(this), -1, -1);
	
	return true;

}
Ejemplo n.º 9
0
Archivo: fight.cpp Proyecto: q4a/attal
void Fight::updateUnits( void )
{
	GenericLord *oldLord;
	GenericFightUnit * oldUnit, * newUnit;
	uint  i;

	oldLord = _game->getLord( getAttack()->getId() );
	for( i = 0; i < MAX_UNIT; i++ ) {
		newUnit = getUnit( i, FIGHTER_ATTACK );
		if(newUnit){
			if(newUnit->getNumber()==0){
				newUnit=0;
			}
		}
		oldUnit = oldLord->getUnit( i );
		if( newUnit && oldUnit ) {
			oldUnit->setNumber( newUnit->getNumber()  );
			oldUnit->setMove( newUnit->getMove() );
			oldUnit->setHealth( newUnit->getHealth() );
		} else if (oldUnit) {
			oldLord->setUnit(i,0);
		}
	}

	oldLord = _game->getLord( getDefense()->getId() );
	for( i = 0; i < MAX_UNIT; i++) {
		newUnit = getUnit( i, FIGHTER_DEFENSE );
		if(newUnit){
			if(newUnit->getNumber()==0){
				newUnit=0;
			}
		}
		oldUnit = oldLord->getUnit( i );
		if( newUnit && oldUnit ) {
			oldUnit->setNumber( newUnit->getNumber()  );
			oldUnit->setMove( newUnit->getMove() );
			oldUnit->setHealth( newUnit->getHealth() );
		} else if (oldUnit) {
			oldLord->setUnit(i,0);
		}
	}
	//} else {
		//_crea=false;
	//}
}
Ejemplo n.º 10
0
void parseActions(Player player)
{
  switch(player.action)
	{
	case FIGHT:
	  //pull out the using attack variable somehow from GUI
	  player.using_attack =  getAttack();
	  break;

        case SWITCH:
	  player.switchTo = showPokemons(player1);
	  break;
	
        case RUN:
	  player1.forfeit = true;
	  //exit battle and report results somehow
	  break;
	}
}
Ejemplo n.º 11
0
void MonsterProperties::setWidgetValue()
{
	InternalOperation = true;
	if (targetSprite->isHasMonsterProperties()){
		auto sprite = dynamic_cast<EntityImageSprite*>(targetSprite);
		this->setVisible(true);
		hp->setText(QString::number(sprite->getHp()));
		mp->setText(QString::number(sprite->getMp()));
		attack->setText(QString::number(sprite->getAttack()));
		defense->setText(QString::number(sprite->getDefense()));
		magic_attack->setText(QString::number(sprite->getMagicAttack()));
		magic_defense->setText(QString::number(sprite->getMagicDefense()));
		speed->setText(QString::number(sprite->getSpeed()));
		hardFactor->setText(QString::number(sprite->getHardFactor()));
	}
	else{
		this->setVisible(false);
		setDefaultValue();
	}
	InternalOperation = false;
}
Ejemplo n.º 12
0
void Player::handleInput(sf::RenderWindow& App, float ElapsedTime, std::vector<Object*>& objects, SpatialHash& grid)
{
  if (!isAnimated)
  {
    //Shooting
    if(App.GetInput().IsKeyDown(sf::Key::Space))
      shoot(ElapsedTime);

    //Rage
    if(App.GetInput().IsKeyDown(sf::Key::S))
    {
      enableRage();

      if(rageMode)
      {
        //Kill nearby enemies
        std::vector<int> nearby = grid.getNearby(this);
        for(unsigned int i = 0; i < nearby.size(); ++i)
        {
          int position = nearby[i];

          if(objects[position]->getType() == FOE)
          {
            objects[position]->takeDamage(objects, position, getAttack());
          }
        }
      }
    }

    //Move the sprite
    if(App.GetInput().IsKeyDown(sf::Key::Left))
      move(LEFT, ElapsedTime, objects, grid.getNearby(this));
    if(App.GetInput().IsKeyDown(sf::Key::Right))
      move(RIGHT, ElapsedTime, objects, grid.getNearby(this));
    if(App.GetInput().IsKeyDown(sf::Key::Up))
      move(UP, ElapsedTime, objects, grid.getNearby(this));
    if(App.GetInput().IsKeyDown(sf::Key::Down))
      move(DOWN, ElapsedTime, objects, grid.getNearby(this));
  }
}
Ejemplo n.º 13
0
void CNpc::checkFreeze(float time)
{
    if (m_State != STATE_FREEZE)
    {
        return;
    }

    //----------------------------------------
    Vec2 endPoint;
    switch (m_refSp->getState())
    {
    case CMySprite::STATE_DRAW:
    case CMySprite::STATE_CLOSE:

        if (hasCollWithPlayer() &&      
            collwithGuide(getPosition(), endPoint))
        {
            collwithPlayerCallBack();
            m_refSp->attiack(getAttack(), this);           
        }

        break;
    default:
        break;
    }
    //-------------------------------------------

    m_fFreezeTime += time;
    if (m_fFreezeTime >= 10)
    {

        setState(STATE_LIVE);
        m_fFreezeTime = 0;
    }

}
Ejemplo n.º 14
0
int Player::doAttack()
{
	RandomGenerator rg;
	int retunVal = rg.getRandom( 0, getAttack());
	return retunVal;
}
Ejemplo n.º 15
0
std::string Item::getDescription(int32_t lookDistance) const
{
	std::stringstream s;
	const ItemType& it = items[id];

	if (it.name.length()) {
		if(isStackable() && count > 1){
			s << (int)count << " " << it.name << "s.";

			if(lookDistance <= 1) {
				s << std::endl << "They weight " << std::fixed << std::setprecision(2) << ((double) count * it.weight) << " oz.";
			}
		}		
		else{
			if(items[id].runeMagLevel != -1)
			{
				s << "a spell rune for level " << it.runeMagLevel << "." << std::endl;

				s << "It's an \"" << it.name << "\" spell (";
				if(getItemCharge())
					s << (int)getItemCharge();
				else
					s << "1";

				s << "x).";
			}
			else if(isWeapon() && (getAttack() || getDefense()))
			{
				if(getAttack()){
					s << "a " << it.name << " (Atk:" << (int)getAttack() << " Def:" << (int)getDefense() << ").";
				}
				else{
					s << "a " << it.name << " (Def:" << (int)getDefense() << ").";	
				}
			}
			else if(getArmor()){
				s << "a " << it.name << " (Arm:" << (int)getArmor() << ").";
			}
			else if(isFluidContainer()){
				s << "a " << it.name;
				if(fluid == 0){
					s << ". It is empty.";
				}
				else{
					s << " of " << items[fluid].name << ".";
				}
			}
			else if(isSplash()){
				s << "a " << it.name << " of ";
				if(fluid == 0){
					s << items[1].name << ".";
				}
				else{
					s << items[fluid].name << ".";
				}
			}
			else if(it.isKey()){
				s << "a " << it.name << " (Key:" << actionId << ").";
			}
			else if(it.isGroundTile()){
				s << it.name << ".";
			}
			else if(it.isContainer()){
				s << "a " << it.name << " (Vol:" << getContainer()->capacity() << ").";
			}
			else if(it.allowDistRead){
				s << it.name << "." << std::endl;

				if(lookDistance <= 4){
					if(text && text->length() > 0){
						s << "You read: " << *text;
					}
					else
						s << "Nothing is written on it.";
				}
				else
					s << "You are too far away to read it.";
			}
			else{
				s << "a " << it.name << ".";
			}

			if(lookDistance <= 1){
				double weight = getWeight();
				if(weight > 0)
					s << std::endl << "It weighs " << std::fixed << std::setprecision(2) << weight << " oz.";
			}

			if(specialDescription)
				s << std::endl << specialDescription->c_str();
			else if(lookDistance <= 1 && it.description.length()){
				s << std::endl << it.description;
			}
		}
	}
	else
		s << "an item of type " << id <<".";
	
	return s.str();
}
Ejemplo n.º 16
0
/*
Set up the actions for the Ai controlled ship
*/
void Ai::aiActions(){
	

	//load in ship information
	enemyAtkModules = 0;
	enemyDefModules = 0;
	enemyUnspentEnergy = 1;
	energyLeft = aiShip->getMaxEnergy();

	for (int y = 0; y < SHIP_HEIGHT; y++){
		for (int x = 0; x < SHIP_WIDTH; x++){
			Module *modu = playerShip->getModule(y, x);
			if (modu != NULL){
				moduleHp[y][x] = modu->getCurrentHealth();
				if (modu->getType() == TURRET){			//check if turret
					enemyAtkModules++;
				}
				else if(modu->getType() == SHIELD){	//check if shield
					enemyDefModules++;
				}
				if (modu->getCurrentEnergy()>enemyUnspentEnergy){ //find highest number of unspent energy in enemy module
					enemyUnspentEnergy = modu->getCurrentEnergy();
				}
			}else{
				moduleHp[y][x] = 0;
			}
			if (aiShip->getModule(y, x) != NULL){
				modulePow[y][x] = aiShip->getModule(y, x)->getCurrentEnergy();
				//cout << "Module y:" << y << " x:" << x << " got Energy: " << modulePow[y][x] << endl;
			}else{
				modulePow[y][x] = 0;
			}

		}
	}

	//Place energy
	for (int i = 0; i < aiShip->getMaxEnergy(); i++){
		int modNr = energyTarget();
		if (modNr >= 0){
			aiShip->getModule((modNr / SHIP_HEIGHT), (modNr % SHIP_WIDTH))->addEnergy();		//add energy
			modulePow[(modNr / SHIP_HEIGHT)][(modNr % SHIP_WIDTH)]++;
			energyLeft--;
		}
		else{
			cout << "NO modules to power up\n";
		}
	}

	//for each attack module with full energy
	for (int y = 0; y < SHIP_HEIGHT; y++){
		for (int x = 0; x < SHIP_WIDTH; x++){
			Module *atkModule = aiShip->getModule(y, x);
			//if an allive attack module with full power
			if (atkModule != NULL && modulePow[y][x] == atkModule->getReqPower() && atkModule->getCurrentHealth() > 0 && atkModule->getType() == TURRET){
				int modNr = getAttack(atkModule);
				if (modNr >= 0){
					//Attack enemy module
					Module *target = playerShip->getModule((modNr / SHIP_HEIGHT), (modNr % SHIP_WIDTH));
					int pixCoorX, pixCoorY; //pixel coordinates of target module...
					target->getPosition(pixCoorX, pixCoorY);	//get coordinates from target module
					atkModule->setTarget((modNr % SHIP_WIDTH), (modNr / SHIP_HEIGHT), pixCoorX, pixCoorY); //set attack modules target
					moduleHp[(modNr / SHIP_HEIGHT)][(modNr % SHIP_WIDTH)] -= atkModule->getDamage();
				}
			}
		}
	}
}
Ejemplo n.º 17
0
Creature::operator BoardCreatureData() const
{
	BoardCreatureData data {getId(), getHealth(), getAttack(), getShield(),
			BoardCreatureData::shieldTypes[getShieldType()]};
	return data;
}
Ejemplo n.º 18
0
bool Ammo::perform( Action a, const Target& t )
{

    switch ( a )
    {
        case aPolymorph:
            form = Random::randint( ammoStats::numAmmo );
            image.val.color = ammoStats::AmmoStats[form].color;
            return Item::perform(a, t);
        case aFire:
        {

            // We now just mark the bullet as fired, to ensure it disappears:
            fired = true;
            // This code should no longer be called, thus:
            /*
              Point3d me=getlocation(), target = t->getlocation();
              int acc = ammoStats::AmmoStats[form].accuracy;
              int scatter =  (acc * max( abs((me-target).getx()), abs((me-target).gety()) ) ) / 10;
              scatter = scatter / 2-scatter;

              // Multiple attacks:
              int numslugs = ammoStats::AmmoStats[form].numslugs;
              if (numslugs > 1)
              for (int slugs = 1; slugs < numslugs; slugs++) {
                  Target slug = clone();
                  target = t->getlocation() + Point3d( Random::randint(scatter),Random::randint(scatter), 0 );
              Target parent = getTarget(tg_parent);
              assert(!!parent);
                  parent->perform(aContain,slug);
              FlightPath::Option flight_opt;
              flight_opt.object = slug;
              flight_opt.start = me;
              flight_opt.delta = Point3d( target-me ).toPoint();
              FlightPath::create( flight_opt );
                  }

            // Make sure that at least this bullet hits the target:
              target = t->getlocation();// + Point( Random::randint(scatter),Random::randint(scatter) );
              Target tMe = Target(THIS);
            FlightPath::Option flight_opt;
            flight_opt.object = tMe;
            flight_opt.start = me;
            flight_opt.delta = Point3d( target-me ).toPoint();
              FlightPath::create( flight_opt );
            */
            return true;
        }
        case aRestack:

            if (fired)
            {
                Cloud::Option cloud_opt;
                Target my_parent = getTarget(tg_parent);

                // Sometimes this can fail.  No memory leak caused,
                // though I should find the cause when I can.
                //assert(!!my_parent);

                if (!my_parent)
                {

                    // May have negative effect on grenade use.

                    // In any case, fail gracefully & don't tell the player:
                    //Message::add("Ammo::perform(aRestack) failure.");

                    return false;
                }

                switch (ammoStats::AmmoStats[form].effect)
                {
                    case ae_smoke:

                        if (my_parent != NULL)
                        {
                            cloud_opt.material = m_smoke;
                            my_parent->perform( aContain, Cloud::create(cloud_opt) );
                        }

                        break;
                    case ae_gas:

                        if (my_parent != NULL)
                        {
                            cloud_opt.material = m_poison;
                            my_parent->perform( aContain, Cloud::create(cloud_opt) );
                        }

                        break;
                    case ae_explode:
                    {
                        // Grenades must soon be rewritten
                        // to acommodate for the new global positioning.

                        /*
                          Point loc = getlocation().toPoint(), cursor = Screen::cursorat();
                          // All grenade rounds have an explosion radius of 2
                          int radius = 2, gx = loc.getx(), gy = loc.gety(),
                              x, y;
                          bool **los;
                          los = new bool *[radius*2+1];
                          for (int i = 0; i < radius*2+1; ++i)
                            los[i] = new bool[radius*2+1];
                        //                xa = max(x-radius,0), xb = min(x+radius,(int)(map_width-1)),
                        //                ya = max(y-radius,0), yb = min(y+radius,(int)(map_height-1));
                          Level &lev = getlevel();
                          Rectangle lev_border = lev.getBorder();
                          Target deliverer = getTarget(tg_controller);
                          Attack dam( 6, DiceRoll(4,3), CombatValues(dam_burn,+10), deliverer, THIS, "grenaded" );
                          Screen::Buffer restore;
                          restore.setSize( Rectangle(max(gx-radius+1,lev_border.getxa()+1)+Screen::mapxoff,
                                                     max(gy-radius+1,lev_border.getya()+1)+Screen::mapyoff,
                                                     min(gx+radius+1,lev_border.getxb()+1)+Screen::mapxoff,
                                                     min(gy+radius+1,lev_border.getyb()+1)+Screen::mapyoff) );

                          for (y = -radius; y <= radius; ++y)
                            for (x = -radius; x <= radius; ++x) {
                              los[x+radius][y+radius] = false;
                              if ( lev_border.contains( Point(gx+x,gy+y) ) ) {
                                Path p;
                                      p.set( loc, loc+Point(x,y) );
                                      p.calculate();

                                      if ( p.hasLOS(lev) )
                                  los[x+radius][y+radius] = true;

                                }
                              }

                          Screen::hidecursor();
                          for (y = -radius; y <= radius; ++y)
                            for (x = -radius; x <= radius; ++x)
                              if (los[x+radius][y+radius] && lev.getTile( Point(gx+x,gy+y) )->getVal(attrib_visible))
                                LEVDRAW(gx+x,gy+y, Image(cRed,'*'));
                          Screen::locate(cursor);
                          Screen::showcursor();

                          Screen::nextFrame();
                          Screen::hidecursor();
                          for (y = -radius; y <= radius; ++y)
                            for (x = -radius; x <= radius; ++x)
                              if (los[x+radius][y+radius] && lev.getTile( Point(gx+x,gy+y) )->getVal(attrib_visible))
                                LEVDRAW(gx+x,gy+y, Image(cOrange,'*'));
                          Screen::locate(cursor);
                          Screen::showcursor();

                          Screen::nextFrame();
                          Screen::hidecursor();
                          for (y = -radius; y <= radius; ++y)
                            for (x = -radius; x <= radius; ++x)
                              if (los[x+radius][y+radius] && lev.getTile( Point(gx+x,gy+y) )->getVal(attrib_visible))
                                LEVDRAW(gx+x,gy+y, Image(cYellow,'*'));
                          Screen::locate(cursor);
                          Screen::showcursor();

                          Screen::nextFrame();
                          Screen::hidecursor();
                          restore.moveToScreen();
                          for (y = -radius; y <= radius; ++y)
                            for (x = -radius; x <= radius; ++x)
                              if (los[x+radius][y+radius])
                                lev.getTile( Point(gx+x,gy+y) )->takeDamage( dam );
                          Screen::locate(cursor);
                          Screen::showcursor();

                          for (int i = 0; i < radius*2+1; ++i)
                            delarr(los[i]);
                          delarr(los);
                          */
                        break;
                    }

                    default:
                        break;
                }

                detach();
            }
            else
            {
                return Item::perform(a, t);
            }

            return true;

        case aLand:

            if ( ammoStats::AmmoStats[form].type == bul_grenade )
            {
                fired = true;
            }

            return Item::perform(a, t);

        case aAttack:
        {

            // If this slug was fired, make sure to give 'shooty' messages:
            String subject, object,
                   hit_str = "hit~";
            Target shooter;

            // If the bullet was fired you want the, "You shoot the frog."
            // message; otherwise you want a "The bullet hits the frog." message.
            if (fired)
            {
                shooter = getTarget(tg_controller);
            }
            else
            {
                shooter = THIS;
            }

            subject = Grammar::Subject(shooter, Grammar::det_definite);
            object = Grammar::Object(t, Grammar::det_definite);

            if (fired)
            {
                hit_str = "shoot~";
            }


            bool t_was_alive = t->getVal(attrib_alive);


            t->takeDamage( getAttack() );

            // If we have killed the target:
            if ( t->getVal(attrib_alive) != t_was_alive )
                if (t->getVal(attrib_flesh_blood))
                {
                    hit_str = "kill~";
                }
                else
                {
                    hit_str = "destroy~";
                }

            if ( RawTarget::getVal(attrib_visible) || t->getVal(attrib_visible) )
            {
                Message::add( subject + " " + Grammar::plural(hit_str, 2 - shooter->getVal(attrib_plural), true, false) + " " + object + "." );
            }

            return true;
        }

        default:
            return Item::perform(a, t);
    }

}