Permalink
Browse files

Merge pull request #966 from igorko/master

Don't hardcode untransform power
  • Loading branch information...
dorkster committed Sep 13, 2012
2 parents 48142fb + 01fc590 commit 07e7cb1c421b50c1d6f5aa5f7d7df0cf19f3666a
Showing with 19 additions and 6 deletions.
  1. +0 −1 mods/fantasycore/powers/powers.txt
  2. +0 −1 mods/minicore/powers/powers.txt
  3. +12 −0 src/Avatar.cpp
  4. +2 −0 src/Avatar.h
  5. +5 −4 src/GameStatePlay.cpp
@@ -1,5 +1,4 @@
# Power Definitions
-# Do not change power with id=136 called Disenchant
[power]
id=1
@@ -1,5 +1,4 @@
# Power Definitions
-# Do not change power with id=136 called Disenchant
[power]
id=1
View
@@ -101,6 +101,7 @@ void Avatar::init() {
setPowers = false;
revertPowers = false;
last_transform = "";
+ untransform_power = getUntransformPower();
stats.hero_cooldown = vector<int>(POWER_COUNT, 0);
@@ -932,6 +933,17 @@ void Avatar::untransform() {
delete hero_stats;
}
+/**
+ * Find untransform power index to use for manual untransfrom ability
+ */
+int Avatar::getUntransformPower() {
+ for (unsigned id=0; id<powers->powers.size(); id++) {
+ if (powers->powers[id].spawn_type == "untransform" && powers->powers[id].requires_item == -1)
+ return id;
+ }
+ return 0;
+}
+
/**
* getRender()
* Map objects need to be drawn in Z order, so we allow a parent object (GameEngine)
View
@@ -94,6 +94,7 @@ class Avatar : public Entity {
bool transform_triggered;
std::string last_transform;
+ int getUntransformPower();
public:
Avatar(PowerManager *_powers, MapRenderer *_map);
@@ -118,6 +119,7 @@ class Avatar : public Entity {
void untransform();
bool setPowers;
bool revertPowers;
+ int untransform_power;
StatBlock *hero_stats;
StatBlock *charmed_stats;
View
@@ -601,10 +601,11 @@ void GameStatePlay::logic() {
}
if (count == 12) count = 0;
}
- if (pc->stats.manual_untransform) {
- menu->act->hotkeys[count] = 136; //untransform power
- menu->act->locked[count] = true;
- }
+ if (pc->stats.manual_untransform && pc->untransform_power > 0) {
+ menu->act->hotkeys[count] = pc->untransform_power;
+ menu->act->locked[count] = true;
+ } else if (pc->stats.manual_untransform && pc->untransform_power == 0)
+ fprintf(stderr, "Untransform power not found, you can't untransform manually\n");
}
// revert hero powers
if (pc->revertPowers) {

0 comments on commit 07e7cb1

Please sign in to comment.