Page 1 of 1

SmallWeapons View Mutator>?!

Posted: Sun Nov 04, 2018 2:10 am
by ~{kRiD}~
Okay so there's this mod i found called "SmallWeapons" which replaces stock ut weps with a "smaller scale" weapon class. Inside the weapons class are new functions,
Spoiler
simulated function vector CalcDrawOffsetSmall();
{
local vector DrawOffset, WeaponBob;
local Pawn PawnOwner;

PawnOwner = Pawn(Owner);
DrawOffset = ((0.01 * PlayerViewOffset) >> PawnOwner.ViewRotation);

if ( (Level.NetMode == NM_DedicatedServer)
|| ((Level.NetMode == NM_ListenServer) && (Owner.RemoteRole == ROLE_AutonomousProxy)) )
DrawOffset += (PawnOwner.BaseEyeHeight * vect(0,0,1));
else
{
DrawOffset += (PawnOwner.EyeHeight * vect(0,0,1));
WeaponBob = BobDamping * PawnOwner.WalkBob;
WeaponBob.Z = (0.45 + 0.55 * BobDamping) * PawnOwner.WalkBob.Z;
DrawOffset += WeaponBob;
}
return DrawOffset;
}
Spoiler
simulated event RenderOverlays(canvas Canvas);
{
local PlayerPawn PlayerOwner;
local int realhand;

if ( (bMuzzleFlash > 0) && !Level.bDropDetail )
MFTexture = MuzzleFlashVariations[Rand(5)];
PlayerOwner = PlayerPawn(Owner);
if ( PlayerOwner != None )
{
if ( PlayerOwner.DesiredFOV != PlayerOwner.DefaultFOV )
return;
realhand = PlayerOwner.Handedness;
if ( (Level.NetMode == NM_Client) && (realHand == 2) )
{
bHideWeapon = true;
return;
}
if ( !bHideWeapon )
{
if ( Mesh == mesh'AutoML' )
PlayerOwner.Handedness = 1;
else if ( bIsSlave || (SlaveEnforcer != None) )
PlayerOwner.Handedness = -1;
}
}
if ( (PlayerOwner == None) || (PlayerOwner.Handedness == 0) )
{
if ( AnimSequence == 'Shot2' )
{
FlashO = -2 * Default.FlashO;
FlashY = Default.FlashY * 2.5;
}
else
{
FlashO = 1.9 * Default.FlashO;
FlashY = Default.FlashY;
}
}
else if ( AnimSequence == 'Shot2' )
{
FlashO = Default.FlashO * 0.3;
FlashY = Default.FlashY * 2.5;
}
else
{
FlashO = Default.FlashO;
FlashY = Default.FlashY;
}
if ( !bHideWeapon && ( (SlaveEnforcer != None) || bIsSlave ) )
{
if ( PlayerOwner == None )
bMuzzleFlash = 0;

SuperRenderOverlays(Canvas);
if ( SlaveEnforcer != None )
{
if ( SlaveEnforcer.bBringingUp )
{
SlaveEnforcer.bBringingUp = false;
SlaveEnforcer.PlaySelect();
}
SlaveEnforcer.RenderOverlays(Canvas);
}
}
else
SuperRenderOverlays(Canvas);

if ( PlayerOwner != None )
PlayerOwner.Handedness = realhand;
}
Spoiler
simulated function SuperRenderOverlays( canvas Canvas );
{
local rotator NewRot;
local bool bPlayerOwner;
local int Hand;
local PlayerPawn PlayerOwner;

if ( bHideWeapon || (Owner == None) )
return;

PlayerOwner = PlayerPawn(Owner);

if ( PlayerOwner != None )
{
if ( PlayerOwner.DesiredFOV != PlayerOwner.DefaultFOV )
return;
bPlayerOwner = true;
Hand = PlayerOwner.Handedness;

if ( (Level.NetMode == NM_Client) && (Hand == 2) )
{
bHideWeapon = true;
return;
}
}

if ( !bPlayerOwner || (PlayerOwner.Player == None) )
Pawn(Owner).WalkBob = vect(0,0,0);

if ( (bMuzzleFlash > 0) && bDrawMuzzleFlash && Level.bHighDetailMode && (MFTexture != None) )
{
MuzzleScale = Default.MuzzleScale * Canvas.ClipX/640.0;
if ( !bSetFlashTime )
{
bSetFlashTime = true;
FlashTime = Level.TimeSeconds + FlashLength;
}
else if ( FlashTime < Level.TimeSeconds )
bMuzzleFlash = 0;
if ( bMuzzleFlash > 0 )
{
if ( Hand == 0 )
Canvas.SetPos(Canvas.ClipX/2 - 0.5 * MuzzleScale * FlashS + Canvas.ClipX * (-0.2 * Default.FireOffset.Y * FlashO), Canvas.ClipY/2 - 0.5 * MuzzleScale * FlashS + Canvas.ClipY * (FlashY + FlashC));
else
Canvas.SetPos(Canvas.ClipX/2 - 0.5 * MuzzleScale * FlashS + Canvas.ClipX * (Hand * Default.FireOffset.Y * FlashO), Canvas.ClipY/2 - 0.5 * MuzzleScale * FlashS + Canvas.ClipY * FlashY);

Canvas.Style = 3;
Canvas.DrawIcon(MFTexture, MuzzleScale);
Canvas.Style = 1;
}
}
else
bSetFlashTime = false;

SetLocation( Owner.Location + CalcDrawOffsetSmall() );
NewRot = Pawn(Owner).ViewRotation;

if ( Hand == 0 )
newRot.Roll = -2 * Default.Rotation.Roll;
else
newRot.Roll = Default.Rotation.Roll * Hand;

setRotation(newRot);
Canvas.DrawActor(self, false);
}
and then the master mutato class withCheckReplacement to replace weapon classes....

would there be an easier way to do this? I would like to re-create for my custom weapons mod and also, possibly have it compatible with any other custom weapons mod .....

Re: SmallWeapons View Mutator>?!

Posted: Sun Nov 04, 2018 3:06 am
by JackGriffin
You can alter the scale of the displayed weapons pretty easily but it's going to look like shit if you care at all about details. In order to do this correctly you really need to dig into the weapon code itself and make the changes there. Then you can also account for the projectiles coming from where they need to be and the smoke effects, etc being in the right spot. To me it's illusion-breaking when this isn't accurate.