PDA

View Full Version : Damageable objects in SCASM



rhumbaflappy
May 25th, 2013, 14:15
I had a request for a simple SCASM example for a damageable library object for CFS2.


A damageable object in CFS2 is a library object. It can be easily made in SCASM code:




Header( 1 N90:00:00.00 S90:00:00.00 E180:00:00.00 W180:00:00.00 )
LatRange( S90:00:00.00 N90:00:00.00 )

; ----------------------------------------
; Library Object #1
; ----------------------------------------

;//////////////////////////////////////////ObjID is a unique GUID number to identify the library object

ObjID( 2C1D3FFB 4259FA73 4B77FAA3 D3FB5C50 )


;//////////////////////////////////////////SIZE and SCALE should be available from the code????
LibObj(
PWR 0
SIZE 10
SCALE 0.5
TYPE 0
NAME "inf_rhumba_object" )


IfVarAnd( :_Undamaged_code 0024 0040 )

BGLVersion( 0732 )

; /////////////////////////////////////////<your code from damage model>

MaterialList( 0
; material 0
0.467 0.525 0.196 1.000 ; diffuse color
0.467 0.525 0.196 1.000 ; ambient color
0.000 0.000 0.000 1.000 ; specular color
0.000 0.000 0.000 1.000 ; emissive color
0.000 ; specular power
)
VertexList( 0
-9.000 9.000 0.000 -0.863 -0.357 0.357 0.000 1.000 ; vertex 0
-9.000 9.000 0.000 -0.863 -0.357 -0.357 0.000 1.000 ; vertex 1
-9.000 9.000 0.000 -0.863 0.357 0.357 0.000 1.000 ; vertex 2
-9.000 9.000 0.000 -0.863 0.357 -0.357 0.000 1.000 ; vertex 3
-6.360 2.640 0.000 -0.863 -0.357 0.357 0.000 1.000 ; vertex 4
-6.360 2.640 0.000 -0.863 -0.357 -0.357 0.000 1.000 ; vertex 5
-6.360 2.640 0.000 -0.378 -0.912 0.157 0.000 1.000 ; vertex 6
-6.360 2.640 0.000 -0.378 -0.912 -0.157 0.000 1.000 ; vertex 7
-6.360 9.000 6.360 -0.863 -0.357 0.357 0.000 1.000 ; vertex 8
-6.360 9.000 6.360 -0.863 0.357 0.357 0.000 1.000 ; vertex 9
-6.360 9.000 6.360 -0.357 -0.357 0.863 0.000 1.000 ; vertex 10
-6.360 9.000 6.360 -0.357 0.357 0.863 0.000 1.000 ; vertex 11
-6.360 9.000 -6.360 -0.863 -0.357 -0.357 0.000 1.000 ; vertex 12
-6.360 9.000 -6.360 -0.863 0.357 -0.357 0.000 1.000 ; vertex 13
-6.360 9.000 -6.360 -0.357 -0.357 -0.863 0.000 1.000 ; vertex 14
-6.360 9.000 -6.360 -0.357 0.357 -0.863 0.000 1.000 ; vertex 15
-6.360 15.360 0.000 -0.863 0.357 0.357 0.000 1.000 ; vertex 16
-6.360 15.360 0.000 -0.863 0.357 -0.357 0.000 1.000 ; vertex 17
-6.360 15.360 0.000 -0.378 0.912 0.157 0.000 1.000 ; vertex 18
-6.360 15.360 0.000 -0.378 0.912 -0.157 0.000 1.000 ; vertex 19
-4.496 2.640 4.496 -0.863 -0.357 0.357 0.000 1.000 ; vertex 20
-4.496 2.640 4.496 -0.378 -0.912 0.157 0.000 1.000 ; vertex 21
-4.496 2.640 4.496 -0.357 -0.357 0.863 0.000 1.000 ; vertex 22
-4.496 2.640 4.496 -0.157 -0.912 0.378 0.000 1.000 ; vertex 23
-4.496 2.640 -4.496 -0.863 -0.357 -0.357 0.000 1.000 ; vertex 24
-4.496 2.640 -4.496 -0.378 -0.912 -0.157 0.000 1.000 ; vertex 25
-4.496 2.640 -4.496 -0.357 -0.357 -0.863 0.000 1.000 ; vertex 26
-4.496 2.640 -4.496 -0.157 -0.912 -0.378 0.000 1.000 ; vertex 27
-4.496 15.360 4.496 -0.863 0.357 0.357 0.000 1.000 ; vertex 28
-4.496 15.360 4.496 -0.378 0.912 0.157 0.000 1.000 ; vertex 29
-4.496 15.360 4.496 -0.357 0.357 0.863 0.000 1.000 ; vertex 30
-4.496 15.360 4.496 -0.157 0.912 0.378 0.000 1.000 ; vertex 31
-4.496 15.360 -4.496 -0.863 0.357 -0.357 0.000 1.000 ; vertex 32
-4.496 15.360 -4.496 -0.378 0.912 -0.157 0.000 1.000 ; vertex 33
-4.496 15.360 -4.496 -0.357 0.357 -0.863 0.000 1.000 ; vertex 34
-4.496 15.360 -4.496 -0.157 0.912 -0.378 0.000 1.000 ; vertex 35
0.000 0.000 0.000 -0.378 -0.912 0.157 0.000 1.000 ; vertex 36
0.000 0.000 0.000 -0.378 -0.912 -0.157 0.000 1.000 ; vertex 37
0.000 0.000 0.000 -0.157 -0.912 0.378 0.000 1.000 ; vertex 38
0.000 0.000 0.000 -0.157 -0.912 -0.378 0.000 1.000 ; vertex 39
0.000 0.000 0.000 0.157 -0.912 0.378 0.000 1.000 ; vertex 40
0.000 0.000 0.000 0.157 -0.912 -0.378 0.000 1.000 ; vertex 41
0.000 0.000 0.000 0.378 -0.912 0.157 0.000 1.000 ; vertex 42
0.000 0.000 0.000 0.378 -0.912 -0.157 0.000 1.000 ; vertex 43
0.000 2.640 6.360 -0.357 -0.357 0.863 0.000 1.000 ; vertex 44
0.000 2.640 6.360 -0.157 -0.912 0.378 0.000 1.000 ; vertex 45
0.000 2.640 6.360 0.157 -0.912 0.378 0.000 1.000 ; vertex 46
0.000 2.640 6.360 0.357 -0.357 0.863 0.000 1.000 ; vertex 47
0.000 2.640 -6.360 -0.357 -0.357 -0.863 0.000 1.000 ; vertex 48
0.000 2.640 -6.360 -0.157 -0.912 -0.378 0.000 1.000 ; vertex 49
0.000 2.640 -6.360 0.157 -0.912 -0.378 0.000 1.000 ; vertex 50
0.000 2.640 -6.360 0.357 -0.357 -0.863 0.000 1.000 ; vertex 51
0.000 9.000 9.000 -0.357 -0.357 0.863 0.000 1.000 ; vertex 52
0.000 9.000 9.000 -0.357 0.357 0.863 0.000 1.000 ; vertex 53
0.000 9.000 9.000 0.357 -0.357 0.863 0.000 1.000 ; vertex 54
0.000 9.000 9.000 0.357 0.357 0.863 0.000 1.000 ; vertex 55
0.000 9.000 -9.000 -0.357 -0.357 -0.863 0.000 1.000 ; vertex 56
0.000 9.000 -9.000 -0.357 0.357 -0.863 0.000 1.000 ; vertex 57
0.000 9.000 -9.000 0.357 -0.357 -0.863 0.000 1.000 ; vertex 58
0.000 9.000 -9.000 0.357 0.357 -0.863 0.000 1.000 ; vertex 59
0.000 15.360 6.360 -0.357 0.357 0.863 0.000 1.000 ; vertex 60
0.000 15.360 6.360 -0.157 0.912 0.378 0.000 1.000 ; vertex 61
0.000 15.360 6.360 0.157 0.912 0.378 0.000 1.000 ; vertex 62
0.000 15.360 6.360 0.357 0.357 0.863 0.000 1.000 ; vertex 63
0.000 15.360 -6.360 -0.357 0.357 -0.863 0.000 1.000 ; vertex 64
0.000 15.360 -6.360 -0.157 0.912 -0.378 0.000 1.000 ; vertex 65
0.000 15.360 -6.360 0.157 0.912 -0.378 0.000 1.000 ; vertex 66
0.000 15.360 -6.360 0.357 0.357 -0.863 0.000 1.000 ; vertex 67
0.000 18.000 0.000 -0.378 0.912 0.157 0.000 1.000 ; vertex 68
0.000 18.000 0.000 -0.378 0.912 -0.157 0.000 1.000 ; vertex 69
0.000 18.000 0.000 -0.157 0.912 0.378 0.000 1.000 ; vertex 70
0.000 18.000 0.000 -0.157 0.912 -0.378 0.000 1.000 ; vertex 71
0.000 18.000 0.000 0.157 0.912 0.378 0.000 1.000 ; vertex 72
0.000 18.000 0.000 0.157 0.912 -0.378 0.000 1.000 ; vertex 73
0.000 18.000 0.000 0.378 0.912 0.157 0.000 1.000 ; vertex 74
0.000 18.000 0.000 0.378 0.912 -0.157 0.000 1.000 ; vertex 75
4.496 2.640 4.496 0.157 -0.912 0.378 0.000 1.000 ; vertex 76
4.496 2.640 4.496 0.357 -0.357 0.863 0.000 1.000 ; vertex 77
4.496 2.640 4.496 0.378 -0.912 0.157 0.000 1.000 ; vertex 78
4.496 2.640 4.496 0.863 -0.357 0.357 0.000 1.000 ; vertex 79
4.496 2.640 -4.496 0.157 -0.912 -0.378 0.000 1.000 ; vertex 80
4.496 2.640 -4.496 0.357 -0.357 -0.863 0.000 1.000 ; vertex 81
4.496 2.640 -4.496 0.378 -0.912 -0.157 0.000 1.000 ; vertex 82
4.496 2.640 -4.496 0.863 -0.357 -0.357 0.000 1.000 ; vertex 83
4.496 15.360 4.496 0.157 0.912 0.378 0.000 1.000 ; vertex 84
4.496 15.360 4.496 0.357 0.357 0.863 0.000 1.000 ; vertex 85
4.496 15.360 4.496 0.378 0.912 0.157 0.000 1.000 ; vertex 86
4.496 15.360 4.496 0.863 0.357 0.357 0.000 1.000 ; vertex 87
4.496 15.360 -4.496 0.157 0.912 -0.378 0.000 1.000 ; vertex 88
4.496 15.360 -4.496 0.357 0.357 -0.863 0.000 1.000 ; vertex 89
4.496 15.360 -4.496 0.378 0.912 -0.157 0.000 1.000 ; vertex 90
4.496 15.360 -4.496 0.863 0.357 -0.357 0.000 1.000 ; vertex 91
6.360 2.640 0.000 0.378 -0.912 0.157 0.000 1.000 ; vertex 92
6.360 2.640 0.000 0.378 -0.912 -0.157 0.000 1.000 ; vertex 93
6.360 2.640 0.000 0.863 -0.357 0.357 0.000 1.000 ; vertex 94
6.360 2.640 0.000 0.863 -0.357 -0.357 0.000 1.000 ; vertex 95
6.360 9.000 6.360 0.357 -0.357 0.863 0.000 1.000 ; vertex 96
6.360 9.000 6.360 0.357 0.357 0.863 0.000 1.000 ; vertex 97
6.360 9.000 6.360 0.863 -0.357 0.357 0.000 1.000 ; vertex 98
6.360 9.000 6.360 0.863 0.357 0.357 0.000 1.000 ; vertex 99
6.360 9.000 -6.360 0.357 -0.357 -0.863 0.000 1.000 ; vertex 100
6.360 9.000 -6.360 0.357 0.357 -0.863 0.000 1.000 ; vertex 101
6.360 9.000 -6.360 0.863 -0.357 -0.357 0.000 1.000 ; vertex 102
6.360 9.000 -6.360 0.863 0.357 -0.357 0.000 1.000 ; vertex 103
6.360 15.360 0.000 0.378 0.912 0.157 0.000 1.000 ; vertex 104
6.360 15.360 0.000 0.378 0.912 -0.157 0.000 1.000 ; vertex 105
6.360 15.360 0.000 0.863 0.357 0.357 0.000 1.000 ; vertex 106
6.360 15.360 0.000 0.863 0.357 -0.357 0.000 1.000 ; vertex 107
9.000 9.000 0.000 0.863 -0.357 0.357 0.000 1.000 ; vertex 108
9.000 9.000 0.000 0.863 -0.357 -0.357 0.000 1.000 ; vertex 109
9.000 9.000 0.000 0.863 0.357 0.357 0.000 1.000 ; vertex 110
9.000 9.000 0.000 0.863 0.357 -0.357 0.000 1.000 ; vertex 111
)

SetMaterial( 0 -1 )
DrawTriList( 0
52 44 22 ; 0
68 29 18 ; 1
69 19 33 ; 2
71 35 65 ; 3
73 66 88 ; 4
75 90 105 ; 5
74 104 86 ; 6
72 84 62 ; 7
60 53 11 ; 8
60 11 30 ; 9
28 9 2 ; 10
28 2 16 ; 11
17 3 13 ; 12
17 13 32 ; 13
34 15 57 ; 14
34 57 64 ; 15
67 59 101 ; 16
67 101 89 ; 17
91 103 111 ; 18
91 111 107 ; 19
106 110 99 ; 20
106 99 87 ; 21
85 97 55 ; 22
85 55 63 ; 23
70 61 31 ; 24
52 22 10 ; 25
8 20 4 ; 26
8 4 0 ; 27
1 5 24 ; 28
1 24 12 ; 29
14 26 48 ; 30
14 48 56 ; 31
58 51 81 ; 32
58 81 100 ; 33
102 83 95 ; 34
102 95 109 ; 35
108 94 79 ; 36
108 79 98 ; 37
96 77 47 ; 38
96 47 54 ; 39
38 23 45 ; 40
36 6 21 ; 41
37 25 7 ; 42
39 49 27 ; 43
41 80 50 ; 44
43 93 82 ; 45
42 78 92 ; 46
40 46 76 ; 47
)
EndVersion
Return
; /////////////////////////////////////////

:_Undamaged_code

BGLVersion( 0732 )

; /////////////////////////////////////////<your code from normal model>

MaterialList( 0
; material 0
0.969 0.063 0.278 1.000 ; diffuse color
0.969 0.063 0.278 1.000 ; ambient color
0.000 0.000 0.000 1.000 ; specular color
0.000 0.000 0.000 1.000 ; emissive color
0.000 ; specular power
)
VertexList( 0
-10.000 0.000 10.000 -1.000 0.000 0.000 0.000 1.000 ; vertex 0
-10.000 0.000 10.000 0.000 -1.000 0.000 0.000 1.000 ; vertex 1
-10.000 0.000 10.000 0.000 0.000 1.000 0.000 1.000 ; vertex 2
-10.000 0.000 -10.000 -1.000 0.000 0.000 0.000 1.000 ; vertex 3
-10.000 0.000 -10.000 0.000 -1.000 0.000 0.000 1.000 ; vertex 4
-10.000 0.000 -10.000 0.000 0.000 -1.000 0.000 1.000 ; vertex 5
-10.000 20.000 10.000 -1.000 0.000 0.000 0.000 1.000 ; vertex 6
-10.000 20.000 10.000 0.000 0.000 1.000 0.000 1.000 ; vertex 7
-10.000 20.000 10.000 0.000 1.000 0.000 0.000 1.000 ; vertex 8
-10.000 20.000 -10.000 -1.000 0.000 0.000 0.000 1.000 ; vertex 9
-10.000 20.000 -10.000 0.000 0.000 -1.000 0.000 1.000 ; vertex 10
-10.000 20.000 -10.000 0.000 1.000 0.000 0.000 1.000 ; vertex 11
10.000 0.000 10.000 0.000 -1.000 0.000 0.000 1.000 ; vertex 12
10.000 0.000 10.000 0.000 0.000 1.000 0.000 1.000 ; vertex 13
10.000 0.000 10.000 1.000 0.000 0.000 0.000 1.000 ; vertex 14
10.000 0.000 -10.000 0.000 -1.000 0.000 0.000 1.000 ; vertex 15
10.000 0.000 -10.000 0.000 0.000 -1.000 0.000 1.000 ; vertex 16
10.000 0.000 -10.000 1.000 0.000 0.000 0.000 1.000 ; vertex 17
10.000 20.000 10.000 0.000 0.000 1.000 0.000 1.000 ; vertex 18
10.000 20.000 10.000 0.000 1.000 0.000 0.000 1.000 ; vertex 19
10.000 20.000 10.000 1.000 0.000 0.000 0.000 1.000 ; vertex 20
10.000 20.000 -10.000 0.000 0.000 -1.000 0.000 1.000 ; vertex 21
10.000 20.000 -10.000 0.000 1.000 0.000 0.000 1.000 ; vertex 22
10.000 20.000 -10.000 1.000 0.000 0.000 0.000 1.000 ; vertex 23
)

SetMaterial( 0 -1 )
DrawTriList( 0
17 14 20 ; 0
12 15 4 ; 1
11 22 19 ; 2
19 8 11 ; 3
5 16 21 ; 4
21 10 5 ; 5
4 1 12 ; 6
20 23 17 ; 7
13 2 7 ; 8
7 18 13 ; 9
0 3 9 ; 10
9 6 0 ; 11
)
EndVersion
Return

; /////////////////////////////////////////

EndObj



Dick

Shessi
May 26th, 2013, 14:32
Dick,
Many thanks for starting this thread off.

A few questions;

To get to the sca situation (as above) do you create two separate models (one undamaged and one damaged), then sca them, to get the info, then combine the sca's to create the combo sca example as above? Do you then combine the two models to create one 2-LOD (undamaged and damaged) model?

Or just create a 2-LOD (undamaged and damaged) model bgl-then sca that, then pick the separate sca sections for each model and create the above combo sca? Or?

Where do the DP boxes and boxmaps come into it?

Cheers

Shessi

rhumbaflappy
May 26th, 2013, 18:11
Hi Shessi.

Yes, create two objects. Then it's pretty much cut and paste from there on.

Try it out with simple models first, then you can use more complicated models.

Dick

Shessi
May 27th, 2013, 11:59
Ok then Dick, thanks.

1) I separately created a simple coloured cube (undamaged object) and a coloured sphere (damaged object).
2) I sca'd both of these.
3) I then went to replicate your posted sca, but.....

1) The initial Header and Latrange at the top, is that the Header and Latrange from the undamaged or damaged object?

2) Can I create any unique GUID number, I use Matts Scasm Editor to create a unique code.

3) You say that size and scale should be from the code, and then ????, where does he scale come from?

4) IfVarAnd( :_Undamaged_code 0024 0040 ) where does this code come from, as neither of the sca'd objects I did (FSDS2.4) have this in the sca?

5) Does the order of the sca text have to be damaged object first then the undamaged object?

6) After getting the above combo sca sorted, do you then combine the two objects as a multi LOD object and create a combo .bgl from that?

7) If that is the case doesn't the code change so that it won't match the hand edited combined sca? Or is the code still correct as it is amde with the same objects?

8) As before, where do the DP boxes and boxmaps come into it?

Sorry for lots of questions! I do work with scasm, and understand the fundementals, but this is whole new ballgame to me, so appreciate your time and answers.

Cheers

Shessi

rhumbaflappy
May 28th, 2013, 13:07
1) The initial Header and Latrange at the top, is that the Header and Latrange from the undamaged or damaged object?

This header is for the object library BGL you are creating. You want the objects to be place-able anywhere in the world.

2) Can I create any unique GUID number, I use Matts Scasm Editor to create a unique code.

Yes. You need to create a unique number for each library object... in this case the object is damagable, but one number for both parts.

3) You say that size and scale should be from the code, and then ????, where does he scale come from?

In the example code, the size is 10, and the scale is 0.5 ( the scale is usually 0.5 for CFS2 and fs2002 objects ). The actual object size is 5 meters ( 10m x 0.5 ).

4) IfVarAnd( :_Undamaged_code 0024 0040 ) where does this code come from, as neither of the sca'd objects I did (FSDS2.4) have this in the sca?

This is the conditional code that displays the damaged model. :_Undamaged_code is the condition failure's jump label, 0024 is the damage variable for CFS2 objects, 0040 ( decimal 64 ) is the universal bitwise "flag" for damage.

5) Does the order of the sca text have to be damaged object first then the undamaged object?

Yes, because on failing the conditional IfVarAnd test, you jump over the damage code and display the undamaged model.

6) After getting the above combo sca sorted, do you then combine the two objects as a multi LOD object and create a combo .bgl from that?

No. You are creating an object library BGL. ( Each model could have LODs if desired... LOD = level of detail, and is triggered by how much of the screen's viewport is taken up by the object. )

7) If that is the case doesn't the code change so that it won't match the hand edited combined sca? Or is the code still correct as it is amde with the same objects?

This is where you're getting mixed up. A damageable object is a library object that has 2 conditional states.

8) As before, where do the DP boxes and boxmaps come into it?

In the example, I named the object "inf_rhumba_object", so the DP file needs to be inf_rhumba_object.dp, and that text file goes into the OBJECTS_DP folder. I'd look at the .dp files for examples of what you might want for the damage ( effects, etc...)


Dick

Shessi
May 30th, 2013, 11:49
Dick,
Appreciate your patience and time...;)

Ok, got all that. I do understand the idea of a condition state and it being controlled and triggered by damage boxes and a DP.

Regarding Q6. I trying to get clear in my head is the intial building of the models to then create a damageable bgl. I have created one model which is the undamaged version and a separate model being the damaged version. These have been separately sca'd, to create the sca info. Is this incorrect, or should the model be created as one, with both the damage and undamage models already together in it?

In FSDS or Gmax are they separate models within the same model (almost like LODs) or are they actually physically combined within each other, so they are as one, and the natural default view is the conditional IfVarAnd test undamaged model and the DP triggers the viewing of the damaged model. (This is why I was asking, when are they combined to create one model?).
I know this may sound obvious, but I'm used to creating mdls with separate LODs which are triggerd by distance.

Cheers

Shessi

rhumbaflappy
May 30th, 2013, 15:20
I have created one model which is the undamaged version and a separate model being the damaged version.

They are separate models. You just need to cut and paste the appropriate SCASM code to combine into a SCASM library.

Each separate model can have distance LOD code as well, if desired.

Dick

Shessi
May 30th, 2013, 15:41
Ahh I'm seeing it now (I think!). So after combining the sca for the two models (undamaged and damaged), you then convert this combined sca back into a bgl using a sca editor (I use MDLC) to create the model/bgl manually?
I was thinking that you mirrored what was done in the sca with what was done in FSDS/Gmax, but in fact you're using the separate models just to supply info for the sca's, to then build the combined sca, and then make the bgl from that.

What do you use for making bgls?

Shessi

rhumbaflappy
May 31st, 2013, 14:49
You don't need a SCASM editor. Use a text editor. Notepad works fine.

Drop the text file onto SCASM.exe to make the library BGL, or use the command line. I think the latest version of SCASM is v89. Note that this is a library BGL and not a placed object. To place it you need to make a placement BGL, just as you would place any default scenery object.

Dick

Shessi
June 1st, 2013, 01:59
Ok, got that.


I wanted to make damageable placed objects ie structures etc. So to make a placed damageble object/item/structure, just make the object but with the correct location co-ordinates, and then make the damageable bgl from that?

Shessi

rhumbaflappy
June 1st, 2013, 07:01
Probably the best way to show you exactly what to do is for you to zip and attach 2 SCASM objects in a post for me. 2 simple objects... say a cube and a flattened cube. Make them textured and attach the textures as well.

I believe you use FSDS 2.? to make the objects, and FSDS will export SCASM code for us... that's what we want.

I'll show you what we want to copy from the objects, and what we add to the code to produce a damageable library object from that.

Dick

Shessi
June 2nd, 2013, 14:34
Here you are, as requested see attached, thanks.

Could you just answer, for damageable objects etc I want to place as scenery. Create undamaged and damaged objects, with the location co-ordinates set in FSDS the same for both, then combine the sca, set a DP for it, and place in the scenery?

Shessi

rhumbaflappy
June 4th, 2013, 12:46
;//////////////////////////////////////////Standard header for library objects allowing them to be placed anywhere in the world

Header( 1 N90:00:00.00 S90:00:00.00 E180:00:00.00 W180:00:00.00 )
LatRange( S90:00:00.00 N90:00:00.00 )

; ----------------------------------------
; Library Object #1
; ----------------------------------------

;//////////////////////////////////////////ObjID is a unique GUID number to identify the library object

ObjID( 5C1D3FAA 4259FA73 4B77FAA3 D3FB5C80 )


;//////////////////////////////////////////SIZE and SCALE should be available from the code ( check your original refpoint for scale, VertexList reveals size )

LibObj(
PWR 0
SIZE 200
SCALE 0.1
TYPE 0
NAME "MyBox" )


IfVarAnd( :_Undamaged_code 0024 0040 )

; /////////////////////////////////////////

:_Damaged_code


BGLVersion( 0800 )
TextureList( 0
6 FF 255 255 255 0 50.000000 "Box_dam.bmp"
)
MaterialList( 0
1.000000 0.000000 0.000000 1.000000 1.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000
)
VertexList( 0
-100.000000 0.000000 -100.000000 0.000000 1.000000 0.000000 0.000000 0.000000
100.000000 -0.000000 -100.000000 0.000000 1.000000 0.000000 1.000000 0.000000
100.000000 -0.000000 100.000000 0.000000 1.000000 0.000000 1.000000 1.000061
-100.000000 -0.000000 100.000000 0.000000 1.000000 0.000000 0.000000 1.000061
)

; Draw Main Model
Call32( :Part000000_Undamaged )
EndVersion
Return

; Part: Box
:Part000000_Undamaged
Transform_Mat(
0.000000 0.000000 0.000000
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
)
SetMaterial( 0 0 )
DrawTriList( 0
0 1 2
0 2 3
)
TransformEnd
Return

; /////////////////////////////////////////

:_Undamaged_code


BGLVersion( 0800 )
TextureList( 0
6 FF 255 255 255 0 50.000000 "Box.bmp"
)
MaterialList( 0
0.000000 0.501961 0.000000 1.000000 0.000000 0.501961 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000
)
VertexList( 0
100.000000 -100.000000 -100.000000 0.000000 0.000000 -1.000000 1.000000 0.000000
100.000000 100.000000 -100.000000 0.000000 0.000000 -1.000000 1.000000 1.000061
-100.000000 100.000000 -100.000000 0.000000 0.000000 -1.000000 0.000000 1.000061
-100.000000 -100.000000 -100.000000 0.000000 0.000000 -1.000000 0.000000 0.000000
-100.000000 -100.000000 100.000000 0.000000 0.000000 1.000000 1.000000 0.000000
-100.000000 100.000000 100.000000 0.000000 0.000000 1.000000 1.000000 1.000061
100.000000 100.000000 100.000000 0.000000 0.000000 1.000000 0.000000 1.000061
100.000000 -100.000000 100.000000 0.000000 0.000000 1.000000 0.000000 0.000000
-100.000000 -100.000000 100.000000 -1.000000 0.000000 0.000000 0.000000 0.000000
-100.000000 -100.000000 -100.000000 -1.000000 0.000000 0.000000 1.000000 0.000000
-100.000000 100.000000 -100.000000 -1.000000 0.000000 0.000000 1.000000 1.000061
-100.000000 100.000000 100.000000 -1.000000 0.000000 0.000000 0.000000 1.000061
100.000000 -100.000000 -100.000000 1.000000 0.000000 0.000000 0.000000 0.000000
100.000000 -100.000000 100.000000 1.000000 0.000000 0.000000 1.000000 0.000000
100.000000 100.000000 100.000000 1.000000 0.000000 0.000000 1.000000 1.000061
100.000000 100.000000 -100.000000 1.000000 0.000000 0.000000 0.000000 1.000061
-100.000000 100.000000 -100.000000 0.000000 1.000000 0.000000 0.000000 0.000000
100.000000 100.000000 -100.000000 0.000000 1.000000 0.000000 1.000000 0.000000
100.000000 100.000000 100.000000 0.000000 1.000000 0.000000 1.000000 1.000061
-100.000000 100.000000 100.000000 0.000000 1.000000 0.000000 0.000000 1.000061
-100.000000 -100.000000 100.000000 0.000000 -1.000000 0.000000 1.000000 1.000061
100.000000 -100.000000 100.000000 0.000000 -1.000000 0.000000 0.000000 1.000061
100.000000 -100.000000 -100.000000 0.000000 -1.000000 0.000000 0.000000 0.000000
-100.000000 -100.000000 -100.000000 0.000000 -1.000000 0.000000 1.000000 0.000000
)

; Draw Main Model
Call32( :Part000000_Damaged )
EndVersion
Return

; Part: Box
:Part000000_Damaged
Transform_Mat(
0.000000 0.000000 0.000000
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
)
SetMaterial( 0 0 )
DrawTriList( 0
0 1 2
0 2 3
4 5 6
4 6 7
8 9 10
8 10 11
12 13 14
12 14 15
16 17 18
16 18 19
20 21 22
20 22 23
)
TransformEnd
Return

; /////////////////////////////////////////

EndObj


This give us a library object that can be placed anywhere in the world.

Compare the damaged and undamaged code to the 2 original objects' code.

Each object starts at:
BGLVersion( 0800 )

Each object ends at:
Return

(... which is found just before the :Exit in the original objects' code. )

In CFS2 you cannot damage an object unless it is of the damagable type, has a .dp profile, and is placed via mission builder ( for a mission ) or by a GSL patch, for global scenery.

A damagable object is a library object.

They can be placed as any other library object. If you place it by the "normal" FS placement code, you can see it, but not damage it.

Dick

Shessi
June 5th, 2013, 07:56
Thanks Dick, I'm now digesting that and trying a few things....

I'll get back to you.

Cheers

Shessi

Shessi
June 16th, 2013, 13:43
Dick,
Just when I was getting to grips with hand editing, good ol' Allen comes along with his tutorial and batch file tools. I had just made a few things with hand construction, so now I know (doesn't seem so complicated!!). It's even easier with Allen's tools, automatic!

Anyway, many thanks for the time and explanations, finally one more thing learnt. Here is what I made for a practice. A sub/damaged sub, simple mission, great fun!

:ernae: Shessi