Skip to content

Commit

Permalink
fix for buying doctors without a hospital
Browse files Browse the repository at this point in the history
lol, oversights.
almost pushed this without checking base transfers.
  • Loading branch information
Warboy1982 committed Oct 29, 2012
1 parent f77400f commit fd95896
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 13 deletions.
4 changes: 4 additions & 0 deletions bin/data/Language/English.lng
Expand Up @@ -2189,3 +2189,7 @@ STR_TRAINING
TRAINING
STR_IN_TRAINING
In Training
STR_NOT_ENOUGH_HOSPITAL_SPACE
NOT ENOUGH HOSPITAL SPACE!{SMALLLINE}Build new Medical Bay or transfer personnel to other bases.
STR_NO_FREE_HOSPITALS
NO FREE HOSPITALS!{SMALLLINE}The destination base does not have enough space in hospitals.
4 changes: 4 additions & 0 deletions bin/data/Language/EnglishUk.lng
Expand Up @@ -2189,3 +2189,7 @@ STR_TRAINING
TRAINING
STR_IN_TRAINING
In Training
STR_NOT_ENOUGH_HOSPITAL_SPACE
NOT ENOUGH HOSPITAL SPACE!{SMALLLINE}Build new Medical Bay or transfer personnel to other bases.
STR_NO_FREE_HOSPITALS
NO FREE HOSPITALS!{SMALLLINE}The destination base does not have enough space in hospitals.
4 changes: 4 additions & 0 deletions bin/data/Language/added strings.txt
Expand Up @@ -119,3 +119,7 @@ STR_TRAINING
TRAINING
STR_IN_TRAINING
In Training
STR_NOT_ENOUGH_HOSPITAL_SPACE
NOT ENOUGH HOSPITAL SPACE!{SMALLLINE}Build new Medical Bay or transfer personnel to other bases.
STR_NO_FREE_HOSPITALS
NO FREE HOSPITALS!{SMALLLINE}The destination base does not have enough space in hospitals.
2 changes: 1 addition & 1 deletion bin/data/Ruleset/Xcom1Ruleset.rul
Expand Up @@ -825,7 +825,7 @@ craftWeapons:
- type: STR_RAIL_CANNON_UC
sprite: 3
sound: 7
damage: 140
damage: 180
range: 60
accuracy: 80
reloadCautious: 12
Expand Down
9 changes: 5 additions & 4 deletions list of things.txt
Expand Up @@ -4,8 +4,6 @@ cultist bases pop up - new mission type: purge - destroy the cultists
cultist attacks on your base.
make a new map type for ground-based assaults, with a 40x40 tile to represent the base compound on a 60x60 map
Training Room for xcom agents using similar rules to X-com apocalypse
medical bay - decreases convalescence time by a percentage based on the number of staff (caps at... 66?)
medical staff, basically scientists that work in the medical bay and add to the modifier
Race specific items and Maps EG: Egg sacks for snakeman, clone tanks for sectiods - recover as alien reproduction
research of reproduction leads to new base facility - cloning facility - allows for dead soldiers to be revived with their stats reduced slightly - option to splice with alien DNA to improve psychic defence by x amount at the cost of... strength? health? stamina? all of the above?
New ufo layouts for variety
Expand All @@ -18,10 +16,13 @@ use weapon mount on craft in missions?
mission types: STR_ANTI_INFILTRATION STR_MILITARY_DEFENCE
make funding nations much harder to please, make them drop out more often, and when they sign a pact, start generating anti-infiltration missions somewhere in their country (use alien base as a template for how to generate a hidden mission) at a rate of about 1.5 per month, and start generating military defence missions every few weeks or so until all anti-infiltration missions are complete, and set the funding nation to "happy"
sattelite defense network? - extra base with free planet wide hyper-wave decode, quadruple transit times, no possibility for manufacturing facilities, no hangers. - new map
make lightning into fast-response unit
make tank shells explosive



done:
medical bay and doctors added
medical bay and doctors added - decreases convalescence time of wounded units based on the number of doctors on hand (current formula is 15 doctors = double heal rate, 40 doctors = triple, 60+ doctors (requires 2 hospitals) = quadruple)
cloning facility added
third map type for terror missions: now has commercial, residential and military base.
researchable disruptor and gauss cannons for hovertanks and crafts
Expand All @@ -31,7 +32,7 @@ hovertank turret placement fixed.
snakemen slither!
hovertanks and laser tanks and guardian fighters, oh my!
added Guardian class interceptor (costs more, is better, funky new sprite(when i can touch dogfight code)
tweaked lightning to be actually good
tweaked firestorm to be actually good
set avenger to have one weapon slot only, hybrid transports don't get to be effective fighter craft too, sorry.
all missing alien races re-implemented, including Chryssalids, and their evil powers.
terror missions at military bases (new map type) with military personnel (new unit type) with flashbangs and all mundane weapon types available
Expand Down
20 changes: 14 additions & 6 deletions src/Basescape/PurchaseState.cpp
Expand Up @@ -309,21 +309,24 @@ void PurchaseState::lstItemsLeftArrowClick(Action *action)
{
int maxByMoney = (_game->getSavedGame()->getFunds() - _total) / getPrice();
int canBeBought = 0;
if (_sel <= 2)
if (_sel <= 3)
{
// Personnel count
int maxByQuarters = _base->getAvailableQuarters() - _base->getUsedQuarters() - _pQty;
canBeBought = std::min(maxByMoney, maxByQuarters);
// in case of doctor
if (_sel == 2)
canBeBought = std::min(std::min(maxByMoney, maxByQuarters),_base->getHospitals());
if (0 < canBeBought) _pQty += canBeBought;
}
else if (_sel >= 3 && _sel < 3 + _crafts.size())
else if (_sel >= 4 && _sel < 4 + _crafts.size())
{
// Craft count
int maxByHangars = _base->getAvailableHangars() - _base->getUsedHangars() - _cQty;
canBeBought = std::min(maxByMoney, maxByHangars);
if (0 < canBeBought) _cQty += canBeBought;
}
else if (_sel >= 3 + _crafts.size())
else if (_sel >= 4 + _crafts.size())
{
// Item count
float storesNeededPerItem = _game->getRuleset()->getItem(_items[_sel - 3 - _crafts.size()])->getSize();
Expand Down Expand Up @@ -381,19 +384,19 @@ void PurchaseState::lstItemsRightArrowClick(Action *action)
if (_qtys[_sel] > 0)
{
// Personnel count
if (_sel <= 2)
if (_sel <= 3)
{
_pQty -= _qtys[_sel];
}
// Craft count
else if (_sel >= 3 && _sel < 3 + _crafts.size())
else if (_sel >= 4 && _sel < 4 + _crafts.size())
{
_cQty -= _qtys[_sel];
}
// Item count
else
{
_iQty -= _game->getRuleset()->getItem(_items[_sel - 3 - _crafts.size()])->getSize() * ((float)(_qtys[_sel]));
_iQty -= _game->getRuleset()->getItem(_items[_sel - 4 - _crafts.size()])->getSize() * ((float)(_qtys[_sel]));
}
_total -= getPrice() * _qtys[_sel];
std::wstring s = _game->getLanguage()->getString("STR_COST_OF_PURCHASES");
Expand Down Expand Up @@ -454,6 +457,11 @@ void PurchaseState::increase()
_timerInc->stop();
_game->pushState(new ErrorMessageState(_game, "STR_NOT_ENOUGH_MONEY", Palette::blockOffset(15)+1, "BACK13.SCR", 0));
}
else if (_sel == 2 && _pQty + 1 > _base->getHospitals())
{
_timerInc->stop();
_game->pushState(new ErrorMessageState(_game, "STR_NOT_ENOUGH_HOSPITAL_SPACE", Palette::blockOffset(15)+1, "BACK13.SCR", 0));
}
else if (_sel <= 3 && _pQty + 1 > _base->getAvailableQuarters() - _base->getUsedQuarters())
{
_timerInc->stop();
Expand Down
9 changes: 9 additions & 0 deletions src/Basescape/TransferItemsState.cpp
Expand Up @@ -361,6 +361,8 @@ void TransferItemsState::lstItemsLeftArrowClick(Action *action)
int freeQuarters = _baseTo->getAvailableQuarters() - _baseTo->getUsedQuarters() - _pQty;
int toBeAdded = getQuantity() - _qtys[_sel];
int canBeAdded = std::min(freeQuarters, toBeAdded);
if((_dOffset)&&_sel == _soldiers.size()+_crafts.size()+_sOffset)
canBeAdded = std::min(std::min(freeQuarters, toBeAdded),_baseTo->getHospitals());
if (0 < canBeAdded)
{
_pQty += canBeAdded;
Expand Down Expand Up @@ -531,6 +533,13 @@ void TransferItemsState::increase()
_game->pushState(new ErrorMessageState(_game, "STR_NO_FREE_ACCOMODATION", Palette::blockOffset(15)+1, "BACK13.SCR", 0));
return;
}
if((_dOffset)&&_sel == _soldiers.size()+_crafts.size()+_sOffset)
{
if(_baseTo->getHospitals()-_baseTo->getDoctors() <= 0);
_timerInc->stop();
_game->pushState(new ErrorMessageState(_game, "STR_NO_FREE_HOSPITALS", Palette::blockOffset(15)+1, "BACK13.SCR", 0));
return;
}
if (_sel >= _soldiers.size() && _sel < _soldiers.size() + _crafts.size())
{
Craft *craft = _crafts[_sel - _soldiers.size()];
Expand Down
16 changes: 15 additions & 1 deletion src/Ruleset/RuleBaseFacility.cpp
Expand Up @@ -26,7 +26,7 @@ namespace OpenXcom
* type of base facility.
* @param type String defining the type.
*/
RuleBaseFacility::RuleBaseFacility(const std::string &type) : _type(type), _requires(), _spriteShape(-1), _spriteFacility(-1), _lift(false), _hyper(false), _mind(false), _grav(false), _size(1), _buildCost(0), _buildTime(0), _monthlyCost(0), _storage(0), _personnel(0), _aliens(0), _crafts(0), _labs(0), _workshops(0), _psiLabs(0), _radarRange(0), _radarChance(0), _defense(0), _hitRatio(0)
RuleBaseFacility::RuleBaseFacility(const std::string &type) : _type(type), _requires(), _spriteShape(-1), _spriteFacility(-1), _lift(false), _hyper(false), _mind(false), _grav(false), _size(1), _buildCost(0), _buildTime(0), _monthlyCost(0), _storage(0), _personnel(0), _aliens(0), _crafts(0), _labs(0), _workshops(0), _psiLabs(0), _radarRange(0), _radarChance(0), _defense(0), _hitRatio(0), _meds(0)
{
}

Expand Down Expand Up @@ -115,6 +115,10 @@ void RuleBaseFacility::load(const YAML::Node &node)
{
i.second() >> _labs;
}
else if (key == "meds")
{
i.second() >> _meds;
}
else if (key == "workshops")
{
i.second() >> _workshops;
Expand Down Expand Up @@ -170,6 +174,7 @@ void RuleBaseFacility::save(YAML::Emitter &out) const
out << YAML::Key << "aliens" << YAML::Value << _aliens;
out << YAML::Key << "crafts" << YAML::Value << _crafts;
out << YAML::Key << "labs" << YAML::Value << _labs;
out << YAML::Key << "meds" << YAML::Value << _meds;
out << YAML::Key << "workshops" << YAML::Value << _workshops;
out << YAML::Key << "psiLabs" << YAML::Value << _psiLabs;
out << YAML::Key << "radarRange" << YAML::Value << _radarRange;
Expand Down Expand Up @@ -350,6 +355,15 @@ int RuleBaseFacility::getLaboratories() const
return _labs;
}

/**
* Returns the amount of hospital space this facility provides
* @return Hospital space.
*/
int RuleBaseFacility::getHospitals() const
{
return _meds;
}

/**
* Returns the amount of workshop space this facility provides
* for manufacturing projects.
Expand Down
4 changes: 3 additions & 1 deletion src/Ruleset/RuleBaseFacility.h
Expand Up @@ -39,7 +39,7 @@ class RuleBaseFacility
std::vector<std::string> _requires;
int _spriteShape, _spriteFacility;
bool _lift, _hyper, _mind, _grav;
int _size, _buildCost, _buildTime, _monthlyCost;
int _size, _buildCost, _buildTime, _monthlyCost, _meds;
int _storage, _personnel, _aliens, _crafts, _labs, _workshops, _psiLabs;
int _radarRange, _radarChance, _defense, _hitRatio;
std::string _mapName;
Expand Down Expand Up @@ -86,6 +86,8 @@ class RuleBaseFacility
int getCrafts() const;
/// Gets the facility's laboratory space.
int getLaboratories() const;
/// Gets the facility's hospital capacity.
int getHospitals() const;
/// Gets the facility's workshop space.
int getWorkshops() const;
/// Gets the facility's psi-training capacity.
Expand Down
16 changes: 16 additions & 0 deletions src/Savegame/Base.cpp
Expand Up @@ -736,6 +736,22 @@ int Base::getFreeLaboratories () const
return getAvailableLaboratories() - getUsedLaboratories();
}

/**
* Return hospital space
* @return hospital space
*/
int Base::getHospitals () const
{
int total = 0;
for (std::vector<BaseFacility*>::const_iterator i = _facilities.begin(); i != _facilities.end(); ++i)
{
if ((*i)->getBuildTime() == 0)
{
total += (*i)->getRules()->getHospitals();
}
}
return total;
}
/**
* Return workshop space not used by a Production
* @return workshop space not used by a Production
Expand Down
3 changes: 3 additions & 0 deletions src/Savegame/Base.h
Expand Up @@ -135,6 +135,9 @@ class Base : public Target
int getAvailableHangars() const;
/// Get the number of available space lab (not used by a ResearchProject)
int getFreeLaboratories () const;
/// Get the number of hospitals
int getHospitals () const;
/// Gets the base's engineers.
/// Get the number of available space lab (not used by a Production)
int getFreeWorkshops () const;

Expand Down

0 comments on commit fd95896

Please sign in to comment.