��������������������������������� BONE DAMAGE SCRIPT

 

����������������������������������������������������

 

What is bone_damage_script?

 

���������

��������� bone_damage_script is a script command which, like all script commands, can be issued in the server section of a .hag file or in a .scr file. bone_damage_script executes the given script when the given bone receives damage. Here is the syntax:

 

bone_damage_script �jointName� �path/to/my/script.scr::myFunction�

 

e.g.

bone_damage_script �joint_nozzle� �global/weldingStart.scr::propelWeldingTank�

 

 

 

Why would I ever use bone_damage_script?

 

 

������� Let�s say you had a shutter. This shutter propped open, but at rest. When the shutter takes damage you would like the shutter to swing freely. If the shutter takes too much damage it has to shatter in pieces. The easiest way to do this is with bone_damage_script. We already have an Exploder class to handle the shutter. With the Exploder class we can give the shutter health, immunities, and the effect to play when it dies. For more information on how to set up an Exploder, please see the Exploder documentation. We can add a hinge constraint on the shutter, for more information on setting up constraints please see Havok_constraints.doc. This shutter will be at rest and will wake up when the shutter takes damage because we are going to use the bone_damage_script. bone_damage_script will execute our specified script that will wake up the shutter, it will execute this script when the specified bone takes damage. For instance:

 

bone_damage_script �joint_flap� �global/window_hinge.scr::start� //when joint_flap takes damage, run window_hinge.scr::start located in global

����������������������������������������������������������������������������������������������������������� //window_hinge.scr::start will wake up the hinge

����������������������������������������������������������������������������������������������������������� //the window is an Exploder, when it dies it will play our shatter effect

 

 

 

 

How do I implement bone_damage_script?

 

������� Supppose this is our current Exploder shutter .hag file, notice the bone_damage_script lines:

 

HAG

setup

{

����������� path models/mission5/manmade/buildings

����������� skelmodel 5_1_Camp_2door_building_window1.gr2

}

init

{

����������� server

����������� {

������� ��������������� classname Exploder

����������������������� health 100

������������������ bone_damage_script "joint_sticks" "global/window_hinge.scr::start"

������� ���������� bone_damage_script "joint_flap"�� "global/window_hinge.scr::start"

����������������������� enable_entity_physics_self_collision

������� ��������������� explosioninfo 1 1 "" "snd_break_large_crate"

������ ���������������� nodamage

����������� }

��� ������� client

��� ������� {

��� ������� }

}

animations

{

��� idle����� 5_1_Camp_2door_building_window1.gr2

 

��� destroyed 5_1_Camp_2door_building_window1.gr2

��� {

������� server

������� {

����������� entry commanddelay 0.0 force_explode

������� }

������� client

�� �����{

����������������������������������� entry tagspawn joint_flap

����������������������������������� (

����������������������������������������������� count 7

����������������������������������������������� count2 12

����������������������������������������������� model models/fx/debris/wood/debris_wood_plank_long.gr2

����������������������������������������������� color 1 1 1

����������������������������������������������� collision

����������������������������������������������� bouncefactor 0

����������������������������������������������� life 3 0

����������������������������������������������� lockscale 1

����������������������������������������������� randvelaxis crandom -123 crandom 123 range 43 130

����������������������������������������������� accel 0 0 -500

����������������������������������������������� avelocity crandom 1120 crandom 123 crandom 1323

����������������������������������������������� scalemin 0.05

����������������������������������������������� scaleminy 0.05

����������������������������������������������� scalemax 0.5

����������������������������������������������� scalemaxy 0.5

����������������������������������������������� sprite_lighting 0.25

����������������������������������� )

����������������������������������� entry tagspawn joint_flap

����������������������������������� (

����������������������������������������������� count 1

����������������������������������������������� count2 1

����������������������������������������������� model smoke_single_1.spr

����������������������������������������������� alpha 0.557

����������������������������������������������� color 0.852 0.818 0.682

����������������������������������������������� scale 0.1

����������������������������������������������� scaley 0.1

����������������������������������������������� life 0.5 0

����������������������������������������������� scalerate 50

����������������������������������������������� scaleratey 50

����������������������������������������������� scalecap 0.2

����������������������������������������������� scalecap_y 0.2

����������������������������������������������� lockscale 1

����������������������������������������������� randvel crandom 12 crandom 12 crandom 12

����������������������������������������������� offsetalongaxis crandom 20 crandom 20 -12

����������������������������������������������� angles 0 0 crandom 360

����������������������������������������������� avelocity 0 0 crandom 3

����������������������������������������������� scalemin 0.1

����������������������������������������������� scaleminy 0.1

����������������������������������������������� scalemax 0.2

����������������������������������������������� scalemaxy 0.2

����������������������������������������������� fade

����������������������������������������������� sprite_lighting 0.15

����������������������������������� )

������� }

��� }

}

 

So what does the script that bone_damage_script calls look like?

//------------

start:

//------------

 

���� //Swap the renderable

��� //self altmodel "awake" //per renderable constraints not yet supported --JimG

���

��� //WORKAROUND -- hide the joint rather than switch renderables

�� //This will make the collision and mesh scale to zero --JimG

��� self hidejoint joint_sticks

�����������

���� //Enable damage on the window

��� self takedamage

�����������

���� //Wake up the hinge

���� self havok_physics_driven

�����������

end

 

I have three renderables in my file:

����������� 1. Model �contains the frame mesh, flap mesh, propping sticks mesh,all collision, and the hinge constraint

����������� 2.awake �contains everything from Model BUT the propping sticks and propping sticks mesh (they delete when the shutter swings)

����������� 3.destroyed �contains only the frame and the frame collision

Notice that I am not using �awake� right now, I think it will work, but there is no reason for me to go back and try it.

 

It sounds cool, I think I will use it everywhere!

 

������� No No No! This was implemented to solve a very specific problem and is not optimized. It is very slow and should be used extremely sparingly.