[Solved]MH2GoldCTG : Forced weapons position :

Discussions about Coding and Scripting
User avatar
Letylove49
Masterful
Posts: 537
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2GoldCTG : Forced weapons position :

Post by Letylove49 »

i will creat a variable for each weapons like

var float EnforcerHand; and this for all the weepons i want to force the Hand position and ignore client settings.




this function must do:

check if settings on client is for exemple 2 and on MH2Base the position of the hand of the weapons has been set 1. the must set to the client the position 1 insteat of 2.   
Auto merged new post submitted 2 hours 19 minutes later
ok i have try this but that doesn't work....

exec Function bool setHand( float Mh2RifleHand )
{

//Change value to new value if the weapon is not on center.


if(MH2RifleHand!=1)
Mh2RifleHand = 1 ;


}
i have added the variable MH2RifleHand on MH2Rifle class
Image
Image
Letylove49 aka Alicia
User avatar
Letylove49
Masterful
Posts: 537
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2GoldCTG : Forced weapons position :

Post by Letylove49 »

ok now i have someting but doesn't work :
if(UseAltSniper)
{
GiveWeapon(Other,class'MH2Rifle');

if(bDebugForceposition)
playerpawn(other).ClientMessage( "MH2RifleHand" @ MH2RifleHand);

if (CAPS(other.weapon)==caps("mh2rifle") )

if(MH2RifleHand==1)
Playerpawn(other).ConsoleCommand("setHand Center" );
}
if(UseMH2SniperRifle)
{
GiveWeapon(Other,class'MH2SniperRifle');

if(bDebugForceposition)
playerpawn(other).ClientMessage( "MH2SniperHand" @ MH2SniperHand);

if (CAPS(other.weapon)==caps("MH2sniperRifle") )
if(MH2SniperHand==1)
Playerpawn(other).ConsoleCommand("setHand Center" );
}

else
if (CAPS(other.weapon)!=caps("MH2sniperRifle"))
if (CAPS(other.weapon)!=caps("MH2Rifle"))
if(Hand==2)
Playerpawn(other).ConsoleCommand("setHand Right" );

}
Pehaps i have forgot some "{" and "}" ???
Image
Image
Letylove49 aka Alicia
User avatar
DsL444
Novice
Posts: 29
Joined: Tue Sep 12, 2023 5:21 pm
Location: Germany

Re: MH2GoldCTG : Forced weapons position :

Post by DsL444 »

The hand position must be enforced inside the weapon while it is rendered.

Weapon rendering is client-side. Temporarily overriding PlayerPawn.Handedness during RenderOverlays() reliably enforces the weapon position without console commands or mutators.

Code: Select all

class MH2Rifle extends TournamentWeapon;

var() config float ForceHand; // -1 = left, 0 = center, 1 = right, 2 = client

simulated function RenderOverlays(Canvas C)
{
    local PlayerPawn PP;
    local float OldHand;

    PP = PlayerPawn(Owner);
    if (PP == None)
    {
        Super.RenderOverlays(C);
        return;
    }

    OldHand = PP.Handedness;

    if (ForceHand != 2)
        PP.Handedness = ForceHand;

    Super.RenderOverlays(C);

    PP.Handedness = OldHand;
}

Code: Select all

defaultproperties
{
    ForceHand=0 // always center
}
Try this, think this should work.
:sniper1:
=============
Join us on Discord! :tu: https://discord.gg/2ZZwYhwpVE
User avatar
Letylove49
Masterful
Posts: 537
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2GoldCTG : Forced weapons position :

Post by Letylove49 »

sorry but that doesn't work.

Your code sugestion:
simulated function RenderOverlays(Canvas C)
{
local PlayerPawn PP;
local float OldHand;

PP = PlayerPawn(Owner);
if (PP == None)
{
Super.RenderOverlays(C);
return;
}

OldHand = PP.Handedness;

if (ForceHand != 2)
PP.Handedness = ForceHand;

Super.RenderOverlays(C);

PP.Handedness = OldHand;
}

// original code: Pehaps i should change it ?
function setHand(float Hand)
{





Super.SetHand(Hand);
if ( Hand == 1 )



{
Mesh = mesh(DynamicLoadObject("Botpack.Rifle2mL", class'Mesh'));
MultiSkins[0] =Texture'MH2GoldCTGv5e.Rifle.AA';
MultiSkins[1] =Texture'MH2GoldCTGv5e.Rifle.SR';
MultiSkins[3] =Texture'MH2GoldCTGv5e.Skins.Rifle2d';
}
else
{
Mesh = mesh'Rifle2m';
MultiSkins[0] =Texture'MH2GoldCTGv5e.Rifle.AA';
MultiSkins[1] =Texture'MH2GoldCTGv5e.Rifle.SR';
MultiSkins[3] =Texture'MH2GoldCTGv5e.Rifle.Rifle2d';
}
}
   
Auto merged new post submitted 1 hour 25 minutes later
now that work but that force all the weapons no only the sniper.

if(UseAltSniper)
{
GiveWeapon(Other,class'MH2Rifle');



if(bDebugForceposition)
playerpawn(other).ClientMessage( "MH2RifleHand" @ MH2RifleHand);

if (CAPS(other.weapon)==caps("mh2rifle") )
if(MH2RifleHand==1)
if(Other.Class==class'MH2Rifle' || Other.Class==class'MH2SniperRifle' || Other.Class==class'SniperRifle')
Playerpawn(other).ConsoleCommand("setHand Center" );
else
if(Hand!=1)
Playerpawn(other).ConsoleCommand("setHand Right" );
}

else
GiveWeapon(Other,class'botpack.sniperRifle');
Image
Image
Letylove49 aka Alicia
User avatar
DsL444
Novice
Posts: 29
Joined: Tue Sep 12, 2023 5:21 pm
Location: Germany

Re: MH2GoldCTG : Forced weapons position :

Post by DsL444 »

Unfortunately, this behavior is exactly what you'd expect: `setHand` sets the global handedness of the PlayerPawn.

This isn't a "weapon setting," but a player setting. If you force it to Center, all weapons will be affected. UT99 is wonderfully inflexible in this regard.

And your code has two more specific problems on top of that:

Incorrect object checked
`Other` in `ModifyPlayer(Pawn Other)` is a Pawn, not a Weapon.

`Other.Class==class'MH2Rifle'` will therefore never be true.

Weapon string comparison is incorrect
`CAPS(other.weapon)==caps("mh2rifle")` is nonsense because `Other.Weapon` is an object.

Corrected logic in MH2Rifle (this weapon only)

Code: Select all

var() config float ForceHand; // -1 left, 0 center, 1 right, 2 client

simulated function RenderOverlays(Canvas Canvas)
{
    local PlayerPawn P;
    local float OldHand;

    P = PlayerPawn(Owner);
    if (P != None && ForceHand != 2)
    {
        OldHand = P.Handedness;
        P.Handedness = ForceHand;

        Super.RenderOverlays(Canvas);

        P.Handedness = OldHand;
        return;
    }

    Super.RenderOverlays(Canvas);
}

defaultproperties
{
    ForceHand=0 // Center MH2Rifle
}
:sniper1:
=============
Join us on Discord! :tu: https://discord.gg/2ZZwYhwpVE
User avatar
Letylove49
Masterful
Posts: 537
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2GoldCTG : Forced weapons position :

Post by Letylove49 »

Same i set the configuration on MH2Rilfe.uc that force on center all the weapons. same if it set ForceHand=2 on the others weapons the orthers weapons stay at the center.

For MH2Rifle
function setHand(float Hand)
{

ForceHand=0;



Super.SetHand(Hand);
if ( Hand == 1 )
For others weapons:
function setHand(float Hand)
{

ForceHand=2;



Super.SetHand(Hand);
if ( Hand == 1 )
i have ask to the patch team if they can add an option for that.

https://github.com/OldUnreal/UnrealTour ... ssues/1984   
Auto merged new post submitted 1 hour 44 minutes later
i have try to forceHand=1 but that not effet
Image
Image
Letylove49 aka Alicia
User avatar
Letylove49
Masterful
Posts: 537
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2GoldCTG : Forced weapons position :

Post by Letylove49 »

DsL444 wrote: ↑Mon Feb 02, 2026 8:32 am Unfortunately, this behavior is exactly what you'd expect: `setHand` sets the global handedness of the PlayerPawn.

This isn't a "weapon setting," but a player setting. If you force it to Center, all weapons will be affected. UT99 is wonderfully inflexible in this regard.

in this case i would like to ask if there are ways to get around the problem with a mutator. ?
Image
Image
Letylove49 aka Alicia
User avatar
Letylove49
Masterful
Posts: 537
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2GoldCTG : Forced weapons position :

Post by Letylove49 »



Class MH2RifleReplacer expands Mutator config(MH2RifleReplacer);

var float hand;
var int AmmoAmmount;
var int MaxAmmo;
var bool bGiveMaxAmmo;

var bool bInitialized;

function PreBeginPlay()
{
if ( !bInitialized )
{
bInitialized = True;
Self.NextMutator = Level.Game.BaseMutator.NextMutator;
}
}

function bool CheckReplacement(Actor Other, out byte bSuperRelevant) // replace sniper by MH2Rilfe)
{
Local int AmmoAmmount;
Local int MaxAmmo;


if(Other.Class==Class'SniperRifle')
{
ReplaceWith(Other,"MH2GoldCTGv5j.MH2Rifle");
return false;


if(GiveMaxAmmo)
{
AmmoAmmount = Maxammo
}
else
AmmoAmmount = AmmoAmmount;
}
}


function setHand(float Hand) // set Hand position for the sniper and MH2Rifle)
{


Super.SetHand(Hand);

if(Other.Class==Class'MH2Rifle') || if(Other.Class==Class'SniperRifle')
{
Hand=1;
}
else
Hand =2;
}

defaultproperties
{
AmmoAmmount=50
MaxAmmo=500
bGiveMaxAmmo=True
}

i got this error with the Function Sethand why ?

Code: Select all

Compiling MH2RifleReplacer
Error in MH2RifleReplacer.uc (45): Unknown Function 'SetHand' in 'Class Engine.Mutator' 
Image
Image
Letylove49 aka Alicia
User avatar
Letylove49
Masterful
Posts: 537
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: [Solved]MH2GoldCTG : Forced weapons position :

Post by Letylove49 »

Image
Image
Letylove49 aka Alicia