Permalink
Browse files

Don't hardcode untransform power

  • Loading branch information...
igorko committed Sep 13, 2012
1 parent 48142fb commit 0023188d43013dab6a52a49697d4c713ad49c964
Showing with 19 additions and 4 deletions.
  1. +12 −0 src/Avatar.cpp
  2. +2 −0 src/Avatar.h
  3. +5 −4 src/GameStatePlay.cpp
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 0023188

Please sign in to comment.