Hi,
I wanted to activate one item, I wasn’t sure how it could work, other than like a brick setup where an item is added in, in the example I have.
import bge
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.ownerequipped = 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’] += 1if 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)
if equipped == 8 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(“endchain”)
cont.deactivate(Kdown)
if timer == 15 and change == True and equipped == 8:
own.sendMessage(“endhammer”)
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(‘chain’, own, 0)
if timer == 15 and change == True and target == 8:
scene.addObject(‘hammer’, 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 < 30 and change == True and target == 8:
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’] = 2Blockquote
So the player can collect an item instead of it being already in the player’s item spawn system.
I did try editing the example, to see if that could load an item once the player is nearby. That doesn’t work.
I am not sure how to activate an item from an oject and have that working from there on. I can only think of add object to load an item, but that wouldn’t be a functioning item.
from bge import logic
cont = logic.getCurrentController()
scene = logic.getCurrentScene()
own = cont.owner#intial weapon selection
if equipped == 0:
self[‘target’] = 7own.worldPosition = gunspawn.worldPosition
own.worldOrientation = gunspawn.worldOrientation
Or
gunspawn = scene.objects[“gun spawn”]
Including that above.
![]()
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.ownerequipped = own[‘equipped’]
target = own[‘target’]
timer = own[‘timer’]
chain = own[‘chain’]
reload = own[‘reload’]#animations
down_m24 = cont.actuators[‘downm24’]
downGlock = cont.actuators[‘downGlock’]
upGlock = cont.actuators[‘pickupGlock’]
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 chain == True
if own[‘target’] != own[‘equipped’] and reload == False and shoot == True or own[‘equipped’] == 0 or own[‘target’] == 7:
self[‘chain’] = True
elif own[‘target’] == own[‘equipped’]:
self[‘chain’] = False#timer
if chain == True and timer < 30 and movement[‘door’] == False:
own[‘timer’] += 1if chain == True and movement[‘door’] == True and timer < 45:
own[‘timer’] += 1#putting down weapon
if equipped == 0 and chain == True and timer == 0:
cont.activate(downGlock)
if equipped == 2 and chain == True and timer == 0:
cont.activate(downGlock)
if equipped == 4 and chain == True and timer == 0:
cont.activate(Sdown)
if equipped == 5 and chain == True and timer == 0:
cont.activate(Kdown)
if equipped == 7 and chain == True and timer == 0:
cont.activate(Kdown)
if equipped == 8 and chain == True and timer == 0:
cont.activate(Kdown)#ends old weapon + animation
if timer == 15 and chain == True and equipped == 0:
cont.deactivate(downGlock)
if timer == 15 and chain == True and equipped == 2:
own.sendMessage(“endglock”)
cont.deactivate(downGlock)
if timer == 15 and chain == True and equipped == 5:
own.sendMessage(“endKnife”)
cont.deactivate(Kdown)
if timer == 15 and chain == True and equipped == 7:
own.sendMessage(“endchain”)
cont.deactivate(Kdown)#spawn new weapon
if timer == 15 and chain == True and target == 1:
scene.addObject(‘m24’, own, 0)
if timer == 15 and chain == True and target == 2:
scene.addObject(‘Glock’, own, 0)
if timer == 15 and chain == True and target == 3:
scene.addObject(‘Grenade’, own, 0)
if timer == 15 and chain == True and target == 4:
scene.addObject(‘smoke’, own, 0)
if timer == 15 and chain == True and target == 5:
scene.addObject(‘knife’, own, 0)
if timer == 15 and chain == True and target == 7:
scene.addObject(‘chain’, own, 0)
if timer == 15 and chain == True and target == 8:
scene.addObject(‘hammer’, own, 0)#picking up weapon
if timer > 15 and timer < 30 and chain == True and target == 2:
cont.activate(upGlock)
if timer > 15 and timer < 30 and chain == True and target == 4:
cont.activate(Sup)
if timer > 15 and timer < 30 and chain == True and target == 5:
cont.activate(Kup)
if timer > 15 and timer < 30 and chain == True and target == 7:
cont.activate(Kup)
if timer > 15 and timer < 30 and chain == True and target == 8:
cont.activate(Kup)
if timer > 15 and timer < 45 and chain == True and movement[‘door’] == True and target == 7:
cont.activate(opendoor)#open sesame
doorsound = cont.actuators[‘doorsound’]
if timer == 30 and chain == True and movement[‘door’] == True and target == 7:
select = collide.hitObjectList[0]
own.sendMessage(“opendoor”, “”, str(select))
cont.activate(doorsound)
#resetting properties
if timer == 30 and chain == True and own[‘equipped’] != own[‘target’] and movement[‘door’] == False:
own[‘equipped’] = own[‘target’]
own[‘timer’] -= 31
cont.deactivate(upGlock)
cont.deactivate(Sup)
cont.deactivate(Kup)#resetting after cutscene
if timer == 45 and chain == True and movement[‘door’] == True and own[‘equipped’] != 7:
own[‘equipped’] = own[‘target’]
movement[‘door’] = False
movement[‘control’] = True
movement[‘cutscene’] = 0
self[‘timer’] = 0
own.sendMessage(“restorecontrol”)
cont.deactivate(opendoor)
own[‘target’] = 7#intial weapon selection
if equipped == 0:
self[‘target’] = 7
That didn’t work. I am sure there is a simplier and to the point way of simply activating an item not available to the player without activation to spawn and use it.





