Skip to content

Commit 7854444

Browse files
committed
large unit loftemps
let there be arrays!
1 parent f8fb0e7 commit 7854444

8 files changed

Lines changed: 105 additions & 30 deletions

File tree

‎bin/data/Ruleset/Xcom1Ruleset.rul‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4627,7 +4627,7 @@ units:
46274627
armor: CYBERDISC_ARMOR
46284628
standHeight: 15
46294629
kneelHeight: 15
4630-
loftemps: 4
4630+
loftempsSet: [ 92, 89, 90, 91 ]
46314631
value: 20
46324632
deathSound: 23
46334633
moveSound: 40
@@ -4795,7 +4795,7 @@ units:
47954795
armor: REAPER_ARMOR
47964796
standHeight: 23
47974797
kneelHeight: 16
4798-
loftemps: 4
4798+
loftempsSet: [ 92, 89, 90, 91 ]
47994799
value: 25
48004800
deathSound: 48
48014801
intelligence: 2
@@ -4817,7 +4817,7 @@ units:
48174817
armor: TANK_ARMOR
48184818
standHeight: 15
48194819
kneelHeight: 15
4820-
loftemps: 4
4820+
loftempsSet: [ 92, 89, 90, 91 ]
48214821
value: 20
48224822
deathSound: 23
48234823
moveSound: 14
@@ -4838,7 +4838,7 @@ units:
48384838
armor: TANK_ARMOR
48394839
standHeight: 15
48404840
kneelHeight: 15
4841-
loftemps: 4
4841+
loftempsSet: [ 92, 89, 90, 91 ]
48424842
value: 20
48434843
deathSound: 23
48444844
moveSound: 14
@@ -4859,7 +4859,7 @@ units:
48594859
armor: TANK_ARMOR
48604860
standHeight: 15
48614861
kneelHeight: 15
4862-
loftemps: 4
4862+
loftempsSet: [ 92, 89, 90, 91 ]
48634863
value: 20
48644864
deathSound: 23
48654865
moveSound: 14
@@ -4880,7 +4880,7 @@ units:
48804880
armor: HOVERTANK_ARMOR
48814881
standHeight: 15
48824882
kneelHeight: 15
4883-
loftemps: 4
4883+
loftempsSet: [ 92, 89, 90, 91 ]
48844884
value: 20
48854885
deathSound: 23
48864886
moveSound: 15
@@ -4901,7 +4901,7 @@ units:
49014901
armor: HOVERTANK_ARMOR
49024902
standHeight: 15
49034903
kneelHeight: 15
4904-
loftemps: 4
4904+
loftempsSet: [ 92, 89, 90, 91 ]
49054905
value: 20
49064906
deathSound: 23
49074907
moveSound: 15
@@ -5298,7 +5298,7 @@ units:
52985298
armor: SECTOPOD_ARMOR
52995299
standHeight: 23
53005300
kneelHeight: 16
5301-
loftemps: 2
5301+
loftempsSet: [ 92, 89, 90, 91 ]
53025302
value: 30
53035303
deathSound: 23
53045304
intelligence: 4

‎src/Battlescape/TileEngine.cpp‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ bool TileEngine::canTargetUnit(Position *originVoxel, Tile *tile, Position *scan
442442
if (otherUnit == 0) return false; //no unit in this tile, even if it elevated and appearing in it.
443443
if (otherUnit == excludeUnit) return false; //skip self
444444
int unitRadius = otherUnit->getLoftemps(); //width == loft in default loftemps set
445+
if (otherUnit->getArmor()->getSize() > 1)
446+
{
447+
unitRadius = 16;
448+
}
445449
int sliceTargets[10]={0,0, 0,unitRadius, 0,-unitRadius, unitRadius,0, -unitRadius,0};
446450

447451
if (!otherUnit->isOut())
@@ -1637,7 +1641,23 @@ int TileEngine::voxelCheck(const Position& voxel, BattleUnit *excludeUnit, bool
16371641
{
16381642
int x = voxel.x%16;
16391643
int y = voxel.y%16;
1640-
int idx = (unit->getLoftemps() * 16) + y;
1644+
int part = 0;
1645+
if (unit->getArmor()->getSize() > 1)
1646+
{
1647+
if (tile->getPosition().x - unit->getPosition().x == 1)
1648+
{
1649+
part = 1;
1650+
}
1651+
if (tile->getPosition().y - unit->getPosition().y == 1)
1652+
{
1653+
part = 2;
1654+
}
1655+
if (tile->getPosition().x - unit->getPosition().x == 1 && tile->getPosition().y - unit->getPosition().y == 1)
1656+
{
1657+
part = 3;
1658+
}
1659+
}
1660+
int idx = (unit->getLoftemps(part) * 16) + y;
16411661
if (_voxelData->at(idx) & (1 << x))
16421662
{
16431663
return 4;
@@ -1655,7 +1675,23 @@ int TileEngine::voxelCheck(const Position& voxel, BattleUnit *excludeUnit, bool
16551675
{
16561676
int x = voxel.x%16;
16571677
int y = voxel.y%16;
1658-
int idx = (unit->getLoftemps() * 16) + y;
1678+
int part = 0;
1679+
if (unit->getArmor()->getSize() > 1)
1680+
{
1681+
if (below->getPosition().x - unit->getPosition().x == 1)
1682+
{
1683+
part = 1;
1684+
}
1685+
if (below->getPosition().y - unit->getPosition().y == 1)
1686+
{
1687+
part = 2;
1688+
}
1689+
if (below->getPosition().x - unit->getPosition().x == 1 && below->getPosition().y - unit->getPosition().y == 1)
1690+
{
1691+
part = 3;
1692+
}
1693+
}
1694+
int idx = (unit->getLoftemps(part) * 16) + y;
16591695
if (_voxelData->at(idx) & (1 << x))
16601696
{
16611697
return 4;

‎src/Ruleset/RuleSoldier.cpp‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace OpenXcom
2626
* type of soldier.
2727
* @param type String defining the type.
2828
*/
29-
RuleSoldier::RuleSoldier(const std::string &type) : _type(type), _minStats(), _maxStats(), _armor(""), _standHeight(0), _kneelHeight(0), _loftemps(0)
29+
RuleSoldier::RuleSoldier(const std::string &type) : _type(type), _minStats(), _maxStats(), _armor(""), _standHeight(0), _kneelHeight(0), _loftempsSet(0)
3030
{
3131

3232
}
@@ -75,7 +75,13 @@ void RuleSoldier::load(const YAML::Node &node)
7575
}
7676
else if (key == "loftemps")
7777
{
78-
i.second() >> _loftemps;
78+
int a;
79+
i.second() >> a;
80+
_loftempsSet.push_back(a);
81+
}
82+
else if (key == "loftempsSet")
83+
{
84+
i.second() >> _loftempsSet;
7985
}
8086
}
8187
}
@@ -94,7 +100,14 @@ void RuleSoldier::save(YAML::Emitter &out) const
94100
out << YAML::Key << "armor" << YAML::Value << _armor;
95101
out << YAML::Key << "standHeight" << YAML::Value << _standHeight;
96102
out << YAML::Key << "kneelHeight" << YAML::Value << _kneelHeight;
97-
out << YAML::Key << "loftemps" << YAML::Value << _loftemps;
103+
if (_loftempsSet.size() == 1)
104+
{
105+
out << YAML::Key << "loftemps" << YAML::Value << _loftempsSet.front();
106+
}
107+
else
108+
{
109+
out << YAML::Key << "loftempsSet" << YAML::Value << _loftempsSet;
110+
}
98111
out << YAML::EndMap;
99112
}
100113

@@ -128,9 +141,13 @@ int RuleSoldier::getKneelHeight() const
128141
return _kneelHeight;
129142
}
130143
///
131-
int RuleSoldier::getLoftemps() const
144+
int RuleSoldier::getLoftemps(int entry) const
145+
{
146+
return _loftempsSet.at(entry);
147+
}
148+
std::vector<int> RuleSoldier::getLoftempsSet() const
132149
{
133-
return _loftemps;
150+
return _loftempsSet;
134151
}
135152

136153
std::string RuleSoldier::getArmor() const

‎src/Ruleset/RuleSoldier.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class RuleSoldier
3636
std::string _type;
3737
UnitStats _minStats, _maxStats;
3838
std::string _armor;
39-
int _standHeight, _kneelHeight, _loftemps;
39+
int _standHeight, _kneelHeight;
40+
std::vector<int> _loftempsSet;
4041
public:
4142
/// Creates a blank unit ruleset.
4243
RuleSoldier(const std::string &type);
@@ -57,7 +58,8 @@ class RuleSoldier
5758
/// Get the height of the soldier when it's kneeling.
5859
int getKneelHeight() const;
5960
/// Get the line of fire template (3D voxels)
60-
int getLoftemps() const;
61+
int getLoftemps(int entry = 0) const;
62+
std::vector<int> getLoftempsSet() const;
6163
/// Get the armor name.
6264
std::string getArmor() const;
6365

‎src/Ruleset/Unit.cpp‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ YAML::Emitter& operator<< (YAML::Emitter& out, const UnitStats& stats)
6060
* @param race String defining the race.
6161
* @param rank String defining the rank.
6262
*/
63-
Unit::Unit(const std::string &type, std::string race, std::string rank) : _type(type), _race(race), _rank(rank), _stats(), _armor(""), _standHeight(0), _kneelHeight(0), _loftemps(0), _value(0), _deathSound(0), _aggroSound(0), _moveSound(-1), _intelligence(0), _aggression(0), _specab(SPECAB_NONE), _zombieUnit(""), _spawnUnit("")
63+
Unit::Unit(const std::string &type, std::string race, std::string rank) : _type(type), _race(race), _rank(rank), _stats(), _armor(""), _standHeight(0), _kneelHeight(0), _loftempsSet(0), _value(0), _deathSound(0), _aggroSound(0), _moveSound(-1), _intelligence(0), _aggression(0), _specab(SPECAB_NONE), _zombieUnit(""), _spawnUnit("")
6464
{
6565
}
6666

@@ -114,7 +114,13 @@ void Unit::load(const YAML::Node &node)
114114
}
115115
else if (key == "loftemps")
116116
{
117-
i.second() >> _loftemps;
117+
int a;
118+
i.second() >> a;
119+
_loftempsSet.push_back(a);
120+
}
121+
else if (key == "loftempsSet")
122+
{
123+
i.second() >> _loftempsSet;
118124
}
119125
else if (key == "value")
120126
{
@@ -170,7 +176,14 @@ void Unit::save(YAML::Emitter &out) const
170176
out << YAML::Key << "armor" << YAML::Value << _armor;
171177
out << YAML::Key << "standHeight" << YAML::Value << _standHeight;
172178
out << YAML::Key << "kneelHeight" << YAML::Value << _kneelHeight;
173-
out << YAML::Key << "loftemps" << YAML::Value << _loftemps;
179+
if (_loftempsSet.size() == 1)
180+
{
181+
out << YAML::Key << "loftemps" << YAML::Value << _loftempsSet.front();
182+
}
183+
else
184+
{
185+
out << YAML::Key << "loftempsSet" << YAML::Value << _loftempsSet;
186+
}
174187
out << YAML::Key << "value" << YAML::Value << _value;
175188
out << YAML::Key << "deathSound" << YAML::Value << _deathSound;
176189
out << YAML::Key << "aggroSound" << YAML::Value << _aggroSound;
@@ -224,11 +237,15 @@ int Unit::getKneelHeight() const
224237
* Returns the unit's 3D template ID.
225238
* @return template ID.
226239
*/
227-
int Unit::getLoftemps() const
240+
int Unit::getLoftemps(int entry) const
228241
{
229-
return _loftemps;
242+
return _loftempsSet.at(entry);
230243
}
231244

245+
std::vector<int> Unit::getLoftempsSet() const
246+
{
247+
return _loftempsSet;
248+
}
232249
/**
233250
* Gets the unit's armor type.
234251
* @return string.

‎src/Ruleset/Unit.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ class Unit
4848
std::string _rank;
4949
UnitStats _stats;
5050
std::string _armor;
51-
int _standHeight, _kneelHeight, _loftemps;
51+
int _standHeight, _kneelHeight;
5252
int _value, _deathSound, _aggroSound, _moveSound;
5353
int _intelligence, _aggression;
5454
SpecialAbility _specab;
5555
std::string _zombieUnit, _spawnUnit;
56+
std::vector<int> _loftempsSet;
5657
public:
5758
/// Creates a blank unit ruleset.
5859
Unit(const std::string &type, std::string race, std::string rank);
@@ -71,7 +72,8 @@ class Unit
7172
/// Get the unit's height when kneeling.
7273
int getKneelHeight() const;
7374
/// Get the 3D templates
74-
int getLoftemps() const;
75+
int getLoftemps(int entry = 0) const;
76+
std::vector<int> getLoftempsSet() const;
7577
/// Get the armor type.
7678
std::string getArmor() const;
7779
/// Get the alien race type.

‎src/Savegame/BattleUnit.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ BattleUnit::BattleUnit(Soldier *soldier, UnitFaction faction) : _faction(faction
5151
_stats = *soldier->getCurrentStats();
5252
_standHeight = soldier->getRules()->getStandHeight();
5353
_kneelHeight = soldier->getRules()->getKneelHeight();
54-
_loftemps = soldier->getRules()->getLoftemps();
54+
_loftempsSet = soldier->getRules()->getLoftempsSet();
5555
_deathSound = 0; // this one is hardcoded
5656
_aggroSound = 0;
5757
_moveSound = -1; // this one is hardcoded
@@ -106,7 +106,7 @@ BattleUnit::BattleUnit(Unit *unit, UnitFaction faction, int id, Armor *armor) :
106106
_stats = *unit->getStats();
107107
_standHeight = unit->getStandHeight();
108108
_kneelHeight = unit->getKneelHeight();
109-
_loftemps = unit->getLoftemps();
109+
_loftempsSet = unit->getLoftempsSet();
110110
_deathSound = unit->getDeathSound();
111111
_aggroSound = unit->getAggroSound();
112112
_moveSound = unit->getMoveSound();
@@ -1960,9 +1960,9 @@ int BattleUnit::getKneelHeight() const
19601960
* Get the unit's loft ID. This is only one, as it is repeated over the entire height of the unit.
19611961
* @return The unit's line of fire template ID.
19621962
*/
1963-
int BattleUnit::getLoftemps() const
1963+
int BattleUnit::getLoftemps(int entry) const
19641964
{
1965-
return _loftemps;
1965+
return _loftempsSet.at(entry);
19661966
}
19671967

19681968
/**

‎src/Savegame/BattleUnit.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class BattleUnit
9595
std::string _race;
9696
std::wstring _name;
9797
UnitStats _stats;
98-
int _standHeight, _kneelHeight, _loftemps;
98+
int _standHeight, _kneelHeight;
9999
int _value, _deathSound, _aggroSound, _moveSound;
100100
int _intelligence, _aggression;
101101
SpecialAbility _specab;
@@ -106,6 +106,7 @@ class BattleUnit
106106
Soldier *_geoscapeSoldier;
107107
BattleUnit *_charging;
108108
int _turnsExposed;
109+
std::vector<int> _loftempsSet;
109110
public:
110111
static const int MAX_SOLDIER_ID = 1000000;
111112
/// Creates a BattleUnit.
@@ -314,7 +315,7 @@ class BattleUnit
314315
/// Get the unit's kneel height.
315316
int getKneelHeight() const;
316317
/// Get the unit's loft ID.
317-
int getLoftemps() const;
318+
int getLoftemps(int entry = 0) const;
318319
/// Get the unit's value.
319320
int getValue() const;
320321
/// Get the unit's death sound.

0 commit comments

Comments
 (0)