Game.cpp 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  1. #include "Hunt.h"
  2. /*typedef struct tagAudioQuad
  3. {
  4. float x1,y1,z1;
  5. float x2,y2,z2;
  6. float x3,y3,z3;
  7. float x4,y4,z4;
  8. } AudioQuad;
  9. AudioQuad data[8192];
  10. HMap[1024][1024];
  11. */
  12. bool ShowFaces = true;
  13. void UploadGeometry()
  14. {
  15. int x,y,xx,yy;
  16. byte temp;
  17. AudioFCount = 0;
  18. int MaxView = 18;
  19. int HalfView = (int)(MaxView/2)+1;
  20. for (x = 0; x < MaxView; x++)
  21. for (y = 0; y < MaxView; y++)
  22. {
  23. xx = (x - HalfView)*2;
  24. yy = (y - HalfView)*2;
  25. data[AudioFCount].x1 = (CCX+xx) * 256 - CameraX;
  26. data[AudioFCount].y1 = HMap[CCY+yy][CCX+xx] * ctHScale - CameraY;
  27. data[AudioFCount].z1 = (CCY+yy) * 256 - CameraZ;
  28. xx = ((x+1) - HalfView)*2;
  29. yy = (y - HalfView)*2;
  30. data[AudioFCount].x2 = (CCX+xx) * 256 - CameraX;
  31. data[AudioFCount].y2 = HMap[CCY+yy][CCX+xx] * ctHScale - CameraY;
  32. data[AudioFCount].z2 = (CCY+yy) * 256 - CameraZ;
  33. xx = ((x+1) - HalfView)*2;
  34. yy = ((y+1) - HalfView)*2;
  35. data[AudioFCount].x3 = (CCX+xx) * 256 - CameraX;
  36. data[AudioFCount].y3 = HMap[CCY+yy][CCX+xx] * ctHScale - CameraY;
  37. data[AudioFCount].z3 = (CCY+yy) * 256 - CameraZ;
  38. xx = (x - HalfView)*2;
  39. yy = ((y+1) - HalfView)*2;
  40. data[AudioFCount].x4 = (CCX+xx) * 256 - CameraX;
  41. data[AudioFCount].y4 = HMap[CCY+yy][CCX+xx] * ctHScale - CameraY;
  42. data[AudioFCount].z4 = (CCY+yy) * 256 - CameraZ;
  43. AudioFCount++;
  44. }
  45. // MessageBeep(-1);
  46. if (ShowFaces)
  47. { wsprintf(logt,"Audio_UpdateGeometry: %i faces uploaded\n", AudioFCount); PrintLog(logt);
  48. ShowFaces = false;}
  49. }
  50. void SetupRes()
  51. {
  52. if (!HARD3D)
  53. if (OptRes>5) OptRes=5;
  54. if (OptRes==0) { WinW = 320; WinH=240; }
  55. if (OptRes==1) { WinW = 400; WinH=300; }
  56. if (OptRes==2) { WinW = 512; WinH=384; }
  57. if (OptRes==3) { WinW = 640; WinH=480; }
  58. if (OptRes==4) { WinW = 800; WinH=600; }
  59. if (OptRes==5) { WinW =1024; WinH=768; }
  60. if (OptRes==6) { WinW =1280; WinH=1024; }
  61. if (OptRes==7) { WinW =1600; WinH=1200; }
  62. }
  63. float GetLandOH(int x, int y)
  64. {
  65. return (float)(HMapO[y][x]) * ctHScale;
  66. }
  67. float GetLandOUH(int x, int y)
  68. {
  69. if (FMap[y][x] & fmReverse)
  70. return (float)((int)(HMap[y][x+1]+HMap[y+1][x])/2.f)*ctHScale;
  71. else
  72. return (float)((int)(HMap[y][x]+HMap[y+1][x+1])/2.f)*ctHScale;
  73. }
  74. float GetLandUpH(float x, float y)
  75. {
  76. int CX = (int)x / 256;
  77. int CY = (int)y / 256;
  78. if (!(FMap[CY][CX] & fmWaterA)) return GetLandH(x,y);
  79. return (float)(WaterList[ WMap[CY][CX] ].wlevel * ctHScale);
  80. }
  81. float GetLandH(float x, float y)
  82. {
  83. int CX = (int)x / 256;
  84. int CY = (int)y / 256;
  85. int dx = (int)x % 256;
  86. int dy = (int)y % 256;
  87. int h1 = HMap[CY][CX];
  88. int h2 = HMap[CY][CX+1];
  89. int h3 = HMap[CY+1][CX+1];
  90. int h4 = HMap[CY+1][CX];
  91. if (FMap[CY][CX] & fmReverse) {
  92. if (256-dx>dy) h3 = h2+h4-h1;
  93. else h1 = h2+h4-h3;
  94. } else {
  95. if (dx>dy) h4 = h1+h3-h2;
  96. else h2 = h1+h3-h4;
  97. }
  98. float h = (float)
  99. (h1 * (256-dx) + h2 * dx) * (256-dy) +
  100. (h4 * (256-dx) + h3 * dx) * dy;
  101. return (h / 256.f / 256.f) * ctHScale;
  102. }
  103. float GetLandLt(float x, float y)
  104. {
  105. int CX = (int)x / 256;
  106. int CY = (int)y / 256;
  107. int dx = (int)x % 256;
  108. int dy = (int)y % 256;
  109. int h1 = LMap[CY][CX];
  110. int h2 = LMap[CY][CX+1];
  111. int h3 = LMap[CY+1][CX+1];
  112. int h4 = LMap[CY+1][CX];
  113. float h = (float)
  114. (h1 * (256-dx) + h2 * dx) * (256-dy) +
  115. (h4 * (256-dx) + h3 * dx) * dy;
  116. return (h / 256.f / 256.f);
  117. }
  118. float GetLandLt2(float x, float y)
  119. {
  120. int CX = ((int)x / 512)*2 - CCX;
  121. int CY = ((int)y / 512)*2 - CCY;
  122. int dx = (int)x % 512;
  123. int dy = (int)y % 512;
  124. int h1 = VMap[CY+128][CX+128].Light;
  125. int h2 = VMap[CY+128][CX+2+128].Light;
  126. int h3 = VMap[CY+2+128][CX+2+128].Light;
  127. int h4 = VMap[CY+2+128][CX+128].Light;
  128. float h = (float)
  129. (h1 * (512-dx) + h2 * dx) * (512-dy) +
  130. (h4 * (512-dx) + h3 * dx) * dy;
  131. return (h / 512.f / 512.f);
  132. }
  133. void CalcModelGroundLight(TModel *mptr, float x0, float z0, int FI)
  134. {
  135. float ca = cos(FI * pi / 2);
  136. float sa = sin(FI * pi / 2);
  137. for (int v=0; v<mptr->VCount; v++) {
  138. float x = mptr->gVertex[v].x * ca + mptr->gVertex[v].z * sa + x0;
  139. float z = mptr->gVertex[v].z * ca - mptr->gVertex[v].x * sa + z0;
  140. mptr->VLight[0][v] = GetLandLt2(x, z) - 128;
  141. }
  142. }
  143. BOOL PointOnBound(float &H, float px, float py, float cx, float cy, float oy, TBound *bound, int angle)
  144. {
  145. px-=cx;
  146. py-=cy;
  147. float ca = (float) cos(angle*pi / 2.f);
  148. float sa = (float) sin(angle*pi / 2.f);
  149. BOOL _on = FALSE;
  150. H=-1000;
  151. for (int o=0; o<8; o++) {
  152. if (bound[o].a<0) continue;
  153. if (bound[o].y2 + oy > PlayerY + 128) continue;
  154. float a,b;
  155. float ccx = bound[o].cx*ca + bound[o].cy*sa;
  156. float ccy = bound[o].cy*ca - bound[o].cx*sa;
  157. if (angle & 1) {
  158. a = bound[o].b;
  159. b = bound[o].a;
  160. } else {
  161. a = bound[o].a;
  162. b = bound[o].b;
  163. }
  164. if ( ( fabs(px - ccx) < a) && (fabs(py - ccy) < b) )
  165. {
  166. _on=TRUE;
  167. if (H < bound[o].y2) H = bound[o].y2;
  168. }
  169. }
  170. return _on;
  171. }
  172. BOOL PointUnBound(float &H, float px, float py, float cx, float cy, float oy, TBound *bound, int angle)
  173. {
  174. px-=cx;
  175. py-=cy;
  176. float ca = (float) cos(angle*pi / 2.f);
  177. float sa = (float) sin(angle*pi / 2.f);
  178. BOOL _on = FALSE;
  179. H=+1000;
  180. for (int o=0; o<8; o++) {
  181. if (bound[o].a<0) continue;
  182. if (bound[o].y1 + oy < PlayerY + 128) continue;
  183. float a,b;
  184. float ccx = bound[o].cx*ca + bound[o].cy*sa;
  185. float ccy = bound[o].cy*ca - bound[o].cx*sa;
  186. if (angle & 1) {
  187. a = bound[o].b;
  188. b = bound[o].a;
  189. } else {
  190. a = bound[o].a;
  191. b = bound[o].b;
  192. }
  193. if ( ( fabs(px - ccx) < a) && (fabs(py - ccy) < b) )
  194. {
  195. _on=TRUE;
  196. if (H > bound[o].y1) H = bound[o].y1;
  197. }
  198. }
  199. return _on;
  200. }
  201. float GetLandCeilH(float CameraX, float CameraZ)
  202. {
  203. float h,hh;
  204. h = GetLandH(CameraX, CameraZ) + 20480;
  205. int ccx = (int)CameraX / 256;
  206. int ccz = (int)CameraZ / 256;
  207. for (int z=-4; z<=4; z++)
  208. for (int x=-4; x<=4; x++)
  209. if (OMap[ccz+z][ccx+x]!=255) {
  210. int ob = OMap[ccz+z][ccx+x];
  211. float CR = (float)MObjects[ob].info.Radius - 1.f;
  212. float oz = (ccz+z) * 256.f + 128.f;
  213. float ox = (ccx+x) * 256.f + 128.f;
  214. float LandY = GetLandOH(ccx+x, ccz+z);
  215. if (!(MObjects[ob].info.flags & ofBOUND)) {
  216. if (MObjects[ob].info.YLo + LandY > h) continue;
  217. if (MObjects[ob].info.YLo + LandY < PlayerY+100) continue;
  218. }
  219. float r = CR+1;
  220. if (MObjects[ob].info.flags & ofBOUND)
  221. {
  222. float hh;
  223. if (PointUnBound(hh, CameraX, CameraZ, ox, oz, LandY, MObjects[ob].bound, ((FMap[ccz+z][ccx+x] >> 2) & 3) ) )
  224. if (h > LandY + hh) h = LandY + hh;
  225. } else {
  226. if (MObjects[ob].info.flags & ofCIRCLE)
  227. r = (float) sqrt( (ox-CameraX)*(ox-CameraX) + (oz-CameraZ)*(oz-CameraZ) );
  228. else
  229. r = (float) max( fabs(ox-CameraX) , fabs(oz-CameraZ) );
  230. if (r<CR) h = MObjects[ob].info.YLo + LandY;
  231. }
  232. }
  233. return h;
  234. }
  235. float GetLandQH(float CameraX, float CameraZ)
  236. {
  237. float h,hh;
  238. h = GetLandH(CameraX, CameraZ);
  239. hh = GetLandH(CameraX-90.f, CameraZ-90.f); if (hh>h) h=hh;
  240. hh = GetLandH(CameraX+90.f, CameraZ-90.f); if (hh>h) h=hh;
  241. hh = GetLandH(CameraX-90.f, CameraZ+90.f); if (hh>h) h=hh;
  242. hh = GetLandH(CameraX+90.f, CameraZ+90.f); if (hh>h) h=hh;
  243. hh = GetLandH(CameraX+128.f, CameraZ); if (hh>h) h=hh;
  244. hh = GetLandH(CameraX-128.f, CameraZ); if (hh>h) h=hh;
  245. hh = GetLandH(CameraX, CameraZ+128.f); if (hh>h) h=hh;
  246. hh = GetLandH(CameraX, CameraZ-128.f); if (hh>h) h=hh;
  247. int ccx = (int)CameraX / 256;
  248. int ccz = (int)CameraZ / 256;
  249. for (int z=-4; z<=4; z++)
  250. for (int x=-4; x<=4; x++)
  251. if (OMap[ccz+z][ccx+x]!=255) {
  252. int ob = OMap[ccz+z][ccx+x];
  253. float CR = (float)MObjects[ob].info.Radius - 1.f;
  254. float oz = (ccz+z) * 256.f + 128.f;
  255. float ox = (ccx+x) * 256.f + 128.f;
  256. float LandY = GetLandOH(ccx+x, ccz+z);
  257. if (!(MObjects[ob].info.flags & ofBOUND)) {
  258. if (MObjects[ob].info.YHi + LandY < h) continue;
  259. if (MObjects[ob].info.YHi + LandY > PlayerY+128) continue;
  260. //if (MObjects[ob].info.YLo + LandY > PlayerY+256) continue;
  261. }
  262. float r = CR+1;
  263. if (MObjects[ob].info.flags & ofBOUND)
  264. {
  265. float hh;
  266. if (PointOnBound(hh, CameraX, CameraZ, ox, oz, LandY, MObjects[ob].bound, ((FMap[ccz+z][ccx+x] >> 2) & 3) ) )
  267. if (h < LandY + hh) h = LandY + hh;
  268. } else {
  269. if (MObjects[ob].info.flags & ofCIRCLE)
  270. r = (float) sqrt( (ox-CameraX)*(ox-CameraX) + (oz-CameraZ)*(oz-CameraZ) );
  271. else
  272. r = (float) max( fabs(ox-CameraX) , fabs(oz-CameraZ) );
  273. if (r<CR) h = MObjects[ob].info.YHi + LandY;
  274. }
  275. }
  276. return h;
  277. }
  278. float GetLandHObj(float CameraX, float CameraZ)
  279. {
  280. float h;
  281. h = 0;
  282. int ccx = (int)CameraX / 256;
  283. int ccz = (int)CameraZ / 256;
  284. for (int z=-3; z<=3; z++)
  285. for (int x=-3; x<=3; x++)
  286. if (OMap[ccz+z][ccx+x]!=255) {
  287. int ob = OMap[ccz+z][ccx+x];
  288. float CR = (float)MObjects[ob].info.Radius - 1.f;
  289. float oz = (ccz+z) * 256.f + 128.f;
  290. float ox = (ccx+x) * 256.f + 128.f;
  291. if (MObjects[ob].info.YHi + GetLandOH(ccx+x, ccz+z) < h) continue;
  292. if (MObjects[ob].info.YLo + GetLandOH(ccx+x, ccz+z) > PlayerY+256) continue;
  293. float r;
  294. if (MObjects[ob].info.flags & ofCIRCLE)
  295. r = (float) sqrt( (ox-CameraX)*(ox-CameraX) + (oz-CameraZ)*(oz-CameraZ) );
  296. else
  297. r = (float) max( fabs(ox-CameraX) , fabs(oz-CameraZ) );
  298. if (r<CR)
  299. h = MObjects[ob].info.YHi + GetLandOH(ccx+x, ccz+z);
  300. }
  301. return h;
  302. }
  303. float GetLandQHNoObj(float CameraX, float CameraZ)
  304. {
  305. float h,hh;
  306. h = GetLandH(CameraX, CameraZ);
  307. hh = GetLandH(CameraX-90.f, CameraZ-90.f); if (hh>h) h=hh;
  308. hh = GetLandH(CameraX+90.f, CameraZ-90.f); if (hh>h) h=hh;
  309. hh = GetLandH(CameraX-90.f, CameraZ+90.f); if (hh>h) h=hh;
  310. hh = GetLandH(CameraX+90.f, CameraZ+90.f); if (hh>h) h=hh;
  311. hh = GetLandH(CameraX+128.f, CameraZ); if (hh>h) h=hh;
  312. hh = GetLandH(CameraX-128.f, CameraZ); if (hh>h) h=hh;
  313. hh = GetLandH(CameraX, CameraZ+128.f); if (hh>h) h=hh;
  314. hh = GetLandH(CameraX, CameraZ-128.f); if (hh>h) h=hh;
  315. return h;
  316. }
  317. void ProcessCommandLine()
  318. {
  319. for (int a=0; a<__argc; a++) {
  320. LPSTR s = __argv[a];
  321. if (strstr(s,"x=")) { PlayerX = (float)atof(&s[2])*256.f; LockLanding = TRUE; }
  322. if (strstr(s,"y=")) { PlayerZ = (float)atof(&s[2])*256.f; LockLanding = TRUE; }
  323. if (strstr(s,"reg=")) TrophyRoom.RegNumber = atoi(&s[4]);
  324. if (strstr(s,"prj=")) strcpy(ProjectName, (s+4));
  325. if (strstr(s,"din=")) TargetDino = (atoi(&s[4])*1024);
  326. if (strstr(s,"wep=")) WeaponPres = atoi(&s[4]);
  327. if (strstr(s,"dtm=")) OptDayNight = atoi(&s[4]);
  328. if (strstr(s,"-debug")) DEBUG = TRUE;
  329. if (strstr(s,"-double")) DoubleAmmo = TRUE;
  330. if (strstr(s,"-radar")) RadarMode = TRUE;
  331. if (strstr(s,"-tranq")) Tranq = TRUE;
  332. if (strstr(s,"-observ")) ObservMode = TRUE;
  333. }
  334. }
  335. void AddWCircle(float x, float z, float scale)
  336. {
  337. WCircles[WCCount].pos.x = x;
  338. WCircles[WCCount].pos.z = z;
  339. WCircles[WCCount].pos.y = GetLandUpH(x, z);
  340. WCircles[WCCount].FTime = 0;
  341. WCircles[WCCount].scale = scale;
  342. WCCount++;
  343. }
  344. void AddShipTask(int cindex)
  345. {
  346. TCharacter *cptr = &Characters[cindex];
  347. BOOL TROPHYON = (GetLandUpH(cptr->pos.x, cptr->pos.z) - GetLandH(cptr->pos.x, cptr->pos.z) < 100) &&
  348. (!Tranq);
  349. if (TROPHYON) {
  350. ShipTask.clist[ShipTask.tcount] = cindex;
  351. ShipTask.tcount++;
  352. AddVoicev(ShipModel.SoundFX[3].length,
  353. ShipModel.SoundFX[3].lpData, 256);
  354. }
  355. //===== trophy =======//
  356. SYSTEMTIME st;
  357. GetLocalTime(&st);
  358. int t=0;
  359. for (t=0; t<23; t++)
  360. if (!TrophyRoom.Body[t].ctype) break;
  361. float score = (float)DinoInfo[Characters[cindex].CType].BaseScore;
  362. if (TrophyRoom.Last.success>1)
  363. score*=(1.f + TrophyRoom.Last.success / 10.f);
  364. if (!(TargetDino & (1<<Characters[cindex].AI)) ) score/=2.f;
  365. if (Tranq ) score *= 1.25f;
  366. if (RadarMode) score *= 0.70f;
  367. if (ScentMode) score *= 0.80f;
  368. if (CamoMode ) score *= 0.85f;
  369. TrophyRoom.Score+=(int)score;
  370. if (!Tranq) {
  371. TrophyTime = 20 * 1000;
  372. TrophyBody = t;
  373. TrophyRoom.Body[t].ctype = Characters[cindex].CType;
  374. TrophyRoom.Body[t].scale = Characters[cindex].scale;
  375. TrophyRoom.Body[t].weapon = CurrentWeapon;
  376. TrophyRoom.Body[t].score = (int)score;
  377. TrophyRoom.Body[t].phase = (RealTime & 3);
  378. TrophyRoom.Body[t].time = (st.wHour<<10) + st.wMinute;
  379. TrophyRoom.Body[t].date = (st.wYear<<20) + (st.wMonth<<10) + st.wDay;
  380. TrophyRoom.Body[t].range = VectorLength( SubVectors(Characters[cindex].pos, PlayerPos) ) / 64.f;
  381. PrintLog("Trophy added: ");
  382. PrintLog(DinoInfo[Characters[cindex].CType].Name);
  383. PrintLog("\n");
  384. }
  385. }
  386. void InitShip(int cindex)
  387. {
  388. TCharacter *cptr = &Characters[cindex];
  389. Ship.DeltaY = 2048.f + DinoInfo[cptr->CType].ShDelta * cptr->scale;
  390. Ship.pos.x = PlayerX - 90*256;
  391. if (Ship.pos.x < 256) Ship.pos.x = PlayerX + 90*256;
  392. Ship.pos.z = PlayerZ - 90*256;
  393. if (Ship.pos.z < 256) Ship.pos.z = PlayerZ + 90*256;
  394. Ship.pos.y = GetLandUpH(Ship.pos.x, Ship.pos.z) + Ship.DeltaY + 1024;
  395. Ship.tgpos.x = cptr->pos.x;
  396. Ship.tgpos.z = cptr->pos.z;
  397. Ship.tgpos.y = GetLandUpH(Ship.tgpos.x, Ship.tgpos.z) + Ship.DeltaY;
  398. Ship.State = 0;
  399. Ship.retpos = Ship.pos;
  400. Ship.cindex = cindex;
  401. Ship.FTime = 0;
  402. }
  403. void HideWeapon()
  404. {
  405. TWeapon *wptr = &Weapon;
  406. if (UNDERWATER && !wptr->state) return;
  407. if (ObservMode || TrophyMode) return;
  408. if (wptr->state == 0) {
  409. if (!ShotsLeft[CurrentWeapon]) return;
  410. if (WeapInfo[CurrentWeapon].Optic) OPTICMODE = TRUE;
  411. AddVoicev(wptr->chinfo[CurrentWeapon].SoundFX[0].length,
  412. wptr->chinfo[CurrentWeapon].SoundFX[0].lpData, 256);
  413. wptr->FTime = 0;
  414. wptr->state = 1;
  415. BINMODE = FALSE;
  416. MapMode = FALSE;
  417. wptr->shakel = 0.2f;
  418. return;
  419. }
  420. if (wptr->state!=2 || wptr->FTime!=0) return;
  421. AddVoicev(wptr->chinfo[CurrentWeapon].SoundFX[2].length,
  422. wptr->chinfo[CurrentWeapon].SoundFX[2].lpData, 256);
  423. wptr->state = 3;
  424. wptr->FTime = 0;
  425. OPTICMODE = FALSE;
  426. return ;
  427. }
  428. void InitGameInfo()
  429. {
  430. for (int c=0; c<32; c++) {
  431. DinoInfo[c].Scale0 = 800;
  432. DinoInfo[c].ScaleA = 600;
  433. DinoInfo[c].ShDelta = 0;
  434. }
  435. /*
  436. WeapInfo[0].Name = "Shotgun";
  437. WeapInfo[0].Power = 1.5f;
  438. WeapInfo[0].Prec = 1.1f;
  439. WeapInfo[0].Loud = 0.3f;
  440. WeapInfo[0].Rate = 1.6f;
  441. WeapInfo[0].Shots = 6;
  442. WeapInfo[1].Name = "X-Bow";
  443. WeapInfo[1].Power = 1.1f;
  444. WeapInfo[1].Prec = 0.7f;
  445. WeapInfo[1].Loud = 1.9f;
  446. WeapInfo[1].Rate = 1.2f;
  447. WeapInfo[1].Shots = 8;
  448. WeapInfo[2].Name = "Sniper Rifle";
  449. WeapInfo[2].Power = 1.0f;
  450. WeapInfo[2].Prec = 1.8f;
  451. WeapInfo[2].Loud = 0.6f;
  452. WeapInfo[2].Rate = 1.0f;
  453. WeapInfo[2].Shots = 6;
  454. DinoInfo[ 0].Name = "Moschops";
  455. DinoInfo[ 0].Health0 = 2;
  456. DinoInfo[ 0].Mass = 0.15f;
  457. DinoInfo[ 1].Name = "Galimimus";
  458. DinoInfo[ 1].Health0 = 2;
  459. DinoInfo[ 1].Mass = 0.1f;
  460. DinoInfo[ 2].Name = "Dimorphodon";
  461. DinoInfo[ 2].Health0 = 1;
  462. DinoInfo[ 2].Mass = 0.05f;
  463. DinoInfo[ 3].Name = "Dimetrodon";
  464. DinoInfo[ 3].Health0 = 2;
  465. DinoInfo[ 3].Mass = 0.22f;
  466. DinoInfo[ 5].Name = "Parasaurolophus";
  467. DinoInfo[ 5].Mass = 1.5f;
  468. DinoInfo[ 5].Length = 5.8f;
  469. DinoInfo[ 5].Radius = 320.f;
  470. DinoInfo[ 5].Health0 = 5;
  471. DinoInfo[ 5].BaseScore = 6;
  472. DinoInfo[ 5].SmellK = 0.8f; DinoInfo[ 4].HearK = 1.f; DinoInfo[ 4].LookK = 0.4f;
  473. DinoInfo[ 5].ShDelta = 48;
  474. DinoInfo[ 6].Name = "Pachycephalosaurus";
  475. DinoInfo[ 6].Mass = 0.8f;
  476. DinoInfo[ 6].Length = 4.5f;
  477. DinoInfo[ 6].Radius = 280.f;
  478. DinoInfo[ 6].Health0 = 4;
  479. DinoInfo[ 6].BaseScore = 8;
  480. DinoInfo[ 6].SmellK = 0.4f; DinoInfo[ 5].HearK = 0.8f; DinoInfo[ 5].LookK = 0.6f;
  481. DinoInfo[ 6].ShDelta = 36;
  482. DinoInfo[ 7].Name = "Stegosaurus";
  483. DinoInfo[ 7].Mass = 7.f;
  484. DinoInfo[ 7].Length = 7.f;
  485. DinoInfo[ 7].Radius = 480.f;
  486. DinoInfo[ 7].Health0 = 5;
  487. DinoInfo[ 7].BaseScore = 7;
  488. DinoInfo[ 7].SmellK = 0.4f; DinoInfo[ 6].HearK = 0.8f; DinoInfo[ 6].LookK = 0.6f;
  489. DinoInfo[ 7].ShDelta = 128;
  490. DinoInfo[ 8].Name = "Allosaurus";
  491. DinoInfo[ 8].Mass = 0.5;
  492. DinoInfo[ 8].Length = 4.2f;
  493. DinoInfo[ 8].Radius = 256.f;
  494. DinoInfo[ 8].Health0 = 3;
  495. DinoInfo[ 8].BaseScore = 12;
  496. DinoInfo[ 8].Scale0 = 1000;
  497. DinoInfo[ 8].ScaleA = 600;
  498. DinoInfo[ 8].SmellK = 1.0f; DinoInfo[ 7].HearK = 0.3f; DinoInfo[ 7].LookK = 0.5f;
  499. DinoInfo[ 8].ShDelta = 32;
  500. DinoInfo[ 8].DangerCall = TRUE;
  501. DinoInfo[ 9].Name = "Chasmosaurus";
  502. DinoInfo[ 9].Mass = 3.f;
  503. DinoInfo[ 9].Length = 5.0f;
  504. DinoInfo[ 9].Radius = 400.f;
  505. DinoInfo[ 9].Health0 = 8;
  506. DinoInfo[ 9].BaseScore = 9;
  507. DinoInfo[ 9].SmellK = 0.6f; DinoInfo[ 8].HearK = 0.5f; DinoInfo[ 8].LookK = 0.4f;
  508. //DinoInfo[ 8].ShDelta = 148;
  509. DinoInfo[ 9].ShDelta = 108;
  510. DinoInfo[10].Name = "Velociraptor";
  511. DinoInfo[10].Mass = 0.3f;
  512. DinoInfo[10].Length = 4.0f;
  513. DinoInfo[10].Radius = 256.f;
  514. DinoInfo[10].Health0 = 3;
  515. DinoInfo[10].BaseScore = 16;
  516. DinoInfo[10].ScaleA = 400;
  517. DinoInfo[10].SmellK = 1.0f; DinoInfo[ 9].HearK = 0.5f; DinoInfo[ 9].LookK = 0.4f;
  518. DinoInfo[10].ShDelta =-24;
  519. DinoInfo[10].DangerCall = TRUE;
  520. DinoInfo[11].Name = "T-Rex";
  521. DinoInfo[11].Mass = 6.f;
  522. DinoInfo[11].Length = 12.f;
  523. DinoInfo[11].Radius = 400.f;
  524. DinoInfo[11].Health0 = 1024;
  525. DinoInfo[11].BaseScore = 20;
  526. DinoInfo[11].SmellK = 0.85f; DinoInfo[10].HearK = 0.8f; DinoInfo[10].LookK = 0.8f;
  527. DinoInfo[11].ShDelta = 168;
  528. DinoInfo[11].DangerCall = TRUE;
  529. DinoInfo[ 4].Name = "Brahiosaurus";
  530. DinoInfo[ 4].Mass = 9.f;
  531. DinoInfo[ 4].Length = 12.f;
  532. DinoInfo[ 4].Radius = 400.f;
  533. DinoInfo[ 4].Health0 = 1024;
  534. DinoInfo[ 4].BaseScore = 0;
  535. DinoInfo[ 4].SmellK = 0.85f; DinoInfo[16].HearK = 0.8f; DinoInfo[16].LookK = 0.8f;
  536. DinoInfo[ 4].ShDelta = 168;
  537. DinoInfo[ 4].DangerCall = FALSE;
  538. */
  539. LoadResourcesScript();
  540. }
  541. void InitEngine()
  542. {
  543. DEBUG = FALSE;
  544. WATERANI = TRUE;
  545. NODARKBACK = TRUE;
  546. LoDetailSky = TRUE;
  547. CORRECTION = TRUE;
  548. FOGON = TRUE;
  549. FOGENABLE = TRUE;
  550. Clouds = TRUE;
  551. SKY = TRUE;
  552. GOURAUD = TRUE;
  553. MODELS = TRUE;
  554. TIMER = DEBUG;
  555. BITMAPP = FALSE;
  556. MIPMAP = TRUE;
  557. NOCLIP = FALSE;
  558. CLIP3D = TRUE;
  559. SLOW = FALSE;
  560. LOWRESTX = FALSE;
  561. MORPHP = TRUE;
  562. MORPHA = TRUE;
  563. _GameState = 0;
  564. RadarMode = FALSE;
  565. fnt_BIG = CreateFont(
  566. 23, 10, 0, 0,
  567. 600, 0,0,0,
  568. #ifdef __rus
  569. RUSSIAN_CHARSET,
  570. #else
  571. ANSI_CHARSET,
  572. #endif
  573. OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, NULL);
  574. fnt_Small = CreateFont(
  575. 14, 5, 0, 0,
  576. 100, 0,0,0,
  577. #ifdef __rus
  578. RUSSIAN_CHARSET,
  579. #else
  580. ANSI_CHARSET,
  581. #endif
  582. OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, NULL);
  583. fnt_Midd = CreateFont(
  584. 16, 7, 0, 0,
  585. 550, 0,0,0,
  586. #ifdef __rus
  587. RUSSIAN_CHARSET,
  588. #else
  589. ANSI_CHARSET,
  590. #endif
  591. OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, NULL);
  592. Heap = HeapCreate( 0, 60000000, 64000000 );
  593. if( Heap == NULL ) {
  594. MessageBox(hwndMain,"Error creating heap.","Error",IDOK);
  595. return; }
  596. Textures[255] = (TEXTURE*) _HeapAlloc(Heap, 0, sizeof(TEXTURE));
  597. WaterR = 10;
  598. WaterG = 38;
  599. WaterB = 46;
  600. WaterA = 10;
  601. TargetDino = 1<<10;
  602. TargetCall = 10;
  603. WeaponPres = 1;
  604. MessageList.timeleft = 0;
  605. InitGameInfo();
  606. CreateVideoDIB();
  607. CreateFadeTab();
  608. CreateDivTable();
  609. InitClips();
  610. TrophyRoom.RegNumber=0;
  611. PlayerX = (ctMapSize / 3) * 256;
  612. PlayerZ = (ctMapSize / 3) * 256;
  613. ProcessCommandLine();
  614. switch (OptDayNight) {
  615. case 0:
  616. SunShadowK = 0.7;
  617. Sun3dPos.x = - 4048;
  618. Sun3dPos.y = + 2048;
  619. Sun3dPos.z = - 4048;
  620. break;
  621. case 1:
  622. SunShadowK = 0.5;
  623. Sun3dPos.x = - 2048;
  624. Sun3dPos.y = + 4048;
  625. Sun3dPos.z = - 2048;
  626. break;
  627. case 2:
  628. SunShadowK = -0.7;
  629. Sun3dPos.x = + 3048;
  630. Sun3dPos.y = + 3048;
  631. Sun3dPos.z = + 3048;
  632. break;
  633. }
  634. LoadTrophy();
  635. ProcessCommandLine();
  636. //ctViewR = 72;
  637. //ctViewR1 = 28;
  638. //ctViewRM = 24;
  639. ctViewR = 42 + (int)(OptViewR / 8)*2;
  640. ctViewR1 = 28;
  641. ctViewRM = 24;
  642. Soft_Persp_K = 1.5f;
  643. HeadY = 220;
  644. FogsList[0].fogRGB = 0x000000;
  645. FogsList[0].YBegin = 0;
  646. FogsList[0].Transp = 000;
  647. FogsList[0].FLimit = 000;
  648. FogsList[127].fogRGB = 0x00504000;
  649. FogsList[127].Mortal = FALSE;
  650. FogsList[127].Transp = 460;
  651. FogsList[127].FLimit = 200;
  652. FillMemory( FogsMap, sizeof(FogsMap), 0);
  653. PrintLog("Init Engine: Ok.\n");
  654. }
  655. void ShutDownEngine()
  656. {
  657. ReleaseDC(hwndMain,hdcMain);
  658. }
  659. void ProcessSyncro()
  660. {
  661. RealTime = timeGetTime();
  662. srand( (unsigned) RealTime );
  663. if (SLOW) RealTime/=4;
  664. TimeDt = RealTime - PrevTime;
  665. if (TimeDt<0) TimeDt = 10;
  666. if (TimeDt>10000) TimeDt = 10;
  667. if (TimeDt>1000) TimeDt = 1000;
  668. PrevTime = RealTime;
  669. Takt++;
  670. if (!PAUSE)
  671. if (MyHealth) MyHealth+=TimeDt*4;
  672. if (MyHealth>MAX_HEALTH) MyHealth = MAX_HEALTH;
  673. }
  674. void AddBloodTrail(TCharacter *cptr)
  675. {
  676. if (BloodTrail.Count>508) {
  677. memcpy(&BloodTrail.Trail[0], &BloodTrail.Trail[1], 510*sizeof(TBloodP));
  678. BloodTrail.Count--;
  679. }
  680. BloodTrail.Trail[BloodTrail.Count].LTime = 210000;
  681. BloodTrail.Trail[BloodTrail.Count].pos = cptr->pos;
  682. BloodTrail.Trail[BloodTrail.Count].pos.x+=siRand(32);
  683. BloodTrail.Trail[BloodTrail.Count].pos.z+=siRand(32);
  684. BloodTrail.Trail[BloodTrail.Count].pos.y =
  685. GetLandH(BloodTrail.Trail[BloodTrail.Count].pos.x,
  686. BloodTrail.Trail[BloodTrail.Count].pos.z)+4;
  687. BloodTrail.Count++;
  688. }
  689. void MakeCall()
  690. {
  691. if (!TargetDino) return;
  692. if (UNDERWATER) return;
  693. if (ObservMode || TrophyMode) return;
  694. if (CallLockTime) return;
  695. CallLockTime=1024*3;
  696. NextCall+=(RealTime % 2)+1;
  697. NextCall%=3;
  698. AddVoicev(fxCall[TargetCall-10][NextCall].length,
  699. fxCall[TargetCall-10][NextCall].lpData, 256);
  700. float dmin = 512*256;
  701. int ai = -1;
  702. for (int c=0; c<ChCount; c++) {
  703. TCharacter *cptr = &Characters[c];
  704. if (DinoInfo[AI_to_CIndex[TargetCall] ].DangerCall)
  705. if (cptr->AI<10) {
  706. cptr->State=2;
  707. cptr->AfraidTime = (10 + rRand(5)) * 1024;
  708. }
  709. if (cptr->AI!=TargetCall) continue;
  710. if (cptr->AfraidTime) continue;
  711. if (cptr->State) continue;
  712. float d = VectorLength(SubVectors(PlayerPos, cptr->pos));
  713. if (d < ctViewR * 400) {
  714. if (rRand(128) > 32)
  715. if (d<dmin) { dmin = d; ai = c; }
  716. cptr->tgx = PlayerX + siRand(1800);
  717. cptr->tgz = PlayerZ + siRand(1800);
  718. }
  719. }
  720. if (ai!=-1) {
  721. answpos = SubVectors(Characters[ai].pos, PlayerPos);
  722. answpos.x/=-3.f; answpos.y/=-3.f; answpos.z/=-3.f;
  723. answpos = SubVectors(PlayerPos, answpos);
  724. answtime = 2000 + rRand(2000);
  725. answcall = TargetCall;
  726. }
  727. }
  728. DWORD ColorSum(DWORD C1, DWORD C2)
  729. {
  730. DWORD R,G,B;
  731. R = min(255, ((C1>> 0) & 0xFF) + ((C2>> 0) & 0xFF));
  732. G = min(255, ((C1>> 8) & 0xFF) + ((C2>> 8) & 0xFF));
  733. B = min(255, ((C1>>16) & 0xFF) + ((C2>>16) & 0xFF));
  734. return R + (G<<8) + (B<<16);
  735. }
  736. #define partBlood 1
  737. #define partWater 2
  738. #define partGround 3
  739. #define partBubble 4
  740. void AddElements(float x, float y, float z, int etype, int cnt)
  741. {
  742. if (ElCount > 30) {
  743. memcpy(&Elements[0], &Elements[1], (ElCount-1) * sizeof(TElements));
  744. ElCount--;
  745. }
  746. Elements[ElCount].EDone = 0;
  747. Elements[ElCount].Type = etype;
  748. Elements[ElCount].ECount = min(30, cnt);
  749. int c;
  750. switch (etype) {
  751. case partBlood:
  752. #ifdef _d3d
  753. Elements[ElCount].RGBA = 0xE0600000;
  754. Elements[ElCount].RGBA2= 0x20300000;
  755. #else
  756. Elements[ElCount].RGBA = 0xE0000060;
  757. Elements[ElCount].RGBA2= 0x20000030;
  758. #endif
  759. break;
  760. case partGround:
  761. #ifdef _d3d
  762. Elements[ElCount].RGBA = 0xF0F09E55;
  763. Elements[ElCount].RGBA2= 0x10F09E55;
  764. #else
  765. Elements[ElCount].RGBA = 0xF0559EF0;
  766. Elements[ElCount].RGBA2= 0x10559EF0;
  767. #endif
  768. break;
  769. case partBubble:
  770. c = WaterList[ WMap[ (int)z / 256][ (int)x / 256] ].fogRGB;
  771. #ifdef _d3d
  772. c = ColorSum( ((c & 0xFEFEFE)>>1) , 0x152020);
  773. #else
  774. c = ColorSum( ((c & 0xFEFEFE)>>1) , 0x202015);
  775. #endif
  776. Elements[ElCount].RGBA = 0x70000000 + (ColorSum(c, ColorSum(c,c)));
  777. Elements[ElCount].RGBA2= 0x40000000 + (ColorSum(c, c));
  778. break;
  779. case partWater:
  780. c = WaterList[ WMap[ (int)z / 256][ (int)x / 256] ].fogRGB;
  781. #ifdef _d3d
  782. c = ColorSum( ((c & 0xFEFEFE)>>1) , 0x152020);
  783. #else
  784. c = ColorSum( ((c & 0xFEFEFE)>>1) , 0x202015);
  785. #endif
  786. Elements[ElCount].RGBA = 0xB0000000 + ( ColorSum(c, ColorSum(c,c)) );
  787. Elements[ElCount].RGBA2 = 0x40000000 + (c);
  788. break;
  789. }
  790. Elements[ElCount].RGBA = conv_xGx(Elements[ElCount].RGBA);
  791. Elements[ElCount].RGBA2 = conv_xGx(Elements[ElCount].RGBA2);
  792. float al = siRand(128) / 128.f * pi / 4.f;
  793. float ss = sin(al);
  794. float cc = cos(al);
  795. for (int e=0; e<Elements[ElCount].ECount; e++) {
  796. Elements[ElCount].EList[e].pos.x = x;
  797. Elements[ElCount].EList[e].pos.y = y;
  798. Elements[ElCount].EList[e].pos.z = z;
  799. Elements[ElCount].EList[e].R = 6 + rRand(5);
  800. Elements[ElCount].EList[e].Flags = 0;
  801. float v;
  802. switch (etype) {
  803. case partBlood:
  804. v = e * 6 + rRand(96) + 220;
  805. Elements[ElCount].EList[e].speed.x =ss*ca*v + siRand(32);
  806. Elements[ElCount].EList[e].speed.y =cc * (v * 3);
  807. Elements[ElCount].EList[e].speed.z =ss*sa*v + siRand(32);
  808. break;
  809. case partGround:
  810. Elements[ElCount].EList[e].speed.x =siRand(52)-sa*64;
  811. Elements[ElCount].EList[e].speed.y =rRand(100) + 600 + e * 20;
  812. Elements[ElCount].EList[e].speed.z =siRand(52)+ca*64;
  813. break;
  814. case partWater:
  815. Elements[ElCount].EList[e].speed.x =siRand(32);
  816. Elements[ElCount].EList[e].speed.y =rRand(80) + 400 + e * 40;
  817. Elements[ElCount].EList[e].speed.z =siRand(32);
  818. break;
  819. case partBubble:
  820. Elements[ElCount].EList[e].speed.x =siRand(40);
  821. Elements[ElCount].EList[e].speed.y =rRand(140) + 20;
  822. Elements[ElCount].EList[e].speed.z =siRand(40);
  823. break;
  824. }
  825. }
  826. ElCount++;
  827. }
  828. void MakeShot(float ax, float ay, float az,
  829. float bx, float by, float bz)
  830. {
  831. int sres;
  832. if (!WeapInfo[CurrentWeapon].Fall)
  833. sres = TraceShot(ax, ay, az, bx, by, bz);
  834. else {
  835. Vector3d dl;
  836. float dy = 40.f * ctViewR / 36.f;
  837. dl.x = (bx-ax) / 3;
  838. dl.y = (by-ay) / 3;
  839. dl.z = (bz-az) / 3;
  840. bx = ax + dl.x;
  841. by = ay + dl.y - dy / 2;
  842. bz = az + dl.z;
  843. sres = TraceShot(ax, ay, az, bx, by, bz);
  844. if (sres!=-1) goto ENDTRACE;
  845. ax = bx; ay = by; az = bz;
  846. bx = ax + dl.x;
  847. by = ay + dl.y - dy * 3;
  848. bz = az + dl.z;
  849. sres = TraceShot(ax, ay, az, bx, by, bz);
  850. if (sres!=-1) goto ENDTRACE;
  851. ax = bx; ay = by; az = bz;
  852. bx = ax + dl.x;
  853. by = ay + dl.y - dy * 5;
  854. bz = az + dl.z;
  855. sres = TraceShot(ax, ay, az, bx, by, bz);
  856. if (sres!=-1) goto ENDTRACE;
  857. ax = bx; ay = by; az = bz;
  858. }
  859. ENDTRACE:
  860. if (sres==-1) return;
  861. int mort = (sres & 0xFF00) && (Characters[ShotDino].Health);
  862. sres &= 0xFF;
  863. if (sres == tresGround)
  864. AddElements(bx, by, bz, partGround, 6 + WeapInfo[CurrentWeapon].Power*4);
  865. if (sres == tresModel)
  866. AddElements(bx, by, bz, partGround, 6 + WeapInfo[CurrentWeapon].Power*4);
  867. if (sres == tresWater) {
  868. AddElements(bx, by, bz, partWater, 4 + WeapInfo[CurrentWeapon].Power*3);
  869. //AddElements(bx, GetLandH(bx, bz), bz, partBubble);
  870. AddWCircle(bx, bz, 1.2);
  871. AddWCircle(bx, bz, 1.2);
  872. }
  873. if (sres!=tresChar) return;
  874. AddElements(bx, by, bz, partBlood, 4 + WeapInfo[CurrentWeapon].Power*4);
  875. if (!Characters[ShotDino].Health) return;
  876. //======= character damage =========//
  877. if (mort) Characters[ShotDino].Health = 0;
  878. else Characters[ShotDino].Health-=WeapInfo[CurrentWeapon].Power;
  879. if (Characters[ShotDino].Health<0) Characters[ShotDino].Health=0;
  880. if (!Characters[ShotDino].Health) {
  881. if (Characters[ShotDino].AI>=10) {
  882. TrophyRoom.Last.success++;
  883. AddShipTask(ShotDino);
  884. }
  885. if (Characters[ShotDino].AI<10)
  886. Characters_AddSecondaryOne(Characters[ShotDino].CType);
  887. }
  888. else {
  889. Characters[ShotDino].AfraidTime = 60*1000;
  890. if (Characters[ShotDino].AI!=AI_TREX || Characters[ShotDino].State==0)
  891. Characters[ShotDino].State = 2;
  892. if (Characters[ShotDino].AI != AI_BRACH)
  893. Characters[ShotDino].BloodTTime+=90000;
  894. }
  895. if (Characters[ShotDino].AI==AI_TREX)
  896. if (Characters[ShotDino].State)
  897. Characters[ShotDino].State = 5;
  898. else
  899. Characters[ShotDino].State = 1;
  900. }
  901. void RemoveCharacter(int index)
  902. {
  903. if (index==-1) return;
  904. memcpy( &Characters[index], &Characters[index+1], (255 - index) * sizeof(TCharacter) );
  905. ChCount--;
  906. if (DemoPoint.CIndex > index) DemoPoint.CIndex--;
  907. for (int c=0; c<ShipTask.tcount; c++)
  908. if (ShipTask.clist[c]>index) ShipTask.clist[c]--;
  909. }
  910. void AnimateShip()
  911. {
  912. if (Ship.State==-1) {
  913. SetAmbient3d(0,0, 0,0,0);
  914. if (!ShipTask.tcount) return;
  915. InitShip(ShipTask.clist[0]);
  916. memcpy(&ShipTask.clist[0], &ShipTask.clist[1], 250*4);
  917. ShipTask.tcount--;
  918. return;
  919. }
  920. SetAmbient3d(ShipModel.SoundFX[0].length,
  921. ShipModel.SoundFX[0].lpData,
  922. Ship.pos.x, Ship.pos.y, Ship.pos.z);
  923. int _TimeDt = TimeDt;
  924. //====== get up/down time acceleration ===========//
  925. if (Ship.FTime) {
  926. int am = ShipModel.Animation[0].AniTime;
  927. if (Ship.FTime < 500) _TimeDt = TimeDt * (Ship.FTime + 48) / 548;
  928. if (am-Ship.FTime < 500) _TimeDt = TimeDt * (am-Ship.FTime + 48) / 548;
  929. if (_TimeDt<2) _TimeDt=2;
  930. }
  931. //===================================
  932. float L = VectorLength( SubVectors(Ship.tgpos, Ship.pos) );
  933. float L2 = sqrt ( (Ship.tgpos.x - Ship.pos.x) * (Ship.tgpos.x - Ship.pos.x) +
  934. (Ship.tgpos.x - Ship.pos.x) * (Ship.tgpos.x - Ship.pos.x) );
  935. Ship.pos.y+=0.3f*(float)cos(RealTime / 256.f);
  936. Ship.tgalpha = FindVectorAlpha(Ship.tgpos.x - Ship.pos.x, Ship.tgpos.z - Ship.pos.z);
  937. float currspeed;
  938. float dalpha = (float)fabs(Ship.tgalpha - Ship.alpha);
  939. float drspd = dalpha; if (drspd>pi) drspd = 2*pi - drspd;
  940. //====== fly more away if I near =============//
  941. if (Ship.State)
  942. if (Ship.speed>1)
  943. if (L<4000)
  944. if (VectorLength(SubVectors(PlayerPos, Ship.pos))<(ctViewR+2)*256) {
  945. Ship.tgpos.x += (float)cos(Ship.alpha) * 256*6.f;
  946. Ship.tgpos.z += (float)sin(Ship.alpha) * 256*6.f;
  947. Ship.tgpos.y = GetLandUpH(Ship.tgpos.x, Ship.tgpos.z) + Ship.DeltaY;
  948. Ship.tgpos.y = max(Ship.tgpos.y, GetLandUpH(Ship.pos.x, Ship.pos.z) + Ship.DeltaY);
  949. }
  950. //==============================//
  951. //========= animate down ==========//
  952. if (Ship.State==3) {
  953. Ship.FTime+=_TimeDt;
  954. if (Ship.FTime>=ShipModel.Animation[0].AniTime) {
  955. Ship.FTime=ShipModel.Animation[0].AniTime-1;
  956. Ship.State=2;
  957. AddVoicev(ShipModel.SoundFX[4].length,
  958. ShipModel.SoundFX[4].lpData, 256);
  959. AddVoice3d(ShipModel.SoundFX[1].length, ShipModel.SoundFX[1].lpData,
  960. Ship.pos.x, Ship.pos.y, Ship.pos.z);
  961. }
  962. return;
  963. }
  964. //========= get body on board ==========//
  965. if (Ship.State) {
  966. if (Ship.cindex!=-1) {
  967. DeltaFunc(Characters[Ship.cindex].pos.y, Ship.pos.y-650 - (Ship.DeltaY-2048), _TimeDt / 3.f);
  968. DeltaFunc(Characters[Ship.cindex].beta, 0, TimeDt / 4048.f);
  969. DeltaFunc(Characters[Ship.cindex].gamma, 0, TimeDt / 4048.f);
  970. }
  971. if (Ship.State==2) {
  972. Ship.FTime-=_TimeDt;
  973. if (Ship.FTime<0) Ship.FTime=0;
  974. if (Ship.FTime==0)
  975. if (fabs(Characters[Ship.cindex].pos.y - (Ship.pos.y-650 - (Ship.DeltaY-2048))) < 1.f) {
  976. Ship.State = 1;
  977. AddVoicev(ShipModel.SoundFX[5].length,
  978. ShipModel.SoundFX[5].lpData, 256);
  979. AddVoice3d(ShipModel.SoundFX[2].length, ShipModel.SoundFX[2].lpData,
  980. Ship.pos.x, Ship.pos.y, Ship.pos.z);
  981. }
  982. return;
  983. }
  984. }
  985. //=====================================//
  986. //====== speed ===============//
  987. float vspeed = 1.f + L / 128.f;
  988. if (vspeed > 24) vspeed = 24;
  989. if (Ship.State) vspeed = 24;
  990. if (fabs(dalpha) > 0.4) vspeed = 0.f;
  991. float _s = Ship.speed;
  992. if (vspeed>Ship.speed) DeltaFunc(Ship.speed, vspeed, TimeDt / 200.f);
  993. else Ship.speed = vspeed;
  994. if (Ship.speed>0 && _s==0)
  995. AddVoice3d(ShipModel.SoundFX[2].length, ShipModel.SoundFX[2].lpData,
  996. Ship.pos.x, Ship.pos.y, Ship.pos.z);
  997. //====== fly ===========//
  998. float l = TimeDt * Ship.speed / 16.f;
  999. if (fabs(dalpha) < 0.4)
  1000. if (l<L) {
  1001. if (l>L2) l = L2 * 0.5f;
  1002. if (L2<0.1) l = 0;
  1003. Ship.pos.x += (float)cos(Ship.alpha)*l;
  1004. Ship.pos.z += (float)sin(Ship.alpha)*l;
  1005. } else {
  1006. if (Ship.State) {
  1007. Ship.State = -1;
  1008. RemoveCharacter(Ship.cindex);
  1009. return;
  1010. } else {
  1011. Ship.pos = Ship.tgpos;
  1012. Ship.State = 3;
  1013. Ship.FTime = 1;
  1014. Ship.tgpos = Ship.retpos;
  1015. Ship.tgpos.y = GetLandUpH(Ship.tgpos.x, Ship.tgpos.z) + Ship.DeltaY;
  1016. Ship.tgpos.y = max(Ship.tgpos.y, GetLandUpH(Ship.pos.x, Ship.pos.z) + Ship.DeltaY);
  1017. Characters[Ship.cindex].StateF = 0xFF;
  1018. AddVoice3d(ShipModel.SoundFX[1].length, ShipModel.SoundFX[1].lpData,
  1019. Ship.pos.x, Ship.pos.y, Ship.pos.z);
  1020. }
  1021. }
  1022. //======= y movement ============//
  1023. float h = GetLandUpH(Ship.pos.x, Ship.pos.z);
  1024. DeltaFunc(Ship.pos.y, Ship.tgpos.y, TimeDt / 4.f);
  1025. if (Ship.pos.y < h + 1024) {
  1026. if (Ship.State)
  1027. if (Ship.cindex!=-1)
  1028. Characters[Ship.cindex].pos.y+= h + 1024 - Ship.pos.y;
  1029. Ship.pos.y = h + 1024;
  1030. }
  1031. //======= rotation ============//
  1032. if (Ship.tgalpha > Ship.alpha) currspeed = 0.1f + (float)fabs(drspd)/2.f;
  1033. else currspeed =-0.1f - (float)fabs(drspd)/2.f;
  1034. if (fabs(dalpha) > pi) currspeed=-currspeed;
  1035. DeltaFunc(Ship.rspeed, currspeed, (float)TimeDt / 420.f);
  1036. float rspd=Ship.rspeed * TimeDt / 1024.f;
  1037. if (fabs(drspd) < fabs(rspd)) { Ship.alpha = Ship.tgalpha; Ship.rspeed/=2; }
  1038. else {
  1039. Ship.alpha+=rspd;
  1040. if (Ship.State)
  1041. if (Ship.cindex!=-1)
  1042. Characters[Ship.cindex].alpha+=rspd;
  1043. }
  1044. if (Ship.alpha<0) Ship.alpha+=pi*2;
  1045. if (Ship.alpha>pi*2) Ship.alpha-=pi*2;
  1046. //======== move body ===========//
  1047. if (Ship.State) {
  1048. if (Ship.cindex!=-1) {
  1049. Characters[Ship.cindex].pos.x = Ship.pos.x;
  1050. Characters[Ship.cindex].pos.z = Ship.pos.z;
  1051. }
  1052. if (L>1000) Ship.tgpos.y+=TimeDt / 12.f;
  1053. } else {
  1054. Ship.tgpos.x = Characters[Ship.cindex].pos.x;
  1055. Ship.tgpos.z = Characters[Ship.cindex].pos.z;
  1056. Ship.tgpos.y = GetLandUpH(Ship.tgpos.x, Ship.tgpos.z) + Ship.DeltaY;
  1057. Ship.tgpos.y = max(Ship.tgpos.y, GetLandUpH(Ship.pos.x, Ship.pos.z) + Ship.DeltaY);
  1058. }
  1059. }
  1060. void ProcessTrophy()
  1061. {
  1062. TrophyBody = -1;
  1063. for (int c=0; c<ChCount; c++) {
  1064. Vector3d p = Characters[c].pos;
  1065. p.x+=Characters[c].lookx * 256*2.5f;
  1066. p.z+=Characters[c].lookz * 256*2.5f;
  1067. if (VectorLength( SubVectors(p, PlayerPos) ) < 148)
  1068. TrophyBody = c;
  1069. }
  1070. if (TrophyBody==-1) return;
  1071. TrophyBody = Characters[TrophyBody].State;
  1072. }
  1073. void AnimateElements()
  1074. {
  1075. for (int eg=0; eg<ElCount; eg++) {
  1076. if (Elements[eg].Type == partGround) {
  1077. int a1 = Elements[eg].RGBA >> 24; a1-=TimeDt/4; if (a1<0) a1=0; Elements[eg].RGBA = (Elements[eg].RGBA & 0x00FFFFFF) + (a1<<24);
  1078. int a2 = Elements[eg].RGBA2>> 24; a2-=TimeDt/4; if (a2<0) a2=0; Elements[eg].RGBA2= (Elements[eg].RGBA2 & 0x00FFFFFF) + (a2<<24);
  1079. if (a1 == 0 && a2==0) Elements[eg].ECount = 0;
  1080. }
  1081. if (Elements[eg].Type == partWater)
  1082. if (Elements[eg].EDone == Elements[eg].ECount)
  1083. Elements[eg].ECount = 0;
  1084. if (Elements[eg].Type == partBubble)
  1085. if (Elements[eg].EDone == Elements[eg].ECount)
  1086. Elements[eg].ECount = 0;
  1087. if (Elements[eg].Type == partBlood)
  1088. if ((Takt & 3)==0)
  1089. if (Elements[eg].EDone == Elements[eg].ECount) {
  1090. int a1 = Elements[eg].RGBA >> 24; a1--; if (a1<0) a1=0; Elements[eg].RGBA = (Elements[eg].RGBA & 0x00FFFFFF) + (a1<<24);
  1091. int a2 = Elements[eg].RGBA2>> 24; a2--; if (a2<0) a2=0; Elements[eg].RGBA2= (Elements[eg].RGBA2 & 0x00FFFFFF) + (a2<<24);
  1092. if (a1 == 0 && a2==0) Elements[eg].ECount = 0;
  1093. }
  1094. //====== remove finished process =========//
  1095. if (!Elements[eg].ECount) {
  1096. memcpy(&Elements[eg], &Elements[eg+1], (ElCount+1-eg) * sizeof(TElements));
  1097. ElCount--;
  1098. eg--;
  1099. continue;
  1100. }
  1101. for (int e=0; e<Elements[eg].ECount; e++) {
  1102. if (Elements[eg].EList[e].Flags) continue;
  1103. Elements[eg].EList[e].pos.x+=Elements[eg].EList[e].speed.x * TimeDt / 1000.f;
  1104. Elements[eg].EList[e].pos.y+=Elements[eg].EList[e].speed.y * TimeDt / 1000.f;
  1105. Elements[eg].EList[e].pos.z+=Elements[eg].EList[e].speed.z * TimeDt / 1000.f;
  1106. float h;
  1107. h = GetLandUpH(Elements[eg].EList[e].pos.x, Elements[eg].EList[e].pos.z);
  1108. BOOL OnWater = GetLandH(Elements[eg].EList[e].pos.x, Elements[eg].EList[e].pos.z) < h;
  1109. switch (Elements[eg].Type) {
  1110. case partBubble:
  1111. Elements[eg].EList[e].speed.y += 2.0 * 256 * TimeDt / 1000.f;
  1112. if (Elements[eg].EList[e].speed.y > 824) Elements[eg].EList[e].speed.y = 824;
  1113. if (Elements[eg].EList[e].pos.y > h) {
  1114. AddWCircle(Elements[eg].EList[e].pos.x, Elements[eg].EList[e].pos.z, 0.6);
  1115. Elements[eg].EDone++;
  1116. Elements[eg].EList[e].Flags = 1;
  1117. if (OnWater) Elements[eg].EList[e].pos.y-= 10240;
  1118. }
  1119. break;
  1120. default:
  1121. Elements[eg].EList[e].speed.y -= 9.8 * 256 * TimeDt / 1000.f;
  1122. if (Elements[eg].EList[e].pos.y < h) {
  1123. if (OnWater) AddWCircle(Elements[eg].EList[e].pos.x, Elements[eg].EList[e].pos.z, 0.6);
  1124. Elements[eg].EDone++;
  1125. Elements[eg].EList[e].Flags = 1;
  1126. if (OnWater) Elements[eg].EList[e].pos.y-= 10240;
  1127. else Elements[eg].EList[e].pos.y = h + 4;
  1128. }
  1129. break;
  1130. } //== switch ==//
  1131. } // for(e) //
  1132. } // for(eg) //
  1133. for (int b=0; b<BloodTrail.Count; b++) {
  1134. BloodTrail.Trail[b].LTime-=TimeDt;
  1135. if (BloodTrail.Trail[b].LTime<=0) {
  1136. memcpy(&BloodTrail.Trail[b], &BloodTrail.Trail[b+1], (511-b)*sizeof(TBloodP));
  1137. BloodTrail.Count--;
  1138. b--;
  1139. }
  1140. }
  1141. }
  1142. void AnimateProcesses()
  1143. {
  1144. AnimateElements();
  1145. if ((Takt & 63)==0) {
  1146. float al2 = CameraAlpha + siRand(60) * pi / 180.f;
  1147. float c2 = cos(al2);
  1148. float s2 = sin(al2);
  1149. float l = 1024 + rRand(3120);
  1150. float xx = CameraX + s2 * l;
  1151. float zz = CameraZ - c2 * l;
  1152. if (GetLandUpH(xx,zz) > GetLandH(xx,zz)+256)
  1153. AddElements(xx, GetLandH(xx,zz), zz, 4, 6 + rRand(6));
  1154. }
  1155. if (Takt & 1) {
  1156. Wind.alpha+=siRand(16) / 4096.f;
  1157. Wind.speed+=siRand(400) / 6400.f;
  1158. }
  1159. if (Wind.speed< 4.f) Wind.speed=4.f;
  1160. if (Wind.speed>18.f) Wind.speed=18.f;
  1161. Wind.nv.x = (float) sin(Wind.alpha);
  1162. Wind.nv.z = (float)-cos(Wind.alpha);
  1163. Wind.nv.y = 0.f;
  1164. if (answtime) {
  1165. answtime-=TimeDt;
  1166. if (answtime<=0) {
  1167. answtime = 0;
  1168. int r = rRand(128) % 3;
  1169. AddVoice3d(fxCall[answcall-10][r].length, fxCall[answcall-10][r].lpData,
  1170. answpos.x, answpos.y, answpos.z);
  1171. }
  1172. }
  1173. if (CallLockTime) {
  1174. CallLockTime-=TimeDt;
  1175. if (CallLockTime<0) CallLockTime=0;
  1176. }
  1177. CheckAfraid();
  1178. AnimateShip();
  1179. if (TrophyMode)
  1180. ProcessTrophy();
  1181. for (int w=0; w<WCCount; w++) {
  1182. if (WCircles[w].scale > 1)
  1183. WCircles[w].FTime+=(int)(TimeDt*3 / WCircles[w].scale);
  1184. else
  1185. WCircles[w].FTime+=TimeDt*3;
  1186. if (WCircles[w].FTime >= 2000) {
  1187. memcpy(&WCircles[w], &WCircles[w+1], sizeof(TWCircle) * (WCCount+1-w) );
  1188. w--;
  1189. WCCount--;
  1190. }
  1191. }
  1192. if (ExitTime) {
  1193. ExitTime-=TimeDt;
  1194. if (ExitTime<=0) {
  1195. TrophyRoom.Total.time +=TrophyRoom.Last.time;
  1196. TrophyRoom.Total.smade +=TrophyRoom.Last.smade;
  1197. TrophyRoom.Total.success+=TrophyRoom.Last.success;
  1198. TrophyRoom.Total.path +=TrophyRoom.Last.path;
  1199. if (MyHealth) SaveTrophy();
  1200. else LoadTrophy();
  1201. DoHalt("");
  1202. }
  1203. }
  1204. }
  1205. void RemoveCurrentTrophy()
  1206. {
  1207. int p = 0;
  1208. if (!TrophyMode) return;
  1209. if (!TrophyRoom.Body[TrophyBody].ctype) return;
  1210. PrintLog("Trophy removed: ");
  1211. PrintLog(DinoInfo[TrophyRoom.Body[TrophyBody].ctype].Name);
  1212. PrintLog("\n");
  1213. for (int c=0; c<TrophyBody; c++)
  1214. if (TrophyRoom.Body[c].ctype) p++;
  1215. TrophyRoom.Body[TrophyBody].ctype = 0;
  1216. if (TrophyMode) {
  1217. memcpy(&Characters[p],
  1218. &Characters[p+1],
  1219. (250-p) * sizeof(TCharacter) );
  1220. ChCount--;
  1221. }
  1222. TrophyTime = 0;
  1223. TrophyBody = -1;
  1224. }
  1225. void LoadTrophy()
  1226. {
  1227. int pr = TrophyRoom.RegNumber;
  1228. FillMemory(&TrophyRoom, sizeof(TrophyRoom), 0);
  1229. TrophyRoom.RegNumber = pr;
  1230. DWORD l;
  1231. char fname[128];
  1232. int rn = TrophyRoom.RegNumber;
  1233. wsprintf(fname, "trophy0%d.sav", TrophyRoom.RegNumber);
  1234. HANDLE hfile = CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  1235. if (hfile==INVALID_HANDLE_VALUE) {
  1236. PrintLog("===> Error loading trophy!\n");
  1237. return;
  1238. }
  1239. ReadFile(hfile, &TrophyRoom, sizeof(TrophyRoom), &l, NULL);
  1240. ReadFile(hfile, &OptAgres, 4, &l, NULL);
  1241. ReadFile(hfile, &OptDens , 4, &l, NULL);
  1242. ReadFile(hfile, &OptSens , 4, &l, NULL);
  1243. ReadFile(hfile, &OptRes, 4, &l, NULL);
  1244. ReadFile(hfile, &FOGENABLE, 4, &l, NULL);
  1245. ReadFile(hfile, &OptText , 4, &l, NULL);
  1246. ReadFile(hfile, &OptViewR, 4, &l, NULL);
  1247. ReadFile(hfile, &SHADOWS3D, 4, &l, NULL);
  1248. ReadFile(hfile, &OptMsSens, 4, &l, NULL);
  1249. ReadFile(hfile, &OptBrightness, 4, &l, NULL);
  1250. ReadFile(hfile, &KeyMap, sizeof(KeyMap), &l, NULL);
  1251. ReadFile(hfile, &REVERSEMS, 4, &l, NULL);
  1252. ReadFile(hfile, &ScentMode, 4, &l, NULL);
  1253. ReadFile(hfile, &CamoMode, 4, &l, NULL);
  1254. ReadFile(hfile, &RadarMode, 4, &l, NULL);
  1255. ReadFile(hfile, &Tranq , 4, &l, NULL);
  1256. ReadFile(hfile, &OPT_ALPHA_COLORKEY, 4, &l, NULL);
  1257. ReadFile(hfile, &OptSys , 4, &l, NULL);
  1258. ReadFile(hfile, &OptSound , 4, &l, NULL);
  1259. ReadFile(hfile, &OptRender, 4, &l, NULL);
  1260. SetupRes();
  1261. CloseHandle(hfile);
  1262. TrophyRoom.RegNumber = rn;
  1263. PrintLog("Trophy Loaded.\n");
  1264. // TrophyRoom.Score = 299;
  1265. }
  1266. void SaveTrophy()
  1267. {
  1268. DWORD l;
  1269. char fname[128];
  1270. wsprintf(fname, "trophy0%d.sav", TrophyRoom.RegNumber);
  1271. int r = TrophyRoom.Rank;
  1272. TrophyRoom.Rank = 0;
  1273. if (TrophyRoom.Score >= 100) TrophyRoom.Rank = 1;
  1274. if (TrophyRoom.Score >= 300) TrophyRoom.Rank = 2;
  1275. HANDLE hfile = CreateFile(fname, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  1276. if (hfile == INVALID_HANDLE_VALUE) {
  1277. PrintLog("==>> Error saving trophy!\n");
  1278. return;
  1279. }
  1280. WriteFile(hfile, &TrophyRoom, sizeof(TrophyRoom), &l, NULL);
  1281. WriteFile(hfile, &OptAgres, 4, &l, NULL);
  1282. WriteFile(hfile, &OptDens , 4, &l, NULL);
  1283. WriteFile(hfile, &OptSens , 4, &l, NULL);
  1284. WriteFile(hfile, &OptRes, 4, &l, NULL);
  1285. WriteFile(hfile, &FOGENABLE, 4, &l, NULL);
  1286. WriteFile(hfile, &OptText , 4, &l, NULL);
  1287. WriteFile(hfile, &OptViewR, 4, &l, NULL);
  1288. WriteFile(hfile, &SHADOWS3D, 4, &l, NULL);
  1289. WriteFile(hfile, &OptMsSens, 4, &l, NULL);
  1290. WriteFile(hfile, &OptBrightness, 4, &l, NULL);
  1291. WriteFile(hfile, &KeyMap, sizeof(KeyMap), &l, NULL);
  1292. WriteFile(hfile, &REVERSEMS, 4, &l, NULL);
  1293. WriteFile(hfile, &ScentMode, 4, &l, NULL);
  1294. WriteFile(hfile, &CamoMode , 4, &l, NULL);
  1295. WriteFile(hfile, &RadarMode, 4, &l, NULL);
  1296. WriteFile(hfile, &Tranq , 4, &l, NULL);
  1297. WriteFile(hfile, &OPT_ALPHA_COLORKEY, 4, &l, NULL);
  1298. WriteFile(hfile, &OptSys , 4, &l, NULL);
  1299. WriteFile(hfile, &OptSound , 4, &l, NULL);
  1300. WriteFile(hfile, &OptRender, 4, &l, NULL);
  1301. CloseHandle(hfile);
  1302. PrintLog("Trophy Saved.\n");
  1303. }