ok, have a look at this:
i suppose you are making it in 3d? then i'll gues that you use the command intersect object for shooting, or something similliar. if you do, it'll look a little bit like this:
firs we define a type. this type contains 2 values: the Zombie object number, the zombie is i think just a person, but then green. and the type also contains the object number of the hitbox. the hitbox is placed at the heads position every loop, so we can check for headshots every loop. How? well, lets say we now what the Y position is. and we now that the psotition of the head limb always the objects y position + 10 is. then we just place the hitbox at y position(objectnum)+10
we also make an array, to store the hitbox object number for every enemy and the main zombie object number for every enemy.
we now have this code:
// First we define the type
type MyMonster
ObjNum as Integer // Object Number of the zombie object
HitBoxNum as Integer // Object Number of the Hitbox
endtype
// Now we define an array for the monsters, we'll make ten monsters
dim Monster(10) as MyMonster
// here you could make a for loop that fills the monster array with data about teh object numbers
// Main Loop:
do
// Position the hitboxes at the heads position
// Count the array for enemys
ArCount = Array Count(Monster())
// Do the zombie AI Stuff
// A for loop for looping through the enemies to update the hitboxes
for ID = 1 to ArCount
position object Monster(ID).HitBoxNum, Object position X(Monster(ID).ObjNum), Object position Y(Monster(ID).ObjNum)+10, Object position Z(Monster(ID).ObjNum)
next ID
loop
Now that we have updated the hitboxes, it's time for checking if the player shooted (or shot) at some of the zombies. first, we loop through the array to get the Object numbers of the main zombie object and the Hitbox. then, we first check for collision with the hitbox, and then we check for collision with the body of teh zombie. Why in this order? because, if we would check for the zombie main object first, and we were aiming at the head, we would always get hit, and if we are aiming at the zombie's torso, and we check for the hitbox first, we'll know that we aren;t aiming at the head cause we'll get a negative for head collision then. so, all in all, it would look like this:
// First we define the type
type MyMonster
ObjNum as Integer // Object Number of the zombie object
HitBoxNum as Integer // Object Number of the Hitbox
endtype
// Now we define an array for the monsters, we'll make ten monsters
dim Monster(10) as MyMonster
// here you could make a for loop that fills the monster array with data about teh object numbers
// Main Loop:
do
// Position the hitboxes at the heads position
// Count the array for enemys
ArCount = Array Count(Monster())
// Do the zombie AI Stuff
// A for loop for looping through the enemies to update the hitboxes
for ID = 1 to ArCount
position object Monster(ID).HitBoxNum, Object position X(Monster(ID).ObjNum), Object position Y(Monster(ID).ObjNum)+10, Object position Z(Monster(ID).ObjNum)
next ID
intersect object
// Now that we updated the hitboxes, we can check for collision
// check for mouseclickm, if thats your primary "SHoot" button :P
If mouseclick() = 1
// First we get the Array size, so we'll loop through every enemy
ArCount = Array Count(Monster())
// Loop through the array for the object hitbox and number data
for ID = 1 to ArCount
// First we check for collision for the hitbox. i'm using an imaginary function here
// but its posiible to make a real one. this "imaginary function" will return if i have hit the
// object or not. if i did, it'll return a 1. otherwise, a 0
HitBoxCollision = CheckForMonsterHit(Monster(ID).HitBoxNum)
// Here i check if the value returned by the "Imaginary function" was true. if it is, i send my
// program to the HeadShotMade routine were it handles health of the currently hit zombie
if HitBoxCollision = 1 then gosub HeadShotMade
// Now i'm gonna check for collision with the Body of the zombie. but first we check if we've hitted
// the hitbox already, because we don;t want double hits and stuff. if its one, we don;t check for collision
// with the body. if its zero, which means we didn;t make a headshot ((:O)) we check for collision with the body
if HitBoxCollision = 0
// Here we check for collision the body object of the enemy
BodyCollision = CheckForMonsterHit(Monster(ID).ObjNum)
// If we hitted the Body object of the enemy, we send the porgram to the NormalShotMade routine
if BodyCollision = 1 then Gosub NormalShotMade
endif
// And when that's all done, on to the next enemy!
next ID
// this should look familliar. if not, read the beginners tutorial
endif
// this should look familliar too. if not, read the beginners tutorial
loop
i hope you can understand the loads of infirmation at once, since i'm not a too good explanator
read through it a few times, and try to run through in your head, that sometimes makes me understand it better. oh, and you can also copy this whole code in your DBP ide, that makes it more understandable.
EDIT: omg sorry, i think i posted in the wrong topic
i think this would be most helpful in this topic: http://forum.thegamecreators.com/?m=forum_view&t=151506&b=7
ohhh i feel so emberrased D:
*ding ding*