• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Weapon pickup needed

You don't need code.

Change the weapon which is picked up:
Just create a Panzerfaust Pick Up base/actor (look in the SDK manual if you don't know how to place this actor). Then go to the properties and change the picked up weapon into an Sniper rifle (it's in the bottom half in the RO ammo or something category if you find the pull down menu you are close).

Change the mesh from a Panzerfaust to a sniper rifle:
Then open the Static mesh browser and open the WeaponPick up package (or something like that :eek:) and select the sniper rifle and go to your PickUp properties to Display and change the mesh by clicking on use.

This should work if you can understand my hints :eek:

But I don't know how to change the text (you will notice it if you try to pick up the rifle)
 
Upvote 0
Ok then, I've done this so far. What next?

Code:
//===================================================================
// MyROK98ScopedPickup
//
// A placeable K98 scoped pickup for mappers to put in their map
//===================================================================
class MyROK98ScopedPickup extends ROPlaceableAmmoPickup;

var() class<Inventory> WeaponType;

static function StaticPrecache(LevelInfo L)
{
	L.AddPrecacheStaticMesh(StaticMesh'WeaponPickupSM.Weapons.k98scoped');
	L.AddPrecacheMaterial(Material'Weapons3rd_tex.German.Kar98_world');
	L.AddPrecacheMaterial(Material'Weapons3rd_tex.German.Kars98_scope_world');
	L.AddPrecacheMaterial(Material'Weapons1st_tex.Rifles.k98_sniper_s');
}

auto state Pickup
{
	function bool ReadyToPickup(float MaxWait)
	{
		return true;
	}

	/* ValidTouch()
	 Validate touch (if valid return true to let other pick me up and trigger event).
	*/
	function bool ValidTouch( actor Other )
	{
		// make sure its a live player
		if ( (Pawn(Other) == None) || !Pawn(Other).bCanPickupInventory || (Pawn(Other).Health <= 0) || (Pawn(Other).DrivenVehicle == None && Pawn(Other).Controller == None))
			return false;

		if( ROPawn(Other) != none && ROPawn(Other).AutoTraceActor != none && ROPawn(Other).AutoTraceActor == self )
		{
			// do nothing
		}
		// make sure not touching through wall
		else if ( !FastTrace(Other.Location, Location) )
			return false;

		// make sure game will let player pick me up
		if( Level.Game.PickupQuery(Pawn(Other), self) )
		{
			TriggerEvent(Event, self, Pawn(Other));
			return true;
		}
		return false;
	}

	// When touched by an actor.
	function Touch( actor Other )
	{
	}

	function CheckTouching()
	{
	}

	function UsedBy( Pawn user )
	{
    	local Inventory Copy;
    	local inventory Inv;
    	local bool bHasWeapon;

		if( user == none )
			return;

	   	// check if Other has a primary weapon
		if( user != none && user.Inventory != none )
		{
			for ( Inv=user.Inventory; Inv!=None; Inv=Inv.Inventory )
			{
				if ( Inv != none && Weapon(Inv) != None )
				{
					if( Inv.class == WeaponType)
					{
						if( Weapon(Inv).AmmoMaxed(0) )
							return;
						else
							bHasWeapon = true;
					}
				}
			}
		}

		// valid touch will pickup the object
		if( ValidTouch( user ) )
		{
			if( bHasWeapon )
				Copy = SpawnCopy(user);
			else
				Copy = SpawnWeaponCopy(user);

			AnnouncePickup(user);
            if ( Copy != None )
				Copy.PickupFunction(user);

			SetRespawn();
		}
	}

	function Timer()
	{
		if ( bDropped )
			GotoState('FadeOut');
	}

	function BeginState()
	{
		UntriggerEvent(Event, self, None);
		if ( bDropped )
        {
			AddToNavigation();
		    SetTimer(DropLifeTime, false);
        }
	}

	function EndState()
	{
		if ( bDropped )
			RemoveFromNavigation();
	}

Begin:
	CheckTouching();
}

//
// Set up respawn waiting if desired.
//
function SetRespawn()
{
	StartSleeping();
}

function inventory SpawnWeaponCopy( pawn Other )
{
	local inventory Copy;

	if ( Inventory != None )
	{
		Copy = Inventory;
		Inventory = None;
	}
	else
		Copy = Other.spawn(WeaponType,Other,,,rot(0,0,0));

	Copy.GiveTo( Other, self );

	return Copy;
}
 
Upvote 0
Ok Ok let me take a look at it.
brb :/

Kar98 scoped
Code:
class ROKar98kScopedPickup extends ROPanzerFaustPickup;

static function StaticPrecache(LevelInfo L)
{
	L.AddPrecacheStaticMesh(StaticMesh'WeaponPickupSM.Weapons.k98scoped');
	L.AddPrecacheMaterial(Material'Weapons3rd_tex.German.Kar98_world');
	L.AddPrecacheMaterial(Material'Weapons3rd_tex.German.Kars98_scope_world');
	L.AddPrecacheMaterial(Material'Weapons1st_tex.Rifles.k98_sniper_s');
}

defaultproperties
{
    InventoryType=class'ROAmmo.Kar792x57Ammo' // this could be     class'ROInventory.Kar98WeaponScoped'  whatever works I guess
    WeaponType=class'ROInventory.Kar98WeaponScoped'

    PickupMessage="You got the Kar98k Scoped."
    TouchMessage="Pick Up: Kar98k Scoped"
    PickupSound=Sound'Inf_Weapons_Foley.WeaponPickup'
    PickupForce="AssaultRiflePickup"  // jdf

    bAmmoPickupIsWeapon=true

	MaxDesireability=+0.78

    StaticMesh=StaticMesh'WeaponPickupSM.Weapons.k98scoped'
    RespawnTime=3.000000
    AmmoAmount = 1
    DrawType=DT_StaticMesh
    DrawScale=1.0
    AmbientGlow=10

    CollisionRadius=25.0
    CollisionHeight=3.0
    PrePivot=(X=0.0,Y=0.0,Z=3.0)
}

The MN is pretty much the same with MN9130Scoped instead of Kar98kScorped everywhere.
 
Last edited:
Upvote 0
quickly done, and didnt test it. No reason why it shouldnt work as its pretty trivial. subclass the items you need from TeamPickup and you will get a new field which allows you to specify the team that is allowed to pick up the item in the editor.
If another team player tries to pick it up, he gets a msg similar to the one for denied entry on vehicles.

Code:
//-----------------------------------------------------------
// Teambased Pickup
// untested
// allows to specify a team which is able to pickup this weapon
// by worluk 2008
//
//-----------------------------------------------------------
class TeamPickup extends ROPanzerFaustPickup
     abstract;

var() enum myTeamIndex{
   AXIS_TEAM_INDEX,
   ALLIES_TEAM_INDEX
   } PickupTeam;

function UsedBy( Pawn user )
{
  if(user.PlayerReplicationInfo.TeamInfo.TeamIndex!=PickupTeam)
  {
     user.ReceiveLocalizedMessage(class'ROTeamPickupMsg');
     return;
  }
  super.UsedBy(user);
}

DefaultProperties
{
}
Code:
//-----------------------------------------------------------
// ROTeamPickupMsg
// untested
// a msg sent to a player in case he tries to pickup an item
// set for the other team.
// by worluk 2008
//
//-----------------------------------------------------------
class ROTeamPickupMsg extends LocalMessage;

var(Messages) localized string WrongTeam;

static function string GetString(
    optional int Switch,
    optional PlayerReplicationInfo RelatedPRI_1,
    optional PlayerReplicationInfo RelatedPRI_2,
    optional Object OptionalObject
    )
{

    return default.WrongTeam;


}

//=============================================================================
// defaultproperties
//=============================================================================

defaultproperties
{
    WrongTeam="You cannot pick up this item"
    bBeep=false
    bFadeMessage=true
    bIsUnique=false
    DrawColor=(R=214,G=28,B=36,A=255)
    FontSize=2
    LifeTime=3
    PosX=0.5
    PosY=0.75
}

oh and since i already wrote the code i will most likely hand this out with CC too
 
Last edited:
Upvote 0
Ok Ok let me take a look at it.
brb :/

Kar98 scoped
Code:
class ROKar98kScopedPickup extends ROPanzerFaustPickup;

static function StaticPrecache(LevelInfo L)
{
	L.AddPrecacheStaticMesh(StaticMesh'WeaponPickupSM.Weapons.k98scoped');
	L.AddPrecacheMaterial(Material'Weapons3rd_tex.German.Kar98_world');
	L.AddPrecacheMaterial(Material'Weapons3rd_tex.German.Kars98_scope_world');
	L.AddPrecacheMaterial(Material'Weapons1st_tex.Rifles.k98_sniper_s');
}

defaultproperties
{
    InventoryType=class'ROAmmo.Kar792x57Ammo' // this could be     class'ROInventory.Kar98WeaponScoped'  whatever works I guess
    WeaponType=class'ROInventory.Kar98WeaponScoped'

    PickupMessage="You got the Kar98k Scoped."
    TouchMessage="Pick Up: Kar98k Scoped"
    PickupSound=Sound'Inf_Weapons_Foley.WeaponPickup'
    PickupForce="AssaultRiflePickup"  // jdf

    bAmmoPickupIsWeapon=true

	MaxDesireability=+0.78

    StaticMesh=StaticMesh'WeaponPickupSM.Weapons.k98scoped'
    RespawnTime=3.000000
    AmmoAmount = 1
    DrawType=DT_StaticMesh
    DrawScale=1.0
    AmbientGlow=10

    CollisionRadius=25.0
    CollisionHeight=3.0
    PrePivot=(X=0.0,Y=0.0,Z=3.0)
}

The MN is pretty much the same with MN9130Scoped instead of Kar98kScorped everywhere.

When I try to compile I'll get
ERROR: unexpected defaultproperties on line 11

:(
 
Upvote 0