I released this script here because it isn't directed at a player, this is rather directed at
modelers that want to implement a system that makes the vehicle shoot on click. Still, if this is the wrong forum, inform me about it.AboutThis script enables you to easily make vehicles shoot projectiles on click.
It's all defined in the datablock if you choose to use this.
Screenshots of testsStuntplane with machine guns.Jeep with multiple rocket launching.Features- Uses a different coordinate system relative to the object, takes the direction it's facing into account.
X: Forward vector
Y: Left Vector
Z: Up vector - Velocity uses this, too.
- Supports holding the left mouse button to keep firing. (has a set delay between shooting)
- Has a simple protection for clickspamming.
- Supports scaled projectiles.
- Supports required slots for using the system in the vehicle.
- Very simple implementation in the vehicle. (datablocks)
- This thing won't reexecute itself if in another add-on, so it only gets executed once.
- Supports sounds on fire.
UsageInclude this in your zip if you are going to use it.
(don't forget to execute it in your server.cs!)
If you don't know how you would execute it, go to the server.cs, on top you write:
exec("./support_shootonclick.cs");
After doing that, go to the script file containing your datablocks.
Go to the vehicleData datablock.
In it, you can set a multitude of stuff, to activate the system simply put in this value:
ShootOnClick=1;
Now we have to set the settings, example:
ShootOnClick_Hold=1;
ShootOnClick_ShootDelay=100;
ShootOnClick_ReShootDelay=100;
ShootOnClick_ProjectileCount=2;
ShootOnClick_RequiredSlot=0;
ShootOnClick_Sound=RocketExplosionSound;
ShootOnClick_Projectile[0]=gunProjectile;
ShootOnClick_Position[0]="0 3 0";
ShootOnClick_Velocity[0]="120 0 0";
ShootOnClick_Scale[0]="1 1 1";
ShootOnClick_Projectile[1]=gunProjectile;
ShootOnClick_Position[1]="0 -3 0";
ShootOnClick_Velocity[1]="120 0 0";
ShootOnClick_Scale[1]="1 1 1";
If hold is 1, the player can hold the left mouse button to make it shoot again.
It shoots again every reshootdelay milliseconds.
Shootdelay is the minimum time between clicks, this is to prevent clickspamming.
ProjectileCount tells it how many projectiles to fire.
RequiredSlot tells it in what slot the player must be to shoot.
After that, we have the individual projectile definitions.
Projectile is the projectile's datablock.
Position is the position where it should be spawned, here it tells us:
0 forward
3 to the left
0 upwards
Velocity tells us how fast it should move, here it tells us:
120 forward
0 to the left
0 upwards
Last one is pretty easy, it's the scale the projectile should be.
Added sound: This is just an audio datablock.
(Fun fact: the example is what I tested on the stuntplane, it gave it machine guns on it's wings. ;D)DownloadYou can download it
here.
ChangelogV1.1- Added sounds, shootOnClick_Sound.
Any questions and/or suggestions? Post them here.