Creating a new DarkJedi , Part I
Required knowledge for this course: Moderate Cog knowledge, time.
Introduction
So you want a darkjedi in your new singleplayer level , but you do not want one of the original ones? That is the question I asked myself 3 weeks ago. The solution to this is simply to make your own. Well, I thought it was simple. There are many things you must do to create a working Darkjedi. This month, we will discuss the basic ones, such as the cog and some basic Artificial Intelligence (AI). So here we go ..
First, you must decide which Jedi to base your new one off of. Since I do not know how to edit Puppet Files well enough(*.pup, the files that control movement) , I figured it was wise to choose a Jedi with the same approximate size of my new one. In my case, that was Yun. Once you choose your Jedi to base off of, you need to first create a new directory to place the files and then extract all of his/her files from the JK gob files. So load up conman, and find your res2.gob (either on your JK CD or in your /resource directory) First , lets take out the Cog Files. Click on the cog Subdirectory and scroll down to where it says darkjedi_boc. This area has all the darkjedis cog files. Select the file for the jedi you want , and extract it to your directory.
Now lets find the other files. In order to make new skins(read the previous article on how to , exactly) we will need the 3do of the jedi. So find your jedis 3do in the 3do directory. Here are the names of the Jedis:
Boc= bo
Gorc=go
Maw=ma
Pic=pi
Jerec=je
Sariss=wa
Yun=yu
Continue the process of extracting files for the /snd and /ai directories. Also, load up the jk1.gob and extract the camera cog from the level your jedi fights in. When you are finishing, you should have all these files:
jedi.3do, darkjedi_ jedi.cog, jedi.ai , jedi.ai0, jedi.ai2, jedi.snd , and xxcamera.cog(The ai0 is easy, ai2 is hard, and ai is medium)
Ok, so we now have all the necessary files for our darkjedi. Note: If you want to make a new skin, hop to it, I got a buddy of mine to do it for me ;-)
Next, lets get take a peak inside the AI files. Load up your jedis .ai file. If you do not have it associated with a program, use word or note pad. Open it up, and try not to shriek in horror. ( I did, mainly because AI files are ugly.) You should see something along the lines of this:
#
#
#
#
#
alignment=-1.0, rank=0.5, fov=180, maxstep=3.5, sightdist=6.0, heardist=3.0
#instinct args
##########################################
Jump 2000.0, 2.5, 2.5
LookForTarget 200.0, 0.0
Saberfighting 0.55, 0.25, 25.0, 1600.0, 0.20, 35.0, 925.0
Listen 0.60, 2.0
Follow 0.0, 0.10
OpenDoors
ForcePowers 4000.0, 0.0, 5.0, 0.0, 4.0, 0.0, 0.5, 0.15, 0.40, 1.00, 10000.0, 15000.0, 1000.0
SpecialAttack 4000.0, 0.50, 0.5, 2.5, 2667.0, 9.0, 0, 40.0, 5000.0
CircleStrafe 5000.0, 45.0, 1.0, 300.0, 0.0
Talk 5000.0, 0.40
This is where it gets tough. The AI file consists a mess of numbers. The first thing you want to modify is the top few lines:
alignment=-1.0, rank=0.5, fov=180, maxstep=3.5, sightdist=6.0, heardist=3.0
These settings are pretty much self explanatory. The rank and alignment settings are still unknown to me. I would leave the be for the time being.
Now, lets hop to the next section.
Saberfighting 0.55, 0.25, 25.0, 1600.0, 0.20, 35.0, 925.0
This is what you see for saber fighting. What does what, you ask? The first number stands for the frequency of attack for the primary attack. In this case, 55 per cent. I recommend not going above .6 because your jedi will be swinging often and vulnerable for attack. The next number is for range of attack. Do not mess with this number, or else your jedi will be able to attack in a greater range than his saber can reach and it will not look appropriate. The next number is for attack damage. You can really have fun here. If your new Jedi is "Strong," go for 35 or so. But remember, balance is the key, so do not make him fast and strong, it will be no fun to fight him. The final number stands for duration of attack. I assume it is in milliseconds (MS). The next four numbers have the same characteristics except they are for the secondary attack.
Right now, that is all the AI that I have gotten to work consistently. Next month I should have many more instincts ready for discussion.
The other part of your Jedis AI is nested in his/her Darkjedi_jedi.cog. Open it up with wordpad and take a few minutes to peruse through it. Take note of the User1 and User0 areas. They are used for the cutscene camera cogs. Now, lets scroll down to the damaged message.
This is what you should see:
damaged:
damage = GetParam(0);
damageType = GetParam(1);
if(damageType & 1) // IMPACT
damage = damage / 2;
else
if(damageType & 2) // ENERGY
damage = damage / 2;
else
if(damageType & 4) // FIRE
damage = damage / 10;
else
if(damageType & 8) // FORCE
damage = damage;
else
if(damageType & 16) // SABER
damage = damage;
ReturnEx(damage);
Return;
This is where your Jedis damage amounts are taken from. You may way to make him weak to fire attack. To do this, just change it to /5 (divided by 5).
else
if(damageType & 4) // FIRE
damage = damage / 10;
That means an attack from fire is twice as damaging as it was before you changed it. That principle holds true for the other damage types as well.
You can also change your Jedis saber through the cog. See up in the symbols section where is mentions the saber tip?
material tip_mat=saberyellow0.mat local
material side_mat=saberyellow1.mat local
Well, lets change the saber to blue for example. The new lines would read:
material tip_mat=saberblue0.mat local
material side_mat=saberblue1.mat local
If you would like a completely new saber, create one (the hard part ;-) ) and save the mats as anything BUT sabergreen0 and sabergreen1, these two mats are your actors sabers. We do not want them having the same exact saber for obvious reasons.
Finally in the cog section, you can change your Jedis vulnerability to force powers, such as blinding. Scroll down to where you see something like this:
{
// This makes the DJ nearly immune to blinding
// by removing the blind flag every 3 seconds
ClearActorFlags(darkjedi, 0x800);
SetTimerEx(3, 2, 0, 0);
}
As the comments state, this section of the script keeps blinding from occurring on the Jedi. To allow him to be blinded ( I am not sure if he will fight blinded, I have yet to try it) remove the lines. To change the timer setting, simply change the 3 to whatever you desire.
Next , we have to make your Jedi appear in JED/Forcebuilder so you can place him/her. In Jed, open up the master.tpl . Do a search for your Jedis name. In my case it was yun, so I searched for that. You should find a few lines reading something like this(excuse the lines , it is the only way to display it:
_darkjedi _humanactor typeflags=0x2000201
# DESC: DarkJedi Yun
# BBOX: -0.031992 -0.017003 -0.134424 0.032032 0.024487 0.073659
yun _darkjedi model3d=yu.3do size=0.060400 movesize=0.060400 puppet=yu.pup soundclass=yu.snd mass=160.000000 maxvel=0.300000 weapon=+gamaxe health=500.00 maxhealth=500.00 maxrotthrust=200.00 jumpspeed=1.60 error=0.60 fov=0.50 chance=1.00 aiclass=yun.ai
This is what we call the template for Yun. Remember, use the Jedi you modifiers template!!! Now, Copy the text, then paste it at the very bottom of the template. You want to edit All the things that apply to you. here is an example template:
_darkjedi _humanactor typeflags=0x2000201
# DESC: DarkJedi Mark
# BBOX: -0.031992 -0.017003 -0.134424 0.032032 0.024487 0.073659
mark _darkjedi model3d=yu.3do size=0.060400 movesize=0.060400 puppet=yu.pup soundclass=mark.snd mass=160.000000 maxvel=0.300000 weapon=+gamaxe health=2000.00 maxhealth=2000.00 maxrotthrust=220.00 jumpspeed=2.00 error=0.60 fov=0.50 chance=1.00 aiclass=mark.ai
#
Take note of the changes I made. I changed the SND/AI settings to acknowledge my new names. I also edited the health and maxhealth areas. This makes the necassary changes for my Jedis endurance. I also tweak the rotthrust(rotational thrust) & jump speed settings. Once you have your template added, save the mater.tpl and load up JED/FB. Place a thing down and search for your new template. He should be at the end of the list. So you have him placed in your level, what now? Well make sure to save your new AI, Cogs, and *.Snd file in your project directory. Then you have to add the darkjed_jedi.cog to your *.jkl. Make sure to specify your Jedis thing number in the cog. So your Jedi is all set up for preliminary testing. There are still a couple of things you need to do in order to make him 100 per cent new. Open up the *.snd file. You will see a lot of references to *.wav files. As you were taught in Rages article a month or so back, you need to make your own sounds and edit the *.snd file to get them to work. I added a few new sounds to mine, check it out:
death1 markdie.wav 0x010000 1.0 4.0
death2 markdie2.wav 0x010000 1.0 4.0
This is the death sequence. Instead of Yuns normal death *.wav, I made up my own sound. (It sounds pretty cool, too ;)
We have one more thing to do before testing our Jedi. The camera sequence. The camera is set on a keyframe. Sure , keyframes are nice, if you want to program them. I find it much easier to use a camera ghost that rotates around our jedi. Here is the cog I wrote for it:
# Camera for Saber Duel
# Mark Jones (c) 1998
# 3/14/98
#
#
#
#
symbols
message startup
thing ghostCam
thing jedi
cog jedicog=jedi.cog nolink
end
code
startup:
// freeze darkjedi for scene.
AISetMode(jedi, 0x2000);
// freeze Kyle .....
SetActorFlags(jkGetLocalPlayer(), 0xa00000);
SetCameraFocus(0, ghostCam);
SetCurrentCamera(0);
Sleep(1.0);
MoveToFrame(ghostCam,1,5.0); //here are all the ghost frames //for where the camera will be moving to. Just treat the ghost item as //an elevator. This is a 7 frame scene, you can have as many as you like
MoveToFrame(ghostCam,2,5.0);
MoveToFrame(ghostCam,3,5.0);
MoveToFrame(ghostCam,4,5.0);
MoveToFrame(ghostCam,5,5.0);
MoveToFrame(ghostCam,6,5.0);
Sleep(1.0);
SetCameraFocus(0, jkGetLocalPlayer());
// Go to external
if (jkGetSaberCam() == 1)
CycleCamera();
DestroyThing(ghostCam);
// wake up the jedi
AIClearMode(jedi, 0x2000);
AISetMode(jedi, 0x4);
// unfreeze Kyle
ClearActorFlags(jkGetLocalPlayer(), 0xa00000);
// autosave
AutosaveGame();
Sleep(3.0);
SendMessage(jedicog, user1);
return;
end
Now we have the cog all done and ready for action. So load up jed and add the cog to your level. Make sure to add the ghost and all of its movement frames. To get some nice camera effects, play with the yaw ,roll, and pitch of the camera. I have got some really cool effects with it.
Now we are all set for a test run with your new jedi. Make sure all your cogs are placed in the level and have the appropriate file links. Then gob it up and check out your new jedi! Good Luck! Next time we will finish up this tutorial with hints at programming AI and a few new goodies!
Mark Jones assures you that no Dark Jedi were injured in the writing of this article |
(c) 1998 Mark Jones.