- Quick Links -


Jedi Knight modifying site

Visitor No.72282
Since July 1999

Theme :

Massassi Temple MILLENNIUM
LucasArts Entertainment Company

- Random Picture -

Lightstaff 2.0 MotS

Lightstaff 2.0 MotS

Forum Projects Documents Features Extra Links
Implementing Sniping On Body Parts

DOWNLOAD


1

Let's implement sniping shall we?

First of all, the way it works is that cog gets the distance from the center of the actor (which is GetThingPos(thing)), and the position where the bullet hit the actor and from those 2, cog works out which part of the body got hit by the bullet. It might sound complicated, but it's easy by following a few steps below.


2

In this case I'm going to make this work with any actors but since this is a simple version, player blocking with saber will even get sniped as well, but you can fix that later. I'm going to attach this cog to a bullet, so anybody got touched by the bullet will get the effect, so I don't have to edit all actor cogs in the damaged section. (hint, hint). Now first step is to the template.

You can make your own bullet template here with fast velocity and small 3do, or even no 3do. I'll just show a simple template that works nicely. As usual paste the template section info at the bottom of static.jkl and then the templates, like this.

   ###### Template information ####
   Section: templates
   World templates 3

   #Name:   Based On:   Params:
   _weapon   none   orient=(0/0/0) type=weapon collide=1 move=physics thingflags=0x20000000
   mass=5 physflags=0x200 maxrotvel=90 damageclass=0x2 typeflags=0x1

   +bullet   _weapon   thingflags=0x20000401 damage=40 mindamage=25 rate=50 vel=(0/100/0)
   size=0.0001 movesize=0.0001 typeflags=0x20440d timer=0.5 cog=else_sniped.cog

"thingflags" got changed with "cog attached" flag, so cogs work.

"damage, mindamage and rate" is to give damages. Rate will decrease the amount of the damage per second by that value.

"vel", fast enough, 100jku per second. Almost travels anywhere instantly.

"size and movesize" specify the size of the object in the 3D world. Bullets are small.

"typeflags" Nothing really got changed from original bryar bolt.

"timer" will destroy the object after the specified value since the creation, so it won't stay in the level forever.

"cog", cog attached to the bullet to give it various effects, also done in the "Giving effect on projectile" tutorial.

ok for the template.


3

Now to the cog. Create a new cog and add only touched message, that's all what it needs. Before the touched message, you must place the distance between the center position of the actor to its leg and to its neck. And I have figured out the following value for them. They work on most of the actors.

ToNeck=0.038
ToLeg=0.025

Place these 2 as a flex in the symbols. Then to the code.

   touched:

   victim = GetSourceRef();      //Who got touched by the bullet?

   if(GetThingHealth(victim) == 0) return;      //If he's dead, don't make him any poorer...

   //If not a player or an actor, don't (surface, chair, etc)
   if( (GetThingType(victim) != 10) && (GetThingType(victim) != 2) ) return;

   //If that was a droid or a mousebot by mistake, don't even think about it.
   if( (GetActorFlags(victim) & 0x100) || (GetThingModel(victim) == Mouse) ) return;

   bullet = GetSenderRef();      //The bullet just arrived its target
   player = GetThingParent(bullet);      //The good sniper man
   vic_tpl = GetThingTemplate(victim);      //Template for the victim, to check if it was a stormtrooper or not below.

   //Since their body looks tad bit different from other creatures, the position of the head is low!
   for(i=0; i<=4; i=i+1) if(vic_tpl == S0[i]) ToNeck = 0.015;
Tutorial Snipe Image 1 The distance from the GetThingPos() to the head differs from the center position of that 3do. Which can be checked by JED. The dot in the body is what you get with GetThingPos() in the level, so you can calculate the distance between there and to the neck. And stormtroopers really have different value on this than other creatures, if you check, you'll see what I saw. And that code was part of the touched message to get ready to know which part of the body the bullet hit.

4

Just below the code I just pasted at the top add the rest of the touched message.

   //Just need to know the up and down position, shown in above pic.
   Vertical = VectorZ(GetThingPos(victim)) - VectorZ(GetThingPos(bullet));

   //If it's negative, it means the position of the bullet was higher than the center of the body, head shot or none.
   if(Vertical < 0)
   {
      if(-Vertical >= ToNeck)   //Now, if that was high enough to reach the neck, it's a head shot
      {
         Print("Sniped head!");

         //Kill the guy, giving force damage, since some can half down the physical damage etc.
         //Saber can chop off arms etc.
         DamageThing(victim, GetThingHealth(victim), 0x8, player);
      }
   }
   else   //If the value was positive, then it must be lower than the center of the body.
   {
      //If it was low enough to reach legs, give it a leg shot.
      //Just giving 2 lines so it can slow down either AI or player within its situation.
      if(Vertical >= ToLeg)
      {
         Print("Sniped leg!");
         AiSetMoveSpeed(victim, 0.5);      //Slows down any AI enemy by half.
         SetActorExtraSpeed(victim, -1);      //Slows down a player by half.
      }
   }

   ToNeck = 0.038;   //Put the ToNeck value to what it was in case it might got changed by stormtroopers.

   return;

All for this cog. But make sure you place all the symbols at the top as well. Mouse is "mb.3do"


5

Make sure to edit the bryar cog so it won't make any autoaiming, which disables this sniping script and also change the projectile template reference.

projectile=+bullet

dummy = FireProjectile(player, projectile, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0, 0, 0);

Now you have made the sniping cog and the bullet. Go shoot the baddies!


Resources

static.jkl

else_sniped.cog

weap_bryar.cog


Forum Projects Documents Features Extra Links

Top - Home - Back

PHP Apache Valid XHTML 1.0! Valid CSS!

This site is developed using PHP under Apache server
with XHTML, JavaScript, CSS and Cookie technology.

Certain parts of this site require Cookie support.

This site is best viewed with Internet Explorer 5.5, Netscape 6.0, Opera 6.0 or Mozilla 1.0 and above
at resolution 800 * 600 and higher.

Nothing on this site is made, distributed, or supported by LEC.
Please use and download all materials at your own risk.

© 1999-2004 Hideki.

This page was last modified on Sat, 30 Jul 2011 17:28:41 +0000.