void Bludgeoning:: takeDamage(int d)
{
    int tempHealth = getHealth();
    
    if (d>tempHealth)
        setHealth(0);
    else
        setHealth(tempHealth-d);
}
示例#2
0
NNType Entity::takeHealth(NNType e)
{
    NNType t = getHealth();
    if (t > e) {
        setHealth(t - e);
        return e;
    }
    else {
        setHealth(0);
        return t;
    }
}
void Hero::equipItem(Item *inventoryItem)
{
    equippedItem=inventoryItem;
    attackPoints=inventoryItem->attackBonus; //Augments player stats based on item stats
    defendPoints=inventoryItem->defenseBonus;
    setHealth(getHealth()+inventoryItem->healthBonus);
    if(getHealth()<=0) //If Item Takes Away All User's Health
    {
        cout<<"You Have Lost A Life"<<endl;
        lives=lives-1;
        setHealth(10);
    }
}
示例#4
0
/**
* CQBZombie::init
* @date Modified May 11, 2006
*/
void CQBZombie::init(void)
{
	CEnemy::init();

	setHealth(3000);
	((CAnimatedMesh*)m_pMesh)->setAnimationSetByName("Walk");
}
示例#5
0
Cat::Cat(const Filesystem::AbsolutePath & filename):
ObjectNonAttack( 0, 0 ),
state( IDLE1 ){

	path = filename;

	setMaxHealth( 1 );
	setHealth( 1 );
	
	TokenReader tr;
	try{
		Token * head;
		head = tr.readTokenFromFile(path.path());
		if ( *head != "cat" ){
			throw LoadException(__FILE__, __LINE__, "File does not begin with 'Cat'" );
		}

		while ( head->hasTokens() ){
			Token * next = head->readToken();
			if ( *next == "animation" ){
				Animation * animation = new Animation( next, 0 );
				animations[ animation->getName() ] = animation;
			}
		}
		if ( animations.size() == 0 ){
			throw LoadException(__FILE__, __LINE__, "No animation given" );
		}
        } catch (const TokenException & ex){
            // Global::debug(0) << "Could not read "<< filename.path() <<": "<< ex.getReason()<<endl;
            throw LoadException(__FILE__, __LINE__, ex, "Could not open file " + filename.path());
        }
	current_animation = animations[ "idle1" ];

	meow = Sound(Storage::instance().find(Filesystem::RelativePath("misc/cat/meow.wav")).path());
}
CharacterUpdaterPlayer::CharacterUpdaterPlayer(CCPathFinderNetwork *pathFinderNetwork)
{
    if( pathFinderNetwork == NULL )
    {
        pathFinderNetwork = &gEngine->collisionManager.pathFinderNetwork;
    }
    this->pathFinderNetwork = pathFinderNetwork;

    player = NULL;

    setHealth( 100.0f, true );

    moving = false;
    distanceToPositionTarget = MAXFLOAT;
    movementMagnitude = 1.0f;

    shootingState = state_stopped;
    shootingBurstTimer = 0.0f;
    shootingTarget = NULL;

    anchorNode = NULL;
    findNewAnchor = false;

    path = NULL;
    pathAnchorNode = NULL;
    currentPath = -1;

    enabled = true;
}
示例#7
0
	//constructor
	Bullit :: Bullit(float xx, float yy,int dir,int ww, int hh){
		setHealth(1);
		setDirectionGoing(dir);
		setSpeed(30);
		setNumOfVertices(3);
		setDistance(0);
		width = 50;
		height = 50;
		setXPos((xx+ww/2-width/2)-(xx+ww/2));
		setYPos((yy+hh+height+10)-(yy+hh/2));
		float dist=sqrt(pow(getXPos(),2)+pow(getYPos(),2));
		setXPos(xx+ww/2-width/2+dist*cos(getDirectionGoing()*PI/180));
		setYPos(yy+hh/2-height/2+dist*sin(getDirectionGoing()*PI/180));
		x=xx;
		y=yy;
		w=ww;
		h=hh;
		setNumOfVertices(3);

		//define the bullit
		vertices[0] = getXPos();	//left x
		vertices[1] = getYPos();	//left y
		
		vertices[2] = getXPos()+width;		//right x
		vertices[3] = getYPos();		//right y
		
		vertices[4] = getXPos()+width/2;	//top x
		vertices[5] = getYPos()+height;		//top y
	}
示例#8
0
void MWMechanics::NpcStats::updateHealth()
{
    const int endurance = getAttribute(ESM::Attribute::Endurance).getBase();
    const int strength = getAttribute(ESM::Attribute::Strength).getBase();

    setHealth(floor(0.5f * (strength + endurance)));
}
示例#9
0
void Hero::InitHero(ALLEGRO_BITMAP *image)
{
	setHealth(50);
	setMana(100);

	GameObject::init((mTotalWidth/2),(mTotalHeight/2 + 300), 0, 0, 0, 0, 10, 10);

	setID(PLAYER);
	setHeroNumber(0);

	setAlive(true);
	setCollideable(true);
	setDirection(DOWN);

	maxFrame = 5;
	curFrame = 1;
	frameWidth = 30;
	frameHeight = 30;
	animationColumns = 3;
	animationRow = 4;

	if (image != NULL)
		Hero::image = image;

}
Character::Character() {

    setName("Bro");
    setHealth(300);
    setAttack(25);
    setDefence(5);
    setMoney(10);

    mana = 300;

    facingRight = true;
    attackingRight = true;
    entityRect.h = 100;
    entityRect.w = 100;

    healthBar.x = 5;
    healthBar.y = 10;
    healthBar.w = 300;
    healthBar.h = 25;

    manaBar.x = 5;
    manaBar.y = 40;
    manaBar.w = 300;
    manaBar.h = 25;


}
示例#11
0
void MWMechanics::NpcStats::updateHealth()
{
    const int endurance = getAttribute(ESM::Attribute::Endurance).getBase();
    const int strength = getAttribute(ESM::Attribute::Strength).getBase();

    setHealth(static_cast<int> (0.5 * (strength + endurance)) + mLevelHealthBonus);
}
示例#12
0
void Bullet::intersect( GameObject* object )
{
	// Destroy self
	setHealth( 0 );

	// Do damage to target
	object->doDamage( 1 );
}
示例#13
0
/**
* CZombie::init
* @date Modified May 11, 2006
*/
void CZombie::init(void)
{
	CEnemy::init();

	setHealth(100);
	((CAnimatedMesh*)m_pMesh)->setAnimationSetByName("Walk");
	m_tSelfDelete.setInterval(5.0f);
}
示例#14
0
ActorInfo::ActorInfo(AEvaCharacter * character) : name(character->getName()) {
	setDirection(character->getDirection());
	setPosition(character->getPosition());
	setTeam(character->team);
	setWeaponType(character->currentWeapon);
	setHealth(character->health);
	setArmour(character->armour);
}
DevastatorClass::DevastatorClass(House* newOwner) : TrackedUnit(newOwner)
{
    DevastatorClass::init();

    setHealth(getMaxHealth());

    devastateTimer = 0;
}
示例#16
0
Palace::Palace(House* newOwner) : StructureBase(newOwner) {
    Palace::init();

    setHealth(getMaxHealth());
    specialWeaponTimer = getMaxSpecialWeaponTimer();

    // TODO: Special weapon is available immediately but AI uses it only after first visual contact
	//specialTimer = 1; // we want the special weapon to be immediately ready
}
示例#17
0
Archer::Archer()
{
    setAttack(15); //level 1 arher is 10 * setAttack = 150
    setHealth(20); //level 1 arher is 10 * setHealth = 200
    setSpawnRate(0.1);
    setAttackRate(0.2);
    setSpeed(3);

}
示例#18
0
void BuddyPlayer::deathReset(){
    setY(200);
    spawn_time = SPAWN_TIME;
    setMoving(true);
    setStatus(Status_Falling);
    setHealth(getMaxHealth());
    setDeath(0);
    animation_current = getMovement("idle");
}
示例#19
0
Enemy::Enemy() {
    setPosition(0,0);
    setDirection(NORTH);
    setHealth(10);
    setMovementRate(5);
    setWidth(20);
    setHeight(20);
    setDamage(10);
    setColor(sf::Color(0,0,220));
}
void player::rest()
{
    //Heals by one point and takes up one turn
    if (getHealth() < getMaxHealth())
    {
        int newHealth = getHealth() + 1;
        setHealth(newHealth);
    }
    return;
}
示例#21
0
bool Hurtable::heal(int h)
{
    int curHealth = getHealth();
    int maxHealth = getMaxHealth();

    if (curHealth >= maxHealth)
        return false;

    setHealth(std::min(getMaxHealth(), getHealth() + h));
    return true;
}
示例#22
0
Sword::Sword() {
    setPosition(100,100);
    setDirection(NORTH);
    setHealth(1000);
    setMovementRate(10);
    setWidth(10);
    setHeight(90);
    setDamage(3);
    setColor(sf::Color(0,0,0));
    _swung = false;
}
void player::setClass(characterClass input)
{
    playerClass=input;
    setHealth(20);
    setMaxHealth(20);
    setLevel(1);
    setExperience(0);
    setXpToLevel(10);

    return;
}
示例#24
0
	void Mogh::collision(gen::Sprite* other, gen::World* w){
		
		if(Troll* ch = dynamic_cast<Troll*>(other)){
			damaged = true; 
			setCurrentAnimationVector("DAMAGED"); 
			setHealth(getHealth() - 10);
			setTimer( SDL_GetTicks() + 2000  );
			setCollidable(false);
			setVelocityX(getVelocityX()*2); 
			setVelocityY(getVelocityY()*2);
		
		}
		else if(gen::Object* o = dynamic_cast<gen::Object*>(other)){
			std::string direction = getKeyOfCurrentAnimationVector(); 
			if(direction == "LEFT"){
				setMovementX(getVelocityX());
				moveX(w);
			}
			else if(direction == "RIGHT"){
				setMovementX(-getVelocityX());
				moveX(w);
			}
			else if(direction == "BACK"){
				setMovementY(getVelocityY());
				moveY(w);
			} 
			else if(direction == "FRONT"){
				setMovementY(-getVelocityY());
				moveY(w);
			}
		}
		else if(SeaStar* s = dynamic_cast<SeaStar*>(other)){
			damaged = true; 
			setCurrentAnimationVector("DAMAGED"); 
			setHealth(getHealth() - s->getDamage()); 			
			setTimer( SDL_GetTicks() + 2000 );
			setCollidable(false);
			setVelocityX(getVelocityX()*2); 
			setVelocityY(getVelocityY()*2);
		}
	} 
示例#25
0
void Entity::initClone(Entity *entity)
{
    mNeuralNetwork = entity->mNeuralNetwork.clone(true);
    setEnergy(std::uniform_int_distribution<>(50, 100)(randgen));
    setHealth(std::uniform_int_distribution<>(30, 60)(randgen));
    setHydration(std::uniform_int_distribution<>(1000, 2000)(randgen));
    setValueStore1(0);
    setValueStore2(0);
    setValueStore3(0);
    setValueStore4(0);
    mGeneration = entity->generation() + 1;
}
示例#26
0
/// <summary>
/// Initializes a new instance of the <see cref="Player"/> class.
/// </summary>
/// <param name="window">The window.</param>
/// <param name="pos">The position.</param>
/// <param name="radius">The radius.</param>
/// <param name="bFactory">The b factory.</param>
/// <param name="bullets">The bullets.</param>
/// <param name="resourceHandler">The resource handler.</param>
/// <param name="timeStep">The time step.</param>
/// <param name="hardMode">The hard mode.</param>
Player::Player(sf::RenderWindow& window,
	sf::Vector2f pos,
	int radius, BulletFactory& bFactory,
	std::list<std::unique_ptr<Bullet>>& bullets,
	std::shared_ptr<ResourceHandler>& resourceHandler,
	const sf::Time& timeStep,
	const bool hardMode,
	std::list<std::shared_ptr<Shooter>>& objects
	)
	:
	objects(objects),
	playerScore(0),
	playerKills(0),
	pulsateGun(false),

	Shooter(window, bFactory, bullets, resourceHandler, timeStep)
{
	// Checks if its hardmode, sets the health correspondingly.
	if (!hardMode)
	{
		setHealth(5);
		startHealth = 5;
	}
	else
	{
		setHealth(1);
		startHealth = 1;
	}

	// Set the shape type
	this->shooterType = Shooter::ShooterType::PLAYER;

	// Define the shape for the player
	sprite = std::shared_ptr<GameShape>(new GameShape(GameShape::ShapeType::PLAYER_SHIP));
	sprite->setTexture(&resourceHandler->getTexture(ResourceHandler::Texture::PLAYER_SHIP));
	sprite->setOutlineThickness(1);
	sprite->setOutlineColor(sf::Color::Cyan);
	this->sprite->setPosition(pos);
}
//Dragon class
Dragon::Dragon(string name, int health, int attack, int defence, int money) {

    setName(name);
    setHealth(health);
    setAttack(attack);
    setDefence(defence);
    setMoney(money);

    entityRect.x = 0;
    entityRect.y = 0;
    entityRect.h = 100;
    entityRect.w = 100;
}
示例#28
0
文件: ingame.cpp 项目: jjardon/eos
void IngameGUI::updatePartyMember(uint partyMember, const Creature &creature, bool force) {
	assert(partyMember < _party.size());

	uint32 lastPartyMemberChange = creature.lastChangedGUIDisplay();
	if (!force && (lastPartyMemberChange <= _lastPartyMemberChange[partyMember]))
		return;

	setPortrait(partyMember, creature.getPortrait());
	setName    (partyMember, creature.getName());
	setHealth  (partyMember, creature.getCurrentHP(), creature.getMaxHP());

	_lastPartyMemberChange[partyMember] = lastPartyMemberChange;
}
示例#29
0
Player :: Player(Dungeon *pp, int r, int c)
: Actor (pp, r, c)
{
    max_health = 20;
    setHealth(20);
    setDexterity(2);
    setSleep(0);
    setArmor(2);
    setStrength(2);
    
    equiped = new ShortSword(r,c);
    Inventory.push_back(equiped);
    
}
示例#30
0
Gib::Gib(const int x, const int y, const int z, double dx, double dy, double dz, const Graphics::Bitmap & image, const Util::ReferenceCount<Graphics::Bitmap> & bloodImage):
ObjectNonAttack(x, z),
dx(dx),
dy(dy),
dz(dz),
angle(0),
fade(0),
image(image),
bloodImage(bloodImage){
    setY(y);
    setMaxHealth(1);
    setHealth(1);

}