00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <actions/AddTarget.h>
00022 #include <engine/ActionController.h>
00023 #include <engine/ScorchedContext.h>
00024 #include <target/TargetContainer.h>
00025 #include <target/TargetDamageCalc.h>
00026 #include <tankai/TankAIAdder.h>
00027 #include <weapons/AccessoryStore.h>
00028 #include <weapons/WeaponAddTarget.h>
00029 #include <weapons/Shield.h>
00030 #include <common/RandomGenerator.h>
00031 #include <common/OptionsScorched.h>
00032
00033 AddTarget::AddTarget(FixedVector &position,
00034 WeaponAddTarget *addTarget) :
00035 ActionReferenced("AddTarget"),
00036 position_(position),
00037 addTarget_(addTarget)
00038 {
00039
00040 }
00041
00042 AddTarget::~AddTarget()
00043 {
00044 }
00045
00046 void AddTarget::init()
00047 {
00048 }
00049
00050 void AddTarget::simulate(fixed frameTime, bool &remove)
00051 {
00052 unsigned int playerId = TankAIAdder::getNextTargetId(*context_);
00053
00054 Target *target = addTarget_->getTargetDefinition().createTarget(
00055 playerId, position_, FixedVector::getNullVector(), *context_,
00056 context_->getActionController().getRandom());
00057 context_->getTargetContainer().addTarget(target);
00058
00059 if (context_->getOptionsGame().getActionSyncCheck())
00060 {
00061 context_->getActionController().addSyncCheck(
00062 S3D::formatStringBuffer("AddTarget : %u %s %i,%i,%i",
00063 playerId,
00064 target->getCStrName().c_str(),
00065 position_[0].getInternal(),
00066 position_[1].getInternal(),
00067 position_[2].getInternal()));
00068 }
00069
00070
00071 WeaponFireContext weaponContext(0, 0);
00072 TargetDamageCalc::damageTarget(*context_, target, addTarget_,
00073 weaponContext, 0, false, true, false);
00074
00075 remove = true;
00076 Action::simulate(frameTime, remove);
00077 }
00078
00079 std::string AddTarget::getActionDetails()
00080 {
00081 return addTarget_->getParent()->getName();
00082 }