| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "global.h" |
| 20 |
|
| 21 |
#include <stdlib.h> |
| 22 |
#include <string.h> |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
void clear_player(player *pl) { |
| 34 |
client_spell *info; |
| 35 |
client_spell *next; |
| 36 |
|
| 37 |
|
| 38 |
free(pl->stack_items); |
| 39 |
pl->stack_position = 0; |
| 40 |
|
| 41 |
info = pl->spell_state; |
| 42 |
while (info) { |
| 43 |
next = info->next; |
| 44 |
free(info); |
| 45 |
info = next; |
| 46 |
} |
| 47 |
if (pl->unarmed_skill) |
| 48 |
FREE_AND_CLEAR_STR(pl->unarmed_skill); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
void free_player(player *pl) { |
| 58 |
if (first_player != pl) { |
| 59 |
player *prev = first_player; |
| 60 |
|
| 61 |
while (prev != NULL && prev->next != NULL && prev->next != pl) |
| 62 |
prev = prev->next; |
| 63 |
if (prev->next != pl) { |
| 64 |
LOG(llevError, "Free_player: Can't find previous player.\n"); |
| 65 |
exit(1); |
| 66 |
} |
| 67 |
prev->next = pl->next; |
| 68 |
} else |
| 69 |
first_player = pl->next; |
| 70 |
|
| 71 |
if (pl->ob != NULL) { |
| 72 |
if (!QUERY_FLAG(pl->ob, FLAG_REMOVED)) |
| 73 |
object_remove(pl->ob); |
| 74 |
object_free_drop_inventory(pl->ob); |
| 75 |
} |
| 76 |
|
| 77 |
clear_player(pl); |
| 78 |
|
| 79 |
free(pl->socket.faces_sent); |
| 80 |
|
| 81 |
free(pl); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
int atnr_is_dragon_enabled(int attacknr) { |
| 96 |
if (attacknr == ATNR_MAGIC |
| 97 |
|| attacknr == ATNR_FIRE |
| 98 |
|| attacknr == ATNR_ELECTRICITY |
| 99 |
|| attacknr == ATNR_COLD |
| 100 |
|| attacknr == ATNR_ACID |
| 101 |
|| attacknr == ATNR_POISON) |
| 102 |
return 1; |
| 103 |
return 0; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
int is_dragon_pl(const object *op) { |
| 115 |
if (op != NULL |
| 116 |
&& op->type == PLAYER |
| 117 |
&& op->arch != NULL |
| 118 |
&& op->arch->clone.race != NULL |
| 119 |
&& strcmp(op->arch->clone.race, "dragon") == 0) |
| 120 |
return 1; |
| 121 |
return 0; |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
client_spell *get_client_spell_state(player *pl, object *spell) { |
| 137 |
client_spell *info = pl->spell_state; |
| 138 |
|
| 139 |
while (info) { |
| 140 |
if (info->spell == spell) |
| 141 |
return info; |
| 142 |
info = info->next; |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
info = (client_spell *)calloc(1, sizeof(client_spell)); |
| 149 |
if (info == NULL) |
| 150 |
fatal(OUT_OF_MEMORY); |
| 151 |
info->next = pl->spell_state; |
| 152 |
info->spell = spell; |
| 153 |
pl->spell_state = info; |
| 154 |
return info; |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
int is_wraith_pl(object *op) { |
| 166 |
return op != NULL && op->type == PLAYER && op->arch != NULL && object_find_by_name(op, "wraith feed") != NULL; |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
int is_old_wraith_pl(object *op) { |
| 178 |
return op != NULL && op->type == PLAYER && op->arch != NULL && object_find_by_name(op, "Wraith_Force") != NULL && !is_wraith_pl(op); |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
void player_set_dragon_title(struct pl *pl, int level, const char *attack, int skin_resist) { |
| 195 |
if (level == 0) |
| 196 |
snprintf(pl->title, sizeof(pl->title), "%s hatchling", attack); |
| 197 |
else if (level == 1) |
| 198 |
snprintf(pl->title, sizeof(pl->title), "%s wyrm", attack); |
| 199 |
else if (level == 2) |
| 200 |
snprintf(pl->title, sizeof(pl->title), "%s wyvern", attack); |
| 201 |
else if (level == 3) |
| 202 |
snprintf(pl->title, sizeof(pl->title), "%s dragon", attack); |
| 203 |
|
| 204 |
else if (skin_resist > 80) |
| 205 |
snprintf(pl->title, sizeof(pl->title), "legendary %s dragon", attack); |
| 206 |
else if (skin_resist > 50) |
| 207 |
snprintf(pl->title, sizeof(pl->title), "ancient %s dragon", attack); |
| 208 |
else |
| 209 |
snprintf(pl->title, sizeof(pl->title), "big %s dragon", attack); |
| 210 |
pl->own_title[0] = '\0'; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
void player_get_title(const struct pl *pl, char *buf, size_t bufsize) { |
| 225 |
if (pl->own_title[0] == '\0') |
| 226 |
snprintf(buf, bufsize, "the %s", pl->title); |
| 227 |
else |
| 228 |
strlcpy(buf, pl->own_title, bufsize); |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
int player_has_own_title(const struct pl *pl) { |
| 240 |
return pl->own_title[0] != '\0'; |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
const char *player_get_own_title(const struct pl *pl) { |
| 253 |
return pl->own_title; |
| 254 |
} |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
void player_set_own_title(struct pl *pl, const char *title) { |
| 265 |
strlcpy(pl->own_title, title, sizeof(pl->own_title)); |
| 266 |
replace_unprintable_chars(pl->own_title); |
| 267 |
} |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
void link_player_skills(object *op) { |
| 280 |
int skill; |
| 281 |
FOR_INV_PREPARE(op, tmp) { |
| 282 |
if (tmp->type == SKILL) { |
| 283 |
for (skill = 0; skill < MAX_SKILLS; skill++) { |
| 284 |
if (op->contr->last_skill_ob[skill] == NULL) { |
| 285 |
|
| 286 |
op->contr->last_skill_ob[skill] = tmp; |
| 287 |
op->contr->last_skill_exp[skill] = -1; |
| 288 |
break; |
| 289 |
} |
| 290 |
if (op->contr->last_skill_ob[skill] == tmp) { |
| 291 |
|
| 292 |
break; |
| 293 |
} |
| 294 |
} |
| 295 |
} |
| 296 |
} FOR_INV_FINISH(); |
| 297 |
} |