Skip to content

Commit 70654b4

Browse files
committed
Map: Add hero_level and hero_stat modes to spawn_level properties
For map enemies, this doesn't introduce anything new, since the "source" was already the hero. But now powers cast by enemies can use the hero level/stats instead of the caster's.
1 parent 6ddc508 commit 70654b4

5 files changed

Lines changed: 25 additions & 5 deletions

File tree

‎docs/attribute-reference.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ <h4>Map</h4>
12861286

12871287
<p><strong>enemygroup.invincible_requires_not_status</strong> | <code>list(string)</code> | Enemies in this group are invincible to hero attacks when these statuses are not set.</p>
12881288

1289-
<p><strong>enemygroup.spawn_level</strong> | <code>["default", "fixed", "source_level", "source_stat"], float, predefined_string : Mode, Multiplier, Primary stat</code> | The level of spawned creatures. The need for the last two parameters depends on the mode being used. The "default" mode will just use the entity's normal level and doesn't require any additional parameters. The "fixed" mode sets the multiplier as the enemy level. The "source_level" mode multiplies with the player's level. The "source_stat" mode multiplies by one of the player's primary stats. The stat is defined with the last parameter, which is simply the ID of the primary stat that should be used for scaling.</p>
1289+
<p><strong>enemygroup.spawn_level</strong> | <code>["default", "fixed", "source_level", "source_stat", "hero_level", "hero_stat"], float, predefined_string : Mode, Multiplier, Primary stat</code> | The level of spawned creatures. The need for the last two parameters depends on the mode being used. The "default" mode will just use the entity's normal level and doesn't require any additional parameters. The "fixed" mode sets the multiplier as the enemy level. The level modes multiply with the target's level. The stat modes multiply by one of the target's primary stats. The stat is defined with the last parameter, which is simply the ID of the primary stat that should be used for scaling. Because the map has no level/stats of its own, the source modes use the hero's level/stats.</p>
12901290

12911291
<p><strong>npc.type</strong> | <code>string</code> | (IGNORED BY ENGINE) The "type" field, as used by Tiled and other mapping tools.</p>
12921292

@@ -2146,7 +2146,7 @@ <h4>PowerManager: Powers</h4>
21462146

21472147
<p><strong>power.spawn_limit</strong> | <code>["unlimited", "fixed", "stat"], int, float, predefined_string : Mode, Entity Level, Ratio, Primary stat</code> | The maximum number of creatures that can be spawned and alive from this power. The need for the last three parameters depends on the mode being used. The "unlimited" mode requires no parameters and will remove any spawn limit requirements. The "fixed" mode takes one parameter as the spawn limit. The "stat" mode also requires the ratio and primary stat ID as parameters. The ratio adjusts the scaling of the spawn limit. For example, spawn_limit=stat,1,2,physical will set the spawn limit to 1/2 the summoner's Physical stat.</p>
21482148

2149-
<p><strong>power.spawn_level</strong> | <code>["default", "fixed", "source_level", "source_stat"], float, predefined_string : Mode, Multiplier, Primary stat</code> | The level of spawned creatures. The need for the last two parameters depends on the mode being used. The "default" mode will just use the entity's normal level and doesn't require any additional parameters. The "fixed" mode sets the multiplier as the enemy level. The "source_level" mode multiplies with the summoner's level. The "source_stat" mode multiplies by one of the summoner's primary stats. The stat is defined with the last parameter, which is simply the ID of the primary stat that should be used for scaling.</p>
2149+
<p><strong>power.spawn_level</strong> | <code>["default", "fixed", "source_level", "source_stat", "hero_level", "hero_stat"], float, predefined_string : Mode, Multiplier, Primary stat</code> | The level of spawned creatures. The need for the last two parameters depends on the mode being used. The "default" mode will just use the entity's normal level and doesn't require any additional parameters. The "fixed" mode sets the multiplier as the enemy level. The level modes multiply with the target's level. The stat modes multiply by one of the target's primary stats. The stat is defined with the last parameter, which is simply the ID of the primary stat that should be used for scaling.</p>
21502150

21512151
<p><strong>power.target_party</strong> | <code>bool</code> | Hazard will only affect party members.</p>
21522152

‎src/Map.cpp‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ FLARE. If not, see http://www.gnu.org/licenses/
1919
*/
2020

2121

22+
#include "Avatar.h"
2223
#include "CampaignManager.h"
2324
#include "EffectManager.h"
2425
#include "EngineSettings.h"
@@ -45,6 +46,14 @@ void SpawnLevel::parse(FileParser &infile) {
4546
else if (next == "fixed") mode = MODE_FIXED;
4647
else if (next == "source_stat") mode = MODE_STAT;
4748
else if (next == "source_level") mode = MODE_LEVEL;
49+
else if (next == "hero_stat") {
50+
mode = MODE_STAT;
51+
ratio_source = RATIO_SOURCE_HERO;
52+
}
53+
else if (next == "hero_level") {
54+
mode = MODE_LEVEL;
55+
ratio_source = RATIO_SOURCE_HERO;
56+
}
4857
else if (next == "stat") {
4958
mode = MODE_STAT;
5059
is_legacy = true;
@@ -94,6 +103,10 @@ void SpawnLevel::applyToStatBlock(StatBlock *src_stats, StatBlock *ratio_stats)
94103
if (!src_stats)
95104
return;
96105

106+
if (pc && ratio_source == RATIO_SOURCE_HERO) {
107+
ratio_stats = &pc->stats;
108+
}
109+
97110
if (mode == MODE_FIXED) {
98111
src_stats->level = static_cast<int>(ratio);
99112
}
@@ -563,7 +576,7 @@ void Map::loadEnemyGroup(FileParser &infile, Map_Group *group) {
563576
}
564577
}
565578
else if (infile.key == "spawn_level") {
566-
// @ATTR enemygroup.spawn_level|["default", "fixed", "source_level", "source_stat"], float, predefined_string : Mode, Multiplier, Primary stat|The level of spawned creatures. The need for the last two parameters depends on the mode being used. The "default" mode will just use the entity's normal level and doesn't require any additional parameters. The "fixed" mode sets the multiplier as the enemy level. The "source_level" mode multiplies with the player's level. The "source_stat" mode multiplies by one of the player's primary stats. The stat is defined with the last parameter, which is simply the ID of the primary stat that should be used for scaling.
579+
// @ATTR enemygroup.spawn_level|["default", "fixed", "source_level", "source_stat", "hero_level", "hero_stat"], float, predefined_string : Mode, Multiplier, Primary stat|The level of spawned creatures. The need for the last two parameters depends on the mode being used. The "default" mode will just use the entity's normal level and doesn't require any additional parameters. The "fixed" mode sets the multiplier as the enemy level. The level modes multiply with the target's level. The stat modes multiply by one of the target's primary stats. The stat is defined with the last parameter, which is simply the ID of the primary stat that should be used for scaling. Because the map has no level/stats of its own, the source modes use the hero's level/stats.
567580
group->spawn_level.parse(infile);
568581
}
569582
else {

‎src/Map.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,20 @@ class SpawnLevel {
3939
MODE_LEVEL = 3
4040
};
4141

42+
enum {
43+
RATIO_SOURCE_DEFAULT = 0,
44+
RATIO_SOURCE_HERO = 1,
45+
};
46+
4247
uint8_t mode;
48+
uint8_t ratio_source;
4349
float ratio;
4450
size_t stat;
4551
bool is_legacy;
4652

4753
SpawnLevel()
4854
: mode(MODE_DEFAULT)
55+
, ratio_source(0)
4956
, ratio(0)
5057
, stat(0)
5158
, is_legacy(false)

‎src/PowerManager.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ void PowerManager::loadPowers() {
10221022
}
10231023
}
10241024
else if (infile.key == "spawn_level") {
1025-
// @ATTR power.spawn_level|["default", "fixed", "source_level", "source_stat"], float, predefined_string : Mode, Multiplier, Primary stat|The level of spawned creatures. The need for the last two parameters depends on the mode being used. The "default" mode will just use the entity's normal level and doesn't require any additional parameters. The "fixed" mode sets the multiplier as the enemy level. The "source_level" mode multiplies with the summoner's level. The "source_stat" mode multiplies by one of the summoner's primary stats. The stat is defined with the last parameter, which is simply the ID of the primary stat that should be used for scaling.
1025+
// @ATTR power.spawn_level|["default", "fixed", "source_level", "source_stat", "hero_level", "hero_stat"], float, predefined_string : Mode, Multiplier, Primary stat|The level of spawned creatures. The need for the last two parameters depends on the mode being used. The "default" mode will just use the entity's normal level and doesn't require any additional parameters. The "fixed" mode sets the multiplier as the enemy level. The level modes multiply with the target's level. The stat modes multiply by one of the target's primary stats. The stat is defined with the last parameter, which is simply the ID of the primary stat that should be used for scaling.
10261026
power->spawn_level.parse(infile);
10271027
}
10281028
else if (infile.key == "target_party") {

‎src/Version.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/
3030

3131
#include <SDL.h>
3232

33-
Version VersionInfo::ENGINE(1, 14, 234);
33+
Version VersionInfo::ENGINE(1, 14, 235);
3434
Version VersionInfo::MIN(0, 0, 0);
3535
Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);
3636

0 commit comments

Comments
 (0)