本文整理汇总了C++中SavedBattleGame类的典型用法代码示例。如果您正苦于以下问题:C++ SavedBattleGame类的具体用法?C++ SavedBattleGame怎么用?C++ SavedBattleGame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SavedBattleGame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SavedBattleGame
/**
* Returns to the previous screen.
* @param action Pointer to an action.
*/
void BaseDefenseState::btnOkClick(Action *)
{
_timer->stop();
_game->setPalette(_game->getResourcePack()->getPalette("PALETTES.DAT_0")->getColors());
_game->popState();
if(_ufo->getStatus() != Ufo::DESTROYED)
{
if (_base->getAvailableSoldiers(true) > 0)
{
size_t month = _game->getSavedGame()->getMonthsPassed();
if (month > _game->getRuleset()->getAlienItemLevels().size()-1)
month = _game->getRuleset()->getAlienItemLevels().size()-1;
SavedBattleGame *bgame = new SavedBattleGame();
_game->getSavedGame()->setBattleGame(bgame);
bgame->setMissionType("STR_BASE_DEFENSE");
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
bgen.setBase(_base);
bgen.setAlienRace(_ufo->getAlienRace());
bgen.setAlienItemlevel(_game->getRuleset()->getAlienItemLevels().at(month).at(RNG::generate(0,9)));
bgen.run();
_state->musicStop();
_game->pushState(new BriefingState(_game, 0, _base));
}
else
{
_game->pushState(new BaseDestroyedState(_game, _base));
}
}
// Whatever happens in the base defense, the UFO has finished its duty
_ufo->setStatus(Ufo::DESTROYED);
}
示例2: think
/*
* Animate explosion sprites. If their animation is finished remove them from the list.
* If the list is empty, this states is finished.
*/
void ExplosionBState::think()
{
for (std::set<Explosion*>::const_iterator i = _parent->getMap()->getExplosions()->begin(), inext = i; i != _parent->getMap()->getExplosions()->end(); i = inext)
{
++inext;
if(!(*i)->animate())
{
_parent->getMap()->getExplosions()->erase((*i));
if (_parent->getMap()->getExplosions()->empty())
{
bool terrainExplosion = false;
SavedBattleGame *save = _parent->getSave();
// after the animation is done, the real explosion takes place
if (_item)
{
save->getTileEngine()->explode(_center, _item->getRules()->getPower(), _item->getRules()->getDamageType(), _item->getRules()->getExplosionRadius(), _unit);
}
if (_tile)
{
save->getTileEngine()->explode(_center, _tile->getExplosive(), DT_HE, 100, _unit);
}
if (!_tile && !_item)
{
// explosion of a cyberdisc
save->getTileEngine()->explode(_center, 120, DT_HE, 8, _unit);
terrainExplosion = true;
}
// now check for new casualties
_parent->checkForCasualties(_item, _unit, false, terrainExplosion);
// if this explosion was caused by a unit shooting, now it's the time to put the gun down
if (_unit && !_unit->isOut())
{
_unit->aim(false);
}
_parent->getMap()->cacheUnits();
_parent->popState();
// check for terrain explosions
Tile *t = save->getTileEngine()->checkForTerrainExplosions();
if (t)
{
Position p = Position(t->getPosition().x * 16, t->getPosition().y * 16, t->getPosition().z * 24);
_parent->statePushNext(new ExplosionBState(_parent, p, 0, _unit, t));
}
return;
}
}
}
}
示例3: think
/*
* Animate explosion sprites. If their animation is finished remove them from the list.
* If the list is empty, this states is finished.
*/
void ExplosionBState::think()
{
for (std::set<Explosion*>::const_iterator i = _parent->getMap()->getExplosions()->begin(), inext = i; i != _parent->getMap()->getExplosions()->end(); i = inext)
{
++inext;
if(!(*i)->animate())
{
_parent->getMap()->getExplosions()->erase((*i));
if (_parent->getMap()->getExplosions()->empty())
{
SavedBattleGame *save = _parent->getGame()->getSavedGame()->getBattleGame();
// after the animation is done, the real explosion takes place
if (_item)
{
save->getTerrainModifier()->explode(_center, _item->getRules()->getPower(), _item->getRules()->getDamageType(), 100, _unit);
}
if (_tile)
{
save->getTerrainModifier()->explode(_center, _tile->getExplosive(), DT_HE, 100, _unit);
}
// now check for new casualties
_parent->checkForCasualties(_item, _unit);
// if this explosion was caused by a unit shooting, now it's the time to put the gun down and put the camera back on the shooter
if (_unit && !_unit->isOut())
{
_unit->aim(false);
if (_parent->getMap()->didCameraFollow())
{
_parent->getMap()->centerOnPosition(_unit->getPosition());
}
}
_parent->getMap()->cacheUnits();
_parent->popState();
// check for terrain explosions
Tile *t = save->getTerrainModifier()->checkForTerrainExplosions();
if (t)
{
Position p = Position(t->getPosition().x * 16, t->getPosition().y * 16, t->getPosition().z * 24);
_parent->statePushNext(new ExplosionBState(_parent, p, 0, _unit, t));
}
return;
}
}
}
}
示例4: SavedBattleGame
/**
* Returns to the previous screen.
* @param action Pointer to an action.
*/
void ConfirmCydoniaState::btnYesClick(Action *)
{
_game->popState();
_game->popState();
SavedBattleGame *bgame = new SavedBattleGame();
_game->getSavedGame()->setBattleGame(bgame);
bgame->setMissionType("STR_MARS_CYDONIA_LANDING");
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
bgen.setCraft(_craft);
bgen.setAlienRace("STR_SECTOID");
bgen.setWorldShade(15);
bgen.run();
_game->pushState(new BriefingState(_game, _craft));
}
示例5: SavedBattleGame
/**
* Enters the mission.
* @param action Pointer to an action.
*/
void ConfirmLandingState::btnYesClick(Action *)
{
_game->popState();
_state->musicStop();
Ufo* u = dynamic_cast<Ufo*>(_craft->getDestination());
TerrorSite* t = dynamic_cast<TerrorSite*>(_craft->getDestination());
AlienBase* b = dynamic_cast<AlienBase*>(_craft->getDestination());
size_t month = _game->getSavedGame()->getMonthsPassed();
if (month > _game->getRuleset()->getAlienItemLevels().size()-1)
month = _game->getRuleset()->getAlienItemLevels().size()-1;
SavedBattleGame *bgame = new SavedBattleGame();
_game->getSavedGame()->setBattleGame(bgame);
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
bgen.setWorldTexture(_texture);
bgen.setWorldShade(_shade);
bgen.setCraft(_craft);
if (u != 0)
{
if(u->getStatus() == Ufo::CRASHED)
bgame->setMissionType("STR_UFO_CRASH_RECOVERY");
else
bgame->setMissionType("STR_UFO_GROUND_ASSAULT");
bgen.setUfo(u);
bgen.setAlienRace(u->getAlienRace());
}
else if (t != 0)
{
bgame->setMissionType("STR_TERROR_MISSION");
bgen.setTerrorSite(t);
bgen.setAlienRace(t->getAlienRace());
}
else if (b != 0)
{
bgame->setMissionType("STR_ALIEN_BASE_ASSAULT");
bgen.setAlienBase(b);
bgen.setAlienRace(b->getAlienRace());
}
else
{
throw Exception("No mission available!");
}
bgen.setAlienItemlevel(_game->getRuleset()->getAlienItemLevels().at(month).at(RNG::generate(0,9)));
bgen.run();
_game->pushState(new BriefingState(_game, _craft));
}
示例6: SavedBattleGame
/**
* Enters the mission.
* @param action Pointer to an action.
*/
void ConfirmLandingState::btnYesClick(Action *action)
{
_game->popState();
Ufo* u = dynamic_cast<Ufo*>(_craft->getDestination());
TerrorSite* t = dynamic_cast<TerrorSite*>(_craft->getDestination());
AlienBase* b = dynamic_cast<AlienBase*>(_craft->getDestination());
if (u != 0)
{
SavedBattleGame *bgame = new SavedBattleGame();
_game->getSavedGame()->setBattleGame(bgame);
if(u->getStatus() == Ufo::CRASHED)
bgame->setMissionType("STR_UFO_CRASH_RECOVERY");
else
bgame->setMissionType("STR_UFO_GROUND_ASSAULT");
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
bgen.setWorldTexture(_texture);
bgen.setWorldShade(_shade);
bgen.setCraft(_craft);
bgen.setUfo(u);
bgen.setAlienRace(u->getAlienRace());
bgen.setAlienItemlevel(0);
bgen.run();
_game->pushState(new BriefingState(_game, _craft));
}
else if (t != 0)
{
SavedBattleGame *bgame = new SavedBattleGame();
_game->getSavedGame()->setBattleGame(bgame);
bgame->setMissionType("STR_TERROR_MISSION");
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
bgen.setWorldTexture(_texture);
bgen.setWorldShade(_shade);
bgen.setCraft(_craft);
bgen.setTerrorSite(t);
bgen.setAlienRace(t->getAlienRace());
bgen.setAlienItemlevel(0);
bgen.run();
_game->pushState(new BriefingState(_game, _craft));
}
else if (b != 0)
{
SavedBattleGame *bgame = new SavedBattleGame();
_game->getSavedGame()->setBattleGame(bgame);
bgame->setMissionType("STR_ALIEN_BASE_ASSAULT");
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
bgen.setWorldTexture(_texture);
bgen.setWorldShade(_shade);
bgen.setCraft(_craft);
bgen.setAlienBase(b);
bgen.setAlienRace(b->getAlienRace());
bgen.setAlienItemlevel(0);
bgen.run();
_game->pushState(new BriefingState(_game, _craft));
}
}
示例7: SavedBattleGame
/**
* Enters the mission.
* @param action Pointer to an action.
*/
void ConfirmLandingState::btnYesClick(Action *)
{
_game->popState();
Ufo* u = dynamic_cast<Ufo*>(_craft->getDestination());
MissionSite* m = dynamic_cast<MissionSite*>(_craft->getDestination());
AlienBase* b = dynamic_cast<AlienBase*>(_craft->getDestination());
SavedBattleGame *bgame = new SavedBattleGame();
_game->getSavedGame()->setBattleGame(bgame);
BattlescapeGenerator bgen(_game);
bgen.setWorldTexture(_texture);
bgen.setWorldShade(_shade);
bgen.setCraft(_craft);
if (u != 0)
{
if (u->getStatus() == Ufo::CRASHED)
bgame->setMissionType("STR_UFO_CRASH_RECOVERY");
else
bgame->setMissionType("STR_UFO_GROUND_ASSAULT");
bgen.setUfo(u);
bgen.setAlienRace(u->getAlienRace());
}
else if (m != 0)
{
bgame->setMissionType(m->getDeployment()->getType());
bgen.setMissionSite(m);
bgen.setAlienRace(m->getAlienRace());
}
else if (b != 0)
{
bgame->setMissionType(b->getDeployment()->getType());
bgen.setAlienBase(b);
bgen.setAlienRace(b->getAlienRace());
bgen.setWorldTexture(0);
}
else
{
throw Exception("No mission available!");
}
bgen.run();
_game->pushState(new BriefingState(_craft));
}
示例8: SavedBattleGame
/**
* Returns to the previous screen.
* @param action Pointer to an action.
*/
void ConfirmCydoniaState::btnYesClick(Action *)
{
_game->popState();
_game->popState();
SavedBattleGame *bgame = new SavedBattleGame();
_game->getSavedGame()->setBattleGame(bgame);
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
for (std::vector<std::string>::const_iterator i = _game->getRuleset()->getDeploymentsList().begin(); i != _game->getRuleset()->getDeploymentsList().end(); ++i)
{
AlienDeployment *deployment = _game->getRuleset()->getDeployment(*i);
if (deployment->isFinalDestination())
{
bgame->setMissionType(*i);
bgen.setAlienRace(deployment->getRace());
break;
}
}
bgen.setCraft(_craft);
bgen.run();
_game->pushState(new BriefingState(_craft));
}
示例9: explode
void ExplosionBState::explode()
{
bool terrainExplosion = false;
SavedBattleGame *save = _parent->getSave();
// after the animation is done, the real explosion/hit takes place
if (_item)
{
if (_areaOfEffect)
{
save->getTileEngine()->explode(_center, _power, _item->getRules()->getDamageType(), _item->getRules()->getExplosionRadius(), _unit);
}
else
{
BattleUnit *victim = save->getTileEngine()->hit(_center, _power, _item->getRules()->getDamageType(), _unit);
// check if this unit turns others into zombies
if (!_unit->getZombieUnit().empty() && victim)
{
// converts the victim to a zombie
_parent->convertUnit(victim, _unit->getZombieUnit());
}
}
}
if (_tile)
{
save->getTileEngine()->explode(_center, _power, DT_HE, 100);
}
if (!_tile && !_item)
{
// explosion not caused by terrain or an item, must be by a unit (cyberdisc)
save->getTileEngine()->explode(_center, _power, DT_HE, 8);
terrainExplosion = true;
}
// now check for new casualties
_parent->checkForCasualties(_item, _unit, false, terrainExplosion);
// if this explosion was caused by a unit shooting, now it's the time to put the gun down
if (_unit && !_unit->isOut())
{
_unit->aim(false);
}
_parent->getMap()->cacheUnits();
_parent->popState();
// check for terrain explosions
Tile *t = save->getTileEngine()->checkForTerrainExplosions();
if (t)
{
Position p = Position(t->getPosition().x * 16, t->getPosition().y * 16, t->getPosition().z * 24);
_parent->statePushNext(new ExplosionBState(_parent, p, 0, _unit, t));
}
}
示例10: explode
/**
* Calculates the effects of the explosion.
*/
void ExplosionBState::explode()
{
bool terrainExplosion = false;
SavedBattleGame *save = _parent->getSave();
// after the animation is done, the real explosion/hit takes place
if (_item)
{
if (!_unit && _item->getPreviousOwner())
{
_unit = _item->getPreviousOwner();
}
BattleUnit *victim = 0;
if (_areaOfEffect)
{
save->getTileEngine()->explode(_center, _power, _item->getRules()->getDamageType(), _item->getRules()->getExplosionRadius(), _unit);
}
else if (!_cosmetic)
{
ItemDamageType type = _item->getRules()->getDamageType();
victim = save->getTileEngine()->hit(_center, _power, type, _unit);
}
// check if this unit turns others into zombies
if (!_item->getRules()->getZombieUnit().empty()
&& victim
&& victim->getArmor()->getSize() == 1
&& (victim->getGeoscapeSoldier() || victim->getUnitRules()->getRace() == "STR_CIVILIAN")
&& victim->getSpawnUnit().empty())
{
// converts the victim to a zombie on death
victim->setRespawn(true);
victim->setSpawnUnit(_item->getRules()->getZombieUnit());
}
}
if (_tile)
{
ItemDamageType DT;
switch (_tile->getExplosiveType())
{
case 0:
DT = DT_HE;
break;
case 5:
DT = DT_IN;
break;
case 6:
DT = DT_STUN;
break;
default:
DT = DT_SMOKE;
break;
}
if (DT != DT_HE)
{
_tile->setExplosive(0,0,true);
}
save->getTileEngine()->explode(_center, _power, DT, _power/10);
terrainExplosion = true;
}
if (!_tile && !_item)
{
int radius = 6;
// explosion not caused by terrain or an item, must be by a unit (cyberdisc)
if (_unit && (_unit->getSpecialAbility() == SPECAB_EXPLODEONDEATH || _unit->getSpecialAbility() == SPECAB_BURN_AND_EXPLODE))
{
radius = _parent->getMod()->getItem(_unit->getArmor()->getCorpseGeoscape())->getExplosionRadius();
}
save->getTileEngine()->explode(_center, _power, DT_HE, radius);
terrainExplosion = true;
}
if (!_cosmetic)
{
// now check for new casualties
_parent->checkForCasualties(_item, _unit, false, terrainExplosion);
}
// if this explosion was caused by a unit shooting, now it's the time to put the gun down
if (_unit && !_unit->isOut() && _lowerWeapon)
{
_unit->aim(false);
_unit->setCache(0);
}
_parent->getMap()->cacheUnits();
_parent->popState();
// check for terrain explosions
Tile *t = save->getTileEngine()->checkForTerrainExplosions();
if (t)
{
Position p = Position(t->getPosition().x * 16, t->getPosition().y * 16, t->getPosition().z * 24);
p += Position(8,8,0);
_parent->statePushFront(new ExplosionBState(_parent, p, 0, _unit, t));
}
//.........这里部分代码省略.........
示例11: DebriefingStat
/**
* Prepares debriefing: gathers Aliens, Corpses, Artefacts, UFO Components.
* Adds the items to the craft.
* Also calculates the soldiers experience, and possible promotions.
* If aborted, only the things on the exit area are recovered.
*/
void DebriefingState::prepareDebriefing()
{
_stats.push_back(new DebriefingStat("STR_ALIENS_KILLED", false));
_stats.push_back(new DebriefingStat("STR_ALIEN_CORPSES_RECOVERED", false));
_stats.push_back(new DebriefingStat("STR_LIVE_ALIENS_RECOVERED", false));
_stats.push_back(new DebriefingStat("STR_ALIEN_ARTIFACTS_RECOVERED", false));
_stats.push_back(new DebriefingStat("STR_ALIEN_BASE_CONTROL_DESTROYED", false));
_stats.push_back(new DebriefingStat("STR_CIVILIANS_KILLED_BY_ALIENS", false));
_stats.push_back(new DebriefingStat("STR_CIVILIANS_KILLED_BY_XCOM_OPERATIVES", false));
_stats.push_back(new DebriefingStat("STR_CIVILIANS_SAVED", false));
_stats.push_back(new DebriefingStat("STR_XCOM_OPERATIVES_KILLED", false));
//_stats.push_back(new DebriefingStat("STR_XCOM_OPERATIVES_RETIRED_THROUGH_INJURY", false));
_stats.push_back(new DebriefingStat("STR_XCOM_OPERATIVES_MISSING_IN_ACTION", false));
_stats.push_back(new DebriefingStat("STR_TANKS_DESTROYED", false));
_stats.push_back(new DebriefingStat("STR_XCOM_CRAFT_LOST", false));
_stats.push_back(new DebriefingStat("STR_UFO_POWER_SOURCE", true));
_stats.push_back(new DebriefingStat("STR_UFO_NAVIGATION", true));
_stats.push_back(new DebriefingStat("STR_UFO_CONSTRUCTION", true));
_stats.push_back(new DebriefingStat("STR_ALIEN_FOOD", true));
_stats.push_back(new DebriefingStat("STR_ALIEN_REPRODUCTION", true));
_stats.push_back(new DebriefingStat("STR_ALIEN_ENTERTAINMENT", true));
_stats.push_back(new DebriefingStat("STR_ALIEN_SURGERY", true));
_stats.push_back(new DebriefingStat("STR_EXAMINATION_ROOM", true));
_stats.push_back(new DebriefingStat("STR_ALIEN_ALLOYS", true));
_stats.push_back(new DebriefingStat("STR_ELERIUM_115", true));
SavedGame *save = _game->getSavedGame();
SavedBattleGame *battle = save->getBattleGame();
bool aborted = battle->isAborted();
Craft* craft = 0;
std::vector<Craft*>::iterator craftIterator;
Base* base = 0;
int playerInExitArea = 0; // if this stays 0 the craft is lost...
int playersSurvived = 0; // if this stays 0 the craft is lost...
for (std::vector<Base*>::iterator i = save->getBases()->begin(); i != save->getBases()->end(); ++i)
{
// in case we have a craft - check which craft it is about
for (std::vector<Craft*>::iterator j = (*i)->getCrafts()->begin(); j != (*i)->getCrafts()->end(); ++j)
{
if ((*j)->isInBattlescape())
{
craft = (*j);
base = (*i);
craftIterator = j;
craft->returnToBase();
craft->setLowFuel(true);
craft->setInBattlescape(false);
}
}
}
// UFO crash/landing site disappears
for (std::vector<Ufo*>::iterator i = save->getUfos()->begin(); i != save->getUfos()->end(); ++i)
{
if ((*i)->isInBattlescape())
{
delete *i;
save->getUfos()->erase(i);
break;
}
}
// lets see what happens with units
for (std::vector<BattleUnit*>::iterator j = battle->getUnits()->begin(); j != battle->getUnits()->end(); ++j)
{
UnitStatus status = (*j)->getStatus();
UnitFaction faction = (*j)->getFaction();
int value = (*j)->getValue();
Soldier *soldier = save->getSoldier((*j)->getId());
if (status == STATUS_DEAD)
{
if (faction == FACTION_HOSTILE)
{
addStat("STR_ALIENS_KILLED", 1, value);
}
if (faction == FACTION_PLAYER)
{
if (soldier != 0)
{
addStat("STR_XCOM_OPERATIVES_KILLED", 1, -value);
for (std::vector<Soldier*>::iterator i = base->getSoldiers()->begin(); i != base->getSoldiers()->end(); ++i)
{
if ((*i) == soldier)
{
delete (*i);
base->getSoldiers()->erase(i);
break;
}
}
}
//.........这里部分代码省略.........
示例12: explode
/**
* Calculates the effects of the explosion.
*/
void ExplosionBState::explode()
{
bool terrainExplosion = false;
SavedBattleGame *save = _parent->getSave();
// after the animation is done, the real explosion/hit takes place
if (_item)
{
if (!_unit && _item->getPreviousOwner())
{
_unit = _item->getPreviousOwner();
}
if (_areaOfEffect)
{
save->getTileEngine()->explode(_center, _power, _item->getRules()->getDamageType(), _item->getRules()->getExplosionRadius(), _unit);
}
else
{
BattleUnit *victim = save->getTileEngine()->hit(_center, _power, _item->getRules()->getDamageType(), _unit);
// check if this unit turns others into zombies
if (!_unit->getZombieUnit().empty()
&& victim
&& victim->getArmor()->getSize() == 1
&& victim->getSpawnUnit().empty()
&& victim->getOriginalFaction() != FACTION_HOSTILE)
{
// converts the victim to a zombie on death
victim->setSpecialAbility(SPECAB_RESPAWN);
victim->setSpawnUnit(_unit->getZombieUnit());
}
}
}
if (_tile)
{
save->getTileEngine()->explode(_center, _power, DT_HE, _power/10);
terrainExplosion = true;
}
if (!_tile && !_item)
{
// explosion not caused by terrain or an item, must be by a unit (cyberdisc)
save->getTileEngine()->explode(_center, _power, DT_HE, 6);
terrainExplosion = true;
}
// now check for new casualties
_parent->checkForCasualties(_item, _unit, false, terrainExplosion);
// if this explosion was caused by a unit shooting, now it's the time to put the gun down
if (_unit && !_unit->isOut() && _lowerWeapon)
{
_unit->aim(false);
}
_parent->getMap()->cacheUnits();
_parent->popState();
// check for terrain explosions
Tile *t = save->getTileEngine()->checkForTerrainExplosions();
if (t)
{
Position p = Position(t->getPosition().x * 16, t->getPosition().y * 16, t->getPosition().z * 24);
_parent->statePushFront(new ExplosionBState(_parent, p, 0, _unit, t));
}
if (_item && (_item->getRules()->getBattleType() == BT_GRENADE || _item->getRules()->getBattleType() == BT_PROXIMITYGRENADE))
{
for (std::vector<BattleItem*>::iterator j = _parent->getSave()->getItems()->begin(); j != _parent->getSave()->getItems()->end(); ++j)
{
if (_item->getId() == (*j)->getId())
{
delete *j;
_parent->getSave()->getItems()->erase(j);
break;
}
}
}
}
示例13: save
/**
* Starts the battle.
* @param action Pointer to an action.
*/
void NewBattleState::btnOkClick(Action *)
{
save();
if (_missionTypes[_cbxMission->getSelected()] != "STR_BASE_DEFENSE" && _craft->getNumSoldiers() == 0 && _craft->getNumVehicles() == 0)
{
return;
}
SavedBattleGame *bgame = new SavedBattleGame();
_game->getSavedGame()->setBattleGame(bgame);
bgame->setMissionType(_missionTypes[_cbxMission->getSelected()]);
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
Base *base = 0;
bgen.setTerrain(_game->getMod()->getTerrain(_terrainTypes[_cbxTerrain->getSelected()]));
// base defense
if (_missionTypes[_cbxMission->getSelected()] == "STR_BASE_DEFENSE")
{
base = _craft->getBase();
bgen.setBase(base);
_craft = 0;
}
// alien base
else if (_game->getMod()->getDeployment(bgame->getMissionType())->isAlienBase())
{
AlienBase *b = new AlienBase(_game->getMod()->getDeployment(bgame->getMissionType()));
b->setId(1);
b->setAlienRace(_alienRaces[_cbxAlienRace->getSelected()]);
_craft->setDestination(b);
bgen.setAlienBase(b);
_game->getSavedGame()->getAlienBases()->push_back(b);
}
// ufo assault
else if (_craft && _game->getMod()->getUfo(_missionTypes[_cbxMission->getSelected()]))
{
Ufo *u = new Ufo(_game->getMod()->getUfo(_missionTypes[_cbxMission->getSelected()]));
u->setId(1);
_craft->setDestination(u);
bgen.setUfo(u);
// either ground assault or ufo crash
if (RNG::generate(0,1) == 1)
{
u->setStatus(Ufo::LANDED);
bgame->setMissionType("STR_UFO_GROUND_ASSAULT");
}
else
{
u->setStatus(Ufo::CRASHED);
bgame->setMissionType("STR_UFO_CRASH_RECOVERY");
}
_game->getSavedGame()->getUfos()->push_back(u);
}
// mission site
else
{
const AlienDeployment *deployment = _game->getMod()->getDeployment(bgame->getMissionType());
const RuleAlienMission *mission = _game->getMod()->getAlienMission(_game->getMod()->getAlienMissionList().front()); // doesn't matter
MissionSite *m = new MissionSite(mission, deployment);
m->setId(1);
m->setAlienRace(_alienRaces[_cbxAlienRace->getSelected()]);
_craft->setDestination(m);
bgen.setMissionSite(m);
_game->getSavedGame()->getMissionSites()->push_back(m);
}
if (_craft)
{
_craft->setSpeed(0);
bgen.setCraft(_craft);
}
_game->getSavedGame()->setDifficulty((GameDifficulty)_cbxDifficulty->getSelected());
bgen.setWorldShade(_slrDarkness->getValue());
bgen.setAlienRace(_alienRaces[_cbxAlienRace->getSelected()]);
bgen.setAlienItemlevel(_slrAlienTech->getValue());
bgame->setDepth(_slrDepth->getValue());
bgen.run();
_game->popState();
_game->popState();
_game->pushState(new BriefingState(_craft, base));
_craft = 0;
}
示例14: explode
/**
* Calculates the effects of the explosion.
*/
void ExplosionBState::explode()
{
bool terrainExplosion = false;
SavedBattleGame *save = _parent->getSave();
// last minute adjustment: determine if we actually
if (_hit)
{
if (_unit && !_unit->isOut())
{
_unit->aim(false);
}
if (_power <= 0)
{
_parent->popState();
return;
}
int sound = _item->getRules()->getMeleeHitSound();
if (!_pistolWhip)
{
// melee weapon with ammo
BattleItem *ammo = _item->getAmmoItem();
if (ammo)
{
optValue(sound, ammo->getRules()->getMeleeHitSound());
}
}
_parent->playSound(sound, _action.target);
}
// after the animation is done, the real explosion/hit takes place
if (_item)
{
if (!_unit && _item->getPreviousOwner())
{
_unit = _item->getPreviousOwner();
}
}
bool range = !(_hit || (_item && _item->getRules()->getBattleType() == BT_PSIAMP));
if (_areaOfEffect)
{
save->getTileEngine()->explode(_center, _power, _damageType, _radius, _unit, _item, range);
}
else
{
BattleUnit *victim = save->getTileEngine()->hit(_center, _power, _damageType, _unit, _item, range);
// check if this unit turns others into zombies
if (!_item->getRules()->getZombieUnit().empty()
&& RNG::percent(_item->getRules()->getSpecialChance())
&& victim
&& victim->getArmor()->getZombiImmune() == false
&& victim->getSpawnUnit().empty()
&& victim->getOriginalFaction() != FACTION_HOSTILE)
{
// converts the victim to a zombie on death
victim->setRespawn(true);
victim->setSpawnUnit(_item->getRules()->getZombieUnit());
}
}
if (_tile)
{
terrainExplosion = true;
}
if (!_tile && !_item)
{
terrainExplosion = true;
}
// now check for new casualties
_parent->checkForCasualties(_item ? _damageType : 0, _item, _unit, false, terrainExplosion);
// revive units if damage could give hp or reduce stun
_parent->getSave()->reviveUnconsciousUnits(true);
// if this explosion was caused by a unit shooting, now it's the time to put the gun down
if (_unit && !_unit->isOut() && _lowerWeapon)
{
_unit->aim(false);
}
if (_item && (_item->getRules()->getBattleType() == BT_GRENADE || _item->getRules()->getBattleType() == BT_PROXIMITYGRENADE))
{
_parent->getSave()->removeItem(_item);
}
_parent->popState();
// check for terrain explosions
Tile *t = save->getTileEngine()->checkForTerrainExplosions();
if (t)
{
Position p = t->getPosition().toVexel();
p += Position(8,8,0);
_parent->statePushFront(new ExplosionBState(_parent, p, BA_NONE, 0, _unit, t));
}
//.........这里部分代码省略.........
示例15: explode
/**
* Calculates the effects of the explosion.
*/
void ExplosionBState::explode()
{
bool terrainExplosion = false;
SavedBattleGame *save = _parent->getSave();
// last minute adjustment: determine if we actually
if (_hit)
{
save->getBattleGame()->getCurrentAction()->type = BA_NONE;
BattleUnit *targetUnit = save->getTile(_center / Position(16, 16, 24))->getUnit();
if (_unit && !_unit->isOut())
{
_unit->aim(false);
_unit->setCache(0);
}
if (!RNG::percent(_unit->getFiringAccuracy(BA_HIT, _item)))
{
_parent->getMap()->cacheUnits();
_parent->popState();
return;
}
else if (targetUnit && targetUnit->getOriginalFaction() == FACTION_HOSTILE &&
_unit->getOriginalFaction() == FACTION_PLAYER)
{
_unit->addMeleeExp();
}
if (_item->getRules()->getMeleeHitSound() != -1)
{
_parent->getResourcePack()->getSoundByDepth(_parent->getDepth(), _item->getRules()->getMeleeHitSound())->play();
}
}
// after the animation is done, the real explosion/hit takes place
if (_item)
{
if (!_unit && _item->getPreviousOwner())
{
_unit = _item->getPreviousOwner();
}
if (_areaOfEffect)
{
save->getTileEngine()->explode(_center, _power, _item->getRules()->getDamageType(), _item->getRules()->getExplosionRadius(), _unit);
}
else
{
ItemDamageType type = _item->getRules()->getDamageType();
if (_pistolWhip)
{
type = DT_STUN;
}
BattleUnit *victim = save->getTileEngine()->hit(_center, _power, type, _unit);
// check if this unit turns others into zombies
if (!_item->getRules()->getZombieUnit().empty()
&& victim
&& victim->getArmor()->getSize() == 1
&& victim->getSpawnUnit().empty()
&& victim->getOriginalFaction() != FACTION_HOSTILE)
{
// converts the victim to a zombie on death
victim->setSpecialAbility(SPECAB_RESPAWN);
victim->setSpawnUnit(_item->getRules()->getZombieUnit());
}
}
}
if (_tile)
{
save->getTileEngine()->explode(_center, _power, DT_HE, _power/10);
terrainExplosion = true;
}
if (!_tile && !_item)
{
int radius = 6;
// explosion not caused by terrain or an item, must be by a unit (cyberdisc)
if (_unit && _unit->getSpecialAbility() == SPECAB_EXPLODEONDEATH)
{
radius = _parent->getRuleset()->getItem(_unit->getArmor()->getCorpseGeoscape())->getExplosionRadius();
}
save->getTileEngine()->explode(_center, _power, DT_HE, radius);
terrainExplosion = true;
}
// now check for new casualties
_parent->checkForCasualties(_item, _unit, false, terrainExplosion);
// if this explosion was caused by a unit shooting, now it's the time to put the gun down
if (_unit && !_unit->isOut() && _lowerWeapon)
{
_unit->aim(false);
_unit->setCache(0);
}
_parent->getMap()->cacheUnits();
_parent->popState();
// check for terrain explosions
Tile *t = save->getTileEngine()->checkForTerrainExplosions();
if (t)
{
Position p = Position(t->getPosition().x * 16, t->getPosition().y * 16, t->getPosition().z * 24);
//.........这里部分代码省略.........