Fix ammo drops in "on-demand" replacement mode.

This commit is contained in:
Mari the Deer 2021-09-16 21:09:33 +02:00
commit 182c209080
4 changed files with 58 additions and 9 deletions

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\chSWWM \czGZ\c- \cw1.1pre r24 \cu(Thu 16 Sep 20:28:45 CEST 2021)\c-";
SWWM_SHORTVER="\cw1.1pre r24 \cu(2021-09-16 20:28:45)\c-";
SWWM_MODVER="\chSWWM \czGZ\c- \cw1.1pre r25 \cu(Thu 16 Sep 21:09:33 CEST 2021)\c-";
SWWM_SHORTVER="\cw1.1pre r25 \cu(2021-09-16 21:09:33)\c-";

View file

@ -1,11 +1,44 @@
// on-demand ammo spawners
Mixin Class SWWMOndemandAmmoSpawner
{
Actor dropper;
bool enemydrop;
int dropamount;
override void ModifyDropAmount( int amt )
{
dropamount = amt;
}
override bool SpecialDropAction( Actor dropper )
{
self.dropper = dropper;
enemydrop = true;
return false;
}
override void SpawnAmmo()
{
let ac = PickAmmo();
if ( !ac ) return;
let a = Spawn(ac,pos);
if ( enemydrop )
{
a.bDropped = true;
a.bNoGravity = false;
if ( !(level.compatflags&COMPATF_NOTOSSDROPS) )
a.TossItem();
if ( a is 'Inventory' )
{
let i = Inventory(a);
i.bTossed = true;
if ( i.SpecialDropAction(dropper) )
{
i.Destroy();
return;
}
}
}
SWWMUtility.TransferItemProp(self,a);
}
}

View file

@ -579,7 +579,7 @@ Class MagAmmo : Inventory abstract
}
// Ref class for ammo spawners, used by on-demand replacers
Class SWWMAmmoSpawner : Actor abstract
Class SWWMAmmoSpawner : Inventory abstract
{
virtual void SpawnAmmo() {}
@ -590,6 +590,16 @@ Class SWWMAmmoSpawner : Actor abstract
Destroy();
}
override bool CanPickup( Actor toucher )
{
return false;
}
override bool TryPickup( in out Actor toucher )
{
return false;
}
default
{
+NOGRAVITY;
@ -597,5 +607,6 @@ Class SWWMAmmoSpawner : Actor abstract
+NOINTERACTION;
+NOTELEPORT;
+DONTSPLASH;
-SPECIAL;
}
}

View file

@ -12,6 +12,7 @@ Class SWWMWeapon : Weapon abstract
String tooltip;
bool tooltipsent;
Class<Ammo> dropammotype;
int dropamount;
Property Tooltip : tooltip;
Property DropAmmoType : dropammotype;
@ -395,6 +396,7 @@ Class SWWMWeapon : Weapon abstract
}
override void ModifyDropAmount( int dropamount )
{
self.dropamount = dropamount;
Super.ModifyDropAmount(dropamount);
if ( (AmmoGive1 <= 0) && (default.AmmoGive1 > 0) )
AmmoGive1 = 1;
@ -412,17 +414,20 @@ Class SWWMWeapon : Weapon abstract
return false; // drop us
// drop our corresponding ammo
if ( !DropAmmoType ) return true;
let a = Inventory(Spawn(DropAmmoType,pos,ALLOW_REPLACE));
let a = Spawn(DropAmmoType,pos,ALLOW_REPLACE);
if ( !a ) return true;
a.bDROPPED = true;
a.bNOGRAVITY = false;
if ( !(level.compatflags&COMPATF_NOTOSSDROPS) )
a.TossItem();
if ( a is 'Ammo' )
a.ModifyDropAmount(Ammo(a).DropAmount);
a.bTOSSED = true;
if ( a.SpecialDropAction(dropper) )
a.Destroy();
if ( a is 'Inventory' )
{
let i = Inventory(a);
i.ModifyDropAmount(dropamount);
i.bTOSSED = true;
if ( i.SpecialDropAction(dropper) )
i.Destroy();
}
return true;
}
// no weapon drops from enemies