Beispiel #1
0
void player::use(int index){
	//WEAPON,ARMOR,CONSUMABLE,ETC
	Item tmp = load::getItemData(getItemList()->at(index).getID());
	if(tmp.getItemType() == "WEAPON"){
		getStat()->addAll(0-getWeapon().getiAtk(),0-getWeapon().getiDef(),0-getWeapon().getiMaxHp());
		getItemList()->at(index) = load::getItemData(getWeapon().getID());
		if(getItemList()->at(index).getID() == 1)delItem(index);
		setWeapon(tmp.getID());
		getStat()->addAll(tmp.getiAtk(),tmp.getiDef(),tmp.getiMaxHp());
		cout << "\n\tEquipe "<<tmp.getName()<<endl;
	}else if(tmp.getItemType() == "ARMOR"){
		getStat()->addAll(0-getArmor().getiAtk(),0-getArmor().getiDef(),0-getArmor().getiMaxHp());
		getItemList()->at(index) = load::getItemData(getArmor().getID());
		if(getItemList()->at(index).getID() == 2)delItem(index);
		setArmor(tmp.getID());
		getStat()->addAll(tmp.getiAtk(),tmp.getiDef(),tmp.getiMaxHp());
		cout << "\n\tEquipe "<<tmp.getName()<<endl;
	}else if(tmp.getItemType() == "CONSUMABLE"){
		getStat()->addAll(tmp.getiAtk(),tmp.getiDef(),tmp.getiMaxHp());
		getStat()->addHp(tmp.getiHp());
		delItem(index);
		cout << "\tUse "<<tmp.getName()<<endl;
	}else{
		cout << "\n\tCannot use "<<tmp.getName()<<endl;
	}
	getch();
}
Beispiel #2
0
CrawlerUnit::CrawlerUnit(DefenseUnit *inUnit, AI *ai) : DefenseUnit(inUnit, ai) {
	setID(inUnit->getID());
	setPos(inUnit->getPosX(), inUnit->getPosY());
	setDistanceTo(inUnit->getDistanceTo());
	setState(inUnit->getState());
	setRadius(inUnit->getRadius());
	setArmor(inUnit->getArmor());
}
Beispiel #3
0
Henchman::Henchman()
{
   strengthDefault = 8;
   setName("Henchman");
   setType(HENCHMAN);
   setStrengthPts(strengthDefault);
   setAttackDice(2);
   setAttackSides(6);
   setDefenseDice(1);
   setDefenseSides(6);
   setArmor(3);
   setAchilles(false);
}
Beispiel #4
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);
    
}
Beispiel #5
0
Raider* Raider::createMonster(std::vector<Point> points)
{
    auto monster = new Raider();
    if (monster && monster->init())
    {
        monster->setPointsVector(points);
		monster->setMaxHp(160);
		monster->setCurrHp(160);
		monster->setMoney(30);
		monster->setRunSpeed(40);
		monster->setArmor(10);
		monster->setForce(8);
		monster->setAttackBySoldier(true);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
void player::levelUp()
{
    //Assigns to a random value at this point
    int currentAttribute;
    int randomAttribute = rand() % 3;
    switch(randomAttribute)
    {
        //Increases Damage
        case 0:
            currentAttribute = getBaseDamage() + 1;
            setBaseDamage(currentAttribute);
            break;
        //Increases Armor
        case 1:
            currentAttribute = getArmor() + 1;
            setArmor(currentAttribute);
            break;
        //Increase Health
        case 2:
            currentAttribute = getMaxHealth() + 1;
            setHealth(currentAttribute);
            setMaxHealth(currentAttribute);
            break;
    }


    experience=xpToLevel%experience;
    if((xpToLevel%2)>0)
    {
        xpToLevel=xpToLevel*1.5;
        xpToLevel++;
    }
    else
    {
        xpToLevel=xpToLevel*1.5;
    }
    int levelHolder=getLevel();
    levelHolder++;
    setLevel(levelHolder);
    return;
}
Beispiel #7
0
Wolf* Wolf::createMonster(std::vector<Point> points)
{
    auto monster = new Wolf();
    if (monster && monster->init())
    {

        monster->setPointsVector(points);
		monster->setMaxHp(35);
		monster->setCurrHp(35);
		monster->setRunSpeed(100);
        monster->runNextPoint();      
		monster->setMoney(20);
		monster->setArmor(0);
		monster->setForce(2);
		monster->setAttackBySoldier(true);
        monster->autorelease();
        return monster;
    }
	CC_SAFE_DELETE(monster);
    return NULL;
}
Beispiel #8
0
Gorilla* Gorilla::createMonster(std::vector<Point> points)
{
    auto monster = new Gorilla();
    if (monster && monster->init())
    {

        monster->setPointsVector(points);
		monster->setMaxHp(2500);
		monster->setCurrHp(2500);
		monster->setMoney(500);
		monster->setForce(60);
		monster->setArmor(0);
		monster->setAttackBySoldier(true);
		monster->setRunSpeed(30);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
Beispiel #9
0
Quetzal* Quetzal::createMonster(std::vector<Point> points)
{
    auto monster = new Quetzal();
    if (monster && monster->init())
    {

        monster->setPointsVector(points);
		monster->setMaxHp(500);
		monster->setCurrHp(500);
		monster->setMoney(20);
		monster->setForce(45);
		monster->setArmor(10);
		monster->setAttackBySoldier(false);
		monster->setRunSpeed(60);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
Beispiel #10
0
Boss_Efreeti* Boss_Efreeti::createMonster(std::vector<Point> points,std::vector<std::vector<std::vector<Point>>> sonpath)
{
    auto monster = new Boss_Efreeti();
    if (monster && monster->init())
    {
        monster->setPointsVector(points);
		monster->setMaxHp(5550);
		monster->setCurrHp(5550);
		monster->setMoney(1500);
		monster->sonPath = sonpath;
		monster->setForce(50);
		monster->setArmor(10);
		monster->setAttackByTower(true);
		monster->setAttackBySoldier(true);
		monster->setRunSpeed(20);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
Beispiel #11
0
Tremor* Tremor::createMonster(std::vector<Point> points)
{
    auto monster = new Tremor();
    if (monster && monster->init())
    {

        monster->setPointsVector(points);
		monster->setMaxHp(35);
		monster->setCurrHp(35);
		monster->setMoney(10);
		monster->setForce(4);
		monster->setArmor(0);
		monster->setForce(8);
		monster->setAttackByTower(false);
		monster->setAttackBySoldier(true);
		monster->setRunSpeed(50);
        monster->runNextPoint();       
        monster->autorelease();
        return monster;
    }
    CC_SAFE_DELETE(monster);
    return NULL;
}
Beispiel #12
0
EnergyUnit::EnergyUnit(AI *ai) : DefenseUnit(ai) {
	setRadius(1);
	setArmor(5);
	setCost(7);
}
Beispiel #13
0
CrawlerUnit::CrawlerUnit(AI *ai) : DefenseUnit(ai) {
	setRadius(1);
	setArmor(3);
	setCost(7);
}
Beispiel #14
0
TowerUnit::TowerUnit(AI *ai) : DefenseUnit(ai) {
	setRadius(1);
	setArmor(3);
	setCost(1);
}
Beispiel #15
0
BridgeUnit::BridgeUnit(AI *ai) : DefenseUnit(ai) {
	setRadius(1);
	setArmor(3);
	setCost(1);
}
Beispiel #16
0
MineUnit::MineUnit(AI *ai) : DefenseUnit(ai) {
	setRadius(80);
	setArmor(1);
	setCost(3);
}
Beispiel #17
0
ShieldUnit::ShieldUnit(AI *ai) : DefenseUnit(ai) {
	setRadius(170);
	setArmor(3);
	setCost(7);
}
Beispiel #18
0
void Monster::adjust(int buffswitch) {
    int     buff=0, crthp=0;
    long    xpmod=0;

    if(buffswitch == -1)
        buff = mrand(1,3)-1;
    else
        buff = MAX(0, MIN(buffswitch, 2));


    /*          Web Editor
     *           _   _  ____ _______ ______
     *          | \ | |/ __ \__   __|  ____|
     *          |  \| | |  | | | |  | |__
     *          | . ` | |  | | | |  |  __|
     *          | |\  | |__| | | |  | |____
     *          |_| \_|\____/  |_|  |______|
     *
     *      If you change anything here, make sure the changes are reflected in the web
     *      editor! Either edit the PHP yourself or tell Dominus to make the changes.
     */
    if(!flagIsSet(M_CUSTOM)) {
        if(level >= 1 && level <= MAXALVL) {
            setArmor(balancedStats[level].armor);
            weaponSkill = (level-1)*10;
            defenseSkill = (level-1)*10;
            setExperience(balancedStats[level].experience);
            damage.setNumber(balancedStats[level].ndice);
            damage.setSides(balancedStats[level].sdice);
            damage.setPlus(balancedStats[level].pdice);
        } else {
            setArmor(100);
            weaponSkill = 1;
            defenseSkill = 1;
            setExperience(6);
            damage.setNumber(1);
            damage.setSides(4);
            damage.setPlus(0);
        }


        if(cClass == CreatureClass::NONE)
            hp.setInitial(level * monType::getHitdice(type));
        else {
            crthp = class_stats[(int) cClass].hpstart + (level*class_stats[(int) cClass].hp);
            hp.setInitial(MAX(crthp, (level * monType::getHitdice(type))));
        }

        hp.restore();

        xpmod = experience / 10;
        xpmod *= monType::getHitdice(type) - monType::getHitdice(HUMANOID);

        if(xpmod > 0)
            addExperience(xpmod);
        else
            subExperience(xpmod*-1);
    }


    switch(buff) {
    case 1:         // Mob is weak.
        hp.setInitial( hp.getMax() - hp.getMax()/5);
        hp.restore();
        coins.set(coins[GOLD] * 4 / 5, GOLD);

        subExperience(experience / 5);
        setArmor(armor - 100);
        damage.setNumber(damage.getNumber() * 9 / 10);
        damage.setPlus(damage.getPlus() * 9 / 10);
        break;
    case 2:         // Mob is stronger
        hp.setInitial( hp.getMax() + hp.getMax()/5);
        hp.restore();
        coins.set(coins[GOLD] * 6 / 5, GOLD);

        addExperience(experience / 5);
        defenseSkill += 5;
        weaponSkill += 5;
        setArmor(armor + 100);

        damage.setNumber(damage.getNumber() * 11 / 10);
        damage.setPlus(damage.getPlus() * 11 / 10);
        break;
    default:
        break;
    }

    armor = MAX<unsigned int>(MIN(armor, MAX_ARMOR), 0);

    if(level >= 7)
        setFlag(M_BLOCK_EXIT);

}
Beispiel #19
0
/**
 * Do an amount of damage.
 * @param position The position defines which part of armor and/or bodypart is hit.
 * @param power
 * @param type
 */
void BattleUnit::damage(Position position, int power, ItemDamageType type)
{
	int damage;
	UnitSide side;
	int impactheight;
	UnitBodyPart bodypart;

	if (power <= 0)
	{
		return;
	}

	power *= _unit->getArmor()->getDamageModifier(type);

	if (type == DT_STUN)
	{
		_stunlevel += power;
		return;
	}

	if (position == Position(0, 0, 0))
	{
		side = SIDE_UNDER;
	}
	else
	{
		// normalize x and y towards north
		int x = 8, y = 8;
		switch(_direction)
		{
		case 0: // heading north
			x = position.x;
			y = 15 - position.y;
			break;
		case 1: // somewhere in between 0 and 2
			x = (position.x + position.y)/2;
			y = ((15 - position.y) + position.x)/2;
			break;
		case 2: // heading east
			x = 15 - position.y;
			y = 15 - position.x;
			break;
		case 3:
			x = (position.y + (15 - position.x))/2;
			y = (position.x + position.y)/2;
			break;
		case 4: // heading south
			x = 15 - position.x;
			y = position.y;
			break;
		case 5:
			x = ((15 - position.x) + (15 - position.y))/2;
			y = (position.y + (15 - position.x))/2;
			break;
		case 6: // heading west
			x = 15 - position.y;
			y = 15 - position.x;
			break;
		case 7:
			x = ((15 - position.y) + position.x)/2;
			y = ((15 - position.x) + (15 - position.y))/2;
			break;
		}
		// determine side
		if (y > 9)
			side = SIDE_FRONT;
		else if (y < 6)
			side = SIDE_REAR;
		else if (x < 6)
			side = SIDE_LEFT;
		else if (x > 9)
			side = SIDE_RIGHT;
		else
			side = SIDE_FRONT;
	}

	impactheight = 10*position.z/getHeight();

	if (impactheight > 4 && impactheight < 7) // torso
	{
		if (side == SIDE_LEFT)
		{
			bodypart = BODYPART_LEFTARM;
		}else if (side == SIDE_RIGHT)
		{
			bodypart = BODYPART_RIGHTARM;
		}else
		{
			bodypart = BODYPART_TORSO;
		}
	}else if (impactheight >= 7) //head
	{
		bodypart = BODYPART_HEAD;
	}else if (impactheight <=4) //legs
	{
		if (side == SIDE_LEFT || side == SIDE_FRONT)
		{
			bodypart = BODYPART_LEFTLEG;
		}else
		{
			bodypart = BODYPART_RIGHTLEG;
		}
	}

	damage = (power - getArmor(side));

	if (damage > 0)
	{
		if (_unit->isWoundable())
		{
			// fatal wounds
			if (RNG::generate(0,damage) > 2)
				_fatalWounds[bodypart] += RNG::generate(1,3);

			if (_fatalWounds[bodypart])
				moraleChange(-_fatalWounds[bodypart]);
		}
		// armor damage
		setArmor(getArmor(side) - (damage/10) - 1, side);
		// health damage
		_health -= damage;
		if (_health < 0)
			_health = 0;
	}
	_needPainKiller = true;
}
Beispiel #20
0
/**
 * Do an amount of damage.
 * @param position The position defines which part of armor and/or bodypart is hit.
 * @param power
 */
void BattleUnit::damage(Position position, int power)
{
	int damage;
	UnitSide side;
	int impactheight;
	UnitBodyPart bodypart;

	if (power <= 0)
	{
		return;
	}

	if (position == Position(0, 0, 0))
	{
		side = SIDE_UNDER;
	}
	else
	{
		// normalize x and y
		int x = 8, y = 8;
		switch(_direction)
		{
		case 0: // heading north, all is the same
			x = position.x;
			y = position.y;
			break;
		case 1: // somewhere in between 0 and 2
			x = (position.x + (15 - position.y))/2;
			y = (position.y + position.x)/2;
			break;
		case 2: // heading east
			x = 15 - position.y;
			y = position.x;
			break;
		case 3:
			x = ((15 - position.y) + (15 - position.x))/2;
			y = (position.x + (15 - position.y))/2;
			break;
		case 4: // heading south, both axis inversed
			x = 15 - position.x;
			y = 15 - position.y;
			break;
		case 5:
			x = ((15 - position.x) + position.y)/2;
			y = ((15 - position.y) + (15 - position.x))/2;
			break;
		case 6: // heading west
			x = position.y;
			y = 15 - position.x;
			break;
		case 7:
			x = (position.y + position.x)/2;
			y = ((15 - position.x) + position.y)/2;
			break;
		}
		// determine side
		if (y > 9)
			side = SIDE_FRONT;
		else if (y < 6)
			side = SIDE_REAR;
		else if (x < 6)
			side = SIDE_LEFT;
		else if (x > 9)
			side = SIDE_RIGHT;
		else
			side = SIDE_FRONT;
	}

	impactheight = 10*position.z/getHeight();

	if (impactheight > 4 && impactheight < 7) // torso
	{
		if (side == SIDE_LEFT)
		{
			bodypart = BODYPART_LEFTARM;
		}else if (side == SIDE_RIGHT)
		{
			bodypart = BODYPART_RIGHTARM;
		}else
		{
			bodypart = BODYPART_TORSO;
		}
	}else if (impactheight >= 7) //head
	{
		bodypart = BODYPART_HEAD;
	}else if (impactheight <=4) //legs
	{
		if (side == SIDE_LEFT || side == SIDE_FRONT)
		{
			bodypart = BODYPART_LEFTLEG;
		}else
		{
			bodypart = BODYPART_RIGHTLEG;
		}
	}

	damage = (power - getArmor(side));

	if (damage > 0)
	{
		// fatal wounds
		if (RNG::generate(0,damage) > 2)
			_fatalWounds[bodypart] += RNG::generate(1,3);

		if (_fatalWounds[bodypart])
			moraleChange(-_fatalWounds[bodypart]);

		// armor damage
		setArmor(getArmor(side) - (damage+5)/10, side);
		// health damage
		_health -= damage;
		if (_health < 0)
			_health = 0;
	}
}
Beispiel #21
0
AntiAirUnit::AntiAirUnit(AI *ai) : DefenseUnit(ai) {
	setRadius(190);
	setArmor(3);
	setCost(1);
}
Beispiel #22
0
/************************************************************************************
** Default Constructor:  Medusa()
** Description: Creates a Medusa object with 3 armor and 8 Strength Points.
************************************************************************************/
Medusa::Medusa()
{
	setArmor(3);
	setSP(8);
	setName("Medusa");
}