00001 /****************************************************************************** 00002 * Wormux is a convivial mass murder game. 00003 * Copyright (C) 2001-2004 Lawrence Azzoug. 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00018 ****************************************************************************** 00019 * Arme grenade : 00020 * Explose au bout de quelques secondes 00021 *****************************************************************************/ 00022 00023 #include "grenade.h" 00024 //----------------------------------------------------------------------------- 00025 #include <sstream> 00026 #include "../game/time.h" 00027 #include "../team/teams_list.h" 00028 #include "../graphic/video.h" 00029 #include "../tool/math_tools.h" 00030 #include "../map/camera.h" 00031 #include "../weapon/explosion.h" 00032 #include "../interface/game_msg.h" 00033 #include "../tool/i18n.h" 00034 #include "../object/objects_list.h" 00035 //----------------------------------------------------------------------------- 00036 00037 Grenade::Grenade(ExplosiveWeaponConfig& cfg, 00038 WeaponLauncher * p_launcher) : 00039 WeaponProjectile ("grenade", cfg, p_launcher) 00040 { 00041 m_rebound_sound = "weapon/grenade_bounce"; 00042 explode_with_collision = false; 00043 } 00044 00045 //----------------------------------------------------------------------------- 00046 00047 void Grenade::Refresh() 00048 { 00049 WeaponProjectile::Refresh(); 00050 image->SetRotation_rad(GetSpeedAngle()); 00051 } 00052 00053 //----------------------------------------------------------------------------- 00054 00055 void Grenade::SignalOutOfMap() 00056 { 00057 GameMessages::GetInstance()->Add (_("The grenade left the battlefield before exploding")); 00058 WeaponProjectile::SignalOutOfMap(); 00059 } 00060 00061 //----------------------------------------------------------------------------- 00062 00063 GrenadeLauncher::GrenadeLauncher() : 00064 WeaponLauncher(WEAPON_GRENADE, "grenade", new ExplosiveWeaponConfig(), VISIBLE_ONLY_WHEN_INACTIVE) 00065 { 00066 00067 m_name = _("Grenade"); 00068 m_allow_change_timeout = true; 00069 ReloadLauncher(); 00070 } 00071 00072 WeaponProjectile * GrenadeLauncher::GetProjectileInstance() 00073 { 00074 return dynamic_cast<WeaponProjectile *> 00075 (new Grenade(cfg(),dynamic_cast<WeaponLauncher *>(this))); 00076 } 00077 00078