Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Linux release.
Browse files Browse the repository at this point in the history
Fix to AIs that begin the level standing still so that they don't leave their home for tile 0,0
Navmeshes now fully generated at level load
  • Loading branch information
hankmorgan committed Feb 14, 2018
1 parent 048cfbb commit 1d69aff
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 38 deletions.
3 changes: 2 additions & 1 deletion UnityScripts/scripts/NPC/NPC.cs
Expand Up @@ -681,8 +681,9 @@ void UpdateGoals ()
case npc_goals.npc_goal_stand_still_12:
{
AnimRange= NPC.AI_RANGE_IDLE;
if ((CurTileX!=DestTileX) && (CurTileY!=DestTileY))
if ((CurTileX!=npc_xhome) && (CurTileY!=npc_yhome))
{
DestTileX = npc_yhome; DestTileY = npc_yhome;
AgentGotoDestTileXY (ref DestTileX, ref DestTileY, ref CurTileX, ref CurTileY);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion UnityScripts/scripts/Objects/ObjectMasters.cs
Expand Up @@ -29,7 +29,7 @@ public ObjectMasters()
break;

default:
Load(Application.dataPath + "//..//" + UWEBase._RES + "_object_settings.txt");
Load(Application.dataPath + "//..//" + UWEBase._RES.ToLower() + "_object_settings.txt");
break;
}
}
Expand Down
18 changes: 9 additions & 9 deletions UnityScripts/scripts/World/GameWorldController.cs
Expand Up @@ -499,14 +499,14 @@ void GenerateNavmesh(NavMeshSurface navmeshobj)
//navmesh.layerMask = layer;
// navmeshobj.BuildNavMesh();
//navmeshobj.
if (navmeshobj.navMeshData==null)
{
navmeshobj.BuildNavMesh();
}
else
{
navmeshobj.UpdateNavMesh(navmeshobj.navMeshData);
}
//if (navmeshobj.navMeshData==null)
//{
navmeshobj.BuildNavMesh();
//}
//else
//{
// navmeshobj.UpdateNavMesh(navmeshobj.navMeshData);
//}

}

Expand Down Expand Up @@ -984,7 +984,7 @@ public void SwitchLevel(short newLevelNo)
//GenerateNavmesh(NavRigLand);
//GenerateNavmesh(NavRigWater);
//GenerateNavmesh(navmeshsurface,256);
//GenerateNavMeshes();
GenerateNavMeshes();
}

if ((LevelNo==7) && (UWEBase._RES==UWEBase.GAME_UW1))
Expand Down
19 changes: 19 additions & 0 deletions asciimode.cpp
Expand Up @@ -335,6 +335,8 @@ void DumpAscii(int game, tile LevelInfo[64][64], ObjectItem objList[1600], int L

printRoomRegions(LevelInfo, LevelNo);

printIndexObjectList(LevelInfo, LevelNo);

//printRoomRegionsForNavmeshTagging(LevelInfo,objList, LevelNo);

if (game == SHOCK)
Expand Down Expand Up @@ -443,6 +445,23 @@ void printFlagsMap(tile LevelInfo[64][64], int LevelNo)
}
}

void printIndexObjectList(tile LevelInfo[64][64], int LevelNo)
{
//Prints the tilemap
int x; int y;
fprintf(LOGFILE, "\nNow Printing object list indices for level :%d.", LevelNo);
for (y = 63; y >= 0; y--) //invert for ascii
{
fprintf(LOGFILE, "\n");
for (x = 0; x <= 63; x++)
{
fprintf(LOGFILE, "%02d", LevelInfo[x][y].indexObjectList);
fprintf(LOGFILE, "\\");//delimiter.
}
}
}


void printFloorHeights(tile LevelInfo[64][64], int LevelNo)
{
//Prints the height map of the level.
Expand Down
1 change: 1 addition & 0 deletions asciimode.h
Expand Up @@ -30,5 +30,6 @@ void printFloorOrientations(tile LevelInfo[64][64], int LevelNo);
void printCeilOrientations(tile LevelInfo[64][64], int LevelNo);
void printRoomRegionsForNavmeshTagging(tile LevelInfo[64][64], ObjectItem objList[1600], int LevelNo);
void printNonStaticTiles(tile LevelInfo[64][64], int LevelNo);
void printIndexObjectList(tile LevelInfo[64][64], int LevelNo);
//int isTrigger(ObjectItem currobj);
#endif /* asciimode_h */
20 changes: 17 additions & 3 deletions fbxExport.cpp
@@ -1,3 +1,4 @@
/*Release uncomment remove all instances of this to restore fbx extract
#include <fbxsdk.h>
#include "tilemap.h"
#include "gameobjects.h"
Expand Down Expand Up @@ -98,6 +99,8 @@ void CreateShockBridgeModel(FbxScene*& gScene);
//FbxString* gAppPath = NULL; // path where the application started
/* Tab character ("\t") counter */

/*Release uncomment
int numTabs = 0;
extern int iGame;
Expand Down Expand Up @@ -285,7 +288,7 @@ extern long UW_CEILING_HEIGHT;
// }



/*Release uncomment
bool InitializeSdkObjects(FbxManager*& pManager, FbxScene*& pScene)
{
//The first thing to do is to create the FBX Manager which is the object allocator for almost all the classes in the SDK
Expand Down Expand Up @@ -1413,6 +1416,7 @@ void RenderFBXOpenTile(FbxScene*& gScene, int x, int y, tile &t, short Water, sh
void RenderFBXCuboid(FbxScene*& gScene, int x, int y, tile &t, short Water, int Bottom, int Top, char *TileName)
{
/* This is main version of this function*/
/*Release uncomment
FbxVector4 lNormalXPos(1, 0, 0);
FbxVector4 lNormalXNeg(-1, 0, 0);
FbxVector4 lNormalYPos(0, 1, 0);
Expand Down Expand Up @@ -2020,6 +2024,7 @@ void RenderFBXCuboidByPoints(FbxScene*& gScene, int x, int y, tile &t, short Wat
)
{
/* FBX Cube with Preset vertical UV settings*/
/*Release uncomment
FbxVector4 lNormalXPos(1, 0, 0);
FbxVector4 lNormalXNeg(-1, 0, 0);
FbxVector4 lNormalYPos(0, 1, 0);
Expand Down Expand Up @@ -4342,7 +4347,8 @@ void RenderSlopedFBXCuboid(FbxScene*& gScene, int x, int y, tile &t, short Water
void CreateFBXMaterials(FbxScene*& gScene, int game)
{
/*Populates the texture list for the fbx model file*/
FbxFileTexture* gTexture = NULL;
/*Release uncomment
FbxFileTexture* gTexture = NULL;
FbxSurfacePhong* gMaterial = NULL;
int NoOfMaterials = 0;
switch (game)
Expand Down Expand Up @@ -4661,6 +4667,7 @@ void RenderFBXDoorway(FbxScene*& gScene, int game, int x, int y, tile &t, Object
/*
left side. east west door
*/
/*Release uncomment
x1 = ((offX + DOORTHICKNESS + doorOffset));
y1 = ((y + 1)*BrushY);
z1 = BrushZ * (CEILING_HEIGHT + 1); //(offZ*BrushZ + doorHeight);
Expand Down Expand Up @@ -4694,6 +4701,7 @@ void RenderFBXDoorway(FbxScene*& gScene, int game, int x, int y, tile &t, Object
/*
right side east west door
*/
/*Release uncomment
x1 = ((offX + DOORTHICKNESS + doorOffset));
if (heading == EAST)
{
Expand Down Expand Up @@ -4727,6 +4735,7 @@ void RenderFBXDoorway(FbxScene*& gScene, int game, int x, int y, tile &t, Object
/*
over the door, east west door
*/
/*Release uncomment
tmpt.tileType = TILE_OPEN;//Treat this as a dropped ceiling.
int dooroverheight = (int)((currDoor.zpos / 128.0f) * (32.0f));
if (currDoor.item_id == 334)
Expand Down Expand Up @@ -4784,6 +4793,7 @@ void RenderFBXDoorway(FbxScene*& gScene, int game, int x, int y, tile &t, Object
/*Left Side. north south door*/
//left side
//east face
/*Release uncomment
if ((heading == NORTH) || (heading == SHOCK_NORTH))
{
x1 = (offX - DOORWIDTH);
Expand Down Expand Up @@ -4824,6 +4834,7 @@ void RenderFBXDoorway(FbxScene*& gScene, int game, int x, int y, tile &t, Object
/*Right side. north south doorway*/
//right
//east face
/*Release uncomment
x1 = ((x + 1)*BrushX);
//north face
y1 = (offY + DOORTHICKNESS + doorOffset);
Expand Down Expand Up @@ -4861,6 +4872,7 @@ void RenderFBXDoorway(FbxScene*& gScene, int game, int x, int y, tile &t, Object
-FrameSideY / BrushY, (((BrushY - DOORWIDTH) / 2) / BrushY) - (FrameSideY / BrushY));
/*Over the door North South*/
/*Release uncomment
tmpt.tileType = TILE_OPEN;//Treat this as a dropped ceiling.
int dooroverheight = (int)((currDoor.zpos / 128.0f) * (32.0f));
Expand Down Expand Up @@ -5091,6 +5103,7 @@ void RenderFBXBridges(FbxScene*& gScene, int game, tile LevelInfo[64][64], Objec
tmpt.South = 267 + textureIndex;//LevelInfo[x][y].wallTexture;
tmpt.North = 267 + textureIndex;//LevelInfo[x][y].wallTexture;
*/
/*Release uncomment
tmpt.wallTexture = objList[nextObj].texture;
tmpt.floorTexture = objList[nextObj].texture;
tmpt.shockCeilingTexture = objList[nextObj].texture;
Expand Down Expand Up @@ -5322,4 +5335,5 @@ void CreateShockBridgeModel(FbxScene*& gScene)
lControlPointl0, lControlPointl1, lControlPointl2, lControlPointl3,
lControlPointl4, lControlPointl5, lControlPointl6, lControlPointl7,
0, 54.0 / 64.0);
}
}
release uncomment*/
23 changes: 16 additions & 7 deletions gamegraphics.cpp
Expand Up @@ -168,21 +168,21 @@ void extractTextureBitmap(int ImageCount, char filePathIn[255], char PaletteFile
getPalette(PaletteFile, pal, p);

//Not to cycle the palettes. To keep them synced I need 28 cycles? (4 water * 7 fire frames?)
for (int paletteFrame = 0; paletteFrame < 28; paletteFrame++)
for (int paletteFrame = 0; paletteFrame < 1; paletteFrame++)
{
// CyclePalette(16, 22);//fire
//CyclePalette(48, 51);//water
cyclePalette(pal, 48, 4);
cyclePalette(pal, 16, 7);//Reverse direction.
//cyclePalette(pal, 48, 4);
//cyclePalette(pal, 16, 7);//Reverse direction.
char paletteOutname[256];
sprintf(paletteOutname, "Palette_%d_frame", p);
//writeTGA(Allpalettefile, 0, 256,16, paletteFrame, pal, paletteOutname, 1);
writeTGA(Allpalettefile, 0, 256,16, paletteFrame, pal, paletteOutname, 1);
}

}


// getPalette(PaletteFile, pal, p);
//getPalette(PaletteFile, pal, p);

if (GREYSCALE == 1)
{
Expand Down Expand Up @@ -899,7 +899,16 @@ void extractCrittersUW1(char fileAssoc[255], char fileCrit[255], char PaletteFil
unsigned char *assocFile;

pal = new palette[256];
getPalette(PaletteFile, pal, 0);//always palette 0?

if (GREYSCALE == 1)
{
getPaletteIndex(PaletteFile, pal, PaletteNo);
}
else
{
getPalette(PaletteFile, pal, PaletteNo);
}
//getPalette(PaletteFile, pal, 0);//always palette 0?

FILE *file = NULL; // File pointer
if ((file = fopen(fileAssoc, "rb")) == NULL)
Expand Down Expand Up @@ -954,7 +963,7 @@ void extractCrittersUW1(char fileAssoc[255], char fileCrit[255], char PaletteFil
if (getValAtAddress(critterFile, AddressPointer, 8) != 255)
{
//fprintf(LOGFILE, "\n\tAnim Frame %d is %d %s_%04d", j, getValAtAddress(critterFile, AddressPointer, 8), fileCrit, getValAtAddress(critterFile, AddressPointer, 8));
printf(" \"CR%02oPAGE_N%02d_%d_%04d\" ,", fileXX, fileYY, auxPalNo, getValAtAddress(critterFile, AddressPointer, 8));
//printf(" \"CR%02oPAGE_N%02d_%d_%04d\" ,", fileXX, fileYY, auxPalNo, getValAtAddress(critterFile, AddressPointer, 8));
fprintf(LOGFILE, " \"CR%02oPAGE_N%02d_%d_%04d\" ,", fileXX, fileYY, auxPalNo, getValAtAddress(critterFile, AddressPointer, 8));
ValidCount++;
}
Expand Down
5 changes: 3 additions & 2 deletions gameobjects.cpp
Expand Up @@ -2427,7 +2427,7 @@ fprintf(LOGFILE, "\n\tName\tAmmo\tDurability");
*/
j=64;
fprintf(LOGFILE, "\nAddress is %d\nCritters\n", addressPtr);
fprintf(LOGFILE, "\nName\tAddress\tLevel\tUnk1\tUnk2\tUnk3\tAvgHit\tAttackPower\tUnk4\tRemainsBody\tRemainsBlood\tGeneralType\tPassive\tDefence\tSpeed\tUnk6\tUnk7\tPoison\tCategory\tEquipDamage\tUnk8\tProbValue1\tProb1_1\tProb_1_2\tProbPercent1\tProbValue2\tProb2_1\tProb_2_2\tProbPercent2\tProbValue3\tProb3_1\tProb_3_2\tProbPercent3\tExp\t73");
fprintf(LOGFILE, "\nName\tAddress\tLevel\tUnk1\tUnk2\tUnk3\tAvgHit\tAttackPower\tUnk4\tRemains Main\tRemainsBody\tRemainsBlood\tGeneralType\tPassive\tDefence\tSpeed\tUnk6\tUnk7\tPoison\tCategory\tEquipDamage\tUnk8\tProbValue1\tProb1_1\tProb_1_2\tProbPercent1\tProbValue2\tProb2_1\tProb_2_2\tProbPercent2\tProbValue3\tProb3_1\tProb_3_2\tProbPercent3\tExp\t73");
for (int i = 0; i < 64; i++)
{//Critters
fprintf(LOGFILE, "\n%s\t", objectMasters[j].desc);
Expand All @@ -2439,7 +2439,8 @@ j=64;
fprintf(LOGFILE, " %d\t", getValAtAddress(obj_dat, addressPtr + 4, 16));//Average Hitpoints
fprintf(LOGFILE, " %d\t", getValAtAddress(obj_dat, addressPtr + 6, 8));//Attack power
fprintf(LOGFILE, " %d\t", getValAtAddress(obj_dat, addressPtr + 7, 8));//unk4
fprintf(LOGFILE, " %d\t", getValAtAddress(obj_dat, addressPtr + 8, 8) & 0xF0);//Remains body
fprintf(LOGFILE, " %d\t", getValAtAddress(obj_dat, addressPtr + 8, 8));//Fluids & remains
fprintf(LOGFILE, " %d\t", (getValAtAddress(obj_dat, addressPtr + 8, 8) & 0xF0) >> 4);//Remains body
fprintf(LOGFILE, " %d\t", getValAtAddress(obj_dat, addressPtr + 8, 8) & 0x0F);//Remains blood
fprintf(LOGFILE, " %d\t", getValAtAddress(obj_dat, addressPtr + 9, 8));//General Type
fprintf(LOGFILE, " %d\t", getValAtAddress(obj_dat, addressPtr + 0xA, 8));//Passiveness
Expand Down
38 changes: 28 additions & 10 deletions main.cpp
Expand Up @@ -17,7 +17,7 @@
#include "gamestrings.h"
#include "gamegraphics.h"
#include "Conversations.h"
#include "fbxExport.h"
//#include "fbxExport.h"
#include "Unity.h"
#include "hacking.h"

Expand Down Expand Up @@ -57,6 +57,24 @@ int main()
int BlocksToRepack = 80;//UW2 blocks to repack
int useTGA = 0;
FILE *f = NULL;


/*
if ((f = fopen("c:\\games\\uw2\\data\\lev.ark", "r")) == NULL)
{
printf("Could not open specified file\n");
return 0;
}
long fileSize = getFileSize(f);
unsigned char *tmp_ark = new unsigned char[fileSize];
fread(tmp_ark, fileSize, 1, f);
fclose(f);
int datalen = 0;
get_rwops_uw2dec(tmp_ark, 240, &datalen);
return 0;*/

if ((f = fopen("gamepaths.txt", "r")) == NULL)
{
printf("Could not open specified file\n");
Expand Down Expand Up @@ -89,14 +107,14 @@ int main()
path_target_platform[ln] = '\0';

fclose(f);
const char *uw_game_files[7];
const char *uw_game_files[6];
uw_game_files[0] = "Data\\LEV.ARK";
uw_game_files[1] = "Save0\\lev.ark";
uw_game_files[2] = "Save1\\lev.ark";
uw_game_files[3] = "Save2\\lev.ark";
uw_game_files[4] = "Save3\\lev.ark";
uw_game_files[5] = "Save4\\lev.ark";
uw_game_files[6] = "data\\cnv.ark"; //UW2 ark files.
//uw_game_files[1] = "Save0\\lev.ark";
uw_game_files[1] = "Save1\\lev.ark";
uw_game_files[2] = "Save2\\lev.ark";
uw_game_files[3] = "Save3\\lev.ark";
uw_game_files[4] = "Save4\\lev.ark";
uw_game_files[5] = "data\\cnv.ark"; //UW2 ark files.

const char *shock_game_files[9];
shock_game_files[0] = "res\\Data\\archive.dat";
Expand Down Expand Up @@ -511,7 +529,7 @@ int main()
case UW1:
case UW2:
printf("\nPick a level archive or save game to open\n");
for (int i = 0; i < 6; i++)
for (int i = 0; i < 5; i++)
{
printf("%d) %s\n", i, uw_game_files[i]);
}
Expand Down Expand Up @@ -1617,7 +1635,7 @@ void exportMaps(int game, int mode, int LevelNo, char OutFileName[255], char fil
case FBX_MODE:
CleanUp(LevelInfo, game); //Get rid of unneeded tiles.
//printf("%d", LevelInfo[3][5].Render);
RenderFBXLevel(LevelInfo, objList, game);
//TODO: restore this for FBX RenderFBXLevel(LevelInfo, objList, game);
break;
case UNITY_MODE:
RenderUnityObjectList(game, LevelNo, LevelInfo, objList);
Expand Down
2 changes: 1 addition & 1 deletion main.h
Expand Up @@ -144,7 +144,7 @@ extern int CEILING_HEIGHT;
#define ALPHA 1

//Generate graphics in Greyscale for palette operations
#define GREYSCALE 0
#define GREYSCALE 1


//Should graphics be actually extracted or should I just go through the motions?
Expand Down

0 comments on commit 1d69aff

Please sign in to comment.