[solved]how to make thrown weapons stay permanent?

Discussions about Coding and Scripting
Post Reply
Dennis
Average
Posts: 72
Joined: Tue Jan 12, 2021 9:18 pm

[solved]how to make thrown weapons stay permanent?

Post by Dennis »

When a player toss a weapon using the ThrowWeapon command it drops to be picked up again but only for a set time then it disapears. I figure there is a timer of some sort that either needs to be disabled or a default property that needs to be set for the inventory item that is beeing dropped. I want tossed inventory to remain in the game until end or when picked up again. Any good ideas how to do this? I have been going through every actor from <actor> up the tree to the weapon itself but are not able to see where/how this time is set and where/how the item is destroyed()?
Last edited by Dennis on Sun Jun 05, 2022 11:22 am, edited 1 time in total.
Fraggers hangout place: http://fraggers.online/
User avatar
OjitroC
Godlike
Posts: 3656
Joined: Sat Sep 12, 2015 8:46 pm

Re: how to make thrown weapons stay permanent?

Post by OjitroC »

It is in the code for Actor -> Inventory (bTossedOut is when a weapon has been thrown out by a PlayerPawn)
Spoiler
// Pickup state: this inventory item is sitting on the ground.

auto state Pickup
{
singular function ZoneChange( ZoneInfo NewZone )
{
local float splashsize;
local actor splash;

if( NewZone.bWaterZone && !Region.Zone.bWaterZone )
{
splashSize = 0.000025 * Mass * (250 - 0.5 * Velocity.Z);
if ( NewZone.EntrySound != None )
PlaySound(NewZone.EntrySound, SLOT_Interact, splashSize);
if ( NewZone.EntryActor != None )
{
splash = Spawn(NewZone.EntryActor);
if ( splash != None )
splash.DrawScale = 2 * splashSize;
}
}
}

// Validate touch, and if valid trigger event.
function bool ValidTouch( actor Other )
{
local Actor A;

if( Other.bIsPawn && Pawn(Other).bIsPlayer && (Pawn(Other).Health > 0) && Level.Game.PickupQuery(Pawn(Other), self) )
{
if( Event != '' )
foreach AllActors( class 'Actor', A, Event )
A.Trigger( Other, Other.Instigator );
return true;
}
return false;
}

// When touched by an actor.
function Touch( actor Other )
{
// If touched by a player pawn, let him pick this up.
if( ValidTouch(Other) )
{
if (Level.Game.LocalLog != None)
Level.Game.LocalLog.LogPickup(Self, Pawn(Other));
if (Level.Game.WorldLog != None)
Level.Game.WorldLog.LogPickup(Self, Pawn(Other));
SpawnCopy(Pawn(Other));
if ( PickupMessageClass == None )
Pawn(Other).ClientMessage(PickupMessage, 'Pickup');
else
Pawn(Other).ReceiveLocalizedMessage( PickupMessageClass, 0, None, None, Self.Class );
PlaySound (PickupSound);
if ( Level.Game.Difficulty > 1 )
Other.MakeNoise(0.1 * Level.Game.Difficulty);
if ( Pawn(Other).MoveTarget == self )
Pawn(Other).MoveTimer = -1.0;
}
else if ( bTossedOut && (Other.Class == Class)
&& Inventory(Other).bTossedOut )
Destroy();
}

// Landed on ground.
function Landed(Vector HitNormal)
{
local rotator newRot;
newRot = Rotation;
newRot.pitch = 0;
netUpdateFrequency = Default.NetUpdateFrequency;
SetRotation(newRot);
SetTimer(2.0, false);
}

// Make sure no pawn already touching (while touch was disabled in sleep).
function CheckTouching()
{
local int i;

bSleepTouch = false;
for ( i=0; i<4; i++ )
if ( (Touching != None) && Touching.IsA('Pawn') )
Touch(Touching);
}

function Timer()
{
if ( RemoteRole != ROLE_SimulatedProxy )
{
NetPriority = 1.4;
RemoteRole = ROLE_SimulatedProxy;
if ( bHeldItem )
{
if ( bTossedOut )
SetTimer(15.0, false);
else
SetTimer(40.0, false);
}
return;
}

if ( bHeldItem )
{
if ( (FRand() < 0.1) || !PlayerCanSeeMe() )
Destroy();
else
SetTimer(3.0, true);
}
}

function BeginState()
{
BecomePickup();
bCollideWorld = true;
if ( bHeldItem )
SetTimer(30, false);
else if ( Level.bStartup )
{
bAlwaysRelevant = true;
NetUpdateFrequency = 8;
}
}

function EndState()
{
bCollideWorld = false;
bSleepTouch = false;
}

Begin:
BecomePickup();
if ( bRotatingPickup && (Physics != PHYS_Falling) )
SetPhysics(PHYS_Rotating);

Dropped:
if( bAmbientGlow )
AmbientGlow=255;
if( bSleepTouch )
CheckTouching();
}


The UnCodex at https://www.madrixis.de/undox/overview.html is good to use when looking for this kind of thing.
User avatar
sektor2111
Godlike
Posts: 6413
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: how to make thrown weapons stay permanent?

Post by sektor2111 »

And bHeldItem is involved too - actually in my works I did exactly a sort of clone for said timer due to fixes applied, because... they were too many spread on the ground at a moment, just stacking actors and even being thrown in a damage zone where Bots were permanently jumping for them, dying, dropping other weapons, then trying to get new dropped ones too and so on...
Dennis
Average
Posts: 72
Joined: Tue Jan 12, 2021 9:18 pm

Re: how to make thrown weapons stay permanent?

Post by Dennis »

OjitroC wrote: Sun Jun 05, 2022 12:26 am It is in the code for Actor -> Inventory (bTossedOut is when a weapon has been thrown out by a PlayerPawn)
Spoiler
// Pickup state: this inventory item is sitting on the ground.

auto state Pickup
{
singular function ZoneChange( ZoneInfo NewZone )
{
local float splashsize;
local actor splash;

if( NewZone.bWaterZone && !Region.Zone.bWaterZone )
{
splashSize = 0.000025 * Mass * (250 - 0.5 * Velocity.Z);
if ( NewZone.EntrySound != None )
PlaySound(NewZone.EntrySound, SLOT_Interact, splashSize);
if ( NewZone.EntryActor != None )
{
splash = Spawn(NewZone.EntryActor);
if ( splash != None )
splash.DrawScale = 2 * splashSize;
}
}
}

// Validate touch, and if valid trigger event.
function bool ValidTouch( actor Other )
{
local Actor A;

if( Other.bIsPawn && Pawn(Other).bIsPlayer && (Pawn(Other).Health > 0) && Level.Game.PickupQuery(Pawn(Other), self) )
{
if( Event != '' )
foreach AllActors( class 'Actor', A, Event )
A.Trigger( Other, Other.Instigator );
return true;
}
return false;
}

// When touched by an actor.
function Touch( actor Other )
{
// If touched by a player pawn, let him pick this up.
if( ValidTouch(Other) )
{
if (Level.Game.LocalLog != None)
Level.Game.LocalLog.LogPickup(Self, Pawn(Other));
if (Level.Game.WorldLog != None)
Level.Game.WorldLog.LogPickup(Self, Pawn(Other));
SpawnCopy(Pawn(Other));
if ( PickupMessageClass == None )
Pawn(Other).ClientMessage(PickupMessage, 'Pickup');
else
Pawn(Other).ReceiveLocalizedMessage( PickupMessageClass, 0, None, None, Self.Class );
PlaySound (PickupSound);
if ( Level.Game.Difficulty > 1 )
Other.MakeNoise(0.1 * Level.Game.Difficulty);
if ( Pawn(Other).MoveTarget == self )
Pawn(Other).MoveTimer = -1.0;
}
else if ( bTossedOut && (Other.Class == Class)
&& Inventory(Other).bTossedOut )
Destroy();
}

// Landed on ground.
function Landed(Vector HitNormal)
{
local rotator newRot;
newRot = Rotation;
newRot.pitch = 0;
netUpdateFrequency = Default.NetUpdateFrequency;
SetRotation(newRot);
SetTimer(2.0, false);
}

// Make sure no pawn already touching (while touch was disabled in sleep).
function CheckTouching()
{
local int i;

bSleepTouch = false;
for ( i=0; i<4; i++ )
if ( (Touching != None) && Touching.IsA('Pawn') )
Touch(Touching);
}

function Timer()
{
if ( RemoteRole != ROLE_SimulatedProxy )
{
NetPriority = 1.4;
RemoteRole = ROLE_SimulatedProxy;
if ( bHeldItem )
{
if ( bTossedOut )
SetTimer(15.0, false);
else
SetTimer(40.0, false);
}
return;
}

if ( bHeldItem )
{
if ( (FRand() < 0.1) || !PlayerCanSeeMe() )
Destroy();
else
SetTimer(3.0, true);
}
}

function BeginState()
{
BecomePickup();
bCollideWorld = true;
if ( bHeldItem )
SetTimer(30, false);
else if ( Level.bStartup )
{
bAlwaysRelevant = true;
NetUpdateFrequency = 8;
}
}

function EndState()
{
bCollideWorld = false;
bSleepTouch = false;
}

Begin:
BecomePickup();
if ( bRotatingPickup && (Physics != PHYS_Falling) )
SetPhysics(PHYS_Rotating);

Dropped:
if( bAmbientGlow )
AmbientGlow=255;
if( bSleepTouch )
CheckTouching();
}


The UnCodex at https://www.madrixis.de/undox/overview.html is good to use when looking for this kind of thing.


Thank you! I must have gone blind scanning the code because I went right pass that Timer function. very easy fix to just comment out the Destroy() call like this:

Code: Select all

function Timer()
{
if ( RemoteRole != ROLE_SimulatedProxy )
{
NetPriority = 1.4;
RemoteRole = ROLE_SimulatedProxy;
if ( bHeldItem )
{
if ( bTossedOut )
SetTimer(15.0, false);
else
SetTimer(40.0, false);
}
return;
}

/* if ( bHeldItem )
{
if ( (FRand() < 0.1) || !PlayerCanSeeMe() )
Destroy();
else
SetTimer(3.0, true);
}*/
}
Fraggers hangout place: http://fraggers.online/
User avatar
Barbie
Godlike
Posts: 2809
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: how to make thrown weapons stay permanent?

Post by Barbie »

OjitroC wrote: Sun Jun 05, 2022 12:26 am The UnCodex at https://www.madrixis.de/undox/overview.html is good to use when looking for this kind of thing.
If you link to https://www.madrixis.de/undox/ you'll get the navigation frames, too.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Buggie
Godlike
Posts: 2749
Joined: Sat Mar 21, 2020 5:32 am

Re: [solved]how to make thrown weapons stay permanent?

Post by Buggie »

You can make Mutator, which once per second walk over all Weapons and set bTossedOut to false for each.
This must be enough for make all tossed weapons permanent. And no need modify code, so it compatible with any weapon.

Someone :wink: can even implement such thing on own server...
Post Reply