INT16 FindDoorAtGridNoOrAdjacent( INT16 sGridNo ) { STRUCTURE * pStructure; STRUCTURE * pBaseStructure; INT16 sTestGridNo; sTestGridNo = sGridNo; pStructure = FindStructure( sTestGridNo, STRUCTURE_ANYDOOR ); if (pStructure) { pBaseStructure = FindBaseStructure( pStructure ); return( pBaseStructure->sGridNo ); } sTestGridNo = sGridNo + DirectionInc( NORTH ); pStructure = FindStructure( sTestGridNo, STRUCTURE_ANYDOOR ); if (pStructure) { pBaseStructure = FindBaseStructure( pStructure ); return( pBaseStructure->sGridNo ); } sTestGridNo = sGridNo + DirectionInc( WEST ); pStructure = FindStructure( sTestGridNo, STRUCTURE_ANYDOOR ); if (pStructure) { pBaseStructure = FindBaseStructure( pStructure ); return( pBaseStructure->sGridNo ); } return( NOWHERE ); }
LEVELNODE *GetWallLevelNodeAndStructOfSameOrientationAtGridno( INT16 sGridNo, INT8 ubOrientation, STRUCTURE **ppStructure ) { LEVELNODE *pNode = NULL; STRUCTURE * pStructure, * pBaseStructure; (*ppStructure) = NULL; pStructure = FindStructure( sGridNo, STRUCTURE_WALLSTUFF ); while ( pStructure != NULL ) { // Check orientation if ( pStructure->ubWallOrientation == ubOrientation ) { pBaseStructure = FindBaseStructure( pStructure ); if (pBaseStructure) { pNode = FindLevelNodeBasedOnStructure( pBaseStructure->sGridNo, pBaseStructure ); (*ppStructure) = pBaseStructure; return( pNode ); } } pStructure = FindNextStructure( pStructure, STRUCTURE_WALLSTUFF ); } return( NULL ); }
BOOLEAN IsJumpableWindowPresentAtGridNo( INT32 sGridNo, INT8 direction2, BOOLEAN fIntactWindowsAlso ) { STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_WALLNWINDOW ); if ( pStructure ) { // anv: additional tile properties hook if(gGameExternalOptions.fAdditionalTileProperties) { LEVELNODE *pNode = FindLevelNodeBasedOnStructure( sGridNo, pStructure ); if(pNode != NULL) { if( gTileDatabase[ pNode->usIndex ].uiAdditionalFlags & ADDITIONAL_TILE_FLAG_BLOCKED_WINDOW ) // special tag disables jumping through specific windows (e.g. barred windows in Tixa) return( FALSE ); } } if ( ( direction2 == SOUTH || direction2 == NORTH ) && (pStructure->ubWallOrientation == OUTSIDE_TOP_LEFT || pStructure->ubWallOrientation == INSIDE_TOP_LEFT ) && pStructure->fFlags & STRUCTURE_WALLNWINDOW && !(pStructure->fFlags & STRUCTURE_SPECIAL) ) { if ( fIntactWindowsAlso || ( pStructure->fFlags & STRUCTURE_OPEN ) ) return( TRUE ); } if ( ( direction2 == EAST || direction2 == WEST ) && ( pStructure->ubWallOrientation == OUTSIDE_TOP_RIGHT || pStructure->ubWallOrientation == INSIDE_TOP_RIGHT ) && pStructure->fFlags & STRUCTURE_WALLNWINDOW && !(pStructure->fFlags & STRUCTURE_SPECIAL) ) { if ( fIntactWindowsAlso || ( pStructure->fFlags & STRUCTURE_OPEN ) ) return( TRUE ); } } return( FALSE ); }
INT NS_PREFIX PrintStructContents (const char *name, char *buffer, int bufLen, int ropt) { static ENVDIR *theDir; static STRVAR *StrVar; static int status; const char *lastname; int ret; buffer[0]=(char) 0; if (name!=NULL) { /* get variable and/or structure with that name */ if (strcmp(name,":")==0) { StrVar=NULL; theDir=path[0]; } else { if ((theDir=FindStructDir(name,&lastname))==NULL) return(7); /* structure path not found */ StrVar=FindStringVar(theDir,lastname); theDir=FindStructure(theDir,lastname); } status=0; } if (status==0) status=(StrVar==NULL) ? 2 : 1; if (status==1) { ret=VarOut(StrVar, buffer, bufLen); if ((ret!=0)&&(ret!=4)) return(ret); if (ret==0) status=2; else StrVar=NULL; return(4); /* also return if a variable was printed to clear the buffer */ } if (status==2) status=(theDir==NULL) ? 4 : 3; if (status==3) { ret=DirOut(theDir, buffer, bufLen, ropt); if ((ret!=0)&&(ret!=4)) return(ret); if (ret==4) { theDir=NULL; return(4); } } return(0); }
BOOLEAN IsFencePresentAtGridno( INT16 sGridNo ) { if ( FindStructure( sGridNo, STRUCTURE_ANYFENCE ) != NULL ) { return( TRUE ); } return( FALSE ); }
BOOLEAN IsRoofPresentAtGridno( INT16 sGridNo ) { if ( FindStructure( sGridNo, STRUCTURE_ROOF ) != NULL ) { return( TRUE ); } return( FALSE ); }
BOOLEAN IsTreePresentAtGridno( INT16 sGridNo ) { if ( FindStructure( sGridNo, STRUCTURE_TREE ) != NULL ) { return( TRUE ); } return( FALSE ); }
BOOLEAN IsDoorPresentAtGridno( INT16 sGridNo ) { if ( FindStructure( sGridNo, STRUCTURE_ANYDOOR ) != NULL ) { return( TRUE ); } return( FALSE ); }
BOOLEAN IsDoorVisibleAtGridNo( INT16 sGridNo ) { STRUCTURE * pStructure; INT16 sNewGridNo; pStructure = FindStructure( sGridNo, STRUCTURE_ANYDOOR ); if ( pStructure != NULL ) { // Check around based on orientation switch( pStructure->ubWallOrientation ) { case INSIDE_TOP_LEFT: case OUTSIDE_TOP_LEFT: // Here, check north direction sNewGridNo = NewGridNo( sGridNo, DirectionInc( NORTH ) ); if ( IsRoofVisible2( sNewGridNo ) ) { // OK, now check south, if true, she's not visible sNewGridNo = NewGridNo( sGridNo, DirectionInc( SOUTH ) ); if ( IsRoofVisible2( sNewGridNo ) ) { return( FALSE ); } } break; case INSIDE_TOP_RIGHT: case OUTSIDE_TOP_RIGHT: // Here, check west direction sNewGridNo = NewGridNo( sGridNo, DirectionInc( WEST ) ); if ( IsRoofVisible2( sNewGridNo ) ) { // OK, now check south, if true, she's not visible sNewGridNo = NewGridNo( sGridNo, DirectionInc( EAST ) ); if ( IsRoofVisible2( sNewGridNo ) ) { return( FALSE ); } } break; } } // Return true here, even if she does not exist return( TRUE ); }
BOOLEAN IsCutWireFenceAtGridNo( INT16 sGridNo ) { STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_WIREFENCE ); if (pStructure != NULL && (pStructure->ubWallOrientation != NO_ORIENTATION) && (pStructure->fFlags & STRUCTURE_OPEN) ) { return( TRUE ); } return( FALSE ); }
STRUCTURE * FindCuttableWireFenceAtGridNo( INT16 sGridNo ) { STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_WIREFENCE ); if (pStructure != NULL && pStructure->ubWallOrientation != NO_ORIENTATION && !(pStructure->fFlags & STRUCTURE_OPEN) ) { return( pStructure ); } return( NULL ); }
// Flugente: determine wether a fortification can be built on this position BOOLEAN IsFortificationPossibleAtGridNo( INT32 sGridNo ) { INT8 bOverTerrainType = GetTerrainType( sGridNo ); if( bOverTerrainType == MED_WATER || bOverTerrainType == DEEP_WATER || bOverTerrainType == LOW_WATER ) return FALSE; STRUCTURE * pStructure = NULL; pStructure = FindStructure( sGridNo, (STRUCTURE_OBSTACLE|STRUCTURE_PERSON) ); return( pStructure == NULL ); }
INT NS_PREFIX MakeStruct (const char *name) { const char *lastname; ENVDIR *theDir,*theStruct; if ((theDir=FindStructDir(name,&lastname))==NULL) return(1); if ((theStruct=FindStructure(theDir,lastname))!=NULL) return(0); if (MakeStructItem(theDir,lastname,theStringDirID,sizeof(ENVDIR))==NULL) return(2); return (0); }
Structs *AddStruct( char *name, ListNode *structs) { static int struct_tok = FIRST_CONSTRUCTOR; Structs *pos = FindStructure( name, structs); if( pos == NULL) { pos = CreateStruct( name, struct_tok++); AddToStructList( pos, structs ); } else if( StructDefined(pos)) { fprintf( stderr,"Redefinition of struct %s\n", name); exit(EXIT_FAILURE); } return( pos ); }
LEVELNODE *IsWallPresentAtGridno( INT16 sGridNo ) { LEVELNODE *pNode = NULL; STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_WALLSTUFF ); if ( pStructure != NULL ) { pNode = FindLevelNodeBasedOnStructure( sGridNo, pStructure ); } return( pNode ); }
void GetUnionEntries(FILE *infile, Unions *newunion, ListNode *unions, ListNode *structs, ListNode *reserved, ListNode *primitives ) { Structs *structure; Unions *haveunion; Strefs *stref; char *struct_name, *union_name = UnionName( newunion); /* read in union entries */ if( skiplayout(infile) != START_UNION_ENTRY ) { fprintf( stderr, "GetUnionEntries: Expecting %c\n", START_UNION_ENTRY ); exit( EXIT_FAILURE ); } fscanf( infile, "%s", buffer); while( *buffer != END_UNION_ENTRY) { if(( haveunion = FindUnion( buffer, unions)) == NULL ) { if( !ReservedValue( reserved, buffer) && (FindPrimitive( buffer, primitives ) == NULL)) { if(( structure = FindStructure( buffer, structs)) != NULL) { struct_name = heapstr( buffer ); AddUnionSort( structure, union_name); AddStructRef( newunion, structure); } else { fprintf( stderr, "Structure %s has not been defined before use in union %s\n", buffer, union_name); exit(EXIT_FAILURE); } } } else { stref = StrefsHead( UnionStrefs( haveunion)); while( stref != NULL ) { structure = StrefStr( stref); AddUnionSort( structure, union_name); AddStructRef( newunion, structure); stref = StrefNext( stref); } } fscanf( infile, "%s", buffer); } }
BOOLEAN IsLegionWallPresentAtGridno( INT32 sGridNo ) { STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_FENCE ); if ( pStructure ) { if ( pStructure->fFlags & STRUCTURE_FENCE && pStructure->fFlags & STRUCTURE_SPECIAL && pStructure->fFlags & STRUCTURE_WALL ) { return( TRUE ); } } return( FALSE ); }
BOOLEAN IsJumpableFencePresentAtGridno( INT16 sGridNo ) { STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_OBSTACLE ); if ( pStructure ) { if ( pStructure->fFlags & STRUCTURE_FENCE && !(pStructure->fFlags & STRUCTURE_SPECIAL) ) { return( TRUE ); } if ( pStructure->pDBStructureRef->pDBStructure->ubArmour == MATERIAL_SANDBAG && StructureHeight( pStructure ) < 2 ) { return( TRUE ); } } return( FALSE ); }
LEVELNODE *GetWallLevelNodeOfSameOrientationAtGridNo( INT32 sGridNo, INT8 ubOrientation ) { LEVELNODE *pNode = NULL; STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_WALLSTUFF ); while ( pStructure != NULL ) { // Check orientation if ( pStructure->ubWallOrientation == ubOrientation ) { pNode = FindLevelNodeBasedOnStructure( sGridNo, pStructure ); return( pNode ); } pStructure = FindNextStructure( pStructure, STRUCTURE_WALLSTUFF ); } return( NULL ); }
BOOLEAN WallExistsOfTopRightOrientation( INT16 sGridNo ) { // CJC: changing to search only for normal walls, July 16, 1998 STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_WALL ); while ( pStructure != NULL ) { // Check orientation if ( pStructure->ubWallOrientation == INSIDE_TOP_RIGHT || pStructure->ubWallOrientation == OUTSIDE_TOP_RIGHT ) { return( TRUE ); } pStructure = FindNextStructure( pStructure, STRUCTURE_WALL ); } return( FALSE ); }
INT NS_PREFIX DeleteStruct (const char *name) { const char *lastname; ENVDIR *theDir,*theStruct; if ((theDir=FindStructDir(name,&lastname))==NULL) return(1); /* structure directory not found */ if ((theStruct=FindStructure(theDir,lastname))==NULL) return(2); /* structure does not exist */ if (CheckIfInStructPath(theStruct)) return(3); /* structure is inside structure path */ if (CheckStructTree(theStruct)) return(4); /* structure contains locked objects */ if (RemoveStructTree(theDir,theStruct)!=0) return(5); /* structure could not be removed */ return (0); }
BOOLEAN OpenLeftOrientedDoorWithDoorOnLeftOfEdgeExists( INT16 sGridNo ) { STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_ANYDOOR ); while ( pStructure != NULL && (pStructure->fFlags & STRUCTURE_OPEN) ) { // Check orientation if ( pStructure->ubWallOrientation == INSIDE_TOP_LEFT || pStructure->ubWallOrientation == OUTSIDE_TOP_LEFT ) { if ( (pStructure->fFlags & STRUCTURE_DOOR) || (pStructure->fFlags & STRUCTURE_DDOOR_LEFT) ) { return( TRUE ); } } pStructure = FindNextStructure( pStructure, STRUCTURE_ANYDOOR ); } return( FALSE ); }
BOOLEAN SetOpenableStructureToClosed( INT16 sGridNo, UINT8 ubLevel ) { STRUCTURE * pStructure; STRUCTURE * pNewStructure; pStructure = FindStructure( sGridNo, STRUCTURE_OPENABLE ); if ( !pStructure ) { return( FALSE ); } if ( pStructure->fFlags & STRUCTURE_OPEN ) { pNewStructure = SwapStructureForPartner( sGridNo, pStructure ); if ( pNewStructure != NULL) { RecompileLocalMovementCosts( sGridNo ); SetRenderFlags( RENDER_FLAG_FULL ); } } // else leave it as is! return( TRUE ); }
BOOLEAN IsOknoFencePresentAtGridno( INT32 sGridNo ) { STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_WALLNWINDOW ); if ( pStructure ) { if ( pStructure->fFlags & STRUCTURE_WALLNWINDOW && !(pStructure->fFlags & STRUCTURE_SPECIAL) && ( pStructure->fFlags & STRUCTURE_OPEN ) ) { return( TRUE ); } } /* STRUCTURE * pStructure; STRUCTURE * pStructure2; pStructure = FindStructure( sGridNo, STRUCTURE_WALLNWINDOW ); if ( pStructure ) { // pStructure2 = FindStructure( sGridNo, STRUCTURE_WALL ); // if ( !pStructure2 ) // { if ( pStructure->fFlags & STRUCTURE_WALLNWINDOW && !(pStructure->fFlags & STRUCTURE_SPECIAL) && ( pStructure->fFlags & STRUCTURE_OPEN )) { return( TRUE ); } // } } */ return( FALSE ); }
BOOLEAN WallOrClosedDoorExistsOfTopRightOrientation( INT16 sGridNo ) { STRUCTURE * pStructure; pStructure = FindStructure( sGridNo, STRUCTURE_WALLSTUFF ); while ( pStructure != NULL ) { // skip it if it's an open door if ( ! ( ( pStructure->fFlags & STRUCTURE_ANYDOOR ) && ( pStructure->fFlags & STRUCTURE_OPEN ) ) ) { // Check orientation if ( pStructure->ubWallOrientation == INSIDE_TOP_RIGHT || pStructure->ubWallOrientation == OUTSIDE_TOP_RIGHT ) { return( TRUE ); } } pStructure = FindNextStructure( pStructure, STRUCTURE_WALLSTUFF ); } return( FALSE ); }
void AddSoldierToSectorGridNo( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubDirection, BOOLEAN fUseAnimation, UINT16 usAnimState, UINT16 usAnimCode ) { INT16 sWorldX, sWorldY; INT16 sNewGridNo; UINT8 ubNewDirection; UINT8 ubInsertionCode; BOOLEAN fUpdateFinalPosition = TRUE; // Add merc to gridno sWorldX = CenterX( sGridNo ); sWorldY = CenterY( sGridNo ); // Set reserved location! pSoldier->sReservedMovementGridNo = NOWHERE; // Save OLD insertion code.. as this can change... ubInsertionCode = pSoldier->ubStrategicInsertionCode; // Remove any pending animations pSoldier->usPendingAnimation = NO_PENDING_ANIMATION; pSoldier->usPendingAnimation2 = NO_PENDING_ANIMATION; pSoldier->ubPendingDirection = NO_PENDING_DIRECTION; pSoldier->ubPendingAction = NO_PENDING_ACTION; //If we are not loading a saved game if( (gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) { // Set final dest to be the same... fUpdateFinalPosition = FALSE; } // If this is a special insertion location, get path! if ( ubInsertionCode == INSERTION_CODE_ARRIVING_GAME ) { EVENT_SetSoldierPositionAndMaybeFinalDestAndMaybeNotDestination( pSoldier, sWorldX, sWorldY, fUpdateFinalPosition, fUpdateFinalPosition ); EVENT_SetSoldierDirection( pSoldier, ubDirection ); EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection ); } else if ( ubInsertionCode == INSERTION_CODE_CHOPPER ) { } else { EVENT_SetSoldierPositionAndMaybeFinalDestAndMaybeNotDestination( pSoldier, sWorldX, sWorldY, fUpdateFinalPosition, fUpdateFinalPosition ); //if we are loading, dont set the direction ( they are already set ) if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) { EVENT_SetSoldierDirection( pSoldier, ubDirection ); EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection ); } } if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) { if ( !( pSoldier->uiStatusFlags & SOLDIER_DEAD ) ) { if ( pSoldier->bTeam == gbPlayerNum ) { RevealRoofsAndItems( pSoldier, TRUE, FALSE, pSoldier->bLevel, TRUE ); // ATE: Patch fix: If we are in an non-interruptable animation, stop! if ( pSoldier->usAnimState == HOPFENCE ) { pSoldier->fInNonintAnim = FALSE; SoldierGotoStationaryStance( pSoldier ); } EVENT_StopMerc( pSoldier, sGridNo, ubDirection ); } } // If just arriving, set a destination to walk into from! if ( ubInsertionCode == INSERTION_CODE_ARRIVING_GAME ) { // Find a sweetspot near... sNewGridNo = FindGridNoFromSweetSpot( pSoldier, gMapInformation.sNorthGridNo, 4, &ubNewDirection ); EVENT_GetNewSoldierPath( pSoldier, sNewGridNo, WALKING ); } // If he's an enemy... set presence if ( !pSoldier->bNeutral && (pSoldier->bSide != gbPlayerNum ) ) { // ATE: Added if not bloodcats // only do this once they are seen..... if ( pSoldier->ubBodyType != BLOODCAT ) { SetEnemyPresence( ); } } } if ( !( pSoldier->uiStatusFlags & SOLDIER_DEAD ) ) { //if we are loading a 'pristine' map ( ie, not loading a saved game ) if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) { // ATE: Double check if we are on the roof that there is a roof there! if ( pSoldier->bLevel == 1 ) { if ( !FindStructure( pSoldier->sGridNo, STRUCTURE_ROOF ) ) { SetSoldierHeight( pSoldier, (FLOAT)( 0 ) ); } } if ( ubInsertionCode != INSERTION_CODE_ARRIVING_GAME ) { // default to standing on arrival if ( pSoldier->usAnimState != HELIDROP ) { if ( fUseAnimation ) { EVENT_InitNewSoldierAnim( pSoldier, usAnimState, usAnimCode, TRUE ); } else if ( pSoldier->ubBodyType != CROW ) { EVENT_InitNewSoldierAnim( pSoldier, STANDING, 1, TRUE ); } } // ATE: if we are below OK life, make them lie down! if ( pSoldier->bLife < OKLIFE ) { SoldierInSectorIncompaciated( pSoldier, pSoldier->sInsertionGridNo ); } else if ( pSoldier->fMercAsleep == TRUE ) { InternalSoldierInSectorSleep( pSoldier, pSoldier->sInsertionGridNo, FALSE ); } else if ( pSoldier->bAssignment == PATIENT ) { SoldierInSectorPatient( pSoldier, pSoldier->sInsertionGridNo ); } else if ( pSoldier->bAssignment == DOCTOR ) { SoldierInSectorDoctor( pSoldier, pSoldier->sInsertionGridNo ); } else if ( pSoldier->bAssignment == REPAIR ) { SoldierInSectorRepair( pSoldier, pSoldier->sInsertionGridNo ); } // ATE: Make sure movement mode is up to date! pSoldier->usUIMovementMode = GetMoveStateBasedOnStance( pSoldier, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ); } } else { // THIS ALL SHOULD HAVE BEEN HANDLED BY THE FACT THAT A GAME WAS LOADED //EVENT_InitNewSoldierAnim( pSoldier, pSoldier->usAnimState, pSoldier->usAniCode, TRUE ); // if the merc had a final destination, get the merc walking there //if( pSoldier->sFinalDestination != pSoldier->sGridNo ) //{ // EVENT_GetNewSoldierPath( pSoldier, pSoldier->sFinalDestination, pSoldier->usUIMovementMode ); //} } } }
void GenerateBuildings( void ) { UINT32 uiLoop; // init building structures and variables memset( &gubBuildingInfo, 0, WORLD_MAX * sizeof( UINT8 ) ); memset( &gBuildings, 0, MAX_BUILDINGS * sizeof( BUILDING ) ); gubNumberOfBuildings = 0; if ( (gbWorldSectorZ > 0) || gfEditMode) { return; } // reset ALL reachable flags // do once before we start building generation for // whole map for ( uiLoop = 0; uiLoop < WORLD_MAX; uiLoop++ ) { gpWorldLevelData[ uiLoop ].uiFlags &= ~(MAPELEMENT_REACHABLE); gpWorldLevelData[ uiLoop ].ubExtFlags[0] &= ~(MAPELEMENT_EXT_ROOFCODE_VISITED); } // search through world // for each location in a room try to find building info for ( uiLoop = 0; uiLoop < WORLD_MAX; uiLoop++ ) { if ( (gubWorldRoomInfo[ uiLoop ] != NO_ROOM) && (gubBuildingInfo[ uiLoop ] == NO_BUILDING) && (FindStructure( (INT16) uiLoop, STRUCTURE_NORMAL_ROOF ) != NULL) ) { GenerateBuilding( (INT16) uiLoop ); } } }
void RevealRoofsAndItems(SOLDIERTYPE *pSoldier, UINT32 itemsToo, BOOLEAN fShowLocators, UINT8 ubLevel, BOOLEAN fForce ) { INT32 maincnt,markercnt,marker,tilesLeftToSee,prevmarker; UINT8 cnt; INT32 Inc[6],Dir[6]; INT8 itemVisible = FALSE; INT8 Blocking,twoMoreTiles,markerDir; INT8 nextDir=0; UINT8 who; //,itemIndex; // for each square checked UINT8 dir,range,Path2; //DBrot: More Rooms //UINT8 ubRoomNo; UINT16 usRoomNo; BOOLEAN fCheckForRooms = FALSE; ITEM_POOL *pItemPool; BOOLEAN fHiddenStructVisible; UINT8 ubMovementCost; BOOLEAN fTravelCostObs; BOOLEAN fGoneThroughDoor = FALSE; BOOLEAN fThroughWindow = FALSE; BOOLEAN fItemsQuoteSaid = FALSE; UINT16 usIndex; BOOLEAN fRevealItems = TRUE; BOOLEAN fStopRevealingItemsAfterThisTile = FALSE; INT8 bTallestStructureHeight; INT32 iDoorGridNo; STRUCTURE *pStructure, *pDummy; INT8 bStructHeight; INT8 bThroughWindowDirection; if ( pSoldier->flags.uiStatusFlags & SOLDIER_ENEMY ) { //pSoldier->needToLookForItems = FALSE; return; } if ( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) { return; } // Return if this guy has no gridno, has bad life, etc if(TileIsOutOfBounds(pSoldier->sGridNo) || !pSoldier->bInSector || pSoldier->stats.bLife < OKLIFE ) { return; } if (pSoldier->bBlindedCounter > 0) { return; } gubGridNoValue++; if ( gubGridNoValue == 255 ) { // Reset! Assert(gubGridNoMarkers); memset(gubGridNoMarkers, 0, sizeof(UINT8)*WORLD_MAX); gubGridNoValue = 1; } // OK, look for doors MercLooksForDoors( pSoldier, TRUE ); who = pSoldier->ubID; dir = pSoldier->ubDirection; //NumMessage("good old reveal",dir); // a gassed merc can only see 1 tile away due to blurred vision if ( pSoldier->flags.uiStatusFlags & SOLDIER_GASSED ) { range = 1; } else { range = pSoldier->bViewRange; // Flugente: adjust sightrange range = (UINT8)( (range * (100 + pSoldier->GetSightRangeBonus()) ) / 100); // balance item viewing range between normal and the limit set by opplist-type functions -- CJC range = (AdjustMaxSightRangeForEnvEffects( pSoldier, LightTrueLevel( pSoldier->sGridNo, pSoldier->pathing.bLevel), range ) + range) / 2; } BuildSightDir(dir,(UINT32 *)&Dir[0],(UINT32 *)&Dir[1],(UINT32 *)&Dir[2],(UINT32 *)&Dir[3],(UINT32 *)&Dir[4]); for (cnt = 0; cnt < 5; cnt++) Inc[cnt] = DirectionInc( (UINT8) Dir[cnt]); // create gridno increment for NOVIEW - in other words, no increment! Inc[5] = 0; Dir[5] = pSoldier->ubDirection; if (dir % 2 == 1) /* even numbers use ViewPath2 */ Path2 = TRUE; else Path2 = FALSE; // ATE: if in this special cercumstance... our guys are moving on their own... // Stop sighting items // IN the future, we may want to do something else here... if ( gTacticalStatus.uiFlags & OUR_MERCS_AUTO_MOVE ) { itemsToo = FALSE; } for (maincnt = 0; maincnt < MAXVIEWPATHS; maincnt++) { marker = pSoldier->sGridNo; Blocking = FALSE; twoMoreTiles = FALSE; tilesLeftToSee = 99; fRevealItems = TRUE; fStopRevealingItemsAfterThisTile = FALSE; #ifdef _DEBUG if ( _KeyDown( NUM_LOCK ) ) { memset( gubFOVDebugInfoInfo, 0, sizeof( gubFOVDebugInfoInfo ) ); SetRenderFlags( RENDER_FLAG_FULL ); RenderWorld( ); } #endif for (markercnt = 0; markercnt < range; markercnt++) { //fGoneThroughDoor = FALSE; //fThroughWindow = FALSE; prevmarker = marker; nextDir = 99; fCheckForRooms = FALSE; fTravelCostObs = FALSE; if ( fStopRevealingItemsAfterThisTile ) { fRevealItems = FALSE; fStopRevealingItemsAfterThisTile = FALSE; } if (Path2) { markerDir = ViewPath2[maincnt][markercnt]; if (markercnt < 12) nextDir = ViewPath2[maincnt][markercnt+1]; } else { markerDir = ViewPath[maincnt][markercnt]; if (markercnt < 12) nextDir = ViewPath[maincnt][markercnt+1]; } // OK, check flags for going through door/window last tile if ( fThroughWindow == 1 ) { // ATE: Make sure we are going through the same direction! // THis is to solve the drassen SAM problem with seeing through walls if ( Dir[markerDir] == bThroughWindowDirection) { fThroughWindow = 2; } else { fThroughWindow = 0; } } else if ( fThroughWindow == 2 ) { // We've overstayed our welcome - remove! fThroughWindow = 0; } if ( fGoneThroughDoor == 1 ) { fGoneThroughDoor = 2; } else if ( fGoneThroughDoor == 2 ) { // We've overstayed our welcome - remove! fGoneThroughDoor = 0; } //ATE CHECK FOR NOVIEW! if ( nextDir == NOVIEW ) { nextDir = 99; } marker = NewGridNo(marker,(INT16)Inc[markerDir]); if ( marker == 12426 ) { int i = 0; } // End if this is a no view... if ( markerDir == NOVIEW && markercnt != 0 ) { break; } #ifdef _DEBUG if ( _KeyDown( NUM_LOCK ) ) { int cnt = GetJA2Clock( ); gubFOVDebugInfoInfo[ marker ] = (UINT8)markercnt; StartFrameBufferRender(); RenderFOVDebug( ); SetFont( LARGEFONT1 ); SetFontBackground( FONT_MCOLOR_BLACK ); SetFontForeground( FONT_MCOLOR_WHITE ); mprintf( 10, 10 , L"%d", maincnt ); //mprintf( 10, 20 , L"%d", marker ); //mprintf( 50, 20 , L"%d", pSoldier->sGridNo ); InvalidateScreen( ); EndFrameBufferRender(); RefreshScreen( NULL ); do { } while( ( GetJA2Clock( ) - cnt ) < 250 ); } #endif // Check if we can get to this gridno from our direction in ubMovementCost = gubWorldMovementCosts[ marker ][ Dir[ markerDir ] ][ ubLevel ]; // ATE: Added: If our current sector is below ground, ignore any blocks! if ( gfCaves && ubMovementCost != TRAVELCOST_CAVEWALL ) { ubMovementCost = TRAVELCOST_FLAT; } if ( IS_TRAVELCOST_DOOR( ubMovementCost ) ) { ubMovementCost = DoorTravelCost( pSoldier, marker, ubMovementCost, (BOOLEAN) (pSoldier->bTeam == gbPlayerNum), &iDoorGridNo ); pStructure = FindStructure( iDoorGridNo, STRUCTURE_ANYDOOR ); if ( pStructure != NULL && pStructure->fFlags & STRUCTURE_TRANSPARENT) { // cell door or somehow otherwise transparent; allow merc to see through ubMovementCost = TRAVELCOST_FLAT; } } // If we have hit an obstacle, STOP HERE if ( ubMovementCost >= TRAVELCOST_BLOCKED ) { // We have an obstacle here... // If it is bigger than a breadbox... err... taller than a man... // Then stop path altogether // otherwise just stop revealing items // CJC: only do this when the direction is horizontal; easier and faster to check // and the effect should still be good enough if ( ubMovementCost == TRAVELCOST_WALL || ubMovementCost == TRAVELCOST_DOOR || ubMovementCost == TRAVELCOST_EXITGRID ) { fTravelCostObs = TRUE; fRevealItems = FALSE; } else { // walls are handled above, so the blocking object is guaranteed not to be a wall bTallestStructureHeight = GetTallestStructureHeight( marker, FALSE ); if (bTallestStructureHeight >= 3) { fTravelCostObs = TRUE; fStopRevealingItemsAfterThisTile = TRUE; } else if ( bTallestStructureHeight != 0 ) { // stop revealing items after this tile but keep going fStopRevealingItemsAfterThisTile = TRUE; } } if ( (Dir[markerDir] % 2) == 1 ) { // diagonal fTravelCostObs = TRUE; // cheap hack... don't reveal items fRevealItems = FALSE; } else { bTallestStructureHeight = GetTallestStructureHeight( marker, FALSE ); if (bTallestStructureHeight >= 3) { fTravelCostObs = TRUE; fStopRevealingItemsAfterThisTile = TRUE; } else if ( bTallestStructureHeight != 0 ) { // stop revealing items after this tile but keep going fStopRevealingItemsAfterThisTile = TRUE; } } } // Check if it's been done already! if ( gubGridNoMarkers[ marker ] != gubGridNoValue ) { // Mark gridno gubGridNoMarkers[ marker ] = gubGridNoValue; // check and see if the gridno changed // if the gridno is the same, avoid redundancy and break if (marker==prevmarker && markercnt != 0 ) { } else // it changed { // Skip others if we have gone through a door but are too far away.... if ( fGoneThroughDoor ) { if (markercnt > 5 ) // Are we near the door? { break; } } // DO MINE FINDING STUFF // GET INDEX FOR ITEM HERE // if there IS a direction after this one, nextdir WILL NOT be 99 if (nextDir != 99) { Blocking = GetBlockingStructureInfo( marker, (INT8)Dir[ markerDir ], (INT8)Dir[ nextDir ], ubLevel, &bStructHeight, &pDummy, FALSE ); } else // no "next" direction, so pass in a NOWHERE so that // "SpecialViewObstruction" will know not to take it UINT32o consideration { Blocking = GetBlockingStructureInfo( marker, (INT8)Dir[markerDir], (INT8)30, ubLevel, &bStructHeight, &pDummy, FALSE ); } if ( gfCaves ) { Blocking = NOTHING_BLOCKING; } // CHECK FOR ROOMS if ( Blocking == BLOCKING_TOPLEFT_WINDOW || Blocking == BLOCKING_TOPLEFT_OPEN_WINDOW ) { // CHECK FACING DIRECTION! if ( Dir[markerDir] == NORTH || Dir[markerDir] == SOUTH ) { if (markercnt <= 1 ) // Are we right beside it? { fThroughWindow = TRUE; bThroughWindowDirection = ( INT8 ) Dir[ markerDir ]; } } } if ( Blocking == BLOCKING_TOPRIGHT_WINDOW || Blocking == BLOCKING_TOPRIGHT_OPEN_WINDOW ) { // CHECK FACING DIRECTION! if ( Dir[markerDir] == EAST || Dir[markerDir] == WEST ) { if (markercnt <= 1 ) // Are we right beside it? { fThroughWindow = TRUE; bThroughWindowDirection = ( INT8 ) Dir[ markerDir ]; } } } if ( Blocking == BLOCKING_TOPLEFT_DOOR ) { fGoneThroughDoor = TRUE; } if ( Blocking == BLOCKING_TOPRIGHT_DOOR ) { fGoneThroughDoor = TRUE; } // ATE: If we hit this tile, find item always! //if (Blocking < FULL_BLOCKING ) { // Handle special things for our mercs, like uncovering roofs // and revealing objects... //gpSoldier->shad |= SEENBIT; //itemVisible = ObjList[itemIndex].visible; // NOTE: don't allow object viewing if gassed XXX if (itemsToo && fRevealItems ) // && itemIndex < MAXOBJECTLIST) { // OK, look for corpses... LookForAndMayCommentOnSeeingCorpse( pSoldier, marker, ubLevel ); if ( GetItemPool( marker, &pItemPool, ubLevel ) ) { itemVisible = pItemPool->bVisible; if ( SetItemPoolVisibilityOn( pItemPool, INVISIBLE, fShowLocators ) ) { SetRenderFlags(RENDER_FLAG_FULL); // WANNE: Should we pause when item was found in tactical? bool enableItemSpottingAction = true; if ( !is_networked && gGameExternalOptions.fItemSpottedNoTalk && gTacticalStatus.uiFlags & TURNBASED && gTacticalStatus.uiFlags & INCOMBAT) enableItemSpottingAction = false; if (enableItemSpottingAction) { if ( fShowLocators ) { // Set makred render flags //gpWorldLevelData[marker].uiFlags|=MAPELEMENT_REDRAW; //gpWorldLevelData[gusCurMousePos].pTopmostHead->uiFlags |= LEVELNODE_DYNAMIC; //SetRenderFlags(RENDER_FLAG_MARKED); SetRenderFlags(RENDER_FLAG_FULL); // Hault soldier // ATE: Only if in combat... if ( gTacticalStatus.uiFlags & INCOMBAT ) { pSoldier->HaultSoldierFromSighting( FALSE ); } else { // ATE: Make sure we show locators... gTacticalStatus.fLockItemLocators = FALSE; } if ( !fItemsQuoteSaid && gTacticalStatus.fLockItemLocators == FALSE ) { gTacticalStatus.fLockItemLocators = TRUE; if ( gTacticalStatus.ubAttackBusyCount > 0 && ( gTacticalStatus.uiFlags & INCOMBAT ) ) { gTacticalStatus.fItemsSeenOnAttack = TRUE; gTacticalStatus.ubItemsSeenOnAttackSoldier = pSoldier->ubID; gTacticalStatus.usItemsSeenOnAttackGridNo = marker; } else { // Display quote! if ( !AM_AN_EPC( pSoldier ) ) { TacticalCharacterDialogueWithSpecialEvent( pSoldier, (UINT16)( QUOTE_SPOTTED_SOMETHING_ONE + Random( 2 ) ), DIALOGUE_SPECIAL_EVENT_SIGNAL_ITEM_LOCATOR_START, marker, 0 ); } else { // Turn off item lock for locators... gTacticalStatus.fLockItemLocators = FALSE; // Slide to location! SlideToLocation( 0, marker ); } } fItemsQuoteSaid = TRUE; } } } } } } // if blood here, let the user see it now... //if (ExtGrid[marker].patrolInfo < MAXBLOOD) // gpSoldier->blood = ExtGrid[marker].patrolInfo; //DoRoofs(marker,gpSoldier); tilesLeftToSee--; } // CHECK FOR HIDDEN STRUCTS // IF we had a hidden struct here that is not visible ( which will still be true because // we set it revealed below... if ( DoesGridNoContainHiddenStruct( marker, &fHiddenStructVisible ) ) { if ( !fHiddenStructVisible ) { gpWorldLevelData[marker].uiFlags|=MAPELEMENT_REDRAW; SetRenderFlags(RENDER_FLAG_MARKED); RecompileLocalMovementCosts( marker ); } } if (tilesLeftToSee <= 0) break; if ( Blocking == FULL_BLOCKING || ( fTravelCostObs && !fThroughWindow ) ) { break; } //if ( Blocking == NOTHING_BLOCKING || Blocking == BLOCKING_NEXT_TILE ) if ( Blocking == NOTHING_BLOCKING ) { fCheckForRooms = TRUE; } if ( ubLevel != 0 ) { fCheckForRooms = FALSE; } // CHECK FOR SLANT ROOF! { STRUCTURE *pStructure, *pBase; pStructure = FindStructure( marker, STRUCTURE_SLANTED_ROOF ); if ( pStructure != NULL ) { pBase = FindBaseStructure( pStructure ); // ADD TO SLANTED ROOF LIST! AddSlantRoofFOVSlot( marker ); } } // Set gridno as revealed if ( ubLevel == FIRST_LEVEL ) { if ( gfBasement || gfCaves ) { // OK, if we are underground, we don't want to reveal stuff if // 1 ) there is a roof over us and // 2 ) we are not in a room if ( gusWorldRoomInfo[ marker ] == NO_ROOM && TypeRangeExistsInRoofLayer( marker, FIRSTROOF, FOURTHROOF, &usIndex ) ) { int i = 0; } else { gpWorldLevelData[ marker ].uiFlags |= MAPELEMENT_REVEALED; if( gfCaves ) { RemoveFogFromGridNo( marker ); } } } else { gpWorldLevelData[ marker ].uiFlags |= MAPELEMENT_REVEALED; } // CHECK FOR ROOMS //if ( fCheckForRooms ) { if ( InAHiddenRoom( marker, &usRoomNo ) ) { RemoveRoomRoof( marker, usRoomNo, pSoldier ); if ( usRoomNo == ROOM_SURROUNDING_BOXING_RING && gWorldSectorX == BOXING_SECTOR_X && gWorldSectorY == BOXING_SECTOR_Y && gbWorldSectorZ == BOXING_SECTOR_Z ) { // reveal boxing ring at same time RemoveRoomRoof( marker, BOXING_RING, pSoldier ); } } } } else { gpWorldLevelData[ marker ].uiFlags |= MAPELEMENT_REVEALED_ROOF; } // Check for blood.... UpdateBloodGraphics( marker, ubLevel ); if ( Blocking != NOTHING_BLOCKING && Blocking != BLOCKING_TOPLEFT_DOOR && Blocking != BLOCKING_TOPRIGHT_DOOR && Blocking != BLOCKING_TOPLEFT_WINDOW && Blocking != BLOCKING_TOPRIGHT_WINDOW && Blocking != BLOCKING_TOPRIGHT_OPEN_WINDOW && Blocking != BLOCKING_TOPLEFT_OPEN_WINDOW) { break; } //gpWorldLevelData[ marker ].uiFlags |= MAPELEMENT_SHADELAND; } } // End of duplicate check else { if ( fTravelCostObs ) { break; } } } // end of one path } // end of path loop // Loop through all availible slant roofs we collected and perform cool stuff on them ExamineSlantRoofFOVSlots( ); //pSoldier->needToLookForItems = FALSE; //LookForDoors(pSoldier,UNAWARE); }
void FindPanicBombsAndTriggers( void ) { // This function searches the bomb table to find panic-trigger-tuned bombs and triggers UINT32 uiBombIndex; OBJECTTYPE * pObj; STRUCTURE * pSwitch; INT32 sGridNo = NOWHERE; INT8 bPanicIndex; for (uiBombIndex = 0; uiBombIndex < guiNumWorldBombs; uiBombIndex++) { if (gWorldBombs[ uiBombIndex ].fExists) { pObj = &(gWorldItems[ gWorldBombs[ uiBombIndex ].iItemIndex ].object); if ((*pObj)[0]->data.misc.bFrequency == PANIC_FREQUENCY || (*pObj)[0]->data.misc.bFrequency == PANIC_FREQUENCY_2 || (*pObj)[0]->data.misc.bFrequency == PANIC_FREQUENCY_3 ) { if (pObj->usItem == SWITCH) { sGridNo = gWorldItems[ gWorldBombs[ uiBombIndex ].iItemIndex ].sGridNo; switch( (*pObj)[0]->data.misc.bFrequency ) { case PANIC_FREQUENCY: bPanicIndex = 0; break; case PANIC_FREQUENCY_2: bPanicIndex = 1; break; case PANIC_FREQUENCY_3: bPanicIndex = 2; break; default: // augh!!! continue; } pSwitch = FindStructure( sGridNo, STRUCTURE_SWITCH ); if (pSwitch) { switch( pSwitch->ubWallOrientation ) { case INSIDE_TOP_LEFT: case OUTSIDE_TOP_LEFT: sGridNo += DirectionInc( SOUTH ); break; case INSIDE_TOP_RIGHT: case OUTSIDE_TOP_RIGHT: sGridNo += DirectionInc( EAST ); break; default: break; } } gTacticalStatus.sPanicTriggerGridNo[ bPanicIndex ] = sGridNo; gTacticalStatus.ubPanicTolerance[ bPanicIndex ] = (*pObj)[0]->data.misc.ubTolerance; if ((*pObj).fFlags & OBJECT_ALARM_TRIGGER) { gTacticalStatus.bPanicTriggerIsAlarm[ bPanicIndex ] = TRUE; } gTacticalStatus.fPanicFlags |= PANIC_TRIGGERS_HERE; bPanicIndex++; if (bPanicIndex == NUM_PANIC_TRIGGERS) { return; } } else { gTacticalStatus.fPanicFlags |= PANIC_BOMBS_HERE; } } } } }
void ExamineGridNoForSlantRoofExtraGraphic( INT32 sCheckGridNo ) { LEVELNODE *pNode = NULL; STRUCTURE *pStructure, *pBase; UINT8 ubLoop; DB_STRUCTURE_TILE ** ppTile; INT32 sGridNo; UINT16 usIndex; BOOLEAN fChanged = FALSE; // CHECK FOR A SLANTED ROOF HERE.... pStructure = FindStructure( sCheckGridNo, STRUCTURE_SLANTED_ROOF ); if ( pStructure != NULL ) { // We have a slanted roof here ... find base and remove... pBase = FindBaseStructure( pStructure ); // Get LEVELNODE for struct and remove! pNode = FindLevelNodeBasedOnStructure( pBase->sGridNo, pBase ); // Loop through each gridno and see if revealed.... for ( ubLoop = 0; ubLoop < pBase->pDBStructureRef->pDBStructure->ubNumberOfTiles; ubLoop++ ) { ppTile = pBase->pDBStructureRef->ppTile; #if 0//dnl ch83 080114 sGridNo = pBase->sGridNo + ppTile[ ubLoop ]->sPosRelToBase; #else sGridNo = AddPosRelToBase(pBase->sGridNo, ppTile[ubLoop]); #endif if (sGridNo < 0 || sGridNo > WORLD_MAX) { continue; } // Given gridno, // IF NOT REVEALED AND HIDDEN.... if ( !( gpWorldLevelData[ sGridNo ].uiFlags & MAPELEMENT_REVEALED ) && pNode->uiFlags & LEVELNODE_HIDDEN ) { // Add graphic if one does not already exist.... if ( !TypeExistsInRoofLayer( sGridNo, SLANTROOFCEILING, &usIndex ) ) { // Add AddRoofToHead( sGridNo, SLANTROOFCEILING1 ); fChanged = TRUE; } } // Revealed? if ( gpWorldLevelData[ sGridNo ].uiFlags & MAPELEMENT_REVEALED ) { ///Remove any slant roof items if they exist if ( TypeExistsInRoofLayer( sGridNo, SLANTROOFCEILING, &usIndex ) ) { RemoveRoof( sGridNo, usIndex ); fChanged = TRUE; } } } } if ( fChanged ) { // DIRTY THE WORLD! InvalidateWorldRedundency(); SetRenderFlags(RENDER_FLAG_FULL ); } }