Changing rate of weapon fire for each weapon

Blitz3D Forums/Blitz3D Beginners Area/Changing rate of weapon fire for each weapon

Chad(Posted 2006) [#1]
I have a set of variables with three (3) different choices..

The player can be one of the following:
1. Bare Hands
2. Hold Shotgun
3. Hold Revolver

http://www.chadmcrae.com/questionofgun.bmp

Now, I was looking at WolRons code for a fps and would like something like that.. But however, instead of parenting the bulletmesh to weapon1, which in the case of his example is a cylinder, can I parent it to my entity of my weapon?

Also, whenever a different weapon is picked, can I use different variables for the rate of fire? Since shotgun "spreads" out when fired, can I have an entity that appears "spread" out when the revolver may be just a simple cone (just an example)?

And one last question before I go, how comes sometimes when I'm testing my code, and I press F5, why is it that sometimes it says "Function can only appear once" or whatever it means by that, and I have to get rid of the last function I did? Did I make a booboo somewhere or am I missing something?

Thanks,
Chad


Matty(Posted 2006) [#2]
"Function can only appear once" suggests you are giving two functions the same name.

Without looking at WolRon's code for a fps I would have thought a fairly easy way to have different rates of fire/spreads etc would be to have something like this (pseudo code not real blitz code shown below)

[code]

type ProjectileWeaponTemplate

field rateoffire
field spread
field ImpartedBulletspeed#
field ImpartedBulletDamage

end type

type BulletObject

field Speed#
field Damage
field pivothandle ;used for positioning the bullet - collision detection is between the pivot and the scene/characters
field entityhandle ;the visual appearance of the bullet, no collision information needed for this, parent it to the pivothandle
end type

then in your code you would, when a weapon is fired, First:create new bullets (1-number specified in rate of fire in the weapon type) and create pivots/copy entities,
Second:orient the bullets to point in the direction of the muzzle, with a random variation in the direction as specified by 'spread' in the weapon type
Third:assign a speed and damage value to the bullet

and each frame you would have some code in a function like this:

function UpdateBullets()
for Bullet.BulletObject=each BulletObject
;move the bullet with 'moveentity'
moveentity bullet\pivothandle
;check if the bullet has collided with the scene/a character and if so then handle damage/explosions etc
next

end function

[code]