I am not sure where to see these errors? Python console isn’t the section to them, and the console below at the very top, doesn’t show any information on them.
So why would all these errors affect the blood effect? Because it pretty much runs, so I couldn’t of caused all of these.
import bge
from bge import logic
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
#self
self = scene.objects[own.name]
#properties
target = own['target']
incover = own['incover']
direction = own['direction']
#sensors
pnear = cont.sensors['Pnear']
collide = cont.sensors['Collision']
Ray = cont.sensors['Ray']
delay = cont.sensors['Delay1']
shootray = cont.sensors['shootray']
#actuators
refind = cont.actuators['State1']
attack = cont.actuators['State6']
flare = cont.actuators['flare']
#steering
findc = cont.actuators['walk']
runc = cont.actuators['runC']
#cover object
cover = scene.objects[own['target']]
#animations
runAnim = cont.actuators['run']
duck = cont.actuators['duck']
fwd = cont.actuators['fwdwalk']
back = cont.actuators['backwalk']
left = cont.actuators['walkleft']
right = cont.actuators['walkright']
fwdfire = cont.actuators['fwdwalkfire']
backfire = cont.actuators['backwalkfire']
leftfire = cont.actuators['walkleftfire']
rightfire = cont.actuators['walkrightfire']
#sound
sound = cont.actuators['sound']
#path finding
if cover['cover'] == 'safe' and pnear.positive == True and Ray.positive == False:
findc.target = str(own['target'])
cont.activate(findc)
if direction == 'Run Forward':
cont.activate(fwd)
elif direction == 'Run Backward':
cont.activate(back)
elif direction == 'Run Left':
cont.activate(left)
elif direction == 'Run Right':
cont.activate(right)
if cover['cover'] == 'safe' and pnear.positive == True and Ray.positive == True:
findc.target = str(own['target'])
cont.activate(findc)
if direction == 'Run Forward':
cont.activate(fwdfire)
elif direction == 'Run Backward':
cont.activate(backfire)
elif direction == 'Run Left':
cont.activate(leftfire)
elif direction == 'Run Right':
cont.activate(rightfire)
elif cover['cover'] == 'safe' and pnear.positive == False:
runc.target = str(own['target'])
cont.activate(runc)
cont.activate(runAnim)
#flare
if pnear.positive == True and Ray.positive == True and delay.positive and shootray.positive == True:
cont.activate(flare)
own.sendMessage("Phit", "", "player")
cont.activate(sound)
elif pnear.positive == True and Ray.positive == True and delay.positive and shootray.positive == False:
cont.activate(flare)
cont.activate(sound)
#find new cover
elif i['cover'] == 'safe':
cont.activate(refind)
#cover found
if collide.positive == True and incover == '':
if collide.hitObject.name == str(cover):
cont.deactivate(findc)
cont.activate(duck)
cover['cover'] = 'used'
own['incover'] = 'cover'
cont.activate(attack)
bge is still an error.
Randomsmoke
import bge
from bge import logic
import random
cont = bge.logic.getCurrentController()
own = cont.owner
smoke1 = cont.actuators['7']
smoke2 = cont.actuators['8']
motion1 = cont.actuators['Motion']
motion2 = cont.actuators['Motion1']
delay = cont.sensors['Delay']
dir = own['back']
dist = own.getDistanceTo("player")
random = random.randint(1,2)
if random == 1 and dist < 250:
cont.activate(smoke1)
if random == 2 and dist < 250:
cont.activate(smoke2)
if delay.positive == True and dir == 0 and dist < 250:
cont.activate(motion1)
cont.deactivate(motion2)
own['back'] += 1
if delay.positive == True and dir == 1 and dist < 250:
cont.activate(motion2)
cont.deactivate(motion1)
own['back'] -= 1
If you ignore errors how will you ever get your problem solved?
Some errors only get listed after others are corrected.
You may be right that these are not directly related to the blood effect. (I corrected them in my copy of your file)
I managed to get blood on your first moving enemy.
For that you must correct ‘bloodhit’:
from bge import logic
import random
import bge
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
if own['blood'] > 0:
own['blood'] -= 1
own.applyRotation([0.0, 0.0, (random.randint(0, 90))])
scene.addObject("blood splat", own, 10)
if own['blood'] == 1 or own['blood'] == 2:
scene.addObject("bloodmist", own, 30)
Then when you shoot at the enemy it just disappears. This is because the blood objects get added but they have NOT been set to “Ghost” and so they push away the enemy into unknown space.
You must set these 2 objects to “Ghost” in the physics settings:
bloodmist
blood splat
This isn’t the bullet hole effect but at least a bit blood.
To your above files.
I suppose your first code is from “movecover.py” (Please give more information in future)
You tried to fix it with my solution for another error.
Here is how “movecover.py” looks like here:
import bge
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
#self
self = scene.objects[own.name]
#properties
target = own['target']
incover = own['incover']
direction = own['direction']
#sensors
pnear = cont.sensors['Pnear']
collide = cont.sensors['Collision']
Ray = cont.sensors['Ray']
delay = cont.sensors['Delay1']
shootray = cont.sensors['shootray']
#actuators
refind = cont.actuators['State1']
attack = cont.actuators['State6']
flare = cont.actuators['flare']
#steering
findc = cont.actuators['walk']
runc = cont.actuators['runC']
#cover object
cover = scene.objects[own['target']]
#animations
runAnim = cont.actuators['run']
duck = cont.actuators['duck']
fwd = cont.actuators['fwdwalk']
back = cont.actuators['backwalk']
left = cont.actuators['walkleft']
right = cont.actuators['walkright']
fwdfire = cont.actuators['fwdwalkfire']
backfire = cont.actuators['backwalkfire']
leftfire = cont.actuators['walkleftfire']
rightfire = cont.actuators['walkrightfire']
#sound
sound = cont.actuators['sound']
#path finding
if cover['cover'] == 'safe' and pnear.positive == True and Ray.positive == False:
findc.target = str(own['target'])
cont.activate(findc)
if direction == 'Run Forward':
cont.activate(fwd)
elif direction == 'Run Backward':
cont.activate(back)
elif direction == 'Run Left':
cont.activate(left)
elif direction == 'Run Right':
cont.activate(right)
if cover['cover'] == 'safe' and pnear.positive == True and Ray.positive == True:
findc.target = str(own['target'])
cont.activate(findc)
if direction == 'Run Forward':
cont.activate(fwdfire)
elif direction == 'Run Backward':
cont.activate(backfire)
elif direction == 'Run Left':
cont.activate(leftfire)
elif direction == 'Run Right':
cont.activate(rightfire)
elif cover['cover'] == 'safe' and pnear.positive == False:
runc.target = str(own['target'])
cont.activate(runc)
cont.activate(runAnim)
#flare
if pnear.positive == True and Ray.positive == True and delay.positive and shootray.positive == True:
cont.activate(flare)
own.sendMessage("Phit", "", "player")
cont.activate(sound)
elif pnear.positive == True and Ray.positive == True and delay.positive and shootray.positive == False:
cont.activate(flare)
cont.activate(sound)
#find new cover
elif cover['cover'] != 'safe':
cont.activate(refind)
#cover found
if collide.positive == True and incover == '':
if collide.hitObject.name == str(cover):
cont.deactivate(findc)
cont.activate(duck)
cover['cover'] = 'used'
own['incover'] = 'cover'
cont.activate(attack)
ok, got more body-hole and ground-hole working in your file.
My suggestion:
From the part 15 project file append the object “eyes” with the option “active layer” unchecked.
in logic bricks you see it has 4 sensors which go to “bullethit.py002”
Select “Camera” and “eyes” to reconnect the logic bricks.
Before:
As for the blood effect, yes it now works, okayish.
As for ground hole and body hole.
I did append eyes and selected player camera, the eyes are in the same layer?
And I coped the bullethit.002 you have edited, no bullet hole on the cube or a ground hole effect The bullet hole I found in the layer and made sure the setting was active. Here is a clip, so gives you a view as to what is or isn’t working correctly.
I feel a bit disappointed, that I should of may be worked out bge import. But hey, what do I know about programming.
I may want to keep the glock’s light effect still active. I may want to use two weapons, knife and the glock. So I wouldn’t want to remove them from the game, just probably deactivate them.
But yes, I think the Ai is useful on the area there, just no on the stairs, so cover objects can be moved within the square area only.
But they were the primary AI, but I am editing my own one, I may keep one AI person. There is already one AI with a melee animation, at the end of the demo, that one more useful than the one with the gun.
Yes, both in Layer 1. Did you reconnect the Sensors as shown in the screenshot?
The bulletholes work on your cube here.
They are not the most exciting effect I want to say.
For me it was quite fun to look into this level. And it’s a good work all together.
I wish you good luck and much fun in creating your modification!
Shooting at the ground needs 2 more objects appended from pthe Part 15 file:
“ground impact”
“dust spawn”
On import always deselect the option “active Layer” !!!
BTW: The Bulletholes on your cube are only visible when the cube doesn’t move towards you because they don’t stick to the skin of the cube. They get immediately covered if the cube moves in front of them.
My main interest is more in the AI and the task, in the area at the end there is one Ai with a melee effect.
Once in contact with the door trigger it then does an animation, I only used the part where it uses the weapon facing forward, so no turn.
Is the AI there usable similar to the AI with the gun, because I tried all of that but didn’t work out.
I will check the box on the door use, for the area, that is useful too, could lead to somewhere. The train station area isn’t of use, the trains may be of use for a future addon. Some sort of mini game with the player on the train. No idea on such a task.
The AI is really the task, a lot of it seems setup.
I mean I have it in the area. But it doesn’t animate when it contact with it.
I am not sure, The Ai will attack the player, once collision, but no sound or blood effect so the player is damaged.
As for the Ai moving around, the movecover code may not work out for it. I tried using it, and the player loaded behind the door, and the program shut down.
I’m guess a simple brick program is may be suited for that task, so once player collides, Ai moves to collide with player to stab and damage the player with the blood effect, similar with the gun AI that shoots at the player and causes damage to the player an eventually is removed from scene after too many stabs.
I did check out the door, they won’t open, none of the two. The door trigger were hidden. They are all now visible in the scene.
I think I can get by with the bricks for AI movement, but the existing python code is obviously useful for the attack player with a weapon. I was wrong on the gun, there is a light, so that is okay like that.
Here is your previous File with corrected scripts, blood, bulletholes and smoke.
All doors but the last are opening.
(You can see the door triggers can still be hidden but the “end Object”-brick has to be turned off)
I am not sure, if duplicating the similar bricks as on player on the enemy helps to get the effect working for the collision May be collision brick works with Message brick ‘phit’ keyword.
Regen python code is to regenerate the player’s health meter or bar.
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
msg = cont.sensors['hit']
Delay = cont.sensors['Delay']
health = own['health']
regen = own['player']
#regen
regenT = cont.actuators['true']
regenF = cont.actuators['false']
#health regen
if msg.positive == True:
cont.activate(regenF)
cont.deactivate(regenF)
if Delay.positive and health < 100 and health > 0 and regen == False:
cont.activate(regenT)
cont.deactivate(regenT)
if regen == True and health < 100 and health > 0:
own['health'] += 1
If you want that a collision of the cube with the player shows the damage blood (like when he gets hit by shots) then you just have to send a message called “Phit” to the player.
This is easiliy done with the logic bricks like in your picture.
Each collision adds a bit. If you want to make it completely deadly then you can turn on “True level triggering” with the 3 dots and to reduce the speed the messages get sent you can edit the “skip” value:
Here is your file with a Knife Attacker.
Had to get rid of the builtin 90 °body-rotation in the knive animation. puh!
For the walk animation I simply used that from the other enemies. But you might want to put your hands on this because it doesn’t match to the knife attacker.
Although I added the blood sensors to the rig he’s immortal
The logic bricks look like that:
It isn’t the same as the primary game AI. So I guess that solved that. The was a sound file with it, but I think I can solve that myself. Bricks are confusing, but it was my motivation for blender game engine. I couldn’t use it without them.
I changed the physics type to dynamic and in the Steering brick unchecked “lock Z velocity”.
Meanwhile I added a sound when you get in contact.
Also you now can shoot at him or attack with the knfe and he will die (almost like the other enemies, but while they die after one knife stroke he will take more ) For that I created a modified “AIHealth2”-Script for him.
Now the logic bricks look more complicated, but far less than on the other enemies.
For me it was also quite interesting how this all works.
The Sensors on the enemy receive messages when the player hits them. These messages are collected by the “AIHealth”-Scripts that subtracts the enemie-health and when it is down to 1 the logic bricks are switched to another state that drive the Death-animations.
Here’s the file: