Jump to content

Creature Conversion


Recommended Posts

Okay, I'm struggling with creature conversion a bit. For most NPC's, weimer's convesion works great (and is even over-kill most of the time).


What I'd like to be able to do is to load an existing creature, make a few modifications, and then save it out under a new name, and to make that scriptable.


But if I can't do that, then I can probably hard code a bunch of these in.


Maybe now it's time to start pouring over the IWD1Tutu code.

Link to comment

Okay, I think I'm realizing the real reason I got into all this in the first place. It's an opportunity to learn OCaml! So, with that in mind, there's this excellent tutorial for us Perl/C++/Java types:




Very nicely done, and maybe I'll be able to write in some of these more radical features I'm thinking about after a fasion.



Link to comment
How much are you actually converting so far?


Every time I look at OCaml I want to cry. No way, no how.

Heh, well, conversion hasn't gotten very far. I've identified several problems and some possible solutions, but theres a ways to go. I have a feeling I'll need to ad somethiing to the IWG lexer so I can script a few common things (I can re-use a lot of IWD2 CRE's so long as I can tweak them, add items and so forth). Actually, scripting isn't completely neccesary and I don't mind hard-coding the conversions, but it would be nice to make this "extensible" in the end.


My co-workers here really like OCaml. I'm just not used to thinking "functionally". The parameterized variant stuff is light years ahead of C++ templates, and we struggled to make C++ efficient (ditching the STL was item #1).


I think it's worth seperating WeiDU from OCaml. I'm no sure how good an example WeiDU is of how to right clean OCaml...

Link to comment

So, I've emersed myself into the OCaml tutorial, and I realized that it's really a pretty nice language!


I also figured out that it sure helps a lot to know a bit more about the language when trying to understand WeiDU.


I may have to re-write chunks of WeiDU for my own sanity (and also as an excercise). This is especially true if I want to try to launch into a bit of parsing/lexing for creature conversions. What I'm imagining is adding a few scriptable operations. Currently this is all handled through rules like this:

// Map IWD1RES.EXT to IWD2RES.EXT (no conversion) 
// There are a bunch of special EXT strings that can be used in the
// above like "spell" (to map spell ID's) or "animate" (to map animation ID's).

// "Map" IWD1RES1 to IWD1RES2 (note the curly brackets)
// This is used for fixing typos in IWD1RES1


That's about it for scripting conversions. So I need to add something like the following:


// Map IWD1RES.CRE to a copy of IWD2RES.CRE after adding an item:
~IWD1MON.CRE~  < ~IWD2MON.CRE~ add_itm ~IWD2BLA.ITM~ >

So the angle brackets would mean "copy", which really means load the IWD2 (target) resource, and save it out to the converted name of the IWD1 (source) resource after performing some operation(s).


This is very hardwired because ~IWD2BLA.ITM~ has to be a resource in IWD2 unless there are load of special cases (add_iwd2_itm or add_targ_itm), and I also have to write a load routine for each of these resource types in IWD2 (not that many).


This seems okay so far, except that the list of operations could get quite large, and somewhere on the back-burner I've been thinking about a scripting language for specifying resources and scripting changes to resources. Something like this:

cre1 = new cre_v90 { name = ~Arlo~, str = 12, items = [ ~RING01~, ~AXE02~ ],
                         l_ring_slot = 0, wpn1_slot = 1 };
cre1.add_item(~HAT02~, helm_slot);

cre2 = load ~SOMECRE~;
cre2.str = 22;


The really cool part would be if you could decompile resources into a data description format, and if the "compiler" new how to initialize all fields to safe "default" values, and verify that the resource if "valid".


A neat idea, but I can already tell I'm not going to do anything like it any time soon :)

Link to comment

Well, iwg2.ml tops the charts at over 8,000 lines of code.


I'm hoping there's a lot of code bloat in there, at least for this project. Trying to convert BG2 was a much more daunting task (dream sequences, banter, etc).


I decided that I agree with the guy who wrote the OCaml tutorial. I can't stand "begin" and "end" bracketing. Emacs supports parens matching which makes parentheses a whole lot better.


I don't quite have the feel for OCaml indenting style. I think I saw a section on that in the tutorial (Emacs caml mode helps a lot, but it seems in consistent).

Link to comment


This topic is now archived and is closed to further replies.

  • Create New...