Gun Manager V ALPHA

Added “force application scripts” programmed into the bullet and easily edited independently,
(pass ammo code between games)

*for applying force along the hit axis and for applying global forces or applying damage or???

Current file is in post ->CurrentFile
(noticed some old animation keys moving everything out of order)

Q- grab weapon
R- Reload

up and down arrows -Cycles weapons

Mouse 1 shoot

3 weapons

3 ammo types

Alpha_2 = crate and gun 1 + programmable offset stored in each gun

Update- Commented out all code
fixed a coding error

if own.children!=None:

does not work

x=[]+[own.children]
if len(x)!=0:

Does work

Attachments

WeaponSelfContainedLogicV7.blend (559 KB)

KX_GameObject always returns a list. That is why our validation always results in False.

Please do not use this cryptic code as replacement. Lets look what it does:
A) “[]” -> creates a new empty list
B) “[<items>]” -> creates another new list
C) “own.children” -> puts a list into the list created with B)
D) “+” -> concatenates the list from C) with the list from A)
E) “if len(x)!=0:” -> you check if the list from D) is empty

This means you create 2 additional lists.
You place a list in another one.
You check a list to be empty. But you just filled the list with an item. This will always evaluate positive.

Better use this code:


if gameObject.children:

This evaluates positive when:

  • children is not None (which will never be the case)
  • children has at least one item (what you want to know)

yeah I just noticed with the way my code is structured none of the code is blocking anyway,

because if there are no objects in

for objects in own.children:

won’t do anything

but good to know,

if object.children: if it has some

does

if not object.children:

work to say only if it has none?

So now

x=own.children

so now if

if no gun-
len(x)==0:

if has gun-
if len(x)!=0:

fixed it .

Added list logic, to initiate the list, and add guns to it as picked up,
now I need to remove the Boolean values checks, and use the switch weapons script to evaluate which gun to draw.

I was thinking [ and ] would cycle through what you have, where as 1-9 would choose guns based on the index of the list, still thinking about how to achieve it.(posted a thread about it to get some help)

Nice work. So many people would want this once it’s done

upload 7B -fixes

Attachments

WeaponSelfContainedLogicV8.blend (566 KB)

Ok, here it is with the list , but it needs work on cycling the index,

Q- grab weapon

R- Reload

up and down arrows -Cycles weapons

Mouse 1 shoot

3 weapons

3 ammo types

Attachments

WeaponSelfContainedLogicV8 (1s).blend (634 KB)

Todo list

Rocket Launcher rockets, missiles lock-on, and homing,

Shotgun example

laser/instant guns,

all wrectified weapon systems

so now there is explosions, and a weapon crate, and a model for gun 1

as well as added “offset” (x,y,z) stored in gun, (for spawning) so all guns can be different sizes etc.

Added “force Push” bullet, and anti gravity burst bullet, and “shared” the impart force code from the force push by use of a scaler property

so bullet imparts 100 units of force, where rocket imparts 1000

<a href=“https://www.youtube.com/watch?v=9rVH1OmSF80” target="_blank">
https://youtu.be/9rVH1OmSF80

Attachments

WeaponManagerBeta2 (1).blend (803 KB)