diff --git a/docs/players/Cheat_Codes.md b/docs/players/Cheat_Codes.md index f0b1ee731..6f3388348 100644 --- a/docs/players/Cheat_Codes.md +++ b/docs/players/Cheat_Codes.md @@ -36,7 +36,7 @@ Gives specific creature in every slot, with optional amount. Examples: ### Movement points -`nwcnebuchadnezzar` or `vcminahar` or `vcmimove` - give 1000000 movement points and free ship boarding for 1 day +`nwcnebuchadnezzar` or `vcminahar` or `vcmimove` - give unlimited (or specified amount of) movement points and free ship boarding Alternative usage: `vcmimove ` - gives specified amount of movement points ### Resources @@ -72,7 +72,7 @@ Alternative usage: `vcmiexp ` - gives selected hero specified amount of `nwcbluepill` or `vcmimelkor` or `vcmilose` - player loses ### Misc -`nwctheone` - reveals the whole map, gives 5 archangels in each empty slot, 1000000 movement points and permanent flight +`nwctheone` - reveals the whole map, gives 5 archangels in each empty slot, unlimited movement points and permanent flight ## Using cheat codes on other players By default, all cheat codes apply to current player. Alternatively, it is possible to specify player that you want to target: diff --git a/lib/bonuses/BonusEnum.h b/lib/bonuses/BonusEnum.h index 86ff1e87a..6b906338b 100644 --- a/lib/bonuses/BonusEnum.h +++ b/lib/bonuses/BonusEnum.h @@ -30,6 +30,7 @@ class JsonNode; BONUS_NAME(SURRENDER_DISCOUNT) /*%*/ \ BONUS_NAME(STACKS_SPEED) /*additional info - percent of speed bonus applied after direct bonuses; >0 - added, <0 - subtracted to this part*/ \ BONUS_NAME(FLYING_MOVEMENT) /*value - penalty percentage*/ \ + BONUS_NAME(UNLIMITED_MOVEMENT) /*cheat bonus*/ \ BONUS_NAME(SPELL_DURATION) \ BONUS_NAME(WATER_WALKING) /*value - penalty percentage*/ \ BONUS_NAME(NEGATE_ALL_NATURAL_IMMUNITIES) \ diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 4037cec39..80d83bc41 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -234,7 +234,10 @@ int CGHeroInstance::movementPointsRemaining() const void CGHeroInstance::setMovementPoints(int points) { - movement = std::max(0, points); + if(getBonusBearer()->hasBonusOfType(BonusType::UNLIMITED_MOVEMENT)) + movement = 1000000; + else + movement = std::max(0, points); } int CGHeroInstance::movementPointsLimit(bool onLand) const diff --git a/server/processors/PlayerMessageProcessor.cpp b/server/processors/PlayerMessageProcessor.cpp index c379aa430..ffb501014 100644 --- a/server/processors/PlayerMessageProcessor.cpp +++ b/server/processors/PlayerMessageProcessor.cpp @@ -290,6 +290,7 @@ void PlayerMessageProcessor::cheatMovement(PlayerColor player, const CGHeroInsta SetMovePoints smp; smp.hid = hero->id; + bool unlimited = false; try { smp.val = std::stol(words.at(0));; @@ -297,16 +298,27 @@ void PlayerMessageProcessor::cheatMovement(PlayerColor player, const CGHeroInsta catch(std::logic_error&) { smp.val = 1000000; + unlimited = true; } gameHandler->sendAndApply(&smp); GiveBonus gb(GiveBonus::ETarget::OBJECT); gb.bonus.type = BonusType::FREE_SHIP_BOARDING; - gb.bonus.duration = BonusDuration::ONE_DAY; + gb.bonus.duration = unlimited ? BonusDuration::PERMANENT : BonusDuration::ONE_DAY; gb.bonus.source = BonusSource::OTHER; gb.id = hero->id; gameHandler->giveHeroBonus(&gb); + + if(unlimited) + { + GiveBonus gb(GiveBonus::ETarget::OBJECT); + gb.bonus.type = BonusType::UNLIMITED_MOVEMENT; + gb.bonus.duration = BonusDuration::PERMANENT; + gb.bonus.source = BonusSource::OTHER; + gb.id = hero->id; + gameHandler->giveHeroBonus(&gb); + } } void PlayerMessageProcessor::cheatResources(PlayerColor player, std::vector words)