tcotd2.acs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. #library "TCOTD2"
  2. #include "zcommon.acs"
  3. #libdefine ONE_SECOND 35
  4. #libdefine MAX_PLAYERS 8
  5. #libdefine INT_MAX 0x7FFFFFFF
  6. #libdefine HUDMSG_TIC 1.0 / 35 + 1
  7. #define MAX_VOLUME 127
  8. #define MAX_PLAYER_HEALTH 200
  9. /**************************************************************************************************
  10. Generates a HUDMessageID, for use with HUDMessage
  11. Example: MakeHUDMessage('L', 'O', 'G', 'O');
  12. **************************************************************************************************/
  13. function int MakeHUDMessageID(int a, int b, int c, int d)
  14. {
  15. // MAKE_ID
  16. return (a << 24) | ( b << 16) | (c << 8) | d;
  17. }
  18. //===========================================================================
  19. //
  20. //
  21. //
  22. //===========================================================================
  23. function void TCOTD_AutoSave(void)
  24. {
  25. // Can only autosave on "Normal" and in single player...
  26. if (GameType() == GAME_SINGLE_PLAYER && GameSkill() == 0)
  27. AutoSave();
  28. }
  29. //===========================================================================
  30. //
  31. //
  32. //
  33. //===========================================================================
  34. function void TCOTD_RaiseThing(int tid)
  35. {
  36. Thing_Raise(tid);
  37. SetUserVariable(tid, "user_ReviveSelfOnly", FALSE);
  38. }
  39. //===========================================================================
  40. //
  41. //
  42. //
  43. //===========================================================================
  44. /*
  45. function void TCOTD_MovePlayersToActivator(void)
  46. {
  47. if (GameType() != GAME_NET_COOPERATIVE)
  48. return;
  49. int atid = ActivatorTID();
  50. if (atid == 0)
  51. return;
  52. for (int i = 0; i < MAX_PLAYERS; i++)
  53. {
  54. SetActivator(0, AAPTR_PLAYER1 << i);
  55. if (ActivatorTID() == atid)
  56. continue;
  57. SetActorPosition(ActivatorTID(), GetActorX(atid), GetActorY(atid), GetActorZ(atid), TRUE);
  58. }
  59. }
  60. */
  61. //===========================================================================
  62. //
  63. //
  64. //
  65. //===========================================================================
  66. function void ReadNote(str noteClassName, int exMarkTID)
  67. {
  68. ScriptCall("TCOTDNote", "ReadNoteFromACS", noteClassName, PlayerNumber());
  69. ScriptCall("TCOTDExMarkNoTouch", "TouchFromACS", exMarkTID);
  70. }
  71. //===========================================================================
  72. //
  73. //
  74. //
  75. //===========================================================================
  76. function void Objective_Add(str objective, bool allPlayers)
  77. {
  78. ScriptCall("TCOTDObjective", "AddFromACS", objective, allPlayers);
  79. }
  80. function void Objective_Complete(str objective, bool allPlayers)
  81. {
  82. ScriptCall("TCOTDObjective", "CompleteFromACS", objective, allPlayers);
  83. }
  84. function void Objective_Fail(str objective, bool allPlayers)
  85. {
  86. ScriptCall("TCOTDObjective", "FailFromACS", objective, allPlayers);
  87. }
  88. function void Objective_Delete(str objective, bool allPlayers)
  89. {
  90. ScriptCall("TCOTDObjective", "DeleteFromACS", objective, allPlayers);
  91. }
  92. //===========================================================================
  93. //
  94. //
  95. //
  96. //===========================================================================
  97. function int FindFontColor(str c)
  98. {
  99. return ScriptCall("TCOTDStrLib", "FindFontColorFromACS", c);
  100. }
  101. //===========================================================================
  102. //
  103. //
  104. //
  105. //===========================================================================
  106. // fadescript for map setup
  107. //$Skip
  108. Script "MapStartFadeIn" ENTER
  109. {
  110. FadeRange(0, 0, 0, 1.0, 0, 0, 0, 0.0, 1.5);
  111. }
  112. //lowhealth scripts - from BoA
  113. //$Skip
  114. Script "DrawLowHealth" ENTER
  115. {
  116. int width = 640, height = 480;
  117. SetHudSize(width, height, 0);
  118. // Half width and height (in fixed-point).
  119. int half_width = (width / 2) << 16;
  120. int half_height = (height / 2) << 16;
  121. while (true)
  122. {
  123. bool poisoned = ScriptCall("TCOTDGameplayStatics", "IsPoisoned");
  124. int health = GetActorProperty(0, APROP_HEALTH);
  125. bool lowHealth = health > 0 && health <= 30;
  126. if (poisoned || lowHealth)
  127. {
  128. if (poisoned)
  129. {
  130. SetFont("poisoned");
  131. }
  132. else if (lowHealth)
  133. {
  134. SetFont("M_INJ");
  135. }
  136. //int alpha = ScriptCall("TCOTDUIHandler", "CheckLocalView");
  137. int alpha = 1.;
  138. HudMessage(s:"A"; HUDMSG_FADEINOUT | HUDMSG_NOTWITHFULLMAP | HUDMSG_LAYER_UNDERHUD | HUDMSG_ALPHA, 0, -1, half_width, half_height, 0.0, 0.5, 0.5, alpha);
  139. // Volume and delay of heartbeat (faster and louder with less health).
  140. int volume = MAX_VOLUME;
  141. int delay1 = 10;
  142. int delay2 = 14;
  143. if (health > 20)
  144. {
  145. volume = MAX_VOLUME - 50;
  146. delay1 = 21;
  147. delay2 = 34;
  148. }
  149. else if (health > 10)
  150. {
  151. volume = MAX_VOLUME - 25;
  152. delay1 = 18;
  153. delay2 = 24;
  154. }
  155. LocalAmbientSound("ui/lowhealth", volume);
  156. Delay(delay1);
  157. LocalAmbientSound("ui/lowhealth", volume);
  158. Delay(delay2);
  159. }
  160. Delay(1);
  161. }
  162. }
  163. //$Skip
  164. Script "Madness" ENTER //ozy81, original script by AFADoomer and Talon1024
  165. {
  166. int width = 512, height = 384;
  167. SetHudSize(width, height, 0);
  168. SetFont("M_MADNES");
  169. // Half width and height (in fixed-point).
  170. int half_width = (width / 2) << 16;
  171. int half_height = (height / 2) << 16;
  172. while (true)
  173. {
  174. int nightmare = GetActorPowerupTics(0, "PowerFear");
  175. if (nightmare)
  176. {
  177. HudMessage(s: "A"; HUDMSG_FADEINOUT | HUDMSG_NOWRAP | HUDMSG_LAYER_OVERHUD | HUDMSG_ALPHA , 0, CR_UNTRANSLATED, half_width, half_height, 0.0, 0.5, nightmare, 0.2);
  178. }
  179. Delay(1);
  180. }
  181. }
  182. //Code necessary for CyberBog
  183. function int degsin(int x)
  184. {
  185. int result;
  186. if (x >= 0)
  187. {
  188. result = sin(FixedMul(x << 16, 0.0111111111) / 4);
  189. }
  190. else
  191. {
  192. result = -sin(FixedMul(-x << 16, 0.0111111111) / 4);
  193. }
  194. return result;
  195. }
  196. function int degcos(int x)
  197. {
  198. return cos(FixedMul(x << 16, 0.0111111111) / 4);
  199. }
  200. function int sqrt_x3(int number)
  201. {
  202. if (number <= 3)
  203. {
  204. if (number > 0)
  205. {
  206. return 1;
  207. }
  208. return 0;
  209. }
  210. int oldAns = number >> 1,
  211. newAns = (oldAns + number / oldAns) >> 1;
  212. while(newAns < oldAns)
  213. {
  214. oldAns = newAns;
  215. newAns = (oldAns + number / oldAns) >> 1;
  216. }
  217. return oldAns;
  218. }
  219. function int abs(int x)
  220. {
  221. if (x < 0)
  222. return -x;
  223. return x;
  224. }
  225. function int sqrt_x(int x)
  226. {
  227. int r;
  228. x = x + 1 >> 1;
  229. while (x > r)
  230. x -= r++;
  231. return r;
  232. }
  233. function int dist(int tid1, int tid2)
  234. {
  235. int x, y, z, d;
  236. x = GetActorX(tid1) - GetActorX(tid2) >> 16;
  237. y = GetActorY(tid1) - GetActorY(tid2) >> 16;
  238. z = GetActorZ(tid1) - GetActorZ(tid2) >> 16;
  239. d = sqrt_x(x * x + y * y + z * z);
  240. return d;
  241. }
  242. //$Skip
  243. Script "SetActivatorTarget" (int tid)
  244. {
  245. int k = ActivatorTID();
  246. int subheight;
  247. int grenangle;
  248. int distancepro, d, i;
  249. SetActivatorToTarget(0);
  250. int distance = dist(0, k);
  251. subheight = (GetActorZ(0) >> 16) - (GetActorZ(k) >> 16);
  252. for (i= -89; i <= 89; ++i)
  253. {
  254. distancepro = sqrt_x3(distance * distance - abs((subheight >> 16) * (subheight >> 16)));
  255. d = ((FixedMul(distancepro << 16, FixedDiv(degsin(i), degcos(i)))) >> 16) - (((FixedMul(1.4, distancepro << 16)) >> 16) * distancepro) / ((FixedMul(4050.0, FixedMul(degcos(i), degcos(i)))) >> 16);
  256. if (d > subheight)
  257. {
  258. grenangle = i * 0.85;
  259. break;
  260. }
  261. }
  262. SetActivator(k);
  263. SetResultValue(i);
  264. }
  265. //===========================================================================
  266. //
  267. //
  268. //
  269. //===========================================================================
  270. //$Skip
  271. Script "PrintCredits" (void)
  272. {
  273. PrintBold(l: "ENDCREDITS");
  274. }