123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- #library "TCOTD2"
- #include "zcommon.acs"
- #libdefine ONE_SECOND 35
- #libdefine MAX_PLAYERS 8
- #libdefine INT_MAX 0x7FFFFFFF
- #libdefine HUDMSG_TIC 1.0 / 35 + 1
- #define MAX_VOLUME 127
- #define MAX_PLAYER_HEALTH 200
- /**************************************************************************************************
- Generates a HUDMessageID, for use with HUDMessage
- Example: MakeHUDMessage('L', 'O', 'G', 'O');
- **************************************************************************************************/
- function int MakeHUDMessageID(int a, int b, int c, int d)
- {
- // MAKE_ID
- return (a << 24) | ( b << 16) | (c << 8) | d;
- }
- //===========================================================================
- //
- //
- //
- //===========================================================================
- function void TCOTD_AutoSave(void)
- {
- // Can only autosave on "Normal" and in single player...
- if (GameType() == GAME_SINGLE_PLAYER && GameSkill() == 0)
- AutoSave();
- }
- //===========================================================================
- //
- //
- //
- //===========================================================================
- function void TCOTD_RaiseThing(int tid)
- {
- Thing_Raise(tid);
- SetUserVariable(tid, "user_ReviveSelfOnly", FALSE);
- }
- //===========================================================================
- //
- //
- //
- //===========================================================================
- /*
- function void TCOTD_MovePlayersToActivator(void)
- {
- if (GameType() != GAME_NET_COOPERATIVE)
- return;
- int atid = ActivatorTID();
- if (atid == 0)
- return;
- for (int i = 0; i < MAX_PLAYERS; i++)
- {
- SetActivator(0, AAPTR_PLAYER1 << i);
- if (ActivatorTID() == atid)
- continue;
- SetActorPosition(ActivatorTID(), GetActorX(atid), GetActorY(atid), GetActorZ(atid), TRUE);
- }
- }
- */
- //===========================================================================
- //
- //
- //
- //===========================================================================
- function void ReadNote(str noteClassName, int exMarkTID)
- {
- ScriptCall("TCOTDNote", "ReadNoteFromACS", noteClassName, PlayerNumber());
- ScriptCall("TCOTDExMarkNoTouch", "TouchFromACS", exMarkTID);
- }
- //===========================================================================
- //
- //
- //
- //===========================================================================
- function void Objective_Add(str objective, bool allPlayers)
- {
- ScriptCall("TCOTDObjective", "AddFromACS", objective, allPlayers);
- }
- function void Objective_Complete(str objective, bool allPlayers)
- {
- ScriptCall("TCOTDObjective", "CompleteFromACS", objective, allPlayers);
- }
- function void Objective_Fail(str objective, bool allPlayers)
- {
- ScriptCall("TCOTDObjective", "FailFromACS", objective, allPlayers);
- }
- function void Objective_Delete(str objective, bool allPlayers)
- {
- ScriptCall("TCOTDObjective", "DeleteFromACS", objective, allPlayers);
- }
- //===========================================================================
- //
- //
- //
- //===========================================================================
- function int FindFontColor(str c)
- {
- return ScriptCall("TCOTDStrLib", "FindFontColorFromACS", c);
- }
- //===========================================================================
- //
- //
- //
- //===========================================================================
- // fadescript for map setup
- //$Skip
- Script "MapStartFadeIn" ENTER
- {
- FadeRange(0, 0, 0, 1.0, 0, 0, 0, 0.0, 1.5);
- }
- //lowhealth scripts - from BoA
- //$Skip
- Script "DrawLowHealth" ENTER
- {
- int width = 640, height = 480;
- SetHudSize(width, height, 0);
- // Half width and height (in fixed-point).
- int half_width = (width / 2) << 16;
- int half_height = (height / 2) << 16;
- while (true)
- {
- bool poisoned = ScriptCall("TCOTDGameplayStatics", "IsPoisoned");
- int health = GetActorProperty(0, APROP_HEALTH);
- bool lowHealth = health > 0 && health <= 30;
- if (poisoned || lowHealth)
- {
- if (poisoned)
- {
- SetFont("poisoned");
- }
- else if (lowHealth)
- {
- SetFont("M_INJ");
- }
- //int alpha = ScriptCall("TCOTDUIHandler", "CheckLocalView");
- int alpha = 1.;
- 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);
- // Volume and delay of heartbeat (faster and louder with less health).
- int volume = MAX_VOLUME;
- int delay1 = 10;
- int delay2 = 14;
- if (health > 20)
- {
- volume = MAX_VOLUME - 50;
- delay1 = 21;
- delay2 = 34;
- }
- else if (health > 10)
- {
- volume = MAX_VOLUME - 25;
- delay1 = 18;
- delay2 = 24;
- }
- LocalAmbientSound("ui/lowhealth", volume);
- Delay(delay1);
- LocalAmbientSound("ui/lowhealth", volume);
- Delay(delay2);
- }
- Delay(1);
- }
- }
- //$Skip
- Script "Madness" ENTER //ozy81, original script by AFADoomer and Talon1024
- {
- int width = 512, height = 384;
- SetHudSize(width, height, 0);
- SetFont("M_MADNES");
- // Half width and height (in fixed-point).
- int half_width = (width / 2) << 16;
- int half_height = (height / 2) << 16;
- while (true)
- {
- int nightmare = GetActorPowerupTics(0, "PowerFear");
- if (nightmare)
- {
- 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);
- }
- Delay(1);
- }
- }
- //Code necessary for CyberBog
- function int degsin(int x)
- {
- int result;
- if (x >= 0)
- {
- result = sin(FixedMul(x << 16, 0.0111111111) / 4);
- }
- else
- {
- result = -sin(FixedMul(-x << 16, 0.0111111111) / 4);
- }
- return result;
- }
- function int degcos(int x)
- {
- return cos(FixedMul(x << 16, 0.0111111111) / 4);
- }
- function int sqrt_x3(int number)
- {
- if (number <= 3)
- {
- if (number > 0)
- {
- return 1;
- }
- return 0;
- }
- int oldAns = number >> 1,
- newAns = (oldAns + number / oldAns) >> 1;
- while(newAns < oldAns)
- {
- oldAns = newAns;
- newAns = (oldAns + number / oldAns) >> 1;
- }
- return oldAns;
- }
- function int abs(int x)
- {
- if (x < 0)
- return -x;
- return x;
- }
- function int sqrt_x(int x)
- {
- int r;
- x = x + 1 >> 1;
- while (x > r)
- x -= r++;
- return r;
- }
- function int dist(int tid1, int tid2)
- {
- int x, y, z, d;
- x = GetActorX(tid1) - GetActorX(tid2) >> 16;
- y = GetActorY(tid1) - GetActorY(tid2) >> 16;
- z = GetActorZ(tid1) - GetActorZ(tid2) >> 16;
- d = sqrt_x(x * x + y * y + z * z);
- return d;
- }
- //$Skip
- Script "SetActivatorTarget" (int tid)
- {
- int k = ActivatorTID();
- int subheight;
- int grenangle;
- int distancepro, d, i;
- SetActivatorToTarget(0);
- int distance = dist(0, k);
- subheight = (GetActorZ(0) >> 16) - (GetActorZ(k) >> 16);
- for (i= -89; i <= 89; ++i)
- {
- distancepro = sqrt_x3(distance * distance - abs((subheight >> 16) * (subheight >> 16)));
- 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);
- if (d > subheight)
- {
- grenangle = i * 0.85;
- break;
- }
- }
- SetActivator(k);
- SetResultValue(i);
- }
- //===========================================================================
- //
- //
- //
- //===========================================================================
- //$Skip
- Script "PrintCredits" (void)
- {
- PrintBold(l: "ENDCREDITS");
- }
|