Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: EdrickV on February 06, 2003, 06:27:28 pm
-
The Robotech MOD had wanted transformable Veritechs (or Valkyries for you Macross fans) but had problems getting it to work in FS2. A SEXP based method was developed and used, but when the source code was released we all realized that now it might be possible to make real transforming ships.
Ronin made a transforming Veritech system (POF switching) that worked both by SEXP and key binding, but what ships could transform and what they transformed into was pretty much hardcoded. His code was also developed from the original freespace2_public code rather then fs2_open.
I had proposed an idea and some untested code to help make a transformation system that was table based. At the time I didn't have MSVC++ 6 so couldn't make it myself and Ronin was too busy to get anywhere with it.
Now that I have MSVC++ 6 I decided to take my old table reading code, the source code Ronin released, and try to make something from them using fs2_open. Right now I've got table reading code working (though I plan to expand it a bit) and some utility functions in. I haven't started on the actual transformation code yet, since to use it I'll also have to make some way to trigger it.
(So far I've been testing my functions using gr_string() and having the results of various function calls printed on the player select screen.) An example table (which will become outdated as I plan to add a flag entry for each ship to store bigflag info) and function prototypes from my header file are below.
;;***********************************************
;; Transformation table
+Name: VF-1A Fighter
+Form1: VF-1A Guardian
+Form2:
+Form3:
#end
+Name: VF-1A Guardian
+Form1: VF-1A Fighter
+Form2:
+Form3:
#end
+Name: VF-1A Super Veritech Fighter
+Form1: VF-1A Super Veritech Guardian
+Form2: VF-1A Veritech Fighter
+Form3:
#end
+Name: VF-1A Super Veritech Guardian
+Form1: VF-1A Super Veritech Fighter
+Form2: VF-1A Veritech Guardian
+Form3:
#end
#done
struct transform_data;
void transform_data_clear();
void table_tf_test();
int can_transform(char *type_name);
char *tf_mode_check(char *type_name, int newmode);
char *ship_type_lookup(ship *Ship);
void parse_transformtbl();
void transform_init();
I'm intending 2 different transformation types: One that carries over weapon and damage info and one that resets that info. The first would be used for a ship changing to another form without any armor/weapon differences. The second could be used for a ship that's jettisoning an armor/weapons pack. (Like a Super Veritech/Valkyrie losing it's FAST pack.)
I've got a ways to go, but I've got Ronin's code available as a reference. (Some of it I'll likely be able to use without major changes, other parts are not applicable to this method.) Right now, each mode can have 3 other modes it can change into. If you examine the table above you'll see that you can have a ship with more then 4 total modes though. A VF-1 Super Veritech Fighter can transform into it's guardian mode, remove it's armor and become a VF-1A Fighter which has it's own guardian mode, and there are still open slots. (You could also make a ship that cycles through modes one by one, by just using Form1: and giving the name of the next mode.
For the above table to work, you would have to have a ships.tbl entry for each mode, which means you can give each one different characteristics which should change the handling when the ship transforms. The max number of transform.tbl entries is set to be the same as the max number of ship types. (Currently 130.) As I don't have CVS access yet and the code doesn't really do anything yet, this isn't in the CVS copy or any releases yet.
Backwards compatibility note: The way I've coded this, the transform.tbl is optional and if not present transformation would be disabled, you won't get an error message about a table error the way you would if ships.tbl was missing. You should still get error messages if the table entries aren't done right though. (I've yet to test that, but it should work.)
I have and will try to keep the table transformation related code in seperate files whenever possible.
So, what were you doing while the forums were down? ;)
-
Email me. Resistance is futile ;)
You, my friend, are overdue for a username and password to CVS.
-
EdrickV, are you aware of the change-ship-type and change-ship-model sexps? They may help you out here.
-
Those SEXPs as I understand it are just interfaces to the corresponding functions. The change ship type function completely resets everything, including setting the ship's weapons to the default for that ship type. (It was made for use on the ship select screen after all.) SEXPs are also set on a mission basis rather then a MOD wide basis. I believe the core of Ronin's ship transformation system was made from the ship type change function with some changes to let it carry over status information. My functions are intended to be more flexable without relying on SEXPs. And I knew of the functions those SEXPs refer to long before those SEXPs existed.
-
;;***********************************************
;; Transformation table
+Name: VF-1A Fighter
+Form1: VF-1A Guardian
+Form2:
+Form3:
#end
+Name: VF-1A Guardian
+Form1: VF-1A Fighter
+Form2:
+Form3:
#end
+Name: VF-1A Super Veritech Fighter
+Form1: VF-1A Super Veritech Guardian
+Form2: VF-1A Veritech Fighter
+Form3:
#end
+Name: VF-1A Super Veritech Guardian
+Form1: VF-1A Super Veritech Fighter
+Form2: VF-1A Veritech Guardian
+Form3:
#end
#done
I don't know much about the SCP but I do know you need something to counter the'#end' thingy there. I ran into a similar problem one time while I was working on a weapons.tbl. I took out one of those flags and FS and FRED would work. So either make those comments or put something before them like '#ship*' replace * with a number or something.
-
Originally posted by HotSnoJ
I don't know much about the SCP but I do know you need something to counter the'#end' thingy there. I ran into a similar problem one time while I was working on a weapons.tbl. I took out one of those flags and FS and FRED would work. So either make those comments or put something before them like '#ship*' replace * with a number or something.
Counter the "#end"? I don't know what you are talking about. And this isn't the weapons.tbl or ships.tbl, it's the transform.tbl. I wrote the code that accesses it so I control exactly how it parses the file. The table reading code was developed using code and table format ideas from the nebula.tbl parsing code, with the addition of the #done tag to tell the program when it's finished reading the file.
-
Ok. It's just that i've noticed it in everyother tbl so just givin' a heads up.
-
Originally posted by HotSnoJ
Ok. It's just that i've noticed it in everyother tbl so just givin' a heads up.
Well, without knowing what exactly you've noticed happening/not happening I don't really know what implications it might have with regard to my transform.tbl parser.
-
Well I deleted the '#Primary Weapons' thing from the weapons tbl and neither FRED or FS would open right. I kept getting and error saying there was a problem on line 'whatever'. So I looked at the line but there was nothing there. So I asked a couple people here and they said I'd need to redo my tbl's. So while I was redoing it I noticed that I had deleted '#Primary Weapons'.
Example:
#Primary Weapons
{Weapon entries}
#End
#Secondary Weapons
{Weapon entries}
#End
well thats my two cent's. You may have done something different with the code that reads the tbl but maybe not. Just giving you some advice from what I've learned.
-
Originally posted by HotSnoJ
Well I deleted the '#Primary Weapons' thing from the weapons tbl and neither FRED or FS would open right. I kept getting and error saying there was a problem on line 'whatever'. So I looked at the line but there was nothing there.
You mean you got something like this?
Error: Error parsing 'weapons.tbl'
Error code = 1.
File: C:\Games\projects\fs2_open\code\Weapon\Weapons.cpp
Line: 1697
That means that there was a problem with the weapons.tbl file. Error code 1 means that it was looking for a "required string" and didn't find it. In this case that would be the #Primary Weapons section identifier. That's not a bug, that is the game telling you that your table is screwy. (Though the error message could be clearer.) If you were running a debug build you would get the following info as well:
In the debug spew window:
weapons.tbl(61):Error: Required token = [#Primary Weapons], found [$Name:
And the "Warning" error message:
Warning: weapons.tbl(61):
Error: Required token = [#Primary Weapons], found [$Name: ] .
File: C:\Games\projects\fs2_open\code\Parse\PARSELO.CPP
Line: 346
Call stack:
------------------------------------------------------------------
required_string() parse_weaponstbl() weapon_init()
game_init() WinMainSub() WinMain() WinMainCRTStartup()
KERNEL32.DLL bff7b9e4()
KERNEL32.DLL bff7b896()
KERNEL32.DLL bff7a24f()
KERNEL32.DLL bff844e0()
------------------------------------------------------------------
Those messages are more useful, but are only shown for debug builds. (It's assumed that if you're using a release build you're using verified tables.) For the table transform parser, if you are missing one of the Form: entries (which are required) it will print a more useful error message I setup, which I may clarify some more, stating which ship entry has a problem and which part of it's entry is missing. (The Form1 entry being part 2 and the Form3 being part 4.)
-
Haven't worked much on the TTF code today, though I've decided how the mode type flag thing will work. I decided to post a screenshot of what I did make tonight though:
(http://members.aol.com/huntercomputers/FS2/TTG.jpg)
That's the result of about an hour and a half's tinkering. A table generator that should be pretty foolproof and comes with built in instructions. (It only saves tables, it doesn't load them or change previously created entries, so for any future editing you would need to use a text editor, but could use this program to create individual entries and copy/paste them.) The radio buttons control which kind of transformation you want going from "ship name" to "form." A type 1 will keep the current damage/ammo info (so you won't get repaired/rearmed by transforming) and a type 2 will basically repair/rearm you. In the example shown in the screen shot the ship would junk it's FAST pack (an armor/weapons pack) and become a regular fighter. That would be a one way transformation, you can't go from a VF-1S Fighter to a VF-1S Super Veritech Fighter. (Well, at least not within a mission.)
-
Originally posted by EdrickV
Those messages are more useful, but are only shown for debug builds. (It's assumed that if you're using a release build you're using verified tables.) For the table transform parser, if you are missing one of the Form: entries (which are required) it will print a more useful error message I setup, which I may clarify some more, stating which ship entry has a problem and which part of it's entry is missing. (The Form1 entry being part 2 and the Form3 being part 4.)
I have the release of FS1 if thats what you're meaning. :wink:
And yes that is the kind of error I was getting.
PS Cool program, think you could make one for weapons and ships?
-
I meant a release build of whatever programs you were getting that error from, as opposed to a debug build. For FS1 we don't have any debug builds and we don't have any debug builds of the full FS2. (In other words FS2 with PXO and MVE code.) The fs2_open/fred2_open exe's come in both debug and release builds. A release build normally assumes that the tables are correct and doesn't do as much reporting of errors/possible errors. A debug build likes to tell you just about everything that it's doing and anything that goes wrong. (Even if what goes wrong isn't really important.)
A program like that would probably be more complicated to use then editing an already existing entry would be, and my program doesn't really do much in the way of error checking. (It won't display an error message if you put a ship name in that is not in the actual ships.tbl file for example.) The main reason I made the program is the flags thing could be confusing for some people. Here's how it would work if you made one by hand:
First we'll assign "flags" a default value of 0. That means no ships will use a type 2 transformation.
If you want Form1 to do a type 2 transformation, add 1 to flags.
If you want Form2 to do a type 2 transformation, add 2 to flags.
If you want Form3 to do a type 2 transformation, add 4 to flags.
So flags = Form1 TF type(1 or 0) + Form2 TF type (2 or 0) + Form3 TF Type (4 or 0)
Confused yet? :) The program was also pretty easy to make and doesn't require a lot of programmer written code due to how Borland C++ Builder works. From a BCB programmer perspective, this is a 76 line program. (And I didn't write all 76 lines.) Ignoring the comments, FS2 as the source was originally released is 323,716 lines long. :)