00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <actions/Resurrection.h>
00022 #include <engine/ActionController.h>
00023 #include <engine/ScorchedContext.h>
00024 #include <landscapemap/DeformLandscape.h>
00025 #include <common/ChannelManager.h>
00026 #include <common/OptionsScorched.h>
00027 #include <tank/TankContainer.h>
00028 #include <tank/TankState.h>
00029 #include <target/TargetLife.h>
00030 #include <lang/LangResource.h>
00031 #ifndef S3D_SERVER
00032 #include <land/VisibilityPatchGrid.h>
00033 #endif
00034
00035 Resurrection::Resurrection(
00036 unsigned int playerId,
00037 FixedVector &position) :
00038 ActionReferenced("Resurrection"),
00039 playerId_(playerId),
00040 position_(position)
00041 {
00042
00043 }
00044
00045 Resurrection::~Resurrection()
00046 {
00047 }
00048
00049 void Resurrection::init()
00050 {
00051 }
00052
00053 void Resurrection::simulate(fixed frameTime, bool &remove)
00054 {
00055 remove = true;
00056
00057 Tank *tank = context_->getTankContainer().getTankById(playerId_);
00058 if (tank)
00059 {
00060 #ifndef S3D_SERVER
00061 {
00062 ChannelText text("combat",
00063 LANG_RESOURCE_2(
00064 "TANK_RESURRECTED",
00065 "[p:{0}] was resurrected, {1} lives remaining",
00066 tank->getTargetName(),
00067 S3D::formatStringBuffer("%i", tank->getState().getLives())));
00068 ChannelManager::showText(*context_, text);
00069 }
00070 #endif
00071
00072 if (context_->getOptionsGame().getActionSyncCheck())
00073 {
00074 context_->getActionController().addSyncCheck(
00075 S3D::formatStringBuffer("TankRez: %u %i, %i, %i",
00076 tank->getPlayerId(),
00077 position_[0].getInternal(),
00078 position_[1].getInternal(),
00079 position_[2].getInternal()));
00080 }
00081
00082
00083 tank->rezTank();
00084 tank->getLife().setTargetPosition(position_);
00085 DeformLandscape::flattenArea(*context_, position_);
00086 #ifndef S3D_SERVER
00087 if (!context_->getServerMode())
00088 {
00089 VisibilityPatchGrid::instance()->recalculateErrors(position_, 2);
00090 }
00091 #endif
00092 }
00093
00094 Action::simulate(frameTime, remove);
00095 }