from bge import logic #the works c = logic.getCurrentController() s = logic.getCurrentScene() o = c.owner def initial(c): #sensors fire = c.sensors['lmb'] #can be tap or true with skips reset = c.sensors['reset'] #resets reload durations reload = c.sensors['reload'] #N/A #properties you need # ammo # clip # rdd # rcd # reload # d_clip #///////////////////////////////////////////////////////# clip = 8 #should be same as controller's clip property # bps = 1 #bullets fired per shot #/////////////////////# rdd = 120 #reload duration #//////////////////////////# #higher value means more wait time rcd = 55 #when ammo is applied #/////////////////////# #Should be lower than rdd #///////////////////////////////////////////////////////# #!!! Only change values above !!!# #!!!No need to change values below!!!# #/////////////////////////////////////////////////////////////////////////////////////////# #fire #apply reload durations o['rdd'] = rdd o['rcd'] = rcd o['d_clip'] = clip #reset reload durations if reset.positive: o['rdd'] = rdd o['rcd'] = rcd #fire if fire.positive: if o['clip'] > 0: o['clip'] += - bps if o['clip'] < 0: o['clip'] = 0 #reload if reload.positive: if o['ammo'] > 0: if o['clip'] < clip: o['reload'] = 1 def application(c): clip = o['d_clip'] #sensors apply = c.sensors['apply'] #applies successful reload if apply.positive: call1 = clip - o['clip'] #ammo to be removed from ammo print('ammo to be removed from ammo =', call1) call2 = call1 #ammo to be added to clip print('ammo to be added to clip =', call2) call3 = o['clip'] + o['ammo'] - clip #ammo to be reduced from clip print('ammo to be reduced from clip =', call3) o['ammo'] += - call2 #adding ammo to ammo if o['ammo'] < 0: o['clip'] += call2 + call3 #removing ammo from clip else: o['clip'] += call2 #adding ammo to clip if o['ammo'] < 0: #check o['ammo'] = 0 #/////////////////////////////////////////////////////////////////////////////////////////# # Created by: BlenderGames3D 06/10/2020