Page: 1 2
Tutorial: How to Create a Model
4. Creation of the MDS file
It's time for the creation of the model script now; there the animation
data stored in asc format will be assigned to the logical animations
needed in the game. Open the text editor (as I said, preferably
UltraEdit32).
a) First, write the file header with the model and mesh specs.
* Model ("Meatbug")
* {
* meshAndTree ("Mbg_Body_M04.asc" DONT_USE_MESH)
* registerMesh ("Mbg_Body_M04.ASC")
* aniEnum
* {
This defines the mesh displayed in the game and the underlying
skeletal structure (see ZENGIN documentation).
b) Now define the animations via the 'ani' command. Start with
the idle animation; this is called S_FISTRUN and will be applied
as follows:
* ani ("s_FistRun" 1 "s_FistRun" 0.0 0.0 M.
"Mbg_Amb_M01.asc" F 0 100)
See the ZENGiN doc for an explanation of the parameters.
c) Now your meatbug can stand in the landscape, but that's a tad
boring. Besides, we exported some other animations as well... so
teach it to run by defining the necessary animations.
d) The run animation is called S_FISTRUNL. To change pace from
standing to running and back to standing again, you have to define
two more animations: transition animations T_FISTRUN_2_FISTRUNL
(for starting to run) and T_FISTRUNL_2_FISTRUN (for stopping). This
is achieved by implementing the following three lines:
* aniBlend ("t_FistRun_2_FistRunL" "s_FistRunL"
0.1 0.1)
* ani ("s_FistRunL" 1 "s_FistRunL" 0.0 0.0 M.
"Mbg_Run_M02.asc" F 0 20)
* aniBlend ("t_FistRunL_2_FistRun" "s_FistRun"
0.0 0.1)
You see, the transitions are interpolated animations only (aniBlend);
they don't have their own sets of animations. That's easy to do
with a meatbug. With other, larger figures the transition animations
should be 'hand made', though; otherwise you'll get the not-too-popular
'skating' effect where the figure slides awkwardly across the ground.
The first and last frame of the animation defined by S_FISTRUNL
should contain the same pose so the loop looks 'clean' and not jerky.
e) Now all you need to do is integrate the Fall animation. It consists
of two parts, a state animation S_FALLDN which plays while the model
is falling and a landing animation T_FALLDN_2_STAND which is triggered
by ground contact.
* ani ("s_FallDn" 1 "s_FallDn" 0.1 0.1 MF "Mbg_Fall_M01.asc"
F 3 3)
* ani ("t_FallDn_2_Stand" 1 "" 0.1 0.0 M. "Mbg_Fall_M01.asc"
R 0 3)
The F-flag set in the S_FALLDN animation specifies that the figure's
elevation level is ignored because this is governed by internal
physics.
f) Finally you'll have to set two cambered braces below the animation
definitions... done! Save the MDS as MyMeatbug.mds in the GOTHIC\_WORK\DATA\ANIMS
folder.
Now you have defined the animations for your model. Unfortunately
that's not enough to view your little friend in the game yet. You'll
need another D-script to define the figure for the game.
5) Figure D-script
The D script defines a figure's attributes and looks (model) as
well as the animation data the figure uses (MDS). You need to make
a script for your meatbug (...in ultraEdit32 :)).
a) First we create a new UltraEdit file with the following header:
* INSTANCE MyMeatbug (C_NPC)
* {
* name = "Buggy";
* guild = GIL_MEATBUG;
Here you specify the name appearing above the figure's head when
focused in the game and the guild it will belong to.
b) Now transfer the following attributes to the file:
* level = 1;
That's the figure's starting experience level.
* attribute [ATR_STRENGTH] = 1;
That's the figure's attack strength.
* attribute [ATR_DEXTERITY] = 1;
This is just important for combat with ranged weapons, but you want
to add it for the sake of completeness.
* attribute [ATR_HITPOINTS_MAX] = 10;
* attribute [ATR_HITPOINTS] = 10;
This defines your figure's health - one is the amount of maximal
hit points [ATR_HITPOINTS_MAX], the other the figure's starting
hit points.
* attribute [ATR_MANA_MAX] = 0;
* attribute [ATR_MANA] = 0;
Those define the figure's mana (analogous to hit points)
* protection [PROT_BLUNT] = 0; // stumpfe Waffen - blunt weapons
* protection [PROT_EDGE] = 0; // Waffen mit EDGE-Schaden (Klingen)
- edged weapons
* protection [PROT_POINT] = 0; // Waffen mit POINT-Schaden (Pfeile,Bolzen)
- arrows, bolts
* protection [PROT_FIRE] = 100; // Feuerschaden - fire damage
* protection [PROT_FLY] = 0; // FLY-Schaden,d.h. wenn die Figur
weggeschleudert wird - falling/concussion damage
* protection [PROT_MAGIC] = 0; // Magie-Schaden - damage by magic
*
* damagetype = DAM_EDGE;
These define the damage a figure does with different forms of attacks.
* Npc_SetToFistMode(self);
This command sets a figure in combat mode at insertion; it's standard
procedure with monsters to save animation data.
c) Now you enter visual data commands into the figure's script;
there's the MDS file the figure should use (its set of animations):
* Mdl_SetVisual (self, "MyMeatbug.mds");
d) This command specifies a figure's appearance. It's especially
important for figures with more than one body model to chose from
(humans, for example, with their different heads, types of armor
and skin colors). In our example most parameters remain at their
default values (skin color, variation, head etc.). Only the body
mesh is specified.
* Mdl_SetVisualBody (self, "Mbg_Body_M04", DEFAULT, DEFAULT,
"", DEFAULT, DEFAULT, -1);
* };
e) Finally (once again) a brace and semicolon. Some people tend
to forget that (not you, obviously ;-)), then they get nasty errors
when starting, and the bug hunt begins...
Well, you created an entity you'll surely want to test in the game.
Save the file as MyMeatbug.d in the GOTHIC\_WORK\DATA\SCRIPTS\CONTENT\AI\MONSTER
folder.
6. In-game testing
Start Gothic, preferably a small level (TESTLEVEL.ZEN for example).
Devmode must be active so you can access the console, and in the
Gothic Starter the option 'parse all scripts' must be enabled so
the file MyMeatbug.d will be read. As soon as level and protagonist
have loaded, feel free to gaze at your new friend in wonder. Open
the console (F2) and type:
insert MyMeatbug
The new figure will be inserted.
Close the console with F2. Turn your character so that he focuses
your little friend "Buggy". Press the 'o' key ('o' as
in 'orc') to take over "Buggy", i.e. 'possess' him. Now
it's time to explore the level as a meatbug!
Too bad he can't do much except for crawling... and falling down
from a height. Then again, he's still young and malleable ;-).
Important: When starting the game the ASC files (which are
just an intermediate format for the engine) will be compiled. The
compiled data can be found in the folder GOTHIC\_WORK\DATA\ANIMS\_COMPILED.
If you change an animation (for example) in MAX and export it, be
sure to delete the old file in the COMPILED folder before you export
the new one, or else the ASC files won't be converted. One file
will be created per logical animation defined by ani in the MDS;
for example, the meatbug's s_FistRunL animation will be MEATBUG-S_FISTRUNL.MAN
as a compiled file. If you revamp the ASC file Mbg_Run_M02.asc,
you'll have to delete all animations compiled from that file - in
our example those would be:
MEATBUG-S_FISTRUNL.MAN
MEATBUG-S_FISTJUMPB.MAN
MEATBUG-S_FISTRUNL.MAN
7. Upgrading the MDS
Your meatbug can crawl forward, but not backwards. You can change
this! You needn't make a new animation for that, though...just use
one of those already in existence. Define crawling backwards in
the file MyMeatbug.mds:
* ani ("t_FistJumpB" 1 "s_FistRun" 0.1 0.0
M. "Mbg_Run_M02.asc" R 1 19)
See the 'R'? It's the animation's directional flag, meaning that
you're still using the Run animation but it's played backwards.
Now "Buggy" can crawl backwards as well...
You surely noticed that your meatbug can make turns, but it remains
stiff as a poker while turning. To get a little movement in there,
define a so-called Turn animation. This ought to be
1. loop capable and
2. shouldn't be animated as a rotation - the engine will handle
the rotation in the game.
Export (in 3D Studio MAX 3.1) the file Mbg_Turn_M01.max as Mbg_Turn_M01.asc
and add the following lines to your MDS:
* ani ("t_FistRunTurnL" 20 "t_FistRunTurnL"
0.0 0.0 M. "Mbg_Turn_M01.asc" F 1 13)
* aniAlias ("t_FistRunTurnR" 20 "t_FistRunTurnR"
0.0 0.0 M. "t_FistRunTurnL" R)
Theses set the turn animations for the "FistRun". The
second animation is just an alias definition of the first, and "Buggy"
is now busily waggling its stubby legs while turning on the spot!
Now I have to tell you something sad for a change... there's a
chance that "Buggy" might die, so he'll need animations
for that as well.
Export the MAX files Mbg_Dead_A02.max and Mbg_Dead_M01.max. By
standard there are two different death animations - one if the fatal
blow hits the figure's front side and one if it hits the figure
in the back. You need to add the following lines to the MDS:
* ani ("t_Dead" 1 "s_Dead" 0.0 0.0 M. "Mbg_Dead_A02.asc"
F 0 15)
* ani ("s_Dead" 1 "s_Dead" 0.0 0.0 M. "Mbg_Dead_A02.asc"
F 15 15)
*
* ani ("t_DeadB" 1 "s_DeadB" 0.0 0.0 M. "Mbg_Dead_M01.asc"
F 0 10)
* ani ("s_DeadB" 1 "s_DeadB" 0.0 0.0 M. "Mbg_Dead_M01.asc"
F 10 10)
The T-DEAD animations describe the figure's death throes, the 1-frame-length
S_DEAD animation specifies the figure lying dead on the ground.
Page: 1 2 |