Repository navigation
AddingNewRaces
Ok, ya dirty little scurvy-eaten wretches. This page is all about adding a new race into the game.
I wrote this because I've now done it 5 times, each time having a couple of months in between - just enough to make one forget completely how it was actually done, resulting in several extra hours of programming 'fun'.
Any way, enough talk, let's walk the walk.
1. Races.h: a) Add a NEWRACE_ID (into the SPECIES_ID enum list), preferably after ISD_ID, and before SLYLANDRO_KOHRAH_ID.
b) Add a NEWRACE_SHIP (into the enum list which ends in NUM_AVAILABLE_RACES.) Put it in the same position as in the SPECIES_ID enum list.
c) Add your new race's CONVERSATION, SHIP, SHIP COST, IP SPEED, HYPERSPACE SPEED, IP ENCOUNTER PERCENT, HYPERSPACE ENCOUNTER PERCENT, TASKFORCE SHIP STRENGTH BOUNDS, and RACE COLOR into the corresponding #define lists.
Most of these things are pretty self-explanatory. The NEWRACE_ID is used in most every place as a "master" numbering of the races.
(Note: If you add the new race after SLYLANDRO_KOHRAH_ID, you're gonna have to also muck around the master.c file. And if you add the new race after LAST_MELEE_ID, you will have to mess with InitGameStructures in globdata.c also.)
2. globdata.h: Add NEWRACE_CONVERSATION to globdata.h's CONVERSATION enum list (with the same name you added it to races.h's RACE_COMMUNICATION define list).
2b. commglue.h: In commglue.h, declare the init_newrace_comm function you'll define in comm/newrace/newracec.c.
2c. commglue.c: Add the case NEWRACE_CONVERSATION to commglue.c's init_race switch function.
3. dummy.c: Add your NEWRACE_CODE_RES into the ShipCodeRes enum list. Confusingly enough, the order of the races in dummy.c differs from the lists in races.h: in dummy.c the original SCII races are ordered by alphabet. However, always add your new races AFTER all the original SCII races regardless of the alphabetic order, don't mix original and new races. Otherwise the universe explodes.
4. dummy.h: Add "#include "ships/newrace/newrace.h" This makes dummy.c see which source files your NEWRACE_CODE_RES points to.
5. Loadship.c: Add a NEWRACE_CODE into the code list. Put it into the same position as in races.h's lists. This list acts as a "link" between the numberings different in dummy.c and races.h.
6. corecode.h: Add #include "ships/newrace/icode.h". This makes loadship.c see which source files your NEWRACE_CODE points to.
7. master.c: Edit LoadMasterShipList in such way that your new race is loaded into the supermelee ship pick list as one of the last races (see examples in the file). This ensures your race isn't loaded in place of the original SCII ones.
8. grpinfo.c: Add your NEWRACE_SHIP into the BuildGroups function. Put it into the same position as in races.h's lists. This ensures your race's homeworld/other important systems work OK.
9. supermelee/melee.h: To make the (normally 5x5) ship selection grid in supermelee house more ships, edit the number of NUM_PICK_COLS and NUM_PICK_ROWS to suit your needs. You also need to photoshop a new grid graphic to make the ships fit :)
10. New files, ship: Add your new ship files by creating folder sc2/src/uqm/ships/newrace. Remember to edit the makeinfo files in sc2/src/uqm/ships/newrace and sc2/src/uqm/ships to compile your new files. (newrace.c, newrace.h, Makeinfo, resinst.h, plus the .h files the gen_refiles.py utility SHOULD create.)
11. New files, comm: Add your new comm files into sc2/src/uqm/comm/newrace. Edit the makeinfo files also, as in the previous item. (newracec.c, strings.h, Makeinfo, resinst.h, plus the .h files the gen_refiles.py utility SHOULD create.)
12. New content files, ship: Add your race's ship's new graphics, sound files and captainnames to sc2/content/base/ships
13. New content files, comm: Add your race's comm graphics, music and dialogue into sc2/content/base/comm
14. resources.csv: Then, let's modify the resources.csv file in tools/resmap. a) Add your race's communication resource identifiers: (NEWRACE_MUSIC, NEWRACE_FONT, NEWRACE_CONVERSATION_PHRASES, NEWRACE_COLOR_MAP and NEWRACE_PMAP_ANIM)
b) Add your race's ship resource identifiers: (NEWRACE_CODE, NEWRACE_VICTORY_SONG, NEWRACE_RACE_STRINGS, NEWRACE_SHIP_SOUNDS, NEWRACE_ICON_MASK_PMAP_ANIM, NEWRACE_MICON_MASK_PMAP_ANIM, NEWRACE_BIG_MASK_PMAP_ANIM, NEWRACE_MED_MASK_PMAP_ANIM, NEWRACE_SML_MASK_PMAP_ANIM, NEWRACEPRIMARY_BIG_MASK_PMAP_ANIM, NEWRACEPRIMARY_MED_MASK_PMAP_ANIM, NEWRACEPRIMARY_SML_MASK_PMAP_ANIM, NEWRACESECONDARY_BIG_MASK_PMAP_ANIM, NEWRACESECONDARY_MED_MASK_PMAP_ANIM, NEWRACESECONDARY_SML_MASK_PMAP_ANIM and NEWRACE_CAPTAIN_MASK_PMAP_ANIM)
-Remember to make these identifiers to point into your new files.
-Remember to change also the 'ship.xxx.graphics' in addition to the NEWRACE_XXX constants.
-Remember to make your NEWRACE_CODE to correspond to its location in the DUMMY.C's list.
-Remember, after you've changed your race's ship code, also increment those ships' RACE_CODEs that come after your ship.
15. gen_resfiles.py: Run the gen_resfiles utility at the tools/resmap folder to propagate the changes to resources.csv to all the necessary .h files in the source code.
16. resinst.h: In sc2/src/uqm/ships/newrace, copy the resource identifiers from igfxres.h, imusicre.h, isndres.h and istrtab.h to resinst.h.
17. COMPILE!!!
Well, my young padawan. Now that I've guided you through this little exercise we can all agree that this has been as fun as pulling rotten, inflamed, plague-ridden wisdom teeth that have their twisted roots stuck so deep that they're tickling your anal canal, if you know what I mean.
Wiki Contents
- Game information
- Development
- DesignNotes
- Story Wiki
- Implementation details
- Older material
- Administration
- Project Rules
- Want to help? HelpingOutIntroduction
- SVN Contributing
- Release Process
- Porting Changes
- Statistics
- Developer Forum
- Team
- TheMisterCat
- add others here!