mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
FindClosestBoxingRingSpot: player boxer should try to move out of ring as close to Darren as possible.
LUA: added new functions SetgfBoxersResting(), SetgubBoxersRests() to change boxers status. ResetBoxers(): keep gfBoxerFought[] unchanged as it will be reset every day at 15:00 by HourlyQuestUpdate() in HourlyUpdate.lua git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8687 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -372,6 +372,9 @@ static int l_TileIsOutOfBoundsClosestPC (lua_State *L);
|
|||||||
static int l_SetgfBoxerFought (lua_State *L);
|
static int l_SetgfBoxerFought (lua_State *L);
|
||||||
static int l_EVENT_StopMerc (lua_State *L);
|
static int l_EVENT_StopMerc (lua_State *L);
|
||||||
|
|
||||||
|
static int l_SetgfBoxersResting(lua_State *L);
|
||||||
|
static int l_SetgubBoxersRests(lua_State *L);
|
||||||
|
|
||||||
static int l_SetEnterCombatMode (lua_State *L);
|
static int l_SetEnterCombatMode (lua_State *L);
|
||||||
|
|
||||||
static int l_PlayerInARoom (lua_State *L);
|
static int l_PlayerInARoom (lua_State *L);
|
||||||
@@ -3061,6 +3064,8 @@ BOOLEAN LetLuaHourlyQuestUpdate(UINT8 Init)
|
|||||||
|
|
||||||
//-----boxer------ only hourly quest update
|
//-----boxer------ only hourly quest update
|
||||||
lua_register(_LS.L(), "gfBoxerFought", l_SetgfBoxerFought);
|
lua_register(_LS.L(), "gfBoxerFought", l_SetgfBoxerFought);
|
||||||
|
lua_register(_LS.L(), "SetgfBoxersResting", l_SetgfBoxersResting);
|
||||||
|
lua_register(_LS.L(), "SetgubBoxersRests", l_SetgubBoxersRests);
|
||||||
lua_register(_LS.L(), "GetWorldHour", l_GetWorldHour);
|
lua_register(_LS.L(), "GetWorldHour", l_GetWorldHour);
|
||||||
|
|
||||||
SGP_THROW_IFFALSE( _LS.L.EvalFile(filename), _BS("Cannot open file: ") << filename << _BS::cget );
|
SGP_THROW_IFFALSE( _LS.L.EvalFile(filename), _BS("Cannot open file: ") << filename << _BS::cget );
|
||||||
@@ -8220,6 +8225,22 @@ static int l_SetgfBoxerFought (lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_SetgfBoxersResting(lua_State *L)
|
||||||
|
{
|
||||||
|
if (lua_gettop(L))
|
||||||
|
gfBoxersResting = lua_toboolean(L, 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int l_SetgubBoxersRests(lua_State *L)
|
||||||
|
{
|
||||||
|
if (lua_gettop(L))
|
||||||
|
gubBoxersRests = lua_tointeger(L, 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_GetWorldHour (lua_State *L)
|
static int l_GetWorldHour (lua_State *L)
|
||||||
{
|
{
|
||||||
UINT32 h2 = GetWorldHour();
|
UINT32 h2 = GetWorldHour();
|
||||||
@@ -10464,7 +10485,7 @@ static int l_SetPendingNewScreen (lua_State *L)
|
|||||||
}
|
}
|
||||||
//--------------
|
//--------------
|
||||||
|
|
||||||
//Set charcter to sector Z
|
//Set character to sector Z
|
||||||
static int l_GetCharacterSectorZ (lua_State *L)
|
static int l_GetCharacterSectorZ (lua_State *L)
|
||||||
{
|
{
|
||||||
UINT8 n = lua_gettop(L);
|
UINT8 n = lua_gettop(L);
|
||||||
@@ -10484,7 +10505,7 @@ static int l_GetCharacterSectorZ (lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set charcter to sector Y
|
//Set character to sector Y
|
||||||
static int l_GetCharacterSectorY (lua_State *L)
|
static int l_GetCharacterSectorY (lua_State *L)
|
||||||
{
|
{
|
||||||
UINT8 n = lua_gettop(L);
|
UINT8 n = lua_gettop(L);
|
||||||
@@ -10504,7 +10525,7 @@ static int l_GetCharacterSectorY (lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set charcter to sector X
|
//Set character to sector X
|
||||||
static int l_GetCharacterSectorX (lua_State *L)
|
static int l_GetCharacterSectorX (lua_State *L)
|
||||||
{
|
{
|
||||||
UINT8 n = lua_gettop(L);
|
UINT8 n = lua_gettop(L);
|
||||||
@@ -10525,7 +10546,7 @@ static int l_GetCharacterSectorX (lua_State *L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------
|
//-----------
|
||||||
//Set charcter to sector Z
|
//Set character to sector Z
|
||||||
static int l_SetCharacterSectorZ (lua_State *L)
|
static int l_SetCharacterSectorZ (lua_State *L)
|
||||||
{
|
{
|
||||||
if ( lua_gettop( L ) >= 2 )
|
if ( lua_gettop( L ) >= 2 )
|
||||||
@@ -10545,13 +10566,14 @@ static int l_ResetBoxers( lua_State *L )
|
|||||||
for ( UINT8 i = 0; i < NUM_BOXERS; ++i )
|
for ( UINT8 i = 0; i < NUM_BOXERS; ++i )
|
||||||
{
|
{
|
||||||
gubBoxerID[i] = NOBODY;
|
gubBoxerID[i] = NOBODY;
|
||||||
gfBoxerFought[i] = FALSE;
|
// sevenfm: keep gfBoxerFought[] unchanged as it will be reset every day at 16:00 by HourlyQuestUpdate(), HourlyUpdate.lua
|
||||||
|
//gfBoxerFought[i] = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set charcter to sector Y
|
//Set character to sector Y
|
||||||
static int l_SetCharacterSectorY (lua_State *L)
|
static int l_SetCharacterSectorY (lua_State *L)
|
||||||
{
|
{
|
||||||
UINT8 n = lua_gettop(L);
|
UINT8 n = lua_gettop(L);
|
||||||
@@ -10570,7 +10592,7 @@ static int l_SetCharacterSectorY (lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set charcter to sector X
|
//Set character to sector X
|
||||||
static int l_SetCharacterSectorX (lua_State *L)
|
static int l_SetCharacterSectorX (lua_State *L)
|
||||||
{
|
{
|
||||||
UINT8 n = lua_gettop(L);
|
UINT8 n = lua_gettop(L);
|
||||||
@@ -10625,7 +10647,7 @@ static int l_TriggerNPCRecordImmediately(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add undern Ground Sector
|
//Add underground Sector
|
||||||
static int l_AddAltUnderGroundSectorNew(lua_State *L)
|
static int l_AddAltUnderGroundSectorNew(lua_State *L)
|
||||||
{
|
{
|
||||||
UINT8 x = 0,y = 0,z = 0;
|
UINT8 x = 0,y = 0,z = 0;
|
||||||
|
|||||||
@@ -2414,9 +2414,10 @@ INT32 FindClosestBoxingRingSpot( SOLDIERTYPE * pSoldier, BOOLEAN fInRing )
|
|||||||
|
|
||||||
INT32 sGridNo, sClosestSpot = NOWHERE;
|
INT32 sGridNo, sClosestSpot = NOWHERE;
|
||||||
INT32 iDistance, iClosestDistance = 9999;
|
INT32 iDistance, iClosestDistance = 9999;
|
||||||
//DBrot: More Rooms
|
|
||||||
//UINT8 ubRoom;
|
|
||||||
UINT16 usRoom;
|
UINT16 usRoom;
|
||||||
|
SOLDIERTYPE *pDarren;
|
||||||
|
UINT8 ubLoop;
|
||||||
|
pDarren = FindSoldierByProfileID(DARREN, FALSE);
|
||||||
|
|
||||||
// set the distance limit of the square region
|
// set the distance limit of the square region
|
||||||
iSearchRange = 7;
|
iSearchRange = 7;
|
||||||
@@ -2427,11 +2428,11 @@ INT32 FindClosestBoxingRingSpot( SOLDIERTYPE * pSoldier, BOOLEAN fInRing )
|
|||||||
sMaxRight = min( iSearchRange, MAXCOL - ((pSoldier->sGridNo % MAXCOL) + 1));
|
sMaxRight = min( iSearchRange, MAXCOL - ((pSoldier->sGridNo % MAXCOL) + 1));
|
||||||
//NumMessage("sMaxRight = ",sMaxRight);
|
//NumMessage("sMaxRight = ",sMaxRight);
|
||||||
|
|
||||||
if ( (pSoldier->bTeam == gbPlayerNum) && (fInRing == FALSE) )
|
/*if ( (pSoldier->bTeam == gbPlayerNum) && (fInRing == FALSE) )
|
||||||
{
|
{
|
||||||
// have player not go to the left of the ring
|
// have player not go to the left of the ring
|
||||||
sMaxLeft = 0;
|
sMaxLeft = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// determine maximum vertical limits
|
// determine maximum vertical limits
|
||||||
sMaxUp = min( iSearchRange, (pSoldier->sGridNo / MAXROW));
|
sMaxUp = min( iSearchRange, (pSoldier->sGridNo / MAXROW));
|
||||||
@@ -2444,19 +2445,25 @@ INT32 FindClosestBoxingRingSpot( SOLDIERTYPE * pSoldier, BOOLEAN fInRing )
|
|||||||
{
|
{
|
||||||
// calculate the next potential gridno
|
// calculate the next potential gridno
|
||||||
sGridNo = pSoldier->sGridNo + sXOffset + (MAXCOL * sYOffset);
|
sGridNo = pSoldier->sGridNo + sXOffset + (MAXCOL * sYOffset);
|
||||||
if ( InARoom( sGridNo, &usRoom ))
|
if (!TileIsOutOfBounds(sGridNo) &&
|
||||||
|
InARoom(sGridNo, &usRoom))
|
||||||
{
|
{
|
||||||
if ( (fInRing && usRoom == BOXING_RING) || (!fInRing && usRoom != BOXING_RING ) && LegalNPCDestination(pSoldier,sGridNo,IGNORE_PATH,NOWATER,0) )
|
if ((fInRing && usRoom == BOXING_RING) || (!fInRing && usRoom != BOXING_RING) &&
|
||||||
|
LegalNPCDestination(pSoldier, sGridNo, IGNORE_PATH, NOWATER, 0))
|
||||||
{
|
{
|
||||||
iDistance = abs( sXOffset ) + abs( sYOffset );
|
// sevenfm: for player merc, find spot closest to Darren
|
||||||
if ( iDistance < iClosestDistance && WhoIsThere2( sGridNo, 0 ) == NOBODY )
|
if (pDarren && pSoldier->bTeam == gbPlayerNum)
|
||||||
|
iDistance = PythSpacesAway(pDarren->sGridNo, sGridNo) + PythSpacesAway(pSoldier->sGridNo, sGridNo);
|
||||||
|
else
|
||||||
|
iDistance = abs(sXOffset) + abs(sYOffset);
|
||||||
|
|
||||||
|
if (iDistance < iClosestDistance && WhoIsThere2(sGridNo, 0) == NOBODY)
|
||||||
{
|
{
|
||||||
sClosestSpot = sGridNo;
|
sClosestSpot = sGridNo;
|
||||||
iClosestDistance = iDistance;
|
iClosestDistance = iDistance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user