Added brightmaps and gldefs entries for most stuff. Imported a bunch of sprites, including some recycled stuff from old mods. Made new icons for the 0.83 status bar. Remade "Teleport Gun" model. Made new models for some ammo variants. Made skeleton code for a lot of stuff, this temporarily makes a lot of items disappear. Began working on ASMD. Flak Cannon has no projectiles yet.
236 lines
6.7 KiB
Text
236 lines
6.7 KiB
Text
// Backpack that only gives ammo for valid weapons
|
|
Class UnrealBackpack : BackpackItem replaces Backpack
|
|
{
|
|
override Inventory CreateCopy( Actor other )
|
|
{
|
|
// Find every unique type of ammoitem. Give it to the player if
|
|
// he doesn't have it already, and double its maximum capacity.
|
|
for ( int i=0; i<AllActorClasses.Size(); i++ )
|
|
{
|
|
let type = (class<Ammo>)(AllActorClasses[i]);
|
|
if ( !type || (type.GetParentClass() != 'Ammo') ) continue;
|
|
// check that it's for a valid weapon
|
|
bool isvalid = false;
|
|
for ( int j=0; j<AllActorClasses.Size(); j++ )
|
|
{
|
|
let type2 = (class<Weapon>)(AllActorClasses[j]);
|
|
if ( !type2 ) continue;
|
|
let rep = GetReplacement(type2);
|
|
if ( (rep != type2) && !(rep is "DehackedPickup") ) continue;
|
|
readonly<Weapon> weap = GetDefaultByType(type2);
|
|
if ( !other.player || !other.player.weapons.LocateWeapon(type2) || weap.bCheatNotWeapon ) continue;
|
|
if ( (weap.AmmoType1 == type) || (weap.AmmoType2 == type) )
|
|
{
|
|
isvalid = true;
|
|
break;
|
|
}
|
|
}
|
|
if ( !isvalid ) continue;
|
|
let ammoitem = Ammo(other.FindInventory(type));
|
|
int amount = GetDefaultByType(type).BackpackAmount;
|
|
// extra ammo in baby mode and nightmare mode
|
|
if ( !bIgnoreSkill ) amount = int(amount*G_SkillPropertyFloat(SKILLP_AmmoFactor));
|
|
if ( amount < 0 ) amount = 0;
|
|
if ( !ammoitem )
|
|
{
|
|
// The player did not have the ammoitem. Add it.
|
|
ammoitem = Ammo(Spawn(type));
|
|
ammoitem.Amount = bDepleted?0:amount;
|
|
if ( ammoitem.BackpackMaxAmount > ammoitem.MaxAmount )
|
|
ammoitem.MaxAmount = ammoitem.BackpackMaxAmount;
|
|
if ( ammoitem.Amount > ammoitem.MaxAmount )
|
|
ammoitem.Amount = ammoitem.MaxAmount;
|
|
ammoitem.AttachToOwner(other);
|
|
}
|
|
else
|
|
{
|
|
// The player had the ammoitem. Give some more.
|
|
if ( ammoitem.MaxAmount < ammoitem.BackpackMaxAmount )
|
|
ammoitem.MaxAmount = ammoitem.BackpackMaxAmount;
|
|
if ( !bDepleted && (ammoitem.Amount < ammoitem.MaxAmount) )
|
|
{
|
|
ammoitem.Amount += amount;
|
|
if ( ammoitem.Amount > ammoitem.MaxAmount )
|
|
ammoitem.Amount = ammoitem.MaxAmount;
|
|
}
|
|
}
|
|
}
|
|
return Inventory.CreateCopy(other);
|
|
}
|
|
override bool HandlePickup( Inventory item )
|
|
{
|
|
// Since you already have a backpack, that means you already have every
|
|
// kind of ammo in your inventory, so we don't need to look at the
|
|
// entire PClass list to discover what kinds of ammo exist, and we don't
|
|
// have to alter the MaxAmount either.
|
|
if ( item is 'BackpackItem' )
|
|
{
|
|
for ( let probe = Owner.Inv; probe; probe = probe.Inv )
|
|
{
|
|
if ( probe.GetParentClass() != 'Ammo' ) continue;
|
|
if ( probe.Amount >= probe.MaxAmount && !sv_unlimited_pickup ) continue;
|
|
int amount = Ammo(probe).Default.BackpackAmount;
|
|
// extra ammo in baby mode and nightmare mode
|
|
if ( !bIgnoreSkill )
|
|
amount = int(amount*G_SkillPropertyFloat(SKILLP_AmmoFactor));
|
|
probe.Amount += amount;
|
|
if ( (probe.Amount > probe.MaxAmount) && !sv_unlimited_pickup )
|
|
probe.Amount = probe.MaxAmount;
|
|
}
|
|
// The pickup always succeeds, even if you didn't get anything
|
|
item.bPickupGood = true;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
override void DoPickupSpecial( Actor toucher )
|
|
{
|
|
Super.DoPickupSpecial(toucher);
|
|
if ( gameinfo.gametype&GAME_DOOMCHEX )
|
|
{
|
|
static const Class<Inventory> xitems[] = {"Flare", "Seeds", "SentryItem", "VoiceBox", "ForceField", "Dampener"};
|
|
int xitemn[6];
|
|
xitemn[0] = max(0,Random[BackpackExtra](-3,5));
|
|
xitemn[1] = max(0,Random[BackpackExtra](-3,5));
|
|
xitemn[2] = max(0,Random[BackpackExtra](-4,1));
|
|
xitemn[3] = max(0,Random[BackpackExtra](-2,1));
|
|
xitemn[4] = max(0,Random[BackpackExtra](-3,1));
|
|
xitemn[5] = max(0,Random[BackpackExtra](-2,1));
|
|
// random doubling
|
|
if ( !Random[BackpackExtra](0,4) ) xitemn[0] *= 2;
|
|
if ( !Random[BackpackExtra](0,4) ) xitemn[1] *= 2;
|
|
if ( !Random[BackpackExtra](0,9) ) xitemn[2] *= 2;
|
|
if ( !Random[BackpackExtra](0,7) ) xitemn[3] *= 2;
|
|
if ( !Random[BackpackExtra](0,6) ) xitemn[4] *= 2;
|
|
if ( !Random[BackpackExtra](0,5) ) xitemn[5] *= 2;
|
|
int total = 0;
|
|
for ( int i=0; i<6; i++ ) total += xitemn[i];
|
|
if ( total <= 0 ) return;
|
|
String extratxt = StringTable.Localize("$I_BACKPACKEXTRA");
|
|
for ( int i=0; i<6; i++ )
|
|
{
|
|
if ( xitemn[i] <= 0 ) continue;
|
|
extratxt = extratxt..String.Format("%dx %s, ",xitemn[i],GetDefaultByType(xitems[i]).GetTag());
|
|
toucher.GiveInventory(xitems[i],xitemn[i]);
|
|
}
|
|
// remove trailing comma
|
|
extratxt.Truncate(extratxt.Length()-2);
|
|
PrintPickupMessage(true,extratxt..".");
|
|
}
|
|
}
|
|
Default
|
|
{
|
|
Tag "$T_BACKPACK";
|
|
Inventory.PickupMessage "$I_BACKPACK";
|
|
Inventory.RespawnTics 2100;
|
|
}
|
|
States
|
|
{
|
|
Spawn:
|
|
BPAK A -1;
|
|
Stop;
|
|
}
|
|
}
|
|
|
|
Class UTranslator : UnrealInventory
|
|
{
|
|
bool bCurrentlyActivated, bNewMessage, bNotNewMessage, bShowHint;
|
|
string NewMessage, Hint;
|
|
ui TextureID thud;
|
|
ui Font tfnt;
|
|
|
|
ui void DrawTranslator( Vector2 scalev, double ClipX, double ClipY )
|
|
{
|
|
if ( thud.IsNull() ) thud = TexMan.CheckForTexture("TranHUD3",TexMan.Type_Any);
|
|
if ( !tfnt ) tfnt = Font.FindFont('UTahoma10');
|
|
double CurX, CurY;
|
|
CurX = ClipX/2-128;
|
|
CurY = ClipY/2-68;
|
|
Screen.DrawTexture(thud,false,CurX,CurY,DTA_VirtualWidthF,ClipX,DTA_VirtualHeightF,ClipY,DTA_KeepRatio,true);
|
|
String ttxt;
|
|
if ( bShowHint && (Hint.length() > 0) ) ttxt = String.Format("%s: %s",StringTable.Localize("$TR_HINT"),Hint);
|
|
else if ( NewMessage.length() > 0 ) ttxt = NewMessage;
|
|
else ttxt = StringTable.Localize("$TR_NOMSG");
|
|
BrokenLines lines = tfnt.BreakLines(ttxt,220);
|
|
int th = tfnt.GetHeight();
|
|
CurX += 20;
|
|
CurY += 18;
|
|
for ( int i=0; i<lines.Count() && i<(110/th); i++ )
|
|
{
|
|
Screen.DrawText(tfnt,Font.CR_GREEN,CurX,CurY,lines.StringAt(i),DTA_VirtualWidthF,ClipX,DTA_VirtualHeightF,ClipY,DTA_KeepRatio,true);
|
|
CurY += th-1;
|
|
}
|
|
}
|
|
|
|
override void Travelled()
|
|
{
|
|
Super.Travelled();
|
|
NewMessage = Hint = "";
|
|
}
|
|
|
|
override bool Use( bool pickup )
|
|
{
|
|
if ( pickup ) return false;
|
|
bActive = bCurrentlyActivated = !bCurrentlyActivated;
|
|
if ( !bActive ) bShowHint = bNewMessage = bNotNewmessage = false;
|
|
return false;
|
|
}
|
|
|
|
Default
|
|
{
|
|
Tag "$T_TRANSLATOR";
|
|
Inventory.PickupMessage "$I_TRANSLATOR";
|
|
Inventory.Icon "I_Tran";
|
|
Inventory.MaxAmount 1;
|
|
}
|
|
}
|
|
|
|
Class VoiceBox : UnrealInventory
|
|
{
|
|
}
|
|
|
|
Class Flare : UnrealInventory
|
|
{
|
|
}
|
|
|
|
Class LightFlare : UnrealInventory
|
|
{
|
|
}
|
|
|
|
Class DarkFlare : UnrealInventory
|
|
{
|
|
}
|
|
|
|
Class Dampener : UnrealInventory
|
|
{
|
|
static bool Active( Actor Owner )
|
|
{
|
|
let d = Dampener(Owner.FindInventory("Dampener"));
|
|
if ( d && d.bActive ) return true;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
Class Forcefield : UnrealInventory
|
|
{
|
|
}
|
|
|
|
Class ForcefieldEffect : Actor
|
|
{
|
|
}
|
|
|
|
Class UFlashlight : UnrealInventory
|
|
{
|
|
}
|
|
|
|
Class USearchlight : UnrealInventory
|
|
{
|
|
}
|
|
|
|
Class SentryItem : UnrealInventory
|
|
{
|
|
}
|
|
|
|
Class MinigunSentry : Actor
|
|
{
|
|
}
|