import bge
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
equipped = own['equipped']
target = own['target']
timer = own['timer']
change = own['change']
reload = own['reload']
Grenades = own['Grenades']
Smoke = own['Smoke']
shoot = own['shoot']
collide = cont.sensors['cutscene']
#animations
down_m24 = cont.actuators['downm24']
downGlock = cont.actuators['downGlock']
upm24 = cont.actuators['pickupm24']
upGlock = cont.actuators['pickupGlock']
downGren = cont.actuators['down_Gren']
upGren = cont.actuators['pickup_Gren']
Sdown = cont.actuators['Sdown']
Sup = cont.actuators['Sup']
Kdown = cont.actuators['knifedown']
Kup = cont.actuators['knifeup']
opendoor = cont.actuators['opendoor']
self = scene.objects[own.name]
movement = scene.objects['player']
#sets change == True
if own['target'] != own['equipped'] and reload == False and shoot == True or own['equipped'] == 0 or own['target'] == 6:
self['change'] = True
elif own['target'] == own['equipped']:
self['change'] = False
#timer
if change == True and timer < 30 and movement['door'] == False:
own['timer'] += 1
if change == True and movement['door'] == True and timer < 45:
own['timer'] += 1
#putting down weapon
if equipped == 0 and change == True and timer == 0:
cont.activate(downGlock)
if equipped == 1 and change == True and timer == 0:
cont.activate(down_m24)
if equipped == 2 and change == True and timer == 0:
cont.activate(downGlock)
if equipped == 3 and change == True and timer == 0:
cont.activate(downGren)
if equipped == 4 and change == True and timer == 0:
cont.activate(Sdown)
if equipped == 5 and change == True and timer == 0:
cont.activate(Kdown)
if equipped == 7 and change == True and timer == 0:
cont.activate(Kdown)
#ends old weapon + animation
if timer == 15 and change == True and equipped == 0:
cont.deactivate(downGlock)
if timer == 15 and change == True and equipped == 1:
own.sendMessage("endm24")
cont.deactivate(down_m24)
if timer == 15 and change == True and equipped == 2:
own.sendMessage("endglock")
cont.deactivate(downGlock)
if timer == 15 and change == True and equipped == 3:
own.sendMessage("endGren")
cont.deactivate(downGren)
if timer == 15 and change == True and equipped == 4:
own.sendMessage("endSmoke")
cont.deactivate(Sdown)
if timer == 15 and change == True and equipped == 5:
own.sendMessage("endKnife")
cont.deactivate(Kdown)
if timer == 15 and change == True and equipped == 7:
own.sendMessage("endKnife")
cont.deactivate(Kdown)
#spawn new weapon
if timer == 15 and change == True and target == 1:
scene.addObject('m24', own, 0)
if timer == 15 and change == True and target == 2:
scene.addObject('Glock', own, 0)
if timer == 15 and change == True and target == 3:
scene.addObject('Grenade', own, 0)
if timer == 15 and change == True and target == 4:
scene.addObject('smoke', own, 0)
if timer == 15 and change == True and target == 5:
scene.addObject('knife', own, 0)
if timer == 15 and change == True and target == 7:
scene.addObject('knife', own, 0)
#picking up weapon
if timer > 15 and timer < 30 and change == True and target == 1:
cont.activate(upm24)
if timer > 15 and timer < 30 and change == True and target == 2:
cont.activate(upGlock)
if timer > 15 and timer < 30 and change == True and target == 3:
cont.activate(upGren)
if timer > 15 and timer < 30 and change == True and target == 4:
cont.activate(Sup)
if timer > 15 and timer < 30 and change == True and target == 5:
cont.activate(Kup)
if timer > 15 and timer < 30 and change == True and target == 7:
cont.activate(Kup)
if timer > 15 and timer < 45 and change == True and movement['door'] == True and target == 6:
cont.activate(opendoor)
#open sesame
doorsound = cont.actuators['doorsound']
if timer == 30 and change == True and movement['door'] == True and target == 6:
select = collide.hitObjectList[0]
own.sendMessage("opendoor", "", str(select))
cont.activate(doorsound)
#resetting properties
if timer == 30 and change == True and own['equipped'] != own['target'] and movement['door'] == False:
own['equipped'] = own['target']
own['timer'] -= 31
cont.deactivate(upm24)
cont.deactivate(upGren)
cont.deactivate(upGlock)
cont.deactivate(Sup)
cont.deactivate(Kup)
#resetting after cutscene
if timer == 45 and change == True and movement['door'] == True and own['equipped'] != 6:
own['equipped'] = own['target']
movement['door'] = False
movement['control'] = True
movement['cutscene'] = 0
self['timer'] = 0
own.sendMessage("restorecontrol")
cont.deactivate(opendoor)
own['target'] = 2
#intial weapon selection
if equipped == 0:
self['target'] = 2
I tried change,py and change.001.py, one is default with the same values, and the other the arms are positioned as I did.
If I have the item available on the gunspawn parent, it will show if moved from layer 2 to 1.
As for getting the item to load using key 7, I have created a few bricks and joined them up where I think they would work, based on the knife item. kdown for example, uses the same animation, but just would load a different object called chain.
The object does function, just after a lot of scaling and removing faces.
So it should be okay for the moment. The action Action key brick for the movement would just use 15 on one value as the others do, and that should work, I’d guess.
So for the following.
#ends old weapon + animation
if timer == 15 and change == True and equipped == 0:
cont.deactivate(downGlock)
if timer == 15 and change == True and equipped == 1:
own.sendMessage("endm24")
cont.deactivate(down_m24)
if timer == 15 and change == True and equipped == 2:
own.sendMessage("endglock")
cont.deactivate(downGlock)
if timer == 15 and change == True and equipped == 3:
own.sendMessage("endGren")
cont.deactivate(downGren)
if timer == 15 and change == True and equipped == 4:
own.sendMessage("endSmoke")
cont.deactivate(Sdown)
if timer == 15 and change == True and equipped == 5:
own.sendMessage("endKnife")
cont.deactivate(Kdown)
if timer == 15 and change == True and equipped == 7:
own.sendMessage("endKnife")
cont.deactivate(Kdown)
#spawn new weapon
if timer == 15 and change == True and target == 1:
scene.addObject('m24', own, 0)
if timer == 15 and change == True and target == 2:
scene.addObject('Glock', own, 0)
if timer == 15 and change == True and target == 3:
scene.addObject('Grenade', own, 0)
if timer == 15 and change == True and target == 4:
scene.addObject('smoke', own, 0)
if timer == 15 and change == True and target == 5:
scene.addObject('knife', own, 0)
if timer == 15 and change == True and target == 7:
scene.addObject('knife', own, 0)
7 would be called chain instead of knife? As the object is chain, so if this make sense, just change the value to the new one, and it just uses the same animation of up and down, so grenade, stun grenade, hand gun. I guess knife.py would be the link for the action brick for chain object. I can’t see too well with the bricks, but it probably is that one.