Advertisement
Guest User

Untitled

a guest
Nov 4th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.26 KB | None | 0 0
  1. //Mostly working but still causing some hardcrashes, figure out why
  2.  
  3. class BabelBFG9000 : BFG9000 Replaces BFG9000
  4. {
  5.     default
  6.     {
  7.         Weapon.SelectionOrder 500;
  8.         Weapon.BobSpeed 2.75;
  9.         Weapon.BobRangeX 0.25;
  10.         Weapon.BobRangeY 0.4;
  11.         Weapon.BobStyle "Alpha";
  12.     }
  13.    
  14.     action void A_NewBFG()
  15.     {
  16.         let p = players[consoleplayer].mo;
  17.         MiniBFGBallTargetCoordinator m = MiniBFGBallTargetCoordinator.Create();
  18.         for(int i = 0; i < 40; i++)
  19.         {
  20.             m.AddBall(MiniBFGBall(
  21.                     p.Spawn("MiniBFGBall",
  22.                         (
  23.                         p.pos.x,// + frandom(3, -3),
  24.                         p.pos.y,// + frandom(3, -3),
  25.                         p.pos.z + (p.height/2) + p.AttackZOffset// + frandom(3, -3)
  26.                         )
  27.                     )
  28.                 )
  29.             );
  30.             //Console.Printf("Ball Spawned %i", i);
  31.         }
  32.         ThinkerIterator targetFinder = ThinkerIterator.Create("BabelMonster");
  33.         BabelMonster other;
  34.         while(other = BabelMonster(targetFinder.Next()))
  35.         {
  36.             if(!p.CheckSight(other) || other.health <= 0)
  37.             {
  38.                 continue;
  39.             }
  40.             Vector2 d = p.Vec2To(other);
  41.             if(absangle(p.angle, BabelLib.atan2(d)) > 50) //use Fov later
  42.                 continue;
  43.             m.Insert(other);
  44.         }
  45.         m.SetTargets();
  46.     }
  47.    
  48.     States
  49.     {
  50.     Ready:
  51.         BFGG A 20 A_WeaponReady;
  52.         Loop;
  53.     Deselect:
  54.         BFGG A 1
  55.         {
  56.             A_Lower(24);
  57.         }
  58.         Loop;
  59.     Select:
  60.         BFGG A 1
  61.         {
  62.             A_Raise(24);
  63.         }
  64.         Loop;
  65.     Fire:
  66.         BFGG A 20
  67.         {
  68.             A_BFGSound();
  69.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  70.         }
  71.         BFGG A 2
  72.         {
  73.             A_GunFlash();
  74.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  75.         }
  76.         BFGN A 8 A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  77.        
  78.         SBFG D 1
  79.         {
  80.             BabelLib.InflictFear(players[consoleplayer].mo, "BabelMonster", random(10, 170));
  81.             //A_FireBFG();
  82.             A_NewBFG();
  83.             A_ZoomFactor(0.95);
  84.             A_SetPitch(pitch-1.0);
  85.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  86.         }
  87.         SBFG D 1
  88.         {
  89.             A_ZoomFactor(0.96);
  90.             A_SetPitch(pitch+0.20);
  91.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  92.         }
  93.         SBFG E 1
  94.         {
  95.             A_ZoomFactor(0.97);
  96.             A_SetPitch(pitch+0.20);
  97.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  98.         }
  99.         SBFG E 1
  100.         {
  101.             A_ZoomFactor(0.98);
  102.             A_SetPitch(pitch+0.20);
  103.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  104.         }
  105.        
  106.         SBFG D 1
  107.         {
  108.             A_ZoomFactor(0.99);
  109.             A_SetPitch(pitch+0.20);
  110.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  111.         }
  112.         SBFG D 1
  113.         {
  114.             A_ZoomFactor(1.0);
  115.             A_SetPitch(pitch+0.20);
  116.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  117.         }
  118.         SBFG CCBA 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  119.         BFGG A 1
  120.         {
  121.             A_ReFire();
  122.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  123.         }
  124.         goto Ready;
  125.     Hold:
  126.         BFGG A 20
  127.         {
  128.             A_BFGSound();
  129.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  130.         }
  131.         BFGG A 2
  132.         {
  133.             A_GunFlash();
  134.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  135.         }
  136.         BFGN A 8 A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  137.        
  138.         SBFG D 1
  139.         {
  140.             BabelLib.InflictFear(players[consoleplayer].mo, "BabelMonster", random(10, 170));
  141.             //A_FireBFG();
  142.             A_NewBFG();
  143.             A_ZoomFactor(0.95);
  144.             A_SetPitch(pitch-1.0);
  145.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  146.         }
  147.         SBFG D 1
  148.         {
  149.             A_ZoomFactor(0.96);
  150.             A_SetPitch(pitch+0.20);
  151.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  152.         }
  153.         SBFG E 1
  154.         {
  155.             A_ZoomFactor(0.97);
  156.             A_SetPitch(pitch+0.20);
  157.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  158.         }
  159.         SBFG E 1
  160.         {
  161.             A_ZoomFactor(0.98);
  162.             A_SetPitch(pitch+0.20);
  163.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  164.         }
  165.        
  166.         SBFG D 1
  167.         {
  168.             A_ZoomFactor(0.99);
  169.             A_SetPitch(pitch+0.20);
  170.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  171.         }
  172.         SBFG D 1
  173.         {
  174.             A_ZoomFactor(1.0);
  175.             A_SetPitch(pitch+0.20);
  176.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  177.         }
  178.         SBFG CCBA 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  179.         BFGG A 1
  180.         {
  181.             A_ReFire();
  182.             A_WeaponReady(WRF_NoFire|WRF_NoSwitch);
  183.         }
  184.         goto Ready;
  185.     Flash:
  186.         BFGW A 2 bright;
  187.         BFGX HGFE 1 bright A_Light2();
  188.         BFGX DCBA 1 bright A_Light2();
  189.         TNT1 A 0 A_Light0;
  190.         Goto LightDone;
  191.     }
  192. }
  193.  
  194. class MiniBFGBallTargetCoordinator : Thinker
  195. {
  196.     Array<BabelMonster> monsters;
  197.     Array<MiniBFGBall> balls;
  198.     static MiniBFGBallTargetCoordinator Create()
  199.     {
  200.         MiniBFGBallTargetCoordinator m = new("MiniBFGBallTargetCoordinator");
  201.         //initialize
  202.         return m;
  203.     }
  204.     void Insert(BabelMonster b)
  205.     {
  206.         if(b.health <= 0)
  207.             return;
  208.         //Console.Printf("%i", monsters.Size());
  209.         for(int i = 0; i < monsters.Size(); i++)
  210.         {
  211.             if(b.health > monsters[i].health)
  212.             {
  213.                 monsters.Insert (i, b);
  214.                 return;
  215.             }
  216.         }
  217.         monsters.Push(b);
  218.     }
  219.     void AddBall(MiniBFGBall b)
  220.     {
  221.         balls.Push(b);
  222.     }
  223.     void SetTargets()
  224.     {
  225.         //Console.Printf("Setting targets");
  226.         int balldmg = balls.Size() * 100;
  227.         int numMonsters = monsters.Size();
  228.         int monsterIndex = 0;
  229.         int ballIndex = 0;
  230.         int monsterHealth;
  231.         //Console.Printf("%i %i", balldmg, numMonsters);
  232.         while((ballIndex < balldmg/100) && (balldmg > 0) && (monsterIndex < numMonsters))
  233.         {
  234.             monsterHealth = monsters[monsterIndex].health;
  235.             //Console.Printf("Monster Health: %i", monsterHealth);
  236.             while(monsterHealth > 0 && balldmg > 0 && ballIndex < 40)
  237.             {
  238.                 //Console.Printf("Assigning ball %i to %s", ballIndex, monsters[monsterIndex].GetClassName());
  239.                 while(monsterHealth%100 != 0 && balldmg - monsterHealth > 0)
  240.                     monsterHealth++;
  241.                
  242.                 balls[ballIndex].tracer = monsters[monsterIndex];
  243.                 balls[ballIndex].target = players[consoleplayer].mo; //so we pass through
  244.                 balls[ballIndex].damageMul = monsterHealth/100; //what the fuck am I doing aaaa
  245.                 double newScale = 0.2 + (0.05*((monsterHealth/100)-1));
  246.                 if(newScale > 1.0)
  247.                     newScale = 1.0;
  248.                 balls[ballIndex].Scale = (newScale, newScale);
  249.                 //Console.Printf("%i", balls[ballIndex].damageMul);
  250.                 ballIndex++;
  251.                 balldmg -= monsterHealth;
  252.                 monsterHealth = 0;
  253.             }
  254.             monsterIndex++;
  255.         }
  256.         //when we reach here, either all balls should be assigned or all monsters should soon be dead
  257.     }
  258. }
  259.  
  260. class MiniBFGBall : BabelFastProjectile
  261. {
  262.     int user_loopCounter;
  263.     int curspeed;
  264.     int damageMul;
  265.     default
  266.     {
  267.         Radius 3;
  268.         Height 2;
  269.         Speed 0;
  270.         DamageFunction (100 * damageMul);
  271.         Projectile;
  272.         RenderStyle "Add";
  273.         Alpha 0.75;
  274.         DeathSound "weapons/bfgx";
  275.         Obituary "$OB_MPBFG_BOOM";
  276.         DamageType "PlayerBFG";
  277.         Scale 0.2;
  278.         +SEEKERMISSILE;
  279.     }
  280.    
  281.     override void BeginPlay()
  282.     {
  283.         target = players[consoleplayer].mo;
  284.         angle = players[consoleplayer].mo.angle%360;
  285.         pitch = players[consoleplayer].mo.pitch;
  286.         damageMul = 1;
  287.         super.BeginPlay();
  288.         heightCorrection = -0.5;
  289.         lerpOffset = 0.6;
  290.         trailDetail = 5;
  291.         particleColors[0] = Color(0x55ff55);//0xffff99);
  292.         particleColors[1] = Color(0xbbff33);
  293.         particleColors[2] = Color(0x22ff22);
  294.         size[0] = 1;
  295.         size[1] = 2;
  296.         lifetime[0] = 25;
  297.         lifetime[1] = 35;
  298.         cubeOffset[0] = 2;
  299.         cubeOffset[1] = 2;
  300.         cubeAccel[0] = 0.02;
  301.         cubeAccel[1] = 0.02;
  302.         startingAlpha = 0.7;
  303.         trailSpawn = false;
  304.         finalTrail = true;
  305.     }
  306.    
  307.     States
  308.     {
  309.     Spawn:
  310.         TNT1 A 0 NoDelay
  311.         {
  312.             if(!tracer)
  313.             {
  314.                 //Console.Printf("Killing Self");
  315.                 return ResolveState("Disappear");
  316.             }
  317.             trailSpawn = true;
  318.             finalTrail = false;
  319.             curspeed = 10;
  320.             A_SetSpeed(curspeed);
  321.             //Console.Printf(tracer.GetClassName());
  322.             return ResolveState(null);
  323.         }
  324.     Fly:
  325.         BFS1 AB 4 Bright
  326.         {
  327.             if(curspeed < 50)
  328.                 curspeed += 4;
  329.             A_SetSpeed(curspeed);
  330.             A_SeekerMissile (360, 360, SMF_PRECISE);
  331.         }
  332.         Loop;
  333.     Disappear:
  334.         TNT1 A 1;
  335.         Stop;
  336.     Death:
  337.         TNT1 A 0
  338.         {
  339.             trailSpawn = false;
  340.         }
  341.         TNT1 AAAAAAAAAA 0
  342.         {
  343.             A_SpawnParticle (0x55ff55, SPF_FULLBRIGHT, random(25,35), random(1,2), 0, frandom(-radius, radius), frandom(-radius, radius), frandom(-height, height),  frandom(-4.0, 4.0),frandom(-4.0, 4.0),frandom(-4.0, 4.0),  frandom(-0.1, 0.1), frandom(-0.1, 0.1), frandom(-0.1, 0.1), 0.7, -1);
  344.             A_SpawnParticle (0xbbff33, SPF_FULLBRIGHT, random(25,35), random(1,2), 0, frandom(-radius, radius), frandom(-radius, radius), frandom(-height, height),  frandom(-4.0, 4.0),frandom(-4.0, 4.0),frandom(-4.0, 4.0),  frandom(-0.1, 0.1), frandom(-0.1, 0.1), frandom(-0.1, 0.1), 0.7, -1);
  345.             A_SpawnParticle (0x22ff22, SPF_FULLBRIGHT, random(25,35), random(1,2), 0, frandom(-radius, radius), frandom(-radius, radius), frandom(-height, height),  frandom(-4.0, 4.0),frandom(-4.0, 4.0),frandom(-4.0, 4.0),  frandom(-0.1, 0.1), frandom(-0.1, 0.1), frandom(-0.1, 0.1), 0.7, -1);
  346.         }
  347.         BFE1 AABBCCDD 2 Bright;
  348.         BFE1 EF 3 Bright;
  349.         Stop;
  350.     }
  351. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement