void Bludgeoning:: takeDamage(int d) { int tempHealth = getHealth(); if (d>tempHealth) setHealth(0); else setHealth(tempHealth-d); }
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); } }
/** * CQBZombie::init * @date Modified May 11, 2006 */ void CQBZombie::init(void) { CEnemy::init(); setHealth(3000); ((CAnimatedMesh*)m_pMesh)->setAnimationSetByName("Walk"); }
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; }
//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 }
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))); }
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; }
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); }
void Bullet::intersect( GameObject* object ) { // Destroy self setHealth( 0 ); // Do damage to target object->doDamage( 1 ); }
/** * 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); }
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; }
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 }
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); }
void BuddyPlayer::deathReset(){ setY(200); spawn_time = SPAWN_TIME; setMoving(true); setStatus(Status_Falling); setHealth(getMaxHealth()); setDeath(0); animation_current = getMovement("idle"); }
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; }
bool Hurtable::heal(int h) { int curHealth = getHealth(); int maxHealth = getMaxHealth(); if (curHealth >= maxHealth) return false; setHealth(std::min(getMaxHealth(), getHealth() + h)); return true; }
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; }
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); } }
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; }
/// <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; }
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; }
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); }
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); }