ijontichy

hatstuff.c

Apr 10th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.12 KB | None | 0 0
  1. #include "zcommon.acs"
  2. #library "hatstuff"
  3.  
  4. #include "commonFuncs.h"
  5.  
  6. int CL_ShipTIDs[PLAYERMAX];     // TIDs of the hats
  7. int CL_ShipScripts[PLAYERMAX];  // Currently running a hat script?
  8. int CL_PlayerTIDS[PLAYERMAX];   // duh
  9.  
  10. script 173 enter
  11. {
  12.     int pln = PlayerNumber();
  13.     int tid;
  14.     int time = 0;
  15.  
  16.     while (1)
  17.     {
  18.         if (!isDead(0)) { tid = defaultTID(-1); }
  19.  
  20.         if (time % 18 == 0)
  21.         {
  22.             ACS_ExecuteAlways(174, 0, 0, tid);
  23.             time %= 18;
  24.         }
  25.  
  26.         time++;
  27.         Delay(1);
  28.     }
  29. }
  30.  
  31. script 174 (int which, int a1, int a2) clientside
  32. {
  33.     int pln = PlayerNumber();
  34.     int testtid = unusedTID(38000, 48000);
  35.  
  36.     switch (which)
  37.     {
  38.       case 0:
  39.         CL_PlayerTIDs[pln] = a1;
  40.         Thing_ChangeTID(0, a1);
  41.         ACS_ExecuteWithResult(175, pln, 0);
  42.         break;
  43.     }
  44. }
  45.  
  46. script 175 (int pln, int nocountdeath) clientside
  47. {
  48.     if (CL_ShipScripts[pln]) { terminate; }
  49.     CL_ShipScripts[pln] = 1;
  50.  
  51.     SetActivator(-1);
  52.     int shipTID = -1;
  53.     int mytid;
  54.     int i, x, y, z, a, vx, vy, vz;
  55.     int reloop;
  56.     int nx, ny, nz;
  57.     int height;
  58.  
  59.     while (PlayerInGame(pln))
  60.     {
  61.         mytid = CL_PlayerTIDs[pln];
  62.  
  63.         if (isDead(mytid) && Timer() >= nocountdeath)
  64.         {
  65.             // do death stuff here
  66.         }
  67.        
  68.         x = GetActorX(mytid);
  69.         y = GetActorY(mytid);
  70.         z = GetActorZ(mytid);
  71.         a = GetActorAngle(mytid);
  72.         vx = GetActorVelX(mytid);
  73.         vy = GetActorVelY(mytid);
  74.         vz = GetActorVelZ(mytid);
  75.  
  76.         if (ThingCount(0, shipTID) <= 0)
  77.         {
  78.             if (ThingCount(0, shipTID) > 0 && shipTID != 0) { Thing_Remove(shipTID); }
  79.  
  80.             shipTID = unusedTID(12000, 15000);
  81.             while (1)
  82.             {
  83.                 reloop = 0;
  84.  
  85.                 for (i = 0; i < PLAYERMAX; i++)
  86.                 {
  87.                     if (CL_PlayerTIDs[i] == shipTID || CL_ShipTIDs[i] == shipTID || ThingCount(0, shipTID) > 0)
  88.                     {
  89.                         shipTID++;
  90.                         reloop = 1;
  91.                         break;
  92.                     }
  93.                 }
  94.                
  95.                 if (!reloop) { break; }
  96.             }
  97.  
  98.             // TOOT TOOT THE BUTT SHIP HAS ARRIVED
  99.             Spawn("ButtShip", x,y,z, shipTID, a);
  100.         }
  101.  
  102.         // YOUR COLORS ARE NEAT, AND THE BUTT
  103.         if (1)
  104.         {
  105.             SetActivator(mytid);
  106.             Thing_SetTranslation(shipTID, -1);
  107.             SetActivator(-1);
  108.         }
  109.  
  110.         CL_ShipTIDs[pln] = shipTID;
  111.  
  112.         // THE BUTT TRAIN IS STEALTHY
  113.         SetActorProperty(shipTID, APROP_Alpha, GetActorProperty(mytid, APROP_Alpha));
  114.  
  115.         // MOVE THAT BUTT TRAIN AROUND WOOP WOOP
  116.         // (angle's factored in; pitch isn't)
  117.         int xOffset = 0, yOffset = 0, zOffset = 0;
  118.  
  119.         nx = x + FixedMul(xOffset, cos(a)) + FixedMul(yOffset, sin(a));
  120.         ny = y + FixedMul(xOffset, sin(a)) - FixedMul(yOffset, cos(a));
  121.         nz = z + zOffset;
  122.  
  123.         if (pln != ConsolePlayerNumber())
  124.         {
  125.             // HOLD ON BACK THAT BUTT TRAIN UP
  126.             nx -= vx; ny -= vy; nz -= vz;
  127.         }
  128.         else
  129.         {
  130.             // NOT FAR ENOUGH, KEEP BACKIN IT UP
  131.             // (players have weird camera interpolation re. Z movement)
  132.             nx -= vx; ny -= vy; nz -= 2*vz;
  133.         }
  134.  
  135.         SetActorAngle(shipTID, a);
  136.         SetActorPosition(shipTID, nx, ny, nz, 0);
  137.         SetActorVelocity(shipTID, vx, vy, vz, 0, 0);
  138.        
  139.         Delay(1);
  140.     }
  141.  
  142.     CL_ShipScripts[pln] = 0;
  143. }
  144.  
  145. script 176 (int pln) disconnect clientside
  146. {
  147.     Thing_Remove(CL_ShipTIDs[pln]);
  148.     CL_PlayerTIDs[pln] = 0;
  149.     CL_ShipTIDs[pln] = 0;
  150. }
  151.  
  152. script 181 (int fadestart, int alpha, int fadetime) clientside
  153. {
  154.     if (CheckInventory("IAmAHat")) { SetActorState(0, "HatDeath"); }
  155.     alpha = itof(alpha) / 100;
  156.     int i;
  157.     int start   = GetActorProperty(0, APROP_Alpha);
  158.     int fademod = alpha - start;
  159.  
  160.     Delay(fadestart);
  161.  
  162.     for (i = 0; i < fadetime-1; i++)
  163.     {
  164.         SetActorProperty(0, APROP_Alpha, start + ((fademod/fadetime) * i));
  165.         Delay(1);
  166.     }
  167.  
  168.     SetActorProperty(0, APROP_Alpha, alpha);
  169.  
  170.     if (alpha == 0 && CheckInventory("IAmAHat")) { Thing_Remove(0); }
  171. }
Advertisement
Add Comment
Please, Sign In to add comment