00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "syringe.h"
00023 #include "../game/game_loop.h"
00024 #include "../team/macro.h"
00025 #include "../tool/point.h"
00026 #include "../tool/i18n.h"
00027 #include "explosion.h"
00028
00029 Syringe::Syringe() : Weapon(WEAPON_SYRINGE, "syringe", new SyringeConfig())
00030 {
00031 m_name = _("Syringe");
00032 }
00033
00034 void Syringe::Draw() {
00035 Weapon::Draw();
00036 }
00037
00038 bool Syringe::p_Shoot (){
00039 double angle = ActiveCharacter().GetFiringAngle();
00040 double radius = 0.0;
00041 bool end = false;
00042
00043 jukebox.Play ("share","weapon/syringe");
00044
00045 do
00046 {
00047
00048 radius += 1.0;
00049 if (cfg().range < radius)
00050 {
00051 radius = cfg().range;
00052 end = true;
00053 }
00054
00055
00056 Point2i relative_pos(static_cast<int>(radius * cos(angle)),
00057 static_cast<int>(radius * sin(angle)) );
00058 Point2i pos_to_check = ActiveCharacter().GetHandPosition() + relative_pos;
00059 FOR_ALL_LIVING_CHARACTERS(team, character)
00060 if (&(*character) != &ActiveCharacter())
00061 {
00062
00063 if( character->ObjTouche(pos_to_check) )
00064 {
00065
00066 character->SetDiseaseDamage(cfg().damage, cfg().turns);
00067 end = true;
00068 }
00069 }
00070 } while (!end);
00071
00072 return true;
00073 }
00074
00075 void Syringe::Refresh(){
00076 if (m_is_active)
00077 m_is_active = false;
00078 }
00079
00080 SyringeConfig& Syringe::cfg() {
00081 return static_cast<SyringeConfig&>(*extra_params);
00082 }
00083
00084 SyringeConfig::SyringeConfig(){
00085 range = 45;
00086 turns = 10;
00087 damage = 10;
00088 }
00089
00090 void SyringeConfig::LoadXml(xmlpp::Element *elem){
00091 WeaponConfig::LoadXml(elem);
00092 XmlReader::ReadUint(elem, "range", range);
00093 XmlReader::ReadUint(elem, "turns", turns);
00094 XmlReader::ReadUint(elem, "damage", damage);
00095 }