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 * gun Weapon : The bullet made a great hole if we hit the ground or made damage 00020 * if we hit a character. 00021 *****************************************************************************/ 00022 00023 #include "../weapon/gun.h" 00024 #include <sstream> 00025 #include "../map/map.h" 00026 #include "../game/time.h" 00027 #include "../object/objects_list.h" 00028 #include "../team/teams_list.h" 00029 #include "../tool/i18n.h" 00030 #include "../interface/game_msg.h" 00031 #include "../interface/game_msg.h" 00032 #include "../weapon/gun.h" 00033 #include "../tool/math_tools.h" 00034 #include "../weapon/explosion.h" 00035 00036 const uint GUN_BULLET_SPEED = 20; 00037 00038 GunBullet::GunBullet(ExplosiveWeaponConfig& cfg, 00039 WeaponLauncher * p_launcher) : 00040 WeaponBullet("gun_bullet", cfg, p_launcher) 00041 { 00042 } 00043 00044 void GunBullet::ShootSound() 00045 { 00046 jukebox.Play("share","weapon/gun"); 00047 } 00048 00049 //----------------------------------------------------------------------------- 00050 00051 Gun::Gun() : WeaponLauncher(WEAPON_GUN, "gun", new ExplosiveWeaponConfig()) 00052 { 00053 m_name = _("Gun"); 00054 m_weapon_fire = new Sprite(resource_manager.LoadImage(weapons_res_profile,m_id+"_fire")); 00055 m_weapon_fire->EnableRotationCache(32); 00056 ReloadLauncher(); 00057 } 00058 00059 WeaponProjectile * Gun::GetProjectileInstance() 00060 { 00061 return dynamic_cast<WeaponProjectile *> 00062 (new GunBullet(cfg(),dynamic_cast<WeaponLauncher *>(this))); 00063 } 00064 00065 bool Gun::p_Shoot() 00066 { 00067 if (m_is_active) 00068 return false; 00069 00070 m_is_active = true; 00071 projectile->Shoot (GUN_BULLET_SPEED); 00072 projectile = NULL; 00073 ReloadLauncher(); 00074 return true; 00075 } 00076