Using firearms weapons

dantedevil

Well-known member
I start to use the firearms weapons and find two problems.

1) With the shotnumber.
I see the shotgun never down the number of bullets when fire.
So after some test find the bug.
The weapon never loose bullets if use
@cmd  shoot.
Only loose bullets if use the simple commands like shootframe or throwframe.
I wanna know if exist an updated version to use firearms with @cmd shoot, @cmd toss, etc.

2) I like the idea to use the shotgun to hit the enemies,  like using the bat. Besides you have a freespecial to shot the shotgun. But so you run out of bullets, the player release the weapon and this disappears.
I want the weapon not die when the player run out of bullets,  you still using to hit enemies until find more bullets,  or in my mod press block to release the weapon.
I know how make this, setting the shotgun like a normal weapon, but this way can't use the shotnumber.
 
Man, its kinda complex to isolate, but I will try to explain.

I use ONMODELCOPY instead of SPAWNSCRIPT because I found that when you enter into a weapon version, there is NO spawnscript and if you set any variable using spawnscript, it crashes the engine. But this is just for the weapon control (since I can change the guns in my case).

I use this on the player before getting the weapon:
Code:
                @script
         if (frame==1){
        void self = getlocalvar("self"); // Get calling entity.
        int ammo = 20;
        setglobalvar("ammoControl", ammo);
        }
	@end_script

So I set a globalvar for the ammo (maybe you should use a localvar, I use a global var because we never can have the same character for both players).

For each attack, I use:

Code:
       @script
         if (frame==1){
        void self = getlocalvar("self"); // Get calling entity.
         int ammoControl = getglobalvar("ammoControl");
        setglobalvar("ammoControl", ammoControl-1);
        }
	@end_script

This will decrease the ammon in 1 for each attack (there are some attacks which uses more bullets).

At my idle, I put a code to check if the ammo is empty. If so, it will send you to a specific animation and lose that weapon.
 
Only loose bullets if use the simple commands like shootframe or throwframe.
I wanna know if exist an updated version to use firearms with @cmd shoot, @cmd toss, etc.

There's no function to do that ATM so I tricked engine by shooting blank entity like this:

anim attack1
delay 8
offset 64 131
throwframe 2 1
custknife Empty2
bbox 61 76 20 55
frame data/chars/billy/knife/kn1.gif
frame data/chars/billy/knife/kn2.gif
bbox 0
sound data/sounds/knife.wav
@cmd shooter2 "KnifeS" 25 48 0 1 0 0
frame data/chars/billy/knife/kn3.gif
frame data/chars/billy/knife/kn4.gif

As you can see Billy shoots KnifeS with script but at same time he also throws empty2 using throwframe command. The latter is to decrement ammo counter

I want the weapon not die when the player run out of bullets,  you still using to hit enemies until find more bullets,  or in my mod press block to release the weapon.

That would be tough since you need to store ammo counter in the weapon if the weapon is dropped. And from rough estimation, it would require script+weapon model to create that
 
Back
Top Bottom