#include <launcher.h>
Inheritance diagram for WeaponProjectile:
Public Member Functions | |
WeaponProjectile (const std::string &nom, ExplosiveWeaponConfig &cfg, WeaponLauncher *p_launcher) | |
virtual | ~WeaponProjectile () |
virtual void | Draw () |
virtual void | Refresh () |
virtual void | Shoot (double strength) |
virtual bool | IsImmobile () const |
void | IncrementTimeOut () |
void | DecrementTimeOut () |
void | SetTimeOut (int timeout) |
int | GetTotalTimeout () const |
void | ResetTimeOut () |
bool | change_timeout_allowed () |
Public Attributes | |
Character * | dernier_ver_touche |
PhysicalObj * | dernier_obj_touche |
WeaponLauncher * | launcher |
int | m_timeout_modifier |
Protected Member Functions | |
virtual void | SignalObjectCollision (PhysicalObj *obj) |
virtual void | SignalGroundCollision () |
virtual void | SignalCollision () |
virtual void | SignalOutOfMap () |
virtual void | SignalTimeout () |
virtual void | SignalExplosion () |
void | SignalDrowning () |
void | SignalGhostState (bool was_dead) |
virtual void | ShootSound () |
virtual void | Explosion () |
virtual void | RandomizeShoot (double &angle, double &strength) |
virtual void | DoExplosion () |
Protected Attributes | |
Sprite * | image |
bool | explode_colliding_character |
bool | explode_with_timeout |
bool | explode_with_collision |
double | begin_time |
ExplosiveWeaponConfig & | cfg |
Definition at line 32 of file launcher.h.
WeaponProjectile::WeaponProjectile | ( | const std::string & | nom, | |
ExplosiveWeaponConfig & | cfg, | |||
WeaponLauncher * | p_launcher | |||
) |
Definition at line 95 of file launcher.cpp.
00098 : PhysicalObj (name), cfg(p_cfg) 00099 { 00100 m_allow_negative_y = true; 00101 SetCollisionModel(false, true, true); 00102 launcher = p_launcher; 00103 00104 explode_colliding_character = false; 00105 explode_with_timeout = true; 00106 explode_with_collision = true; 00107 00108 image = resource_manager.LoadSprite( weapons_res_profile, name); 00109 image->EnableRotationCache(32); 00110 SetSize(image->GetSize()); 00111 00112 // Set rectangle test 00113 int dx = image->GetWidth()/2-1; 00114 int dy = image->GetHeight()/2-1; 00115 SetTestRect (dx, dx, dy, dy); 00116 00117 ResetTimeOut(); 00118 }
Here is the call graph for this function:
WeaponProjectile::~WeaponProjectile | ( | ) | [virtual] |
bool WeaponProjectile::change_timeout_allowed | ( | ) |
Definition at line 299 of file launcher.cpp.
00300 { 00301 return cfg.allow_change_timeout; 00302 }
Here is the caller graph for this function:
void WeaponProjectile::DecrementTimeOut | ( | ) |
Definition at line 268 of file launcher.cpp.
00269 { 00270 // -1s for grenade timout. 1 is min. 00271 if (cfg.allow_change_timeout && GetTotalTimeout()>1) 00272 m_timeout_modifier -= 1 ; 00273 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponProjectile::DoExplosion | ( | ) | [protected, virtual] |
Reimplemented in Cluster, ClusterBomb, WeaponBullet, and RiotBombRocket.
Definition at line 256 of file launcher.cpp.
00257 { 00258 Point2i pos = GetCenter(); 00259 ApplyExplosion (pos, cfg); 00260 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponProjectile::Draw | ( | ) | [virtual] |
Implements PhysicalObj.
Reimplemented in ObjMine.
Definition at line 167 of file launcher.cpp.
00168 { 00169 image->Draw(GetPosition()); 00170 00171 int tmp = GetTotalTimeout(); 00172 00173 if (cfg.timeout && tmp != 0) 00174 { 00175 tmp -= (int)((Time::GetInstance()->Read() - begin_time) / 1000); 00176 if (tmp >= 0) 00177 { 00178 std::ostringstream ss; 00179 ss << tmp ; 00180 int txt_x = GetX() + GetWidth() / 2; 00181 int txt_y = GetY() - GetHeight(); 00182 (*Font::GetInstance(Font::FONT_SMALL)).WriteCenterTop( Point2i(txt_x, txt_y) - camera.GetPosition(), 00183 ss.str(), white_color); 00184 } 00185 } 00186 }
Here is the call graph for this function:
void WeaponProjectile::Explosion | ( | ) | [protected, virtual] |
Reimplemented in DiscoGrenade.
Definition at line 242 of file launcher.cpp.
00243 { 00244 MSG_DEBUG (m_name.c_str(), "Explosion"); 00245 DoExplosion(); 00246 SignalExplosion(); 00247 Ghost(); 00248 }
Here is the call graph for this function:
Here is the caller graph for this function:
int WeaponProjectile::GetTotalTimeout | ( | ) | const |
Definition at line 286 of file launcher.cpp.
00287 { 00288 return (int)(cfg.timeout)+m_timeout_modifier; 00289 }
Here is the caller graph for this function:
void WeaponProjectile::IncrementTimeOut | ( | ) |
Definition at line 262 of file launcher.cpp.
00263 { 00264 if (cfg.allow_change_timeout && GetTotalTimeout()<(int)cfg.timeout*2) 00265 m_timeout_modifier += 1 ; 00266 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool WeaponProjectile::IsImmobile | ( | ) | const [virtual] |
Reimplemented from PhysicalObj.
Reimplemented in ObjMine.
Definition at line 188 of file launcher.cpp.
00189 { 00190 if(explode_with_timeout && begin_time + GetTotalTimeout() * 1000 > Time::GetInstance()->Read()) 00191 return false; 00192 return PhysicalObj::IsImmobile(); 00193 }
Here is the call graph for this function:
void WeaponProjectile::RandomizeShoot | ( | double & | angle, | |
double & | strength | |||
) | [protected, virtual] |
Reimplemented in ShotgunBuckshot, and SubMachineGunBullet.
Definition at line 237 of file launcher.cpp.
Here is the caller graph for this function:
void WeaponProjectile::Refresh | ( | ) | [virtual] |
Implements PhysicalObj.
Reimplemented in Anvil, RPG, BazookaRocket, BounceBall, Cluster, ClusterBomb, DiscoGrenade, DynamiteStick, Gnu, Grenade, WeaponBullet, ObjMine, Polecat, RiotBombRocket, and SuperTux.
Definition at line 159 of file launcher.cpp.
00160 { 00161 // Explose after timeout 00162 double tmp = Time::GetInstance()->Read() - begin_time; 00163 00164 if(cfg.timeout && tmp > 1000 * (GetTotalTimeout())) SignalTimeout(); 00165 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponProjectile::ResetTimeOut | ( | ) |
Definition at line 281 of file launcher.cpp.
00282 { 00283 m_timeout_modifier = 0 ; 00284 }
Here is the caller graph for this function:
void WeaponProjectile::SetTimeOut | ( | int | timeout | ) |
Definition at line 275 of file launcher.cpp.
00276 { 00277 if (cfg.allow_change_timeout && timeout <= (int)cfg.timeout*2 && timeout >= 1) 00278 m_timeout_modifier = timeout - cfg.timeout ; 00279 }
Here is the caller graph for this function:
void WeaponProjectile::Shoot | ( | double | strength | ) | [virtual] |
Reimplemented in RPG, DynamiteStick, Gnu, Polecat, and SuperTux.
Definition at line 125 of file launcher.cpp.
00126 { 00127 MSG_DEBUG("weapon_projectile", "shoot.\n"); 00128 00129 Init(); 00130 00131 if (launcher != NULL) launcher->IncActiveProjectile(); 00132 00133 // Set the physical factors 00134 ResetConstants(); 00135 00136 // Set the initial position. 00137 SetXY(launcher->GetGunHolePosition()); 00138 SetOverlappingObject(&ActiveCharacter()); 00139 00140 // Set the initial speed. 00141 double angle = ActiveCharacter().GetFiringAngle(); 00142 RandomizeShoot(angle,strength); 00143 SetSpeed (strength, angle); 00144 PutOutOfGround(angle); 00145 00146 begin_time = Time::GetInstance()->Read(); 00147 00148 ShootSound(); 00149 00150 lst_objects.AddObject (this); 00151 camera.FollowObject(this, true, true, true); 00152 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponProjectile::ShootSound | ( | ) | [protected, virtual] |
Reimplemented in DynamiteStick, GunBullet, SnipeBullet, and SubMachineGunBullet.
Definition at line 154 of file launcher.cpp.
00155 { 00156 jukebox.Play(ActiveTeam().GetSoundProfile(), "fire"); 00157 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponProjectile::SignalCollision | ( | ) | [protected, virtual] |
Reimplemented from PhysicalObj.
Definition at line 212 of file launcher.cpp.
00213 { 00214 if (launcher != NULL && !launcher->ignore_collision_signal) launcher->SignalProjectileCollision(); 00215 }
Here is the call graph for this function:
void WeaponProjectile::SignalDrowning | ( | ) | [protected, virtual] |
Reimplemented from Physics.
Reimplemented in RPG, BazookaRocket, and DynamiteStick.
Definition at line 218 of file launcher.cpp.
00219 { 00220 PhysicalObj::SignalDrowning(); 00221 if (launcher != NULL && !launcher->ignore_drowning_signal) 00222 launcher->SignalProjectileDrowning(); 00223 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponProjectile::SignalExplosion | ( | ) | [protected, virtual] |
Reimplemented in DynamiteStick.
Definition at line 250 of file launcher.cpp.
00251 { 00252 if (launcher != NULL && !launcher->ignore_explosion_signal) 00253 launcher->SignalProjectileExplosion(); 00254 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponProjectile::SignalGhostState | ( | bool | was_dead | ) | [protected, virtual] |
Reimplemented from Physics.
Definition at line 226 of file launcher.cpp.
00227 { 00228 if (launcher != NULL && !launcher->ignore_ghost_state_signal) 00229 launcher->SignalProjectileGhostState(); 00230 }
Here is the call graph for this function:
void WeaponProjectile::SignalGroundCollision | ( | ) | [protected, virtual] |
Reimplemented from PhysicalObj.
Reimplemented in Anvil, and WeaponBullet.
Definition at line 205 of file launcher.cpp.
00206 { 00207 if (explode_with_collision) 00208 Explosion(); 00209 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponProjectile::SignalObjectCollision | ( | PhysicalObj * | obj | ) | [protected, virtual] |
Reimplemented from PhysicalObj.
Reimplemented in PolecatFart, Anvil, and WeaponBullet.
Definition at line 196 of file launcher.cpp.
00197 { 00198 assert (obj != NULL); 00199 00200 if (explode_colliding_character) 00201 Explosion(); 00202 }
Here is the call graph for this function:
void WeaponProjectile::SignalOutOfMap | ( | ) | [protected, virtual] |
Reimplemented from PhysicalObj.
Reimplemented in RPG, BazookaRocket, BounceBall, Cluster, ClusterBomb, DiscoGrenade, DynamiteStick, Gnu, Grenade, WeaponBullet, Polecat, RiotBombRocket, and SuperTux.
Definition at line 232 of file launcher.cpp.
Here is the caller graph for this function:
void WeaponProjectile::SignalTimeout | ( | ) | [protected, virtual] |
Definition at line 292 of file launcher.cpp.
00293 { 00294 if (launcher != NULL && !launcher->ignore_timeout_signal) launcher->SignalProjectileTimeout(); 00295 if (explode_with_timeout) Explosion(); 00296 }
Here is the call graph for this function:
Here is the caller graph for this function:
double WeaponProjectile::begin_time [protected] |
Definition at line 40 of file launcher.h.
ExplosiveWeaponConfig& WeaponProjectile::cfg [protected] |
Definition at line 42 of file launcher.h.
Definition at line 46 of file launcher.h.
Definition at line 45 of file launcher.h.
bool WeaponProjectile::explode_colliding_character [protected] |
Definition at line 37 of file launcher.h.
bool WeaponProjectile::explode_with_collision [protected] |
Definition at line 39 of file launcher.h.
bool WeaponProjectile::explode_with_timeout [protected] |
Definition at line 38 of file launcher.h.
Sprite* WeaponProjectile::image [protected] |
Definition at line 35 of file launcher.h.
Definition at line 47 of file launcher.h.
Definition at line 48 of file launcher.h.