I have attached a patch (2, since I am not quite sure how to do 2 files in one patch) that should implement this change. Please forgive me if the patches are weird, as I have never used "diff" before.
Thanks,
Kyle
--- wormux/src/weapon/air_attack.cpp 2006-11-05 01:03:50.000000000 -0500
+++ air_attack.cpp 2006-11-05 01:01:00.000000000 -0500
@@ -21,6 +21,7 @@
#include "air_attack.h"
#include <sstream>
+#include <math.h>
#include "../game/game_loop.h"
#include "../graphic/sprite.h"
#include "../include/action_handler.h"
@@ -69,6 +70,7 @@
int dir = ActiveCharacter().GetDirection();
cible_x = target.x;
SetY (0);
+ distance_to_release =(int)( (speed) * sqrt((2*(GetY()+target.y))));
image->Scale(dir, 1);
@@ -76,11 +78,13 @@
{
speed_vector.SetValues( speed, 0);
SetX (-image->GetWidth()+1);
+ distance_to_release-=obus_dx;
}
else
{
speed_vector.SetValues( -speed, 0) ;
SetX (world.GetWidth()-1);
+ distance_to_release+=obus_dx;
}
SetSpeedXY (speed_vector);
@@ -96,12 +100,8 @@
instance->SetXY( Point2i(GetX(), obus_dy) );
Point2d speed_vector;
+ GetSpeedXY(speed_vector);
- int fx = randomSync.GetLong (FORCE_X_MIN, FORCE_X_MAX);
- fx *= GetDirection();
- int fy = randomSync.GetLong (FORCE_Y_MIN, FORCE_Y_MAX);
-
- speed_vector.SetValues( fx/30.0, fy/30.0);
instance->SetSpeedXY (speed_vector);
lst_objects.AddObject(instance);
@@ -117,8 +117,8 @@
UpdatePosition();
image->Update();
// First shoot !!
- if ( OnTopOfTarget() && nb_dropped_bombs == 0)
- DropBomb();
+ if ( InPlaceToDrop() && nb_dropped_bombs == 0) { std::cout<<"Releasing at: "<<GetX()<<std::endl;
+ DropBomb(); }
else if (nb_dropped_bombs > 0 && nb_dropped_bombs < cfg.nbr_obus) {
// Get the last rocket and check the position to be sure to not collide with it
if ( last_dropped_bomb->GetY() > GetY()+GetHeight()+10 )
@@ -139,12 +139,12 @@
image->Draw(GetPosition());
}
-bool Plane::OnTopOfTarget() const
+bool Plane::InPlaceToDrop() const
{
- if (GetDirection() == 1)
- return (cible_x <= GetX()+obus_dx);
+ if(GetDirection() == 1)
+ return (cible_x <= GetX()+obus_dx+distance_to_release);
else
- return (GetX()+(int)image->GetWidth()-obus_dx <= cible_x);
+ return (GetX()+(int)image->GetWidth()-obus_dx-distance_to_release <= cible_x);
}
//-----------------------------------------------------------------------------
--- wormux/src/weapon/air_attack.h 2006-11-05 01:03:50.000000000 -0500
+++ air_attack.h 2006-11-05 01:01:08.000000000 -0500
@@ -54,9 +54,10 @@
Sprite *image;
int cible_x;
+ int distance_to_release;
AirAttackConfig &cfg;
- bool OnTopOfTarget() const;
+ bool InPlaceToDrop() const;
int GetDirection() const;
void DropBomb();
_______________________________________________ Wormux-dev mailing list [email protected] https://mail.gna.org/listinfo/wormux-dev
