Enemies only drop ammo for owned weapons.

This commit is contained in:
Mari the Deer 2022-08-04 18:17:21 +02:00
commit fa6c8f68d6
4 changed files with 84 additions and 106 deletions

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r249 \cu(Thu 4 Aug 17:58:16 CEST 2022)\c-";
SWWM_SHORTVER="\cw1.3pre r249 \cu(2022-08-04 17:58:16)\c-";
SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r250 \cu(Thu 4 Aug 18:17:21 CEST 2022)\c-";
SWWM_SHORTVER="\cw1.3pre r250 \cu(2022-08-04 18:17:21)\c-";

View file

@ -1,5 +1,6 @@
// on-demand ammo spawners
Mixin Class SWWMOndemandAmmoSpawner
// Ref class for ammo spawners, used by on-demand replacers
Class SWWMAmmoSpawner : Inventory abstract
{
Actor dropper;
bool enemydrop;
@ -11,9 +12,11 @@ Mixin Class SWWMOndemandAmmoSpawner
return false;
}
override void SpawnAmmo()
abstract Class<Actor> PickAmmo( bool enemydrop = false );
void SpawnAmmo()
{
let ac = PickAmmo();
let ac = PickAmmo(enemydrop);
if ( !ac ) return;
let a = Spawn(ac,pos);
if ( enemydrop )
@ -35,16 +38,41 @@ Mixin Class SWWMOndemandAmmoSpawner
}
SWWMUtility.TransferItemProp(self,a);
}
}
override void PostBeginPlay()
{
SpawnAmmo();
ClearCounters();
Destroy();
}
override bool CanPickup( Actor toucher )
{
return false;
}
override bool TryPickup( in out Actor toucher )
{
return false;
}
default
{
+NOGRAVITY;
+NOBLOCKMAP;
+NOINTERACTION;
+NOTELEPORT;
+DONTSPLASH;
+DONTGIB;
-SPECIAL;
}
}
Class SWWMShellAmmoSmall : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
bool aex = (SWWMUtility.ItemExists('Spreadgun')||SWWMUtility.ItemExists('Wallbuster')),
bex = (SWWMUtility.ItemExists('PuntzerBeta')||SWWMUtility.ItemExists('PuntzerGamma'));
bool aex = (SWWMUtility.ItemExists('Spreadgun',ownedonly:enemydrop)||SWWMUtility.ItemExists('Wallbuster',ownedonly:enemydrop)),
bex = (SWWMUtility.ItemExists('PuntzerBeta',ownedonly:enemydrop)||SWWMUtility.ItemExists('PuntzerGamma',ownedonly:enemydrop));
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
return Random[Replacements](0,2)?'SMW05SmallAmmo':'SMW05Ammo3';
switch( Random[Replacements](0,9) )
@ -67,12 +95,10 @@ Class SWWMShellAmmoSmall : SWWMAmmoSpawner
}
Class SWWMShellAmmoBig : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
bool aex = (SWWMUtility.ItemExists('Spreadgun')||SWWMUtility.ItemExists('Wallbuster')),
bex = (SWWMUtility.ItemExists('PuntzerBeta')||SWWMUtility.ItemExists('PuntzerGamma'));
bool aex = (SWWMUtility.ItemExists('Spreadgun',ownedonly:enemydrop)||SWWMUtility.ItemExists('Wallbuster',ownedonly:enemydrop)),
bex = (SWWMUtility.ItemExists('PuntzerBeta',ownedonly:enemydrop)||SWWMUtility.ItemExists('PuntzerGamma',ownedonly:enemydrop));
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
return Random[Replacements](0,2)?'SMW05SmallAmmo':'SMW05BigAmmo';
switch( Random[Replacements](0,14) )
@ -101,21 +127,19 @@ Class SWWMShellAmmoBig : SWWMAmmoSpawner
}
Class SWWMClipAmmoSmall : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
if ( !Random[Replacements](0,4) )
{
bool aex = SWWMUtility.ItemExists('Eviscerator'),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun');
bool aex = SWWMUtility.ItemExists('Eviscerator',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
return Random[Replacements](0,2)?'SheenAmmo3':'SheenSmallAmmo';
if ( aex )
return 'EvisceratorShell';
}
bool aex = (SWWMUtility.ItemExists('Spreadgun')||SWWMUtility.ItemExists('Wallbuster')),
bex = (SWWMUtility.ItemExists('PuntzerBeta')||SWWMUtility.ItemExists('PuntzerGamma'));
bool aex = (SWWMUtility.ItemExists('Spreadgun',ownedonly:enemydrop)||SWWMUtility.ItemExists('Wallbuster',ownedonly:enemydrop)),
bex = (SWWMUtility.ItemExists('PuntzerBeta',ownedonly:enemydrop)||SWWMUtility.ItemExists('PuntzerGamma',ownedonly:enemydrop));
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
return Random[Replacements](0,2)?'SMW05Ammo':'SMW05Ammo2';
return Random[Replacements](0,1)?'RedShell':'GreenShell';
@ -124,12 +148,10 @@ Class SWWMClipAmmoSmall : SWWMAmmoSpawner
// special for chaingun ammo drops
Class SWWMClipAmmoMed : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
bool aex = SWWMUtility.ItemExists('Eviscerator'),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun');
bool aex = SWWMUtility.ItemExists('Eviscerator',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
return Random[Replacements](0,1)?'SheenAmmo3':'SheenSmallAmmo';
return Random[Replacements](0,1)?'EvisceratorShell':'EvisceratorShell2';
@ -137,12 +159,10 @@ Class SWWMClipAmmoMed : SWWMAmmoSpawner
}
Class SWWMClipAmmoBig : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
bool aex = SWWMUtility.ItemExists('Eviscerator'),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun');
bool aex = SWWMUtility.ItemExists('Eviscerator',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
return Random[Replacements](0,2)?'SheenSmallAmmo':'SheenBigAmmo';
return Random[Replacements](0,5)?'EvisceratorShell':Random[Replacements](0,2)?'EvisceratorShell2':'EvisceratorShell3';
@ -150,12 +170,10 @@ Class SWWMClipAmmoBig : SWWMAmmoSpawner
}
Class SWWMBlastAmmoSmall : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
bool aex = SWWMUtility.ItemExists('Eviscerator'),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun');
bool aex = SWWMUtility.ItemExists('Eviscerator',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
return Random[Replacements](0,2)?'SheenAmmo3':'SheenSmallAmmo';
return 'EvisceratorShell';
@ -163,12 +181,10 @@ Class SWWMBlastAmmoSmall : SWWMAmmoSpawner
}
Class SWWMBlastAmmoBig : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
bool aex = SWWMUtility.ItemExists('Eviscerator'),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun');
bool aex = SWWMUtility.ItemExists('Eviscerator',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('HeavyMahSheenGun',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
return Random[Replacements](0,2)?'SheenSmallAmmo':'SheenBigAmmo';
return Random[Replacements](0,2)?'EvisceratorShell':Random[Replacements](0,1)?'EvisceratorShell2':'EvisceratorShell3';
@ -176,24 +192,20 @@ Class SWWMBlastAmmoBig : SWWMAmmoSpawner
}
Class SWWMRocketAmmoSmall : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
bool aex = SWWMUtility.ItemExists('Hellblazer'),
bex = SWWMUtility.ItemExists('Quadravol');
bool aex = SWWMUtility.ItemExists('Hellblazer',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('Quadravol',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) ) return 'QuadravolAmmo';
return Random[Replacements](0,2)?'HellblazerMissiles':'HellblazerCrackshots';
}
}
Class SWWMRocketAmmoBig : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
bool aex = SWWMUtility.ItemExists('Hellblazer'),
bex = SWWMUtility.ItemExists('Quadravol');
bool aex = SWWMUtility.ItemExists('Hellblazer',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('Quadravol',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
return Random[Replacements](0,4)?'QuadravolAmmo2':'QuadravolAmmo3';
switch ( Random[Replacements](0,11) )
@ -219,35 +231,31 @@ Class SWWMRocketAmmoBig : SWWMAmmoSpawner
}
Class SWWMCellAmmoSmall : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
if ( !Random[Replacements](0,2) )
{
if ( !Random[Replacements](0,3) )
{
bool aex = SWWMUtility.ItemExists('CandyGun'),
bex = SWWMUtility.ItemExists('MisterRifle');
bool aex = SWWMUtility.ItemExists('CandyGun',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('MisterRifle',ownedonly:enemydrop);
if ( (!aex && bex) || (!Random[Replacements](0,2) && bex) ) return 'MisterGAmmo';
if ( aex ) return 'CandyGunBullets';
}
bool aex = SWWMUtility.ItemExists('SilverBullet'),
bex = SWWMUtility.ItemExists('RayKhom');
bool aex = SWWMUtility.ItemExists('SilverBullet',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('RayKhom',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) ) return 'RayBolt2';
if ( aex ) return Random[Replacements](0,2)?'SilverBullets':'SilverBullets2';
}
bool aex = SWWMUtility.ItemExists('Sparkster'),
bex = SWWMUtility.ItemExists('ModernSparkster');
bool aex = SWWMUtility.ItemExists('Sparkster',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('ModernSparkster',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) ) return Random[Replacements](0,2)?'SparksterBAmmo':'SparksterRAmmo';
return 'SparkUnit';
}
}
Class SWWMCellAmmoBig : SWWMAmmoSpawner
{
Mixin SWWMOndemandAmmoSpawner;
static Class<Actor> PickAmmo()
override Class<Actor> PickAmmo( bool enemydrop )
{
if ( !Random[Replacements](0,3) )
{
@ -258,8 +266,8 @@ Class SWWMCellAmmoBig : SWWMAmmoSpawner
}
if ( Random[Replacements](0,1) )
{
bool aex = SWWMUtility.ItemExists('SilverBullet'),
bex = SWWMUtility.ItemExists('RayKhom');
bool aex = SWWMUtility.ItemExists('SilverBullet',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('RayKhom',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) ) return Random[Replacements](0,2)?'RayBolt5':'RayAmmo';
if ( aex )
{
@ -269,13 +277,13 @@ Class SWWMCellAmmoBig : SWWMAmmoSpawner
}
if ( !Random[Replacements](0,2) )
{
bool aex = SWWMUtility.ItemExists('CandyGun'),
bex = SWWMUtility.ItemExists('MisterRifle');
bool aex = SWWMUtility.ItemExists('CandyGun',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('MisterRifle',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) ) return Random[Replacements](0,2)?'MisterRound5':'MisterAmmo';
if ( aex ) return Random[Replacements](0,3)?'CandyGunBullets3':'CandyGunAmmo';
}
bool aex = SWWMUtility.ItemExists('Sparkster'),
bex = SWWMUtility.ItemExists('ModernSparkster');
bool aex = SWWMUtility.ItemExists('Sparkster',ownedonly:enemydrop),
bex = SWWMUtility.ItemExists('ModernSparkster',ownedonly:enemydrop);
if ( (!aex && bex) || (Random[Replacements](0,1) && bex) )
{
if ( Random[Replacements](0,1) ) return Random[Replacements](0,2)?'SparksterBAmmo2':'SparksterBAmmo3';

View file

@ -645,37 +645,3 @@ Class MagAmmo : Inventory abstract
Amount = Random[ShellDrop](1,clamp(dropamount,1,maxdrop));
}
}
// Ref class for ammo spawners, used by on-demand replacers
Class SWWMAmmoSpawner : Inventory abstract
{
virtual void SpawnAmmo() {}
override void PostBeginPlay()
{
SpawnAmmo();
ClearCounters();
Destroy();
}
override bool CanPickup( Actor toucher )
{
return false;
}
override bool TryPickup( in out Actor toucher )
{
return false;
}
default
{
+NOGRAVITY;
+NOBLOCKMAP;
+NOINTERACTION;
+NOTELEPORT;
+DONTSPLASH;
+DONTGIB;
-SPECIAL;
}
}

View file

@ -2117,7 +2117,9 @@ Class SWWMUtility
// mapstart: this function is being called during map load, so we
// should also check STAT_TRAVELLING inventory
// worldonly: only checks for items that are placed in the world
static bool ItemExists( Class<Inventory> itm, Inventory skipme = null, bool mapstart = false, bool worldonly = false )
// ownedonly: only checks for items that are owned by players
// (note that this is mutually exclusive with worldonly)
static bool ItemExists( Class<Inventory> itm, Inventory skipme = null, bool mapstart = false, bool worldonly = false, bool ownedonly = false )
{
let ti = ThinkerIterator.Create(itm);
Inventory i;
@ -2125,6 +2127,7 @@ Class SWWMUtility
{
if ( i == skipme ) continue;
if ( worldonly && i.Owner ) continue;
if ( ownedonly && (!i.Owner || !i.Owner.player) ) continue;
return true;
}
if ( worldonly || !mapstart ) return false;
@ -2132,6 +2135,7 @@ Class SWWMUtility
while ( i = Inventory(ti.Next()) )
{
if ( i == skipme ) continue;
if ( ownedonly && (!i.Owner || !i.Owner.player) ) continue;
return true;
}
return false;