From 1c1b50fc77dba1a1bd031d7b8974987c425e2fc6 Mon Sep 17 00:00:00 2001 From: MaddMugsy Date: Fri, 11 Aug 2006 04:02:32 +0000 Subject: [PATCH] -added some limited auto-aim to spread fire to make it actually useful git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@420 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameVersion.cpp | 4 +-- Tactical/Spread Burst.cpp | 66 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/GameVersion.cpp b/GameVersion.cpp index bb71a45b..b33a4d95 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -23,12 +23,12 @@ INT16 zVersionLabel[256] = { L"Beta v. 0.98" }; #else //RELEASE BUILD VERSION - INT16 zVersionLabel[256] = { L"Release v1.13.413" }; + INT16 zVersionLabel[256] = { L"Release v1.13.420" }; #endif -INT8 czVersionNumber[16] = { "Build 06.08.09" }; +INT8 czVersionNumber[16] = { "Build 06.08.10" }; INT16 zTrackingNumber[16] = { L"Z" }; diff --git a/Tactical/Spread Burst.cpp b/Tactical/Spread Burst.cpp index 42092ced..204c4ccf 100644 --- a/Tactical/Spread Burst.cpp +++ b/Tactical/Spread Burst.cpp @@ -30,10 +30,10 @@ void ResetBurstLocations( ) gbNumBurstLocations = 0; } -void AccumulateBurstLocation( INT16 sGridNo ) + +void InternalAccumulateBurstLocation( INT16 sGridNo ) { INT32 cnt; - if ( gbNumBurstLocations < MAX_BURST_LOCATIONS ) { // Check if it already exists! @@ -54,6 +54,68 @@ void AccumulateBurstLocation( INT16 sGridNo ) } } +//Madd: to add a bit more usefulness to spread fire, I'm making it so that +//it will automatically latch onto enemies within iSearchRange tiles of the mouse drag. +void AccumulateBurstLocation( INT16 sGridNo ) +{ + SOLDIERTYPE* pTarget; + int iSearchRange = 2; // number of tiles beside the mouse drag to look at + INT16 sMaxLeft, sMaxRight, sMaxUp, sMaxDown, sXOffset, sYOffset, sAdjacentGridNo; + BOOLEAN foundTarget = FALSE; + + //first see if we can find a guy standing right on the spot + pTarget = SimpleFindSoldier(sGridNo,0); + if (!pTarget) + pTarget = SimpleFindSoldier(sGridNo, 1); //try on a roof + + if (pTarget) + { + InternalAccumulateBurstLocation(sGridNo); + foundTarget = TRUE; + } + //let's now look around this square - maybe there are some adjacent enemies we can latch onto + + // stay away from the edges + + // determine maximum horizontal limits + sMaxLeft = min( iSearchRange, (sGridNo % MAXCOL)); + sMaxRight = min( iSearchRange, MAXCOL - ((sGridNo % MAXCOL) + 1)); + + // determine maximum vertical limits + sMaxUp = min( iSearchRange, (sGridNo / MAXROW)); + sMaxDown = min( iSearchRange, MAXROW - ((sGridNo / MAXROW) + 1)); + + // reset the "reachable" flags in the region we're looking at + for (sYOffset = -sMaxUp; sYOffset <= sMaxDown; sYOffset++) + { + for (sXOffset = -sMaxLeft; sXOffset <= sMaxRight; sXOffset++) + { + sAdjacentGridNo = sGridNo + sXOffset + (MAXCOL * sYOffset); + if ( !(sAdjacentGridNo >=0 && sAdjacentGridNo < WORLD_MAX) ) + { + continue; + } + + pTarget = SimpleFindSoldier(sAdjacentGridNo,0); // look for a guy in that gridno + + if (!pTarget) + pTarget = SimpleFindSoldier(sAdjacentGridNo, 1); //try on a roof + + if (pTarget) + { + InternalAccumulateBurstLocation(sAdjacentGridNo); //there's somebody there! let's latch onto him + foundTarget = TRUE; + } + } + } + + + if ( !foundTarget ) + { + //didn't find anyone nearby, but we should target this space anyway to prevent players from abusing this feature + InternalAccumulateBurstLocation(sGridNo); + } +} void PickBurstLocations( SOLDIERTYPE *pSoldier )