Advertisement
Chronos_Ouroboros

JGP thing 2 v2

Jul 26th, 2020
1,302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 KB | None | 0 0
  1.     array <Actor> demontargets;
  2.     bool demonMorphActive;
  3.  
  4.     override void WorldThingspawned (worldevent e) {
  5.         if (!e.thing)
  6.             return;
  7.  
  8.         if (e.thing.bISMONSTER || e.thing.bMISSILE || (e.thing is "PlayerPawn")) {
  9.             demontargets.push(e.thing);
  10.  
  11.             if (demonMorphActive && !e.thing.FindInventory("PK_DemonWeapon")) {
  12.                 e.thing.GiveInventory("PK_SlowMoControl",1);
  13.             }
  14.         }
  15.  
  16.         if ((e.thing is "PlayerPawn") && !e.thing.FindInventory("PK_DemonMorphControl"))
  17.             e.thing.GiveInventory("PK_DemonMorphControl",1);
  18.     }
  19.  
  20.     override void WorldTick() {
  21.         if (players[consoleplayer].mo.FindInventory("PK_DemonWeapon"))
  22.             Shader.SetEnabled( players[consoleplayer], "DemonMorph", true);
  23.         else
  24.             Shader.SetEnabled( players[consoleplayer], "DemonMorph", false);
  25.  
  26.         bool demonMorphFound = false;
  27.         for (int pn = 0; pn < MAXPLAYERS; pn++) {
  28.             if (!playerInGame[pn])
  29.                 continue;
  30.  
  31.             PlayerInfo player   = players[pn];
  32.             PlayerPawn mo       = player.mo;
  33.  
  34.             if (!player || !mo)
  35.                 continue;
  36.  
  37.             let weap = PK_DemonWeapon(mo.FindInventory("PK_DemonWeapon"));
  38.  
  39.             demonMorphFound |= (weap != null);
  40.         }
  41.  
  42.         if (!demonMorphActive && demonMorphFound) {
  43.             for (int i = 0; i < demontargets.Size(); i++) {
  44.                 if (demontargets[i] && !(demontargets[i].FindInventory("PK_SlowMoControl")) && !(demontargets[i].FindInventory("PK_DemonWeapon")))
  45.                     demontargets[i].GiveInventory("PK_SlowMoControl",1);
  46.             }
  47.  
  48.             demonMorphActive = true;
  49.         }
  50.         else if (demonMorphActive && !demonMorphFound) {
  51.             for (int i = 0; i < demontargets.Size(); i++) {
  52.                 if (demontargets[i])
  53.                     demontargets[i].TakeInventory("PK_SlowMoControl",1);
  54.             }
  55.  
  56.             demonMorphActive = false;
  57.         }
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement