Quote: All right, new question, same idea. I want to add an array that has the stats priority order to the class_type struct, but I'm not sure which file has the code that imports the class info from file. If someone could fill me in on that, I'd appreciate it greatly.
How I would probably tackle this.
In params.h, we have:
// Stat stuff
#define MAX_STATS 10
#define STAT_ST 0
#define STAT_QU 1
#define STAT_PR 2
#define STAT_EM 3
#define STAT_IN 4
#define STAT_CO 5
#define STAT_AG 6
#define STAT_SD 7
#define STAT_ME 8
#define STAT_RE 9
Add an array in the class_type struct (structs.h).
e.g. sh_int stat_priority[MAX_STATS];
If strength is the highest priority for the warrior class, presence has second, quickness has the fourth, then the values would be defined a long the lines of:
class_table[warrior_class_index].stat_priority[STAT_ST]=1;
class_table[warrior_class_index].stat_priority[STAT_QU]=4;
class_table[warrior_class_index].stat_priority[STAT_PR]=2;
NOTE: You wouldn't use the above code though, you would write an olc editor to set this stuff, and don't use STAT_?? in the code, instead use a variable to reference by index and look up the index into a name using stat_flags[] defined in tables.cpp. Search for 'stat_flags' in raceedit.cpp you will see what I mean about using a variable to access stuff.
Assuming you manage to get in the class table, a sorted list of priorities...
Within roll_stats() (nanny.cpp), after the call to gen_rolemaster_stats(), there is a transfer of stats to the character. Just before that, sort them.
To achieve this, first sort the rm_stats_set, so highest stat is first in the array, lowest is last. Then use something like the following loop to transfer them to the character.
// i = transfers stats one by one
// p = locates the correct position to get stat from
int i,p;
for(i=0; i<MAX_STATS; i++){
p=class_table[ch->clss].stat_priority;
ch->perm_stats= rm_stats_set.perm[p];
ch->potential_stats=rm_stats_set.potential[p];
}
I would probably go a bit flasher than this in real development... e.g. make it so you can set a variable amount of prority for different classes, say for mage 5 stats are sorted in priority, warrior only has the first two stats in priority. To achieve this, I would most likely stop my sorting routine sorting after the specified number of values.
Also the above system assumes the priorities are unique... if not you have to develop a more extensive system.
In order to save the priority information, I would probably just put into the class_type gio structure in class (search for GIO_START(class_type) in dynamics.cpp),
GIO_SHINTH(stat_priority[STAT_ST], "statprior_ST")
GIO_SHINTH(stat_priority[STAT_QU], "statprior_QU")
GIO_SHINTH(stat_priority[STAT_PR], "statprior_PR")
GIO_SHINTH(stat_priority[STAT_EM], "statprior_EM")
GIO_SHINTH(stat_priority[STAT_IN], "statprior_IN")
GIO_SHINTH(stat_priority[STAT_CO], "statprior_CO")
GIO_SHINTH(stat_priority[STAT_AG], "statprior_AG")
GIO_SHINTH(stat_priority[STAT_SD], "statprior_SD")
GIO_SHINTH(stat_priority[STAT_ME], "statprior_ME")
GIO_SHINTH(stat_priority[STAT_RE], "statprior_RE")
I did something simular a long time ago with racial stat modifiers (search for GIO_START(race_data) in races.cpp).
Hope this helps, let us know how you get on.
- Kal |