Here's another small patch that allows to change the timeout for the weapons 
holly grenade, bounce ball, gnu, dynamite and cluster bomb (using a small 
timeout here can be like an air attack :) )

It also adds the possibility to change the timeout using the number keys on 
the keyboard.
Index: src/include/enum.h
===================================================================
--- src/include/enum.h	(revision 818)
+++ src/include/enum.h	(working copy)
@@ -75,6 +76,15 @@
 	ACTION_SYNC_BEGIN,
 	ACTION_SYNC_END,
 	ACTION_EXPLOSION,
+	ACTION_WEAPON_1,
+	ACTION_WEAPON_2,
+	ACTION_WEAPON_3,
+	ACTION_WEAPON_4,
+	ACTION_WEAPON_5,
+	ACTION_WEAPON_6,
+	ACTION_WEAPON_7,
+	ACTION_WEAPON_8,
+	ACTION_WEAPON_9,
 	ACTION_WEAPON_MORE,
 	ACTION_WEAPON_LESS,
 
Index: src/weapon/launcher.cpp
===================================================================
--- src/weapon/launcher.cpp	(revision 818)
+++ src/weapon/launcher.cpp	(working copy)
@@ -274,6 +274,13 @@
 	
 }
 
+void WeaponProjectile::SetTimeOut(int timeout)
+{
+  if (timeout <= cfg.timeout*2 && timeout >= 1) 
+	 m_timeout_modifier = timeout - cfg.timeout ;
+
+}
+
 void WeaponProjectile::ResetTimeOut()
 {
 	 m_timeout_modifier = 0 ;	
@@ -382,6 +389,34 @@
 
  if (event_type == KEY_RELEASED)
   switch (action) {
+    case ACTION_WEAPON_1:
+	      projectile->SetTimeOut(1);
+	break;
+    case ACTION_WEAPON_2:
+	      projectile->SetTimeOut(2);
+	break;
+    case ACTION_WEAPON_3:
+	      projectile->SetTimeOut(3);
+	break;
+    case ACTION_WEAPON_4:
+	      projectile->SetTimeOut(4);
+	break;
+    case ACTION_WEAPON_5:
+	      projectile->SetTimeOut(5);
+	break;
+    case ACTION_WEAPON_6:
+	      projectile->SetTimeOut(6);
+	break;
+    case ACTION_WEAPON_7:
+	      projectile->SetTimeOut(7);
+	break;
+    case ACTION_WEAPON_8:
+	      projectile->SetTimeOut(8);
+	break;
+    case ACTION_WEAPON_9:
+	      projectile->SetTimeOut(9);
+	break;
+
     case ACTION_WEAPON_MORE:  
 	      projectile->IncrementTimeOut();
       	break ;
Index: src/weapon/holly_grenade.cpp
===================================================================
--- src/weapon/holly_grenade.cpp	(revision 818)
+++ src/weapon/holly_grenade.cpp	(working copy)
@@ -106,5 +106,6 @@
 {  
   m_name = _("HollyGrenade");
   projectile = new HollyGrenade(cfg());
+  m_allow_change_timeout = true;
 }
 
Index: src/weapon/cluster_bomb.cpp
===================================================================
--- src/weapon/cluster_bomb.cpp	(revision 818)
+++ src/weapon/cluster_bomb.cpp	(working copy)
@@ -140,8 +140,8 @@
   WeaponLauncher(WEAPON_CLUSTER_BOMB, "cluster_bomb", new ClusterBombConfig(), VISIBLE_ONLY_WHEN_INACTIVE)
 {  
   m_name = _("ClusterBomb");  
-  
   projectile = new ClusterBomb(cfg());
+  m_allow_change_timeout = true;
 }
 
 ClusterBombConfig& ClusterLauncher::cfg() 
Index: src/weapon/bounce_ball.cpp
===================================================================
--- src/weapon/bounce_ball.cpp	(revision 818)
+++ src/weapon/bounce_ball.cpp	(working copy)
@@ -73,6 +73,7 @@
 {  
   m_name = _("BounceBall");
   projectile = new BounceBall(cfg());
+  m_allow_change_timeout = true;
 }
 
 bool BounceBallLauncher::p_Shoot ()
Index: src/weapon/gnu.cpp
===================================================================
--- src/weapon/gnu.cpp	(revision 818)
+++ src/weapon/gnu.cpp	(working copy)
@@ -119,7 +119,7 @@
   WeaponLauncher(WEAPON_GNU, "gnulauncher", new ExplosiveWeaponConfig(), VISIBLE_ONLY_WHEN_INACTIVE)
 {
   m_name = _("GnuLauncher");
-
   projectile = new Gnu(cfg());
+  m_allow_change_timeout = true;
 }
 
Index: src/game/config.cpp
===================================================================
--- src/game/config.cpp	(revision 818)
+++ src/game/config.cpp	(working copy)
@@ -198,6 +198,15 @@
   clavier->SetKeyAction(SDLK_F7, ACTION_WEAPONS7);
   clavier->SetKeyAction(SDLK_F8, ACTION_WEAPONS8);
   clavier->SetKeyAction(SDLK_c, ACTION_CENTER);
+  clavier->SetKeyAction(SDLK_1, ACTION_WEAPON_1);
+  clavier->SetKeyAction(SDLK_2, ACTION_WEAPON_2);
+  clavier->SetKeyAction(SDLK_3, ACTION_WEAPON_3);
+  clavier->SetKeyAction(SDLK_4, ACTION_WEAPON_4);
+  clavier->SetKeyAction(SDLK_5, ACTION_WEAPON_5);
+  clavier->SetKeyAction(SDLK_6, ACTION_WEAPON_6);
+  clavier->SetKeyAction(SDLK_7, ACTION_WEAPON_7);
+  clavier->SetKeyAction(SDLK_8, ACTION_WEAPON_8);
+  clavier->SetKeyAction(SDLK_9, ACTION_WEAPON_9);
   clavier->SetKeyAction(SDLK_PAGEUP, ACTION_WEAPON_MORE);
   clavier->SetKeyAction(SDLK_PAGEDOWN, ACTION_WEAPON_LESS);
 }
Index: src/weapon/launcher.h
===================================================================
--- src/weapon/launcher.h	(revision 818)
+++ src/weapon/launcher.h	(working copy)
@@ -63,6 +63,7 @@
   
   void IncrementTimeOut();
   void DecrementTimeOut();
+  void SetTimeOut(int timeout);
   int GetTotalTimeout();
   void ResetTimeOut();
   
Index: src/weapon/grenade.cpp
===================================================================
--- src/weapon/grenade.cpp	(revision 818)
+++ src/weapon/grenade.cpp	(working copy)
@@ -72,7 +72,6 @@
   m_name = _("Grenade");
   projectile = new Grenade(cfg());
   m_allow_change_timeout = true;
- 
 }
 
 
Index: src/weapon/dynamite.cpp
===================================================================
--- src/weapon/dynamite.cpp	(revision 818)
+++ src/weapon/dynamite.cpp	(working copy)
@@ -96,8 +96,8 @@
   WeaponLauncher(WEAPON_DYNAMITE, "dynamite", new ExplosiveWeaponConfig(), VISIBLE_ONLY_WHEN_INACTIVE)
 {
   m_name = _("Dynamite");
-  
   projectile = new BatonDynamite(cfg());
+  m_allow_change_timeout = true;
 }
 
 void Dynamite::p_Select()
_______________________________________________
Wormux-dev mailing list
Wormux-dev@gna.org
https://mail.gna.org/listinfo/wormux-dev

Répondre à