Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 1,086 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 1 of 4 1 2 3 4
Shotting detection in different body parts #254953
03/06/09 16:16
03/06/09 16:16
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
Hi

Some people might be tired of awnsering posts about this, sorry.
For what i could find, some people use vertex distance to define shots in different body parts, but I found that a bit innacurate, maybe because the way i've wrote the code or vertex distance is not the right way to do it.

So could anyone help me telling which way is the right way to detect, headshots, leg shot..... ?

thanks smile

Re: Shotting detection in different body parts [Re: DestroyTheRunner] #255040
03/07/09 08:34
03/07/09 08:34
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
the only thing i could think of is the closet bones ore make parts which you need to hit instead of the whole model


"empty"
Re: Shotting detection in different body parts [Re: flits] #255045
03/07/09 09:07
03/07/09 09:07
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I would go for the bone that the hit vertex is attached to.
I think this (UNTESTED) code should give satisfactory results.
(there is more in there than you'll need, but I put it in just in case)
Code:
STRING* HitBoneName = str_create("");
///
var dist = c_trace(whatever);
if(dist>0)   //make sure something WAS hit
{  if(hit.entity!=NULL);     //make sure we have an ENTITY
   {  ent_bonename(hit.entity, HitBoneName, hit.vertex);    //get the bone name
      if(str_len(HitBoneName)>0)   //make sure a BONE has been hit
      {  //"HitBoneName" is the name of the bone we've hit.
         //and if you name them simple like L_Arm_0, L_Arm_1, R_Arm_0, R_Arm_1, etc 
         //they'll be easy to spot with
         if(str_cmpni(HitBoneName,"L_Arm_")==1)
         {   //some part of LEFT ARM was hit      }
         else if(str_cmpni(HitBoneName,"R_Arm_")==1)
         {   //some part of RIGHT ARM was hit      }
         else if(str_cmpni(HitBoneName,"L_Leg_")==1)
         {   //some part of LEFT LEG was hit      }
         else if(str_cmpni(HitBoneName,"R_Leg_")==1)
         {   //some part of RIGHT LEG was hit      }
      }
      else
      {
         //entity has been hit but no bone is assigned to that vertex
      }
   }
   else
   {
      //there was a hit but NOT an entity
   }
}
else
{
   //NOTHING was hit
}



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Shotting detection in different body parts [Re: EvilSOB] #255074
03/07/09 13:13
03/07/09 13:13
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
hey guys thanks for your replies...
something I should've metioned before is that I still use A6 standard version which does not support bones. frown
but thanks if someday I upgrade to a higher version, the bones detection code will be surely put in use smile

does anyone has any other idea of how I could achieve this with my a6 standard version?

Re: Shotting detection in different body parts [Re: DestroyTheRunner] #255085
03/07/09 14:24
03/07/09 14:24
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Ive never used A6, so you'll need to to a bit of research on HOW to implement,
this but here is a concept that may be managable in A6.
1> Get the vertex nearest the 'impact" point.
2> Get the UV co-ordinate of that vertex.
3> Get the COLOR of the pixel at that UV co-ordinate from an unused,
color-coded skin(that is embedded in the MDL file). These colors relate to
which limb / body-part is in the actual uv-mapped skin.
4> From this color you know which body part was hit.

Get what I mean? Have a second, never-displayed skin with simple colors
painting the different body parts.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Shotting detection in different body parts [Re: EvilSOB] #255097
03/07/09 15:40
03/07/09 15:40
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
wow...thats a freaking clever idea!
But Ill check the manual to see if the Part 3 of the concept is possible.
I'll let you know if i managed to work it out!

thanks smile

Re: Shotting detection in different body parts [Re: DestroyTheRunner] #255105
03/07/09 16:26
03/07/09 16:26
Joined: Jun 2007
Posts: 152
Norway
D
Darkyyes Offline
Member
Darkyyes  Offline
Member
D

Joined: Jun 2007
Posts: 152
Norway
part 3 concept should work, if you store a color skin(arms red, feets blue, groin-stomach purple, chest green, head yellow) then through the hit detection it will check one of these colors, then if it hits red then it will hit the arms and damage lets say, 10, if it hits yellow which is head it will damage 100


through code you should be able to scan which color it detects on that skin, lets say its named hitskin then tell the code to scan that skin for the colors,
if you want random damage on head or the other parts, like this
if yellow(head)
78....100(or higher if you want "overkill" damage) then have like a random(20)

if you want random damage from different weapons this should be a function inside every type of weapon. just change the values inside the damage part.

this is just for filling out the third concept


New to lite-c and gamestudio in general, thank you for reading.
Com, A7 v7.7
Re: Shotting detection in different body parts [Re: DestroyTheRunner] #255107
03/07/09 16:38
03/07/09 16:38
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
In case it may aid your search, here are the commands I would use in A7 - LiteC
Code:
Check before here that we have a sucessful hit on an entity.
1> var ClosestVertex = hitvertex;    //get the nearest vertex to the hit position
2> var UV[3];  vec_for_uv(UV, you, ClosestVertex);    //get the X,Y co-ordinate of that vertex in the UV map
3> BMAP* ColorMap = ent_getskin(you, 3);  //get the color-map skin, assume limb-color skin to be number 3
   var BmapType = bmap_lock(ColorMap);   //required to allow use of pixel_for_bmap
   var LimbPixel = pixel_for_bmap(ColorMap, UV[0], UV[1]);   //get the pixel from the colormap at UV position
   var LimbColor[3];   pixel_to_vec(LimbColor, NULL, BmapType, LimbPixel);    //convert pixel to a color vector
   bmap_unlock(ColorMap);   //free bmap now we are done with it
And now LimbColor contains the blue[0], green[1], and red[2] contents of the limb that got hit.
This code is a bit long winded and could easily be compressed, but Ive put it all in
to aid in your understanding of whats going on.
Remember, this is A7 stuff, but you may be able to find A6 equivalents for most of it.
Also, this code ISNT tested.

Best of luck...




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Shotting detection in different body parts [Re: EvilSOB] #255117
03/07/09 18:27
03/07/09 18:27
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
@darkyyes
thanks for you addon.. i already have an ideia about the damages and stuff...

@EvilSOB
thanks... thats what i was doing, searching for functions that would detect the color inside da skin... as soon as i get home, ill try them...

thanks you guys very much smile

Re: Shotting detection in different body parts [Re: DestroyTheRunner] #255581
03/11/09 12:02
03/11/09 12:02
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
It worked!

the only problem is that my model contains several skins from several different mapped parts. eg. Head and throat, arms, legs....

and as far as i know i cant have the whole model mapped onto only one skin while the others skins have different vertices mapped ....
any work around?

Page 1 of 4 1 2 3 4

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1