I just finished an effect that gonna be played when the player is choosing weapon.
Everytime the player holds down SPACE KEY it should play but ONLY when there is one or more special abilities enabled
I have 6 boolen properties
Slot 0 = True ( this is basic weapon and always True)
Slot 1,2,3,4,5 = False ( these are special weapons that need to be unlocked)
====> in this case the fx should be off
I want the effect to be played when player has 1 of those special weapons. Can I achieve this with only few lines of code?
I imagine its like… if i not in range (1,5): fx off ?
I dont know how to use it but due to the methods of Monster and guramarx, i came to this.
from bge import logic as log
import random as rand
def isAtLeastOneItemEnabled(items):
for item in items:
if item:
return True
return False
def main():
c = log.getCurrentController()
o = c.owner
sc = log.getCurrentScene()
fx= c.sensors["fx"]
na = "lock_0"
if specialEffectEnabled == isAtLeastOneItemEnabled(o[na]):
if fx.positive:
if fx.repeat == o["trig"]:
for i in range(0,10):
rx = rand.randint(-60 , 60)
ry = rand.randint(-30 , 30)
rz = rand.randint(-30 , 30)
px = o.worldPosition[0] + rx
py = o.worldPosition[1] + ry
pz = o.worldPosition[2] + rz
b = sc.addObject("chip-pick_pa", o , 60)
b.worldPosition = (px,py,pz)
main()
I describe the function again. These are 6 locks , the 0 one stands for the basic weapon, so we can ignore it. I want the FX to happen only if one or more of the lock_1/2/3/4/5 is True.