Final weapon questions

Topics regarding Scripting with Reality Factory
Post Reply
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Final weapon questions

Post by Lynkyn »

Well for finish, I want to do some questions for do my weapons more realistic: :mrgreen:
1.- Decals. Is it possible to alternate the decals of the projectiles? I say this because with a gun it doesn't look bad, but with shotguns, it's not realistic that always appears the same decal...
2.- Sounds. Is there any way to do sounds for arm and idle? It would be handy for weapons like chainsaw (motor sound at idle) or guns that reload in draw animation.
3.- Alt-things(XD). Is it possible to do that in the alt-shoot the ammunition wasted be double, or the fire rate more slow (in weapons than a shotgun with a simple and double fire)

Thanks all you :wink:
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: Final weapon questions

Post by Danimita92 »

Joer, que pesao con las armas (Jesus, you and your weapons)
I only really know how to answer number 2.
You can use a script that plays a chainsaw (or whatever sound you want) sound whenever you've selected X weapon and the shooting key hasn't been pressed (you're not attacking with the weapon). And another one that plays if you're attacking with a weapon and you're using that weapon.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Final weapon questions

Post by Juutis »

None of those things are possible with the built-in weapon system.

1.) and 3.) Scripted weapons is the only solution. You could have a variety of projectiles for one weapon, each having a different decal and then randomly choose which projectile to shoot. Also, the built-in weapons can't have alternative fire. It doesn't really matter whether you press the fire or the alt-fire button, the action is always the same. Scripted weapons would solve this one too...

2.) As Danimita already said you could use a script to check if the chainsaw is armed and then play a sound. You can also check if the player changes his weapon -> A new weapon is armed -> Play the arming sound:

Code: Select all

{

playerweapon    [0]

soundtimer    [0]

Spawn[ ()
{
     LowLevel("run");
} ]

run[ ()
{
     self.ThinkTime = 0.05;

     if(soundtimer < 0)    // a timer to prevent the sound from overlapping
     {
          if(self.player_weapon = 1)     //if the player has the weapon with index 1 armed
          {
               PlaySound("idlesound.wav",100000);
          }

          soundtimer = self.time + 0.5;    //play the sound every 0.5 seconds
     }

     if(playerweapon != self.player_weapon)   //if player changes his weapon
     {
          playerweapon = self.player_weapon;

          if(playerweapon = 1)
          {
               PlaySound("armsound",100000);
          }
     }
} ]

}
I hope this gets you started.
Pain is only psychological.
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: Final weapon questions

Post by Lynkyn »

Thanks you, I will try this :wink:

HAHAHA AND THE FINAL QUESTION (XDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD)
In some weapons, like shotguns or non-semiautomatic-rifles, the shell must go out a few seconds after the shoot, but I dont know how to do it. Is it necesary a scripted weapon? thanks

PD: i looked the ''shellspray'' in effect.ini, I didn't see any parameter to change for this :cry:
Thanks!
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Final weapon questions

Post by Juutis »

Yeah, I think that requires scripted weapons. Not sure about this one though...
Pain is only psychological.
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: Final weapon questions

Post by Lynkyn »

Ok.
Note: i dont know how to do you script works :mrgreen: :mrgreen:

I changed ''playerweapon'' to ''motosierra'' (chainsaw), the name of my weapon, and i do a pawn type ''camera'', etc. What I must to do?

Thanks again. And again. And again XDD
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Final weapon questions

Post by Juutis »

No. 'playerweapon' is just a variable that stores an integer (a number) that tells the slot of the player's weapon. There's no need to change that in any way.

These are the lines you want to change:

Code: Select all

if(self.player_weapon = 1)
...
if(playerweapon = 1)
They check if the player has the weapon in slot 1 armed. So if you have your chainsaw in weapon slot number 4 you would set:

Code: Select all

if(self.player_weapon = 4)
...
if(playerweapon = 4)

You'll probably want to change the sounds in the PlaySound() commands, too. And:

Code: Select all

soundtimer = self.time + 0.5;
Controls how often the idle sound is played. So if your idle sound is 2 seconds long you would set:

Code: Select all

soundtimer = self.time + 2;
Pain is only psychological.
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: Final weapon questions

Post by Lynkyn »

Code: Select all

{

playerweapon    [0]

soundtimer    [0]

Spawn[ ()
{
     LowLevel("run");
} ]

run[ ()
{
     self.ThinkTime = 0.05;

     if(soundtimer < 0)    // a timer to prevent the sound from overlapping
     {
          if(self.player_weapon = 10)     //if the player has the weapon with index 1 armed
          {
               PlaySound("motoidle.wav",100000);
          }

          soundtimer = self.time + 0.5;    //play the sound every 0.5 seconds
     }

     if(playerweapon != self.player_weapon)   //if player changes his weapon
     {
          playerweapon = self.player_weapon;

          if(playerweapon = 10)
          {
               PlaySound("motodraw",100000);
          }
     }
} ]

}
It doesn't work :cry: :cry:
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Final weapon questions

Post by Juutis »

Oh, sorry! My bad. Once again. Try this: :D

Code: Select all

{

playerweapon    [0]

soundtimer    [0]

Spawn[ ()
{
     LowLevel("run");
} ]

run[ ()
{
     self.ThinkTime = 0.05;

     if(soundtimer < self.time)    // a timer to prevent the sound from overlapping
     {
          if(self.player_weapon = 10)     //if the player has the weapon with index 1 armed
          {
               PlaySound("motoidle.wav",100000);
          }

          soundtimer = self.time + 0.5;    //play the sound every 0.5 seconds
     }

     if(playerweapon != self.player_weapon)   //if player changes his weapon
     {
          playerweapon = self.player_weapon;

          if(playerweapon = 10)
          {
               PlaySound("motodraw",100000);
          }
     }
} ]

}
It worked for me at least. I tested it with weapon slots 1, 2, 3 and 10. All worked except for 10, for some reason. Maybe because the weapons are normally 0-9 or something like that...
Pain is only psychological.
Lynkyn
Posts: 48
Joined: Sat Jun 21, 2008 2:17 pm

Re: Final weapon questions

Post by Lynkyn »

Thanks (I will change the slot of my chainsaw XD)

Aaarg, it doesn't works, but...

Where the sounds must be? I have got them all on media/sounds.

Note: my chainsaw is now on slot 9, and... there isn't a 'slot 10' because the slots are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. XDDDDDDDDDDDDDDDDDDDDDDDD I am idiotXD
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Final weapon questions

Post by Juutis »

Lynkyn wrote:In some weapons, like shotguns or non-semiautomatic-rifles, the shell must go out a few seconds after the shoot, but I dont know how to do it. Is it necesary a scripted weapon?
Actually, yeah. There might be a way:

You can set a delay to the effects in explosion.ini. So for example if you have a muzzle flash explosion:

Code: Select all

[MuzzleFlash]
effect0 = MuzzleFlash
delay0 = 0
offset0 = 0 0 0
effect1 = WhiteLight
delay1 = 0
offset1 = 0 0 0
effect2 = ShellSpray
delay2 = 0
offset2 = 0 0 0
You could set:

Code: Select all

[MuzzleFlash]
effect0 = MuzzleFlash
delay0 = 0
offset0 = 0 0 0
effect1 = WhiteLight
delay1 = 0
offset1 = 0 0 0
effect2 = ShellSpray
delay2 = 1
offset2 = 0 0 0
And the ShellSpray effect would come one second after the other effects.
Pain is only psychological.
Post Reply