| 1 |
root |
1.1 |
|
| 2 |
|
|
|
| 3 |
|
|
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
| 4 |
|
|
A New EXPERIENCE/SKILLS system for CF |
| 5 |
|
|
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
| 6 |
|
|
|
| 7 |
|
|
This patch represents a "developer's" version of the exp/skills |
| 8 |
|
|
system. While I have now achieved all of the objectives |
| 9 |
|
|
in sections "B" and "C" of the coding proposal (see README.PROPOSAL) |
| 10 |
|
|
and have play-tested as much of the code as possible, I am sure some |
| 11 |
|
|
big bugs must remain. (One for sure is that exp gained when using |
| 12 |
|
|
rod/horn/wand is wrong.) |
| 13 |
|
|
|
| 14 |
|
|
Below this section I outline 1) coding philosophy, 2) gross |
| 15 |
|
|
description of how the code impinges/interacts within older |
| 16 |
|
|
code. 3) designer's notes on the changes to the code. |
| 17 |
|
|
|
| 18 |
|
|
Comments on any area of this coding would be appreciated. Personally, |
| 19 |
|
|
I would like to see the Pow stat and a 2-type system of magic |
| 20 |
|
|
come into being. After all of you check out the code, I would |
| 21 |
|
|
like to discuss enhancements/bug fixes/implementation. For instance, |
| 22 |
|
|
is it too hard to figure out how to use the code! |
| 23 |
|
|
|
| 24 |
|
|
Sometime tomorrow exp2.tar.gz will be available in pub/thomas on |
| 25 |
|
|
ftp.astro.psu.edu. |
| 26 |
|
|
|
| 27 |
|
|
b.t. |
| 28 |
|
|
|
| 29 |
|
|
|
| 30 |
|
|
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
| 31 |
|
|
CODE PHILOSOPHY - |
| 32 |
|
|
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
| 33 |
|
|
|
| 34 |
|
|
To move CF over to a new skills-based experience system. In |
| 35 |
|
|
this implementation several kinds of experience will exist. Players |
| 36 |
|
|
will gain experience in each kind of experience (or category) |
| 37 |
|
|
based on their actions in the game. The sum of all the various |
| 38 |
|
|
categories of experience equals the player "score", from which |
| 39 |
|
|
dam, wc, and hp are determined. |
| 40 |
|
|
|
| 41 |
|
|
All experience gaining actions will be through the use of |
| 42 |
|
|
certain skills -- so called "associated skills". Associated skills |
| 43 |
|
|
are each related to 1 kind of experience. Thus, for example, |
| 44 |
|
|
"stealing" is a skill associated with "agility" experience. |
| 45 |
|
|
There exists also "miscellaneous" skills which allow the use |
| 46 |
|
|
of a unique skill, but which are not related to any kind of |
| 47 |
|
|
experience and whose use does not generate experience points. |
| 48 |
|
|
|
| 49 |
|
|
In this implementation, skills and objects are both treated |
| 50 |
|
|
as objects in the inventory of the user. Experience "objects" |
| 51 |
|
|
each represent one kind of experience and are always invisible. |
| 52 |
|
|
Skills objects each represent one kind of skill available in the |
| 53 |
|
|
game. Skills objects may either be invisible or have an associated |
| 54 |
|
|
bitmap (in which case they are "tools"). |
| 55 |
|
|
|
| 56 |
|
|
All experience gaining actions will be through the use of |
| 57 |
|
|
certain skills -- called "associated skills". Associated skills |
| 58 |
|
|
are each related to 1 kind of experience. Thus, for example, |
| 59 |
|
|
"stealing" is a skill associated with "agility" experience. |
| 60 |
|
|
|
| 61 |
|
|
Both Players and NPC's may only use skills which are in their |
| 62 |
|
|
inventories. NPC's do not use experience objects. |
| 63 |
|
|
|
| 64 |
|
|
A breakdown of the properties of skills and exp objects objects is |
| 65 |
|
|
as follows: |
| 66 |
|
|
|
| 67 |
|
|
Object Property NPC use? |
| 68 |
|
|
------ ----------------------------------- ------- |
| 69 |
|
|
Experience Each represents a different kind of NO |
| 70 |
|
|
experience in the game. The object |
| 71 |
|
|
in the player inventory keeps track |
| 72 |
|
|
of player experience in that category. |
| 73 |
|
|
Always is invisible. |
| 74 |
|
|
|
| 75 |
|
|
Skill- Represents a skill the player may YES |
| 76 |
|
|
associated perform. May be either invisible or |
| 77 |
|
|
visible as a "tool". Successful use |
| 78 |
|
|
of this skill generates experience. |
| 79 |
|
|
Experience is allocated to appropriate |
| 80 |
|
|
experience object. |
| 81 |
|
|
|
| 82 |
|
|
Skill- Same as above, *but* this skill is not YES |
| 83 |
|
|
miscell. related to any experience category, and |
| 84 |
|
|
use of this skill generates *no* |
| 85 |
|
|
experience. |
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
Linking of associated skills to experience categories is done |
| 89 |
|
|
during initialization of the code (in init()) based on the |
| 90 |
|
|
shared stats of both. |
| 91 |
|
|
|
| 92 |
|
|
How skills and experience categories are named and linked may be |
| 93 |
|
|
changed by editing the skills/experience object archetypes. |
| 94 |
|
|
|
| 95 |
|
|
|
| 96 |
|
|
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
| 97 |
|
|
CODE STRUCTURE and IMPLEMENTATION - |
| 98 |
|
|
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
| 99 |
|
|
|
| 100 |
|
|
The most important thing is that I moved most of the code into |
| 101 |
|
|
the server/skills.c and server/skill_util.c files. The skills code |
| 102 |
|
|
is loosely implemented along the lines of the spell code. This is |
| 103 |
|
|
to say that: |
| 104 |
|
|
|
| 105 |
|
|
1. skills use (do_skill) is called from fire(). |
| 106 |
|
|
2. there is a skills[] table similar to spells[]. |
| 107 |
|
|
3. server files skills.c and skill_util.c parallel |
| 108 |
|
|
spell_effect.c and spell_util.c in respective |
| 109 |
|
|
functionallity. |
| 110 |
|
|
|
| 111 |
|
|
Particular notes about the implementation are outlined below. |
| 112 |
|
|
|
| 113 |
|
|
Defines |
| 114 |
|
|
------- |
| 115 |
|
|
|
| 116 |
|
|
#define MAX_EXP_CAT maximum number of exp categories. Must |
| 117 |
|
|
be >= number in the game. Always include |
| 118 |
|
|
the "NULL" exp object - EXP_NONE. |
| 119 |
|
|
#define EXP_NONE (MAX_EXP_CAT - 1) |
| 120 |
|
|
#define NROFSKILLS Equal to the number of elements in the |
| 121 |
|
|
skills[] array. See skillist.h for more |
| 122 |
|
|
info. |
| 123 |
|
|
#define MAX_EXP_IN_OBJ (MAX_EXPERIENCE/MAX_EXP_CAT) the maximum |
| 124 |
|
|
experience that an experience object |
| 125 |
|
|
may have. See fuller description in |
| 126 |
|
|
common/living.c |
| 127 |
|
|
|
| 128 |
|
|
Dump switch |
| 129 |
|
|
----------- |
| 130 |
|
|
How the experience and skills archetypes are configured in |
| 131 |
|
|
any CF session can be seen by using the "-m5" flag. You must have |
| 132 |
|
|
DUMP_SWITCHES defined. |
| 133 |
|
|
|
| 134 |
|
|
|
| 135 |
|
|
Global parameters |
| 136 |
|
|
----------------- |
| 137 |
|
|
Unfortunately, I had to make use of several global parameters. |
| 138 |
|
|
These are: |
| 139 |
|
|
exp_cat[] - the default experience objects |
| 140 |
|
|
nrofexpcat - number of exp categories in the |
| 141 |
|
|
current session. |
| 142 |
|
|
|
| 143 |
|
|
New Flags used by the code |
| 144 |
|
|
-------------------------- |
| 145 |
|
|
|
| 146 |
|
|
FLAG_IS_WOODED -- needed by the woodsman skill. Should be set |
| 147 |
|
|
on all "wooded" terrain (eg woods2, swamp, etc.) |
| 148 |
|
|
|
| 149 |
|
|
FLAG_IS_HILLY -- needed by the mountaineer skill. Should be |
| 150 |
|
|
set on all "mountainous" terrain. |
| 151 |
|
|
|
| 152 |
|
|
FLAG_READY_WEAPON -- Code needs this for both players and monsters, |
| 153 |
|
|
and its use differs for each. |
| 154 |
|
|
|
| 155 |
|
|
FLAG_READY_SKILL -- Code needs this for both players and monsters, |
| 156 |
|
|
and its use differs for each. |
| 157 |
|
|
|
| 158 |
|
|
New structures |
| 159 |
|
|
-------------- |
| 160 |
|
|
A couple of changes to the object structure where made: |
| 161 |
|
|
(following excerpt taken from structs.h) |
| 162 |
|
|
|
| 163 |
|
|
/* These are used by the skills code */ |
| 164 |
|
|
struct obj *chosen_skill; /* the skill chosen to use */ |
| 165 |
|
|
struct obj *exp_obj; /* the exp. obj (category) assoc. w/ this object */ |
| 166 |
|
|
uint32 hide; /* The object is hidden, not invisible */ |
| 167 |
|
|
|
| 168 |
|
|
And the 'skill' structure used by the skills[] table is: |
| 169 |
|
|
|
| 170 |
|
|
typedef struct skill_struct { |
| 171 |
|
|
char *name; /* how to describe it to the player */ |
| 172 |
|
|
short category; /* the experience category to which this skill belongs */ |
| 173 |
|
|
long time; /* How many ticks it takes to use the skill */ |
| 174 |
|
|
long bexp; /* base exp gain for this skill */ |
| 175 |
|
|
float lexp; /* level multiplier of exp gain for using this skill */ |
| 176 |
|
|
short stat1; /* primary stat effecting use of this skill */ |
| 177 |
|
|
short stat2; /* secondary stat for this skill */ |
| 178 |
|
|
short stat3; /* tertiary stat for this skill */ |
| 179 |
|
|
} skill; |
| 180 |
|
|
|
| 181 |
|
|
Interaction of the skills patch with older code |
| 182 |
|
|
----------------------------------------------- |
| 183 |
|
|
Interaction of the skills "patch" with older code is minimized. |
| 184 |
|
|
below is an outline of how skills/exp code impinges on older CF |
| 185 |
|
|
code (did I miss anything here??)): |
| 186 |
|
|
|
| 187 |
|
|
-- in apply() and apply_special() changes were made to allow |
| 188 |
|
|
the use of skill "tools" and to better handle the readying of |
| 189 |
|
|
combat weapons (swords, bows, etc). |
| 190 |
|
|
|
| 191 |
|
|
-- in hit_player() changes made to allow skills control attacking. |
| 192 |
|
|
|
| 193 |
|
|
-- cosmetic changes (as in c_object.c to make pick_up() routine |
| 194 |
|
|
monster friendly) Changes in c_wiz.c, input.c fall into this |
| 195 |
|
|
category. |
| 196 |
|
|
|
| 197 |
|
|
-- new commands are inserted into the code 'skills' and |
| 198 |
|
|
'use_skills'. |
| 199 |
|
|
|
| 200 |
|
|
-- In init() init_new_exp_system() is called. Linking of |
| 201 |
|
|
exp objects/skills is done here. |
| 202 |
|
|
|
| 203 |
|
|
-- add_exp() was rewritten to accommodate changes needed. |
| 204 |
|
|
new add_exp() is called from all same locations as before, |
| 205 |
|
|
plus it is called by do_skill(). See calc_skill_exp() in |
| 206 |
|
|
skills_util.c for details of how experience is calculated |
| 207 |
|
|
in skill use. |
| 208 |
|
|
|
| 209 |
|
|
-- fix_player() changed to allow skills to affect player/monster |
| 210 |
|
|
status. |
| 211 |
|
|
|
| 212 |
|
|
-- skill_attack() is called by hit_player(). |
| 213 |
|
|
|
| 214 |
|
|
-- do_skill() is called from fire(). This is the core routine for |
| 215 |
|
|
the use of skills. Only other way to use skills is by player |
| 216 |
|
|
undertaking an action requiring a skill (a "key" skill). These |
| 217 |
|
|
are currently: |
| 218 |
|
|
(unimplemented skills in parenthesis) |
| 219 |
|
|
|
| 220 |
|
|
action skill(s) auto-readied Notes |
| 221 |
|
|
------ --------------------- ---------------------- |
| 222 |
|
|
combat - hand_weapons, Occurs when player: |
| 223 |
|
|
missile_weapons. 1. readies a weapon |
| 224 |
|
|
2. runs into opponent |
| 225 |
|
|
*and* has ready weapon |
| 226 |
|
|
|
| 227 |
|
|
wand/rod/horn- use magic item Occurs when player zaps |
| 228 |
|
|
approprite item. |
| 229 |
|
|
|
| 230 |
|
|
magic use - spellcasting, Occurs when player |
| 231 |
|
|
(praying) attempts to cast a |
| 232 |
|
|
spell of appropriate nature |
| 233 |
|
|
|
| 234 |
|
|
rod/horn/wand - (magic item use) Occurs when player |
| 235 |
|
|
use uses wand/rod/horn. |
| 236 |
|
|
|
| 237 |
|
|
In all of these cases, skills are used merely as "keys" needed |
| 238 |
|
|
by the player in order to perform an action. For example, if |
| 239 |
|
|
a player doesn't have "spellcasting", they are unable to cast |
| 240 |
|
|
spells. |
| 241 |
|
|
|
| 242 |
|
|
|
| 243 |
|
|
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
| 244 |
|
|
DESIGNER'S NOTES - more nitty gritty |
| 245 |
|
|
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
| 246 |
|
|
|
| 247 |
|
|
|
| 248 |
|
|
I have just taken the objectives from the crossfire proposal I |
| 249 |
|
|
made earlier. Each is discussed one-by-one: |
| 250 |
|
|
|
| 251 |
|
|
> Part B - Multiple experience categories |
| 252 |
|
|
> -------- |
| 253 |
|
|
> B1 - Multiple categories in which a player may gain experience. |
| 254 |
|
|
|
| 255 |
|
|
Experience objects owned by the player are not directly |
| 256 |
|
|
viewed. The "skills" command does give some information. |
| 257 |
|
|
|
| 258 |
|
|
> B3 - Each experience category will have an associated stat(s)- |
| 259 |
|
|
|
| 260 |
|
|
There must exist an experience category with Str and Int |
| 261 |
|
|
set. Otherwise, no wc, or sp will be gained after 1st |
| 262 |
|
|
level. Multiple Str, Int experience objects could exist, |
| 263 |
|
|
but will only accelerate player wc, sp gains. |
| 264 |
|
|
|
| 265 |
|
|
> B4 - Wc, hp and dam will become related to the appropriate |
| 266 |
|
|
|
| 267 |
|
|
Right now hp are related to the player "score" which |
| 268 |
|
|
is the total of all player experience. |
| 269 |
|
|
|
| 270 |
|
|
> Part C - Skills |
| 271 |
|
|
> -------- |
| 272 |
|
|
|
| 273 |
|
|
> C1 - Two kinds of skills will be available: "associated" skills |
| 274 |
|
|
|
| 275 |
|
|
Implemented. Seems to work well. |
| 276 |
|
|
|
| 277 |
|
|
> C2 - Skills will be objects in the character inventory. These |
| 278 |
|
|
|
| 279 |
|
|
Implemented. Seems to work well. |
| 280 |
|
|
|
| 281 |
|
|
> C3 - experience will be now only be gained through the use of |
| 282 |
|
|
> skills associated to one of the categories of experience. |
| 283 |
|
|
|
| 284 |
|
|
Implemented. Seems to work well. |
| 285 |
|
|
|
| 286 |
|
|
> C4 - Both NPC and players will be able to use skills. |
| 287 |
|
|
|
| 288 |
|
|
Implemented. Seems to work well. |
| 289 |
|
|
|
| 290 |
|
|
> C5 - Players will be able to learn skills by reading scrolls of |
| 291 |
|
|
|
| 292 |
|
|
Fixed a minor bug in this. |
| 293 |
|
|
|
| 294 |
|
|
|
| 295 |
|
|
General background note on why experience objects change stats from |
| 296 |
|
|
Brian Thomas, Aug 20, 1997: |
| 297 |
|
|
|
| 298 |
|
|
Nope. Stats are used by experience objects to 'tag' the |
| 299 |
|
|
category of experience, ie |
| 300 |
|
|
|
| 301 |
|
|
"physique" exp objects have Str 1 |
| 302 |
|
|
"wisdom" exp object have Wis 1 |
| 303 |
|
|
|
| 304 |
|
|
There shouldnt be an increase in the stat in question. |
| 305 |
|
|
|
| 306 |
|
|
[ now for a bit of explaination, longish...] |
| 307 |
|
|
|
| 308 |
|
|
This setup seems a bit arcane I know..so why this way? |
| 309 |
|
|
Why not hardcode the experience archetypes, eg have type |
| 310 |
|
|
EXP_FIGHTING, EXP_MAGIC, and so on? |
| 311 |
|
|
|
| 312 |
|
|
Well... at the time I did this, there was some debate about |
| 313 |
|
|
what experience system was the best, as some ppl wanted to |
| 314 |
|
|
have only 4 instead of 6 categories, and so on .. (*sigh*). |
| 315 |
|
|
|
| 316 |
|
|
In the attempt to make the experience system as flexible as |
| 317 |
|
|
possible, I coded the experience 'categories' to be defined |
| 318 |
|
|
by the archetypes and using various stats to differentiate |
| 319 |
|
|
them. Properities of the experience categories are set by the |
| 320 |
|
|
stat(s) they have defined. To my knowledge the stats have |
| 321 |
|
|
the following properties: |
| 322 |
|
|
|
| 323 |
|
|
str --> gains experience, from fighting |
| 324 |
|
|
con --> controls hp progression somewhat (if a define |
| 325 |
|
|
in living.c is set). |
| 326 |
|
|
dex --> gains exp from agility skills |
| 327 |
|
|
wis --> gains exp from priest skills, effects grace |
| 328 |
|
|
calculation |
| 329 |
|
|
int --> gain exp from mental skills |
| 330 |
|
|
cha --> gain exp from personality skills |
| 331 |
|
|
pow --> gain exp from wizard skills, effects mana calc. |
| 332 |
|
|
|
| 333 |
|
|
So, If you didnt like the current 6 experience catagories and |
| 334 |
|
|
wanted only 3 for your server, say "fighting" "presense" and |
| 335 |
|
|
"holyness" you could remove all of the old experience archetypes |
| 336 |
|
|
and define the following new ones: |
| 337 |
|
|
|
| 338 |
|
|
Name Properties Explaination |
| 339 |
|
|
fighting Str 1, Con 1, Dex 1 Combines old physique, agility exp |
| 340 |
|
|
presence Pow 1, Cha 1 Combines old magic, personality exp |
| 341 |
|
|
holyness Wis 1 same as old wisdom exp |
| 342 |
|
|
|
| 343 |
|
|
So, every player on this server would only see 3 types of |
| 344 |
|
|
experience to be gained. If you fight or steal something, then |
| 345 |
|
|
experience points go to the "fighting" category. |
| 346 |
|
|
|
| 347 |
|
|
And note, since we DIDNT design an arch with Int 1, there will be |
| 348 |
|
|
NO experience gained for use of mental skills (at least in theory |
| 349 |
|
|
this should be the case. I dont recogmend leaving out a stat, |
| 350 |
|
|
eg you should have a every stat covered between all of your new |
| 351 |
|
|
experience archetypes). |
| 352 |
|
|
|
| 353 |
|
|
Even though I wrote a doc to help explain how to do this, probably |
| 354 |
|
|
nobody but me (or maybe Peter) really is knowledgeable enough (and |
| 355 |
|
|
has the desire) to reconfigure the game experience to suit their |
| 356 |
|
|
individual tastes. This might be some code we could 'simplify' |
| 357 |
|
|
(heh, remove it). |
| 358 |
|
|
|
| 359 |
|
|
|