Change weapon settings in game?

Discussions about Coding and Scripting
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Change weapon settings in game?

Post by iloveut99 »

I have this:
function bool CheckReplacement(Actor Other, out byte bSuperRelevant){

if (Other.IsA('ShockRifle')){
ShockRifle(Other).DeathMessage="%k electrified %o with the Combo %w.";
ShockRifle(Other).PickupMessage="You got the enhanced Combo Shock Rifle.";
ShockRifle(Other).ItemName="Enhanced Combo Shock Rifle";
ShockRifle(Other).PlayerViewMesh=LodMesh'Botpack.sshockm';
ShockRifle(Other).ThirdPersonMesh=LodMesh'Botpack.SASMD2hand';
return true;
}
}
But seems doesn't work isn't actually possible to change this settings in game without change the weapon class directly?
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: Change weapon settings in game?

Post by Rakiayn »

If a player picksup a weapon, a new weapon is spawned and gived directly to the player. however, this new weapon has the default properties
you would have to change to weapons code so this properties are given to the new weapon.
perhaps there is a more easy way. isnt there a function in the mutator class that allows picked up inventory to be changed?
correct me if im wrong
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Change weapon settings in game?

Post by iloveut99 »

I have tried this:
function Tick(float DeltaTime){
local ShockRifle aux;

foreach Level.AllActors(Class'ShockRifle',aux){
aux.DeathMessage="%k electrified %o with the Combo %w.";
aux.PickupMessage="You got the enhanced Combo Shock Rifle.";
aux.ItemName="Enhanced Combo Shock Rifle";
aux.PlayerViewMesh=LodMesh'Botpack.sshockm';
aux.ThirdPersonMesh=LodMesh'Botpack.SASMD2hand';
}
}
Don't work either, so I believe I can only edit that in the weapon classes. If anyone know another way please tell.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: Change weapon settings in game?

Post by Rakiayn »

strange. try to alter the drawscale in the code to 3.0
if you have huge shockrifles in the map, then perhaps my theory is correct.
if not, something is wrong with the code
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Change weapon settings in game?

Post by iloveut99 »

in which should I add the drawscale? in the tick?
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: Change weapon settings in game?

Post by Rakiayn »

use the code in your first post.
doing a for each search in tick function is a very bad idea (can cause lag)

code:

Code: Select all

function bool CheckReplacement(Actor Other, out byte bSuperRelevant){

if (Other.IsA('ShockRifle')){
ShockRifle(Other).drawscale=3.0;
ShockRifle(Other).DeathMessage="%k electrified %o with the Combo %w.";
ShockRifle(Other).PickupMessage="You got the enhanced Combo Shock Rifle.";
ShockRifle(Other).ItemName="Enhanced Combo Shock Rifle";
ShockRifle(Other).PlayerViewMesh=LodMesh'Botpack.sshockm';
ShockRifle(Other).ThirdPersonMesh=LodMesh'Botpack.SASMD2hand';
return true;
}
}

iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Change weapon settings in game?

Post by iloveut99 »

I've tried that but seems doesn't work the weapons scale are normal. =/
doing a for each search in tick function is a very bad idea (can cause lag)
Yeah I know, I just did that for testing purposes, with it I didn't need to find a function that is called every time when a player pickups a weapon.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: Change weapon settings in game?

Post by Rakiayn »

hmm ok. I guess there is something wrong with the check replacement code
perhaps try it with the tick function code.
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Change weapon settings in game?

Post by iloveut99 »

yeah with tick works nicely.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: Change weapon settings in game?

Post by Rakiayn »

only the drawscale or all the other properties too?
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Change weapon settings in game?

Post by iloveut99 »

only drawscale.
JackGriffin
Godlike
Posts: 3829
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Change weapon settings in game?

Post by JackGriffin »

CheckReplacement is only called on spawn. Do a ForEach iteration and get them that way. BTW you might have to use Set too.
So long, and thanks for all the fish
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: Change weapon settings in game?

Post by Rakiayn »

the problem in this case is that the code is not working at all. not even when the shockrifle is spawned
User avatar
Feralidragon
Godlike
Posts: 5503
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Change weapon settings in game?

Post by Feralidragon »

If I may:

1 - Changing DrawScale won't lead anywhere: inventory works diferently regarding DrawScale: they have PickupViewScale, PlayerViewScale and ThirdPersonScale. Change those instead from CheckReplacement.

2 - Messages from the weapons are generally read by static functions which only work with default properties and they cannot handle instances, they handle only classes and primitive data types. So no matter how you change it dynamically, the default property will remain the same and can only be changed by a subclass indeed. This applies to DeathMessage, PickupMessage, ItemName.

3 - To make sure your code is affecting the weapon, use "fool-proof" variables instead: MultiSkins, turn the weapon bMeshEnvironment=True, make it translucent, etc, use other universal variables which affect absolutelly all the mesh actors instead.