ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/doc/playbook-html/char-extract
Revision: 1.2
Committed: Thu Sep 7 21:43:22 2006 UTC (17 years, 8 months ago) by pippijn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Log Message:
Moved documents to doc/historic

File Contents

# Content
1 # stats-extract - parse the archetypes-file and output the
2 # player's stats in a structured format.
3
4 # July 96 - this was modified slightly for the player's handbook.
5 # -b.t. thomas@astro.psu.edu
6
7 # Variables passed when invoked:
8 # living_c - filename where the array attacks is defined.
9
10 BEGIN {
11 # These stats will be added to the "magik" string according
12 # to the pattern. "%s" should be "%+d", but that isn't
13 # portable.
14 magic["luck"] = "luck %s";
15 magic["exp"] = "speed %s";
16 magic["sp"] = "spell-point regeneration %s";
17 magic["hp"] = "hit-point regeneration %s";
18 magic["dam"] = "Dam %s";
19 magic["wc"] = "Wc %s";
20 magic["ac"] = "Ac %s";
21 magic["armour"] = "armour %s";
22
23 magic["reflect_spell"] = "reflect spells";
24 magic["xrays"] = "X-ray vision";
25 magic["stealth"] = "stealth";
26 magic["flying"] = "flying";
27
28 # Read the attack-types (and immune/protection)
29 while ((getline buff < living_c) == 1) {
30 if (buff ~ /attacks\[/) {
31 att = 0;
32 while (1) {
33 getline buff < living_c;
34 if (buff ~ "^}")
35 break;
36 gsub("[ \t]*\"", "", buff);
37 nr = split(buff, arr, ",");
38 for (i = 1; i <= nr && arr[i]; i++)
39 attack[++att] = arr[i];
40 }
41 break;
42 }
43 }
44 close(living_c);
45 }
46
47 /^Object/ {
48 slay = magik = "";
49 name = obj = $2;
50 type = weight = last_sp = 0;
51 att = prot = immune = 0;
52 stat["Str"] = stat["Dex"] = stat["Con"] = 0;
53 stat["Int"] = stat["Wis"] = stat["Pow"] = stat["Cha"] = 0;
54 }
55
56 /^Str|^Dex|^Con|^Int|^Wis|^Pow|^Cha/ { stat[$1] = $2; next }
57
58 $1 in magic { add_magik(magic[$1], $2) }
59
60 /^type/ { type = $2 }
61 /^last_sp/ { last_sp = $2 }
62 /^weight/ { weight = $2 }
63 /^attacktype/ { att = $2 }
64 /^protected/ { prot = $2 }
65 /^immune/ { immune = $2 }
66 /^slaying/ { slay = $2; }
67 /^name/ { name = substr($0, 6) }
68
69 /^end/ {
70 if (type == 1) { # Players
71 if (att % 2) --att; # Skip physical attack
72 magik = magik attacktype(att , "Attacks:");
73 magik = magik attacktype(prot, "Protected:");
74 magik = magik attacktype(immune, "Immune:");
75 if (slay)
76 magik = magik "<br>" capitalize(slay=="wall" ? "excavation" : slay "-slaying");
77 sub("^<br>", "", magik);
78 magik = capitalize(magik);
79 name = capitalize(name);
80 sub("_", " ", name);
81 printf("<tr><td>%s</td><td>~~%s~~</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%s</tr>\n",
82 name, obj,
83 20+stat["Str"], 20+stat["Dex"], 20+stat["Con"],
84 20+stat["Int"], 20+stat["Wis"], 20+stat["Pow"],
85 20+stat["Cha"], magik);
86 }
87 }
88
89 END {
90 close("items");
91 }
92
93
94 # Given a bitmask, give a string enumerating the meaning of the bits.
95 function attacktype(at, type, i, str) {
96 for (i = 1; i in attack; i++) {
97 if (at % 2)
98 str = (str ? str ", " : "") attack[i];
99 at = int(at/2);
100 }
101 return str ? "<br>" type " " str : "";
102 }
103
104 function add_magik(str, val) {
105 str = sprintf(str, val < 0 ? val : val);
106 if (str)
107 magik = magik ? magik ", " str : str;
108 }
109
110 function capitalize(str) {
111 return toupper(substr(str, 1, 1)) substr(str, 2);
112 }