| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
#define WANT_UNARMED_SKILLS |
| 36 |
|
| 37 |
#include "global.h" |
| 38 |
|
| 39 |
#include <assert.h> |
| 40 |
#include <ctype.h> |
| 41 |
#include <stdlib.h> |
| 42 |
#include <string.h> |
| 43 |
#include <math.h> |
| 44 |
|
| 45 |
#include "living.h" |
| 46 |
#include "object.h" |
| 47 |
#include "shop.h" |
| 48 |
#include "skills.h" |
| 49 |
#include "spells.h" |
| 50 |
#include "sproto.h" |
| 51 |
|
| 52 |
static void attack_hth(object *pl, int dir, const char *string, object *skill); |
| 53 |
static void attack_melee_weapon(object *op, int dir, const char *string, object *skill); |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
const char *skill_names[MAX_SKILLS]; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
const Face *skill_faces[MAX_SKILLS]; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
void init_skills(void) { |
| 69 |
int i; |
| 70 |
archetype *at; |
| 71 |
|
| 72 |
for (i = 0; i < MAX_SKILLS; i++) { |
| 73 |
skill_names[i] = NULL; |
| 74 |
skill_faces[i] = NULL; |
| 75 |
} |
| 76 |
i = 0; |
| 77 |
|
| 78 |
for (at = first_archetype; at != NULL; at = at->next) { |
| 79 |
if (at->clone.type == SKILL) { |
| 80 |
if (i == MAX_SKILLS) { |
| 81 |
LOG(llevError, "init_skills: too many skills, increase MAX_SKILLS and rebuild server!"); |
| 82 |
fatal(SEE_LAST_ERROR); |
| 83 |
} |
| 84 |
skill_names[i] = add_refcount(at->clone.skill); |
| 85 |
if (at->clone.face != NULL) |
| 86 |
skill_faces[i] = at->clone.face; |
| 87 |
i++; |
| 88 |
} |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
int get_skill_client_code(const char *skill_name) |
| 98 |
{ |
| 99 |
int index; |
| 100 |
for (index = 0; index < MAX_SKILLS && skill_names[index] != NULL; index++) |
| 101 |
if (strcmp(skill_names[index], skill_name) == 0) |
| 102 |
return index; |
| 103 |
|
| 104 |
assert("invalid skill!"); |
| 105 |
return 0; |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
static object *adjust_skill_tool(object *who, object *skill, object *skill_tool) { |
| 131 |
if (!skill && !skill_tool) |
| 132 |
return NULL; |
| 133 |
|
| 134 |
|
| 135 |
if (skill && QUERY_FLAG(skill, FLAG_CAN_USE_SKILL) && (!skill_tool || QUERY_FLAG(skill_tool, FLAG_APPLIED) || strcmp(skill->skill, "clawing") == 0)) |
| 136 |
return skill; |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
if (skill_tool) { |
| 143 |
if (!QUERY_FLAG(skill_tool, FLAG_APPLIED)) { |
| 144 |
if (apply_special(who, skill_tool, 0)) { |
| 145 |
if (skill && QUERY_FLAG(skill, FLAG_CAN_USE_SKILL)) |
| 146 |
return skill; |
| 147 |
else |
| 148 |
return NULL; |
| 149 |
} |
| 150 |
} |
| 151 |
if (!skill) { |
| 152 |
skill = give_skill_by_name(who, skill_tool->skill); |
| 153 |
link_player_skills(who); |
| 154 |
} |
| 155 |
return skill; |
| 156 |
} |
| 157 |
if (skill && QUERY_FLAG(skill, FLAG_CAN_USE_SKILL)) |
| 158 |
return skill; |
| 159 |
else |
| 160 |
return NULL; |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
object *find_skill_by_name(object *who, const char *name) { |
| 193 |
object *skill = NULL, *skills[MAX_SKILLS], *skill_tools[MAX_SKILLS]; |
| 194 |
const char *skill_names[MAX_SKILLS]; |
| 195 |
char *ourname=NULL; |
| 196 |
int num_names, highest_level_skill=0, i; |
| 197 |
|
| 198 |
if (!name) |
| 199 |
return NULL; |
| 200 |
|
| 201 |
|
| 202 |
if (!strchr(name, ',')) { |
| 203 |
skill_names[0] = name; |
| 204 |
skill_tools[0] = NULL; |
| 205 |
skills[0] = NULL; |
| 206 |
num_names = 1; |
| 207 |
} else { |
| 208 |
|
| 209 |
char *lasts; |
| 210 |
ourname = strdup(name); |
| 211 |
|
| 212 |
if ((skill_names[0] = strtok_r(ourname, ",", &lasts)) == NULL) { |
| 213 |
|
| 214 |
LOG(llevError, "find_skill_by_name: strtok_r returned null, but strchr did not?\n"); |
| 215 |
free(ourname); |
| 216 |
return NULL; |
| 217 |
} else { |
| 218 |
skill_tools[0] = NULL; |
| 219 |
skills[0] = NULL; |
| 220 |
|
| 221 |
num_names=1; |
| 222 |
while ((skill_names[num_names] = strtok_r(NULL, ",", &lasts)) != NULL) { |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
while (isspace(*skill_names[num_names])) |
| 227 |
skill_names[num_names]++; |
| 228 |
skills[num_names] = NULL; |
| 229 |
skill_tools[num_names] = NULL; |
| 230 |
num_names++; |
| 231 |
} |
| 232 |
} |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
} |
| 237 |
|
| 238 |
FOR_INV_PREPARE(who, tmp) { |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
if (tmp->type == SKILL || (tmp->type == SKILL_TOOL && !QUERY_FLAG(tmp, FLAG_UNPAID))) { |
| 244 |
for (i = 0; i<num_names; i++) { |
| 245 |
if (!strncasecmp(skill_names[i], tmp->skill, strlen(skill_names[i])) && |
| 246 |
strlen(tmp->skill) >= strlen(skill_names[i])) { |
| 247 |
if (tmp->type == SKILL) { |
| 248 |
skills[i] = tmp; |
| 249 |
if (!skill || tmp->level > skill->level) { |
| 250 |
skill = tmp; |
| 251 |
highest_level_skill=i; |
| 252 |
} |
| 253 |
} |
| 254 |
else { |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
if (QUERY_FLAG(tmp, FLAG_APPLIED) || !skill_tools[i] || |
| 259 |
!QUERY_FLAG(skill_tools[i], FLAG_APPLIED)) { |
| 260 |
skill_tools[i] = tmp; |
| 261 |
} |
| 262 |
} |
| 263 |
|
| 264 |
break; |
| 265 |
} |
| 266 |
} |
| 267 |
} |
| 268 |
} FOR_INV_FINISH(); |
| 269 |
free(ourname); |
| 270 |
return adjust_skill_tool(who, skills[highest_level_skill], skill_tools[highest_level_skill]); |
| 271 |
} |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
object *find_skill_by_number(object *who, int skillno) { |
| 296 |
object *skill = NULL, *skill_tool = NULL; |
| 297 |
|
| 298 |
if (skillno <= 0 || skillno > MAX_SKILLS) { |
| 299 |
return NULL; |
| 300 |
} |
| 301 |
|
| 302 |
FOR_INV_PREPARE(who, tmp) { |
| 303 |
if (tmp->type == SKILL && tmp->subtype == skillno) |
| 304 |
skill = tmp; |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
else if (tmp->type == SKILL_TOOL && tmp->subtype == skillno) { |
| 310 |
if (QUERY_FLAG(tmp, FLAG_APPLIED)) |
| 311 |
skill_tool = tmp; |
| 312 |
else if (!skill_tool || !QUERY_FLAG(skill_tool, FLAG_APPLIED)) |
| 313 |
skill_tool = tmp; |
| 314 |
} |
| 315 |
} FOR_INV_FINISH(); |
| 316 |
|
| 317 |
return adjust_skill_tool(who, skill, skill_tool); |
| 318 |
} |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
int change_skill(object *who, object *new_skill, int flag) { |
| 341 |
rangetype old_range; |
| 342 |
|
| 343 |
if (who->type != PLAYER) |
| 344 |
return 0; |
| 345 |
|
| 346 |
old_range = who->contr->shoottype; |
| 347 |
|
| 348 |
|
| 349 |
if (who->chosen_skill && who->chosen_skill->skill == new_skill->skill) { |
| 350 |
|
| 351 |
if (!(flag&0x1)) |
| 352 |
who->contr->shoottype = range_skill; |
| 353 |
return 1; |
| 354 |
} |
| 355 |
|
| 356 |
if (who->chosen_skill) |
| 357 |
apply_special(who, who->chosen_skill, AP_UNAPPLY|(flag&AP_NOPRINT)); |
| 358 |
|
| 359 |
|
| 360 |
if (!new_skill) |
| 361 |
return 0; |
| 362 |
|
| 363 |
if (apply_special(who, new_skill, AP_APPLY|(flag&AP_NOPRINT))) { |
| 364 |
return 0; |
| 365 |
} |
| 366 |
if (flag&0x1) |
| 367 |
who->contr->shoottype = old_range; |
| 368 |
|
| 369 |
return 1; |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
void clear_skill(object *who) { |
| 380 |
who->chosen_skill = NULL; |
| 381 |
CLEAR_FLAG(who, FLAG_READY_SKILL); |
| 382 |
if (who->type == PLAYER) { |
| 383 |
who->contr->ranges[range_skill] = NULL; |
| 384 |
if (who->contr->shoottype == range_skill) |
| 385 |
who->contr->shoottype = range_none; |
| 386 |
} |
| 387 |
} |
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
int do_skill(object *op, object *part, object *skill, int dir, const char *string) { |
| 413 |
int success = 0, exp = 0; |
| 414 |
|
| 415 |
if (!skill) |
| 416 |
return 0; |
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
if (skill->type != SKILL && op->type == PLAYER) { |
| 424 |
object *tmp; |
| 425 |
|
| 426 |
tmp = object_find_by_type_and_skill(op, SKILL, skill->skill); |
| 427 |
if (!tmp) { |
| 428 |
tmp = give_skill_by_name(op, skill->skill); |
| 429 |
if (!tmp) { |
| 430 |
LOG(llevError, "do_skill: asked for skill %s but couldn't find matching SKILL archetype.\n", skill->skill); |
| 431 |
return 0; |
| 432 |
} |
| 433 |
} |
| 434 |
skill = tmp; |
| 435 |
} |
| 436 |
|
| 437 |
if (skill->anim_suffix) |
| 438 |
apply_anim_suffix(op, skill->anim_suffix); |
| 439 |
|
| 440 |
switch (skill->subtype) { |
| 441 |
case SK_LEVITATION: |
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
if (QUERY_FLAG(skill, FLAG_APPLIED)) { |
| 448 |
CLEAR_FLAG(skill, FLAG_APPLIED); |
| 449 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_SUCCESS, |
| 450 |
"You come to earth."); |
| 451 |
} else { |
| 452 |
SET_FLAG(skill, FLAG_APPLIED); |
| 453 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_SUCCESS, |
| 454 |
"You rise into the air!."); |
| 455 |
} |
| 456 |
fix_object(op); |
| 457 |
success = 1; |
| 458 |
break; |
| 459 |
|
| 460 |
case SK_STEALING: |
| 461 |
exp = success = steal(op, dir, skill); |
| 462 |
break; |
| 463 |
|
| 464 |
case SK_LOCKPICKING: |
| 465 |
exp = success = pick_lock(op, dir, skill); |
| 466 |
break; |
| 467 |
|
| 468 |
case SK_HIDING: |
| 469 |
exp = success = hide(op, skill); |
| 470 |
break; |
| 471 |
|
| 472 |
case SK_JUMPING: |
| 473 |
success = jump(op, dir, skill); |
| 474 |
break; |
| 475 |
|
| 476 |
case SK_INSCRIPTION: |
| 477 |
exp = success = write_on_item(op, string, skill); |
| 478 |
break; |
| 479 |
|
| 480 |
case SK_MEDITATION: |
| 481 |
meditate(op, skill); |
| 482 |
success = 1; |
| 483 |
break; |
| 484 |
|
| 485 |
|
| 486 |
case SK_KARATE: |
| 487 |
attack_hth(op, dir, "karate-chopped", skill); |
| 488 |
break; |
| 489 |
|
| 490 |
case SK_PUNCHING: |
| 491 |
attack_hth(op, dir, "punched", skill); |
| 492 |
break; |
| 493 |
|
| 494 |
case SK_FLAME_TOUCH: |
| 495 |
attack_hth(op, dir, "flamed", skill); |
| 496 |
break; |
| 497 |
|
| 498 |
case SK_CLAWING: |
| 499 |
attack_hth(op, dir, "clawed", skill); |
| 500 |
break; |
| 501 |
|
| 502 |
case SK_WRAITH_FEED: |
| 503 |
attack_hth(op, dir, "fed upon", skill); |
| 504 |
break; |
| 505 |
|
| 506 |
case SK_ONE_HANDED_WEAPON: |
| 507 |
case SK_TWO_HANDED_WEAPON: |
| 508 |
(void)attack_melee_weapon(op, dir, NULL, skill); |
| 509 |
break; |
| 510 |
|
| 511 |
case SK_FIND_TRAPS: |
| 512 |
exp = success = find_traps(op, skill); |
| 513 |
break; |
| 514 |
|
| 515 |
case SK_SINGING: |
| 516 |
exp = success = singing(op, dir, skill); |
| 517 |
break; |
| 518 |
|
| 519 |
case SK_ORATORY: |
| 520 |
exp = success = use_oratory(op, dir, skill); |
| 521 |
break; |
| 522 |
|
| 523 |
case SK_SMITHERY: |
| 524 |
case SK_BOWYER: |
| 525 |
case SK_JEWELER: |
| 526 |
case SK_ALCHEMY: |
| 527 |
case SK_THAUMATURGY: |
| 528 |
case SK_LITERACY: |
| 529 |
case SK_WOODSMAN: |
| 530 |
if (use_alchemy(op) == 0) |
| 531 |
exp = success = skill_ident(op, skill); |
| 532 |
break; |
| 533 |
|
| 534 |
case SK_DET_MAGIC: |
| 535 |
case SK_DET_CURSE: |
| 536 |
exp = success = skill_ident(op, skill); |
| 537 |
break; |
| 538 |
|
| 539 |
case SK_DISARM_TRAPS: |
| 540 |
exp = success = remove_trap(op, skill); |
| 541 |
break; |
| 542 |
|
| 543 |
case SK_THROWING: |
| 544 |
success = skill_throw(op, part, dir, skill); |
| 545 |
break; |
| 546 |
|
| 547 |
case SK_SET_TRAP: |
| 548 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_ERROR, |
| 549 |
"This skill is not currently implemented."); |
| 550 |
break; |
| 551 |
|
| 552 |
case SK_USE_MAGIC_ITEM: |
| 553 |
case SK_MISSILE_WEAPON: |
| 554 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_ERROR, |
| 555 |
"There is no special attack for this skill."); |
| 556 |
break; |
| 557 |
|
| 558 |
case SK_PRAYING: |
| 559 |
success = pray(op, skill); |
| 560 |
break; |
| 561 |
|
| 562 |
case SK_BARGAINING: |
| 563 |
success = shop_describe(op); |
| 564 |
break; |
| 565 |
|
| 566 |
case SK_SORCERY: |
| 567 |
case SK_EVOCATION: |
| 568 |
case SK_PYROMANCY: |
| 569 |
case SK_SUMMONING: |
| 570 |
case SK_CLIMBING: |
| 571 |
case SK_EARTH_MAGIC: |
| 572 |
case SK_AIR_MAGIC: |
| 573 |
case SK_FIRE_MAGIC: |
| 574 |
case SK_WATER_MAGIC: |
| 575 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_ERROR, |
| 576 |
"This skill is already in effect."); |
| 577 |
break; |
| 578 |
|
| 579 |
case SK_HARVESTING: |
| 580 |
do_harvest(op, dir, skill); |
| 581 |
success = 0; |
| 582 |
break; |
| 583 |
|
| 584 |
default: { |
| 585 |
char name[MAX_BUF]; |
| 586 |
|
| 587 |
query_name(op, name, MAX_BUF); |
| 588 |
LOG(llevDebug, "%s attempted to use unknown skill: %d\n", name, op->chosen_skill->stats.sp); |
| 589 |
break; |
| 590 |
} |
| 591 |
} |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
if (op->type == PLAYER) |
| 601 |
op->speed_left -= 1.0; |
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
if (success && exp) |
| 609 |
change_exp(op, exp, skill->skill, SK_SUBTRACT_SKILL_EXP); |
| 610 |
|
| 611 |
return success; |
| 612 |
} |
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
int64_t calc_skill_exp(const object *who, const object *op, const object *skill) { |
| 647 |
int64_t op_exp; |
| 648 |
int op_lvl; |
| 649 |
float base, value, lvl_mult; |
| 650 |
|
| 651 |
if (!skill) |
| 652 |
skill = who; |
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
if (!op) { |
| 665 |
op_lvl = MAX(who->map->difficulty, 1); |
| 666 |
op_exp = 0; |
| 667 |
} else if (op->type == RUNE || op->type == TRAP) { |
| 668 |
|
| 669 |
op_exp = op->stats.Cha > 1 ? op->stats.Cha : op->stats.exp; |
| 670 |
op_lvl = op->level; |
| 671 |
} else { |
| 672 |
op_exp = op->stats.exp; |
| 673 |
op_lvl = op->level; |
| 674 |
if (!QUERY_FLAG(op, FLAG_ALIVE)) { |
| 675 |
op_lvl += 5*abs(op->magic); |
| 676 |
} |
| 677 |
} |
| 678 |
|
| 679 |
if (op_lvl < 1) |
| 680 |
op_lvl = 1; |
| 681 |
|
| 682 |
if (who->type != PLAYER) { |
| 683 |
return ((int64_t)(op_exp*0.1)+1); |
| 684 |
} |
| 685 |
|
| 686 |
|
| 687 |
base = op_exp; |
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
if (skill->type == SKILL) { |
| 692 |
base += skill->arch->clone.stats.exp; |
| 693 |
if (settings.simple_exp) { |
| 694 |
if (skill->arch->clone.level) |
| 695 |
lvl_mult = (float)skill->arch->clone.level/100.0; |
| 696 |
else |
| 697 |
lvl_mult = 1.0; |
| 698 |
} else { |
| 699 |
if (skill->level) |
| 700 |
lvl_mult = ((float)skill->arch->clone.level*(float)op_lvl)/((float)skill->level*100.0); |
| 701 |
else |
| 702 |
lvl_mult = 1.0; |
| 703 |
} |
| 704 |
} else { |
| 705 |
|
| 706 |
lvl_mult = (float)op_lvl/(float)(skill->level ? skill->level : 1); |
| 707 |
} |
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
value = base*lvl_mult; |
| 712 |
if (value < 1) |
| 713 |
value = 1; |
| 714 |
|
| 715 |
#ifdef SKILL_UTIL_DEBUG |
| 716 |
LOG(llevDebug, "calc_skill_exp(): who: %s(lvl:%d) op:%s(lvl:%d)\n", who->name, skill->level, op->name, op_lvl); |
| 717 |
#endif |
| 718 |
return ((int64_t)value); |
| 719 |
} |
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
int learn_skill(object *pl, object *scroll) { |
| 739 |
object *tmp; |
| 740 |
|
| 741 |
if (!scroll->skill) { |
| 742 |
LOG(llevError, "skill scroll %s does not have skill pointer set.\n", scroll->name); |
| 743 |
return 2; |
| 744 |
} |
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
tmp = NULL; |
| 751 |
FOR_INV_PREPARE(pl, inv) |
| 752 |
if (inv->type == SKILL && !strncasecmp(scroll->skill, inv->skill, strlen(scroll->skill))) { |
| 753 |
tmp = inv; |
| 754 |
break; |
| 755 |
} |
| 756 |
FOR_INV_FINISH(); |
| 757 |
|
| 758 |
|
| 759 |
if (tmp && QUERY_FLAG(tmp, FLAG_CAN_USE_SKILL)) |
| 760 |
return 0; |
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
if (random_roll(0, 99, pl, PREFER_LOW) > (get_learn_spell(pl->stats.Int)+(pl->level/5))) |
| 767 |
return 2; |
| 768 |
|
| 769 |
if (!tmp) |
| 770 |
tmp = give_skill_by_name(pl, scroll->skill); |
| 771 |
|
| 772 |
if (!tmp) { |
| 773 |
LOG(llevError, "skill scroll %s does not have valid skill name (%s).\n", scroll->name, scroll->skill); |
| 774 |
return 2; |
| 775 |
} |
| 776 |
|
| 777 |
SET_FLAG(tmp, FLAG_CAN_USE_SKILL); |
| 778 |
link_player_skills(pl); |
| 779 |
return 1; |
| 780 |
} |
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
static int clipped_percent(int64_t a, int64_t b) { |
| 794 |
int rv; |
| 795 |
|
| 796 |
if (b <= 0) |
| 797 |
return 0; |
| 798 |
|
| 799 |
rv = (int)((100.0f*((float)a)/((float)b))+0.5f); |
| 800 |
|
| 801 |
if (rv < 0) |
| 802 |
return 0; |
| 803 |
else if (rv > 100) |
| 804 |
return 100; |
| 805 |
|
| 806 |
return rv; |
| 807 |
} |
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
static int digits_in_long(int64_t num) |
| 819 |
{ |
| 820 |
return num == 0 ? 1 : floor( log10( labs(num) ) ) + 1; |
| 821 |
} |
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
void show_skills(object *op, const char *parms) { |
| 840 |
const char *cp; |
| 841 |
int i, num_skills_found = 0; |
| 842 |
|
| 843 |
char skills[MAX_SKILLS][MAX_BUF]; |
| 844 |
const char *search = parms; |
| 845 |
bool long_format = false; |
| 846 |
|
| 847 |
if ( parms && strncmp(parms,"-l",2) == 0 ) { |
| 848 |
long_format = true; |
| 849 |
search += 2; |
| 850 |
while ( *search && *search != ' ' ) ++search; |
| 851 |
while ( *search == ' ' ) ++search; |
| 852 |
} |
| 853 |
FOR_INV_PREPARE(op, tmp) { |
| 854 |
if (tmp->type == SKILL) { |
| 855 |
if (search && strstr(tmp->name, search) == NULL) |
| 856 |
continue; |
| 857 |
|
| 858 |
if (settings.permanent_exp_ratio) { |
| 859 |
if ( long_format ) { |
| 860 |
int perm_level = exp_level(tmp->total_exp * settings.permanent_exp_ratio / 100); |
| 861 |
snprintf(skills[num_skills_found++], MAX_BUF, "[fixed]%-20slvl:%3d (xp:%"FMT64"/%"FMT64")%-*sperm lvl:%3d (xp:%"FMT64"/%"FMT64") ", |
| 862 |
tmp->name, tmp->level, |
| 863 |
tmp->stats.exp, |
| 864 |
level_exp(tmp->level+1, op->expmul), |
| 865 |
1+2*digits_in_long(op->stats.exp)-digits_in_long(tmp->stats.exp)-digits_in_long(level_exp(tmp->level+1, op->expmul)), |
| 866 |
"", |
| 867 |
perm_level, |
| 868 |
tmp->total_exp * settings.permanent_exp_ratio / 100, |
| 869 |
level_exp(perm_level+1, op->expmul)); |
| 870 |
} else { |
| 871 |
snprintf(skills[num_skills_found++], MAX_BUF, "[fixed]%-20slvl:%3d (xp:%"FMT64"/%"FMT64"/%d%%)", |
| 872 |
tmp->name, tmp->level, |
| 873 |
tmp->stats.exp, |
| 874 |
level_exp(tmp->level+1, op->expmul), |
| 875 |
clipped_percent(PERM_EXP(tmp->total_exp), tmp->stats.exp)); |
| 876 |
} |
| 877 |
} else { |
| 878 |
snprintf(skills[num_skills_found++], MAX_BUF, "[fixed]%-20slvl:%3d (xp:%"FMT64"/%"FMT64")", |
| 879 |
tmp->name, tmp->level, |
| 880 |
tmp->stats.exp, |
| 881 |
level_exp(tmp->level+1, op->expmul)); |
| 882 |
} |
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
if (num_skills_found >= MAX_SKILLS) { |
| 890 |
draw_ext_info(NDI_RED, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_ERROR, |
| 891 |
"Your character has too many skills.\n" |
| 892 |
"Something isn't right - contact the server admin"); |
| 893 |
break; |
| 894 |
} |
| 895 |
} |
| 896 |
} FOR_INV_FINISH(); |
| 897 |
|
| 898 |
if ( search && *search ) { |
| 899 |
draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_LIST, |
| 900 |
"Player skills%s: (matching '%s')", long_format ? " (long format)":"",search); |
| 901 |
} else { |
| 902 |
draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_LIST, |
| 903 |
"Player skills%s:", long_format ? " (long format)":""); |
| 904 |
} |
| 905 |
|
| 906 |
if (num_skills_found > 1) |
| 907 |
qsort(skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *))strcmp); |
| 908 |
|
| 909 |
for (i = 0; i < num_skills_found; i++) { |
| 910 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_LIST, |
| 911 |
skills[i]); |
| 912 |
} |
| 913 |
|
| 914 |
cp = determine_god(op); |
| 915 |
if (strcmp(cp, "none") == 0) |
| 916 |
cp = NULL; |
| 917 |
|
| 918 |
draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_LIST, |
| 919 |
"You can handle %d weapon improvements.\n" |
| 920 |
"You worship %s.\n" |
| 921 |
"Your equipped item power is %d out of %d\n", |
| 922 |
op->level/5+5, |
| 923 |
cp ? cp : "no god at current time", |
| 924 |
op->contr->item_power, op->level); |
| 925 |
} |
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
int use_skill(object *op, const char *string) { |
| 944 |
object *skop; |
| 945 |
size_t len; |
| 946 |
|
| 947 |
if (!string) |
| 948 |
return 0; |
| 949 |
|
| 950 |
skop = NULL; |
| 951 |
FOR_INV_PREPARE(op, tmp) { |
| 952 |
if (tmp->type == SKILL |
| 953 |
&& QUERY_FLAG(tmp, FLAG_CAN_USE_SKILL) |
| 954 |
&& !strncasecmp(string, tmp->skill, MIN(strlen(string), strlen(tmp->skill)))) { |
| 955 |
skop = tmp; |
| 956 |
break; |
| 957 |
} else if (tmp->type == SKILL_TOOL |
| 958 |
&& !QUERY_FLAG(tmp, FLAG_UNPAID) |
| 959 |
&& !strncasecmp(string, tmp->skill, MIN(strlen(string), strlen(tmp->skill)))) { |
| 960 |
skop = tmp; |
| 961 |
break; |
| 962 |
} |
| 963 |
} FOR_INV_FINISH(); |
| 964 |
if (!skop) { |
| 965 |
draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_MISSING, |
| 966 |
"Unable to find skill %s", |
| 967 |
string); |
| 968 |
return 0; |
| 969 |
} |
| 970 |
|
| 971 |
len = strlen(skop->skill); |
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
if (len >= strlen(string)) { |
| 979 |
string = NULL; |
| 980 |
} else { |
| 981 |
string += len; |
| 982 |
while (*string == 0x20) |
| 983 |
string++; |
| 984 |
if (strlen(string) == 0) |
| 985 |
string = NULL; |
| 986 |
} |
| 987 |
|
| 988 |
#ifdef SKILL_UTIL_DEBUG |
| 989 |
LOG(llevDebug, "use_skill() got skill: %s\n", sknum > -1 ? skills[sknum].name : "none"); |
| 990 |
#endif |
| 991 |
|
| 992 |
|
| 993 |
if (do_skill(op, op, skop, op->facing, string)) |
| 994 |
return 1; |
| 995 |
|
| 996 |
return 0; |
| 997 |
} |
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
static object *find_best_player_hth_skill(object *op) { |
| 1022 |
object *best_skill = NULL; |
| 1023 |
int last_skill; |
| 1024 |
|
| 1025 |
if (op->contr->unarmed_skill) { |
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
best_skill = find_skill_by_name(op, op->contr->unarmed_skill); |
| 1038 |
|
| 1039 |
if (!best_skill) { |
| 1040 |
draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_MISSING, |
| 1041 |
"Unable to find skill %s - using default unarmed skill", |
| 1042 |
op->contr->unarmed_skill); |
| 1043 |
} else { |
| 1044 |
size_t i; |
| 1045 |
|
| 1046 |
for (i = 0; i < sizeof(unarmed_skills); i++) |
| 1047 |
if (best_skill->subtype == unarmed_skills[i]) |
| 1048 |
break; |
| 1049 |
if (i < sizeof(unarmed_skills)) |
| 1050 |
return(best_skill); |
| 1051 |
} |
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
} |
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
if (is_dragon_pl(op)) { |
| 1063 |
object *tmp; |
| 1064 |
|
| 1065 |
tmp = find_skill_by_number(op, SK_CLAWING); |
| 1066 |
if (tmp) |
| 1067 |
|
| 1068 |
return tmp; |
| 1069 |
} |
| 1070 |
|
| 1071 |
last_skill = sizeof(unarmed_skills); |
| 1072 |
FOR_INV_PREPARE(op, tmp) { |
| 1073 |
if (tmp->type == SKILL) { |
| 1074 |
int i; |
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
for (i = 0; i < last_skill; i++) { |
| 1085 |
if (tmp->subtype == unarmed_skills[i] && QUERY_FLAG(tmp, FLAG_CAN_USE_SKILL)) { |
| 1086 |
best_skill = tmp; |
| 1087 |
last_skill = i; |
| 1088 |
if (i == 0) |
| 1089 |
return best_skill; |
| 1090 |
} |
| 1091 |
} |
| 1092 |
} |
| 1093 |
} FOR_INV_FINISH(); |
| 1094 |
return best_skill; |
| 1095 |
} |
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
static void do_skill_attack(object *tmp, object *op, const char *string, object *skill) { |
| 1111 |
int success; |
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
if (op->type == PLAYER) { |
| 1120 |
if (!QUERY_FLAG(op, FLAG_READY_WEAPON)) { |
| 1121 |
size_t i; |
| 1122 |
|
| 1123 |
if (!skill) { |
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
if (op->chosen_skill) { |
| 1128 |
|
| 1129 |
|
| 1130 |
for (i = 0; unarmed_skills[i] != 0; i++) |
| 1131 |
if (op->chosen_skill->subtype == unarmed_skills[i]) { |
| 1132 |
skill = op->chosen_skill; |
| 1133 |
break; |
| 1134 |
} |
| 1135 |
} |
| 1136 |
|
| 1137 |
if (!skill) { |
| 1138 |
skill = find_best_player_hth_skill(op); |
| 1139 |
|
| 1140 |
if (!skill) { |
| 1141 |
draw_ext_info(NDI_BLACK, 0, op, |
| 1142 |
MSG_TYPE_SKILL, MSG_TYPE_SKILL_MISSING, |
| 1143 |
"You have no unarmed combat skills!"); |
| 1144 |
return; |
| 1145 |
} |
| 1146 |
} |
| 1147 |
} |
| 1148 |
if (skill != op->chosen_skill) { |
| 1149 |
|
| 1150 |
if (!change_skill(op, skill, 1)) { |
| 1151 |
draw_ext_info_format(NDI_UNIQUE, 0, tmp, |
| 1152 |
MSG_TYPE_SKILL, MSG_TYPE_SKILL_ERROR, |
| 1153 |
"Couldn't change to skill %s", |
| 1154 |
skill->name); |
| 1155 |
return; |
| 1156 |
} |
| 1157 |
} |
| 1158 |
} else { |
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
if (!op->current_weapon) { |
| 1164 |
object *tmp; |
| 1165 |
|
| 1166 |
LOG(llevError, "Player %s does not have current weapon set but flag_ready_weapon is set\n", op->name); |
| 1167 |
tmp = object_find_by_type_applied(op, WEAPON); |
| 1168 |
if (!tmp) { |
| 1169 |
LOG(llevError, "Could not find applied weapon on %s\n", op->name); |
| 1170 |
op->current_weapon = NULL; |
| 1171 |
return; |
| 1172 |
} else { |
| 1173 |
char weapon[MAX_BUF]; |
| 1174 |
|
| 1175 |
query_name(tmp, weapon, MAX_BUF); |
| 1176 |
op->current_weapon = tmp; |
| 1177 |
} |
| 1178 |
} |
| 1179 |
|
| 1180 |
|
| 1181 |
if (!op->chosen_skill || op->current_weapon->skill != op->chosen_skill->skill) { |
| 1182 |
object *found_skill = find_skill_by_name(op, op->current_weapon->skill); |
| 1183 |
assert(found_skill != NULL); |
| 1184 |
change_skill(op, found_skill, 1); |
| 1185 |
} |
| 1186 |
} |
| 1187 |
} |
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
if (op->type == PLAYER && op->contr->tmp_invis) { |
| 1192 |
op->contr->tmp_invis = 0; |
| 1193 |
op->invisible = 0; |
| 1194 |
op->hide = 0; |
| 1195 |
object_update(op, UP_OBJ_FACE); |
| 1196 |
} |
| 1197 |
|
| 1198 |
success = attack_ob(tmp, op); |
| 1199 |
|
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
if (string != NULL && tmp && !QUERY_FLAG(tmp, FLAG_FREED)) { |
| 1211 |
char op_name[MAX_BUF]; |
| 1212 |
if (success){ |
| 1213 |
if (op->type == PLAYER) { |
| 1214 |
query_name(tmp, op_name, MAX_BUF); |
| 1215 |
draw_ext_info_format(NDI_UNIQUE, 0, op, |
| 1216 |
MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_DID_HIT, |
| 1217 |
"You %s %s!", |
| 1218 |
string, op_name); |
| 1219 |
} else if (tmp->type == PLAYER) { |
| 1220 |
query_name(op, op_name, MAX_BUF); |
| 1221 |
draw_ext_info_format(NDI_UNIQUE, 0, tmp, |
| 1222 |
MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_WAS_HIT, |
| 1223 |
"%s %s you!", |
| 1224 |
op_name, string); |
| 1225 |
} |
| 1226 |
} |
| 1227 |
else{ |
| 1228 |
query_name(tmp, op_name, MAX_BUF); |
| 1229 |
draw_ext_info_format(NDI_UNIQUE, 0, op, |
| 1230 |
MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_MISS, |
| 1231 |
"You miss %s!", |
| 1232 |
op_name); |
| 1233 |
} |
| 1234 |
} |
| 1235 |
} |
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
void skill_attack(object *tmp, object *pl, int dir, const char *string, object *skill) { |
| 1261 |
int16_t tx, ty; |
| 1262 |
mapstruct *m; |
| 1263 |
int mflags; |
| 1264 |
|
| 1265 |
if (!dir) |
| 1266 |
dir = pl->facing; |
| 1267 |
tx = freearr_x[dir]; |
| 1268 |
ty = freearr_y[dir]; |
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
if (tmp == NULL) { |
| 1275 |
m = pl->map; |
| 1276 |
tx = pl->x+freearr_x[dir]; |
| 1277 |
ty = pl->y+freearr_y[dir]; |
| 1278 |
|
| 1279 |
mflags = get_map_flags(m, &m, tx, ty, &tx, &ty); |
| 1280 |
if (mflags&P_OUT_OF_MAP) |
| 1281 |
return; |
| 1282 |
|
| 1283 |
|
| 1284 |
if (!(mflags&P_IS_ALIVE) |
| 1285 |
&& !OB_TYPE_MOVE_BLOCK(pl, GET_MAP_MOVE_BLOCK(m, tx, ty))) { |
| 1286 |
return; |
| 1287 |
} |
| 1288 |
|
| 1289 |
FOR_MAP_PREPARE(m, tx, ty, tmp2) |
| 1290 |
if ((QUERY_FLAG(tmp2, FLAG_ALIVE) && tmp2->stats.hp >= 0) |
| 1291 |
|| QUERY_FLAG(tmp2, FLAG_CAN_ROLL) |
| 1292 |
|| tmp2->type == LOCKED_DOOR) { |
| 1293 |
|
| 1294 |
if ((pl->type == PLAYER && tmp2->type == PLAYER) |
| 1295 |
&& (pl->contr->party != NULL && pl->contr->party == tmp2->contr->party)) |
| 1296 |
return; |
| 1297 |
tmp = tmp2; |
| 1298 |
break; |
| 1299 |
} |
| 1300 |
FOR_MAP_FINISH(); |
| 1301 |
} |
| 1302 |
if (!tmp) { |
| 1303 |
if (pl->type == PLAYER) |
| 1304 |
draw_ext_info(NDI_UNIQUE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, |
| 1305 |
"There is nothing to attack!"); |
| 1306 |
return; |
| 1307 |
} |
| 1308 |
|
| 1309 |
do_skill_attack(tmp, pl, string, skill); |
| 1310 |
} |
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
static void attack_hth(object *pl, int dir, const char *string, object *skill) { |
| 1331 |
object *weapon; |
| 1332 |
|
| 1333 |
if (QUERY_FLAG(pl, FLAG_READY_WEAPON)) { |
| 1334 |
weapon = object_find_by_type_applied(pl, WEAPON); |
| 1335 |
if (weapon != NULL) { |
| 1336 |
if (apply_special(pl, weapon, AP_UNAPPLY|AP_NOPRINT)) { |
| 1337 |
char weaponname[MAX_BUF]; |
| 1338 |
|
| 1339 |
query_name(weapon, weaponname, MAX_BUF); |
| 1340 |
draw_ext_info_format(NDI_UNIQUE, 0, pl, |
| 1341 |
MSG_TYPE_SKILL, MSG_TYPE_SKILL_ERROR, |
| 1342 |
"You are unable to unwield %s in order to attack with %s.", |
| 1343 |
weaponname, skill->name); |
| 1344 |
return; |
| 1345 |
} else { |
| 1346 |
draw_ext_info(NDI_UNIQUE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_ERROR, |
| 1347 |
"You unwield your weapon in order to attack."); |
| 1348 |
} |
| 1349 |
} |
| 1350 |
} |
| 1351 |
skill_attack(NULL, pl, dir, string, skill); |
| 1352 |
} |
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
static void attack_melee_weapon(object *op, int dir, const char *string, object *skill) { |
| 1375 |
if (!QUERY_FLAG(op, FLAG_READY_WEAPON)) { |
| 1376 |
if (op->type == PLAYER) |
| 1377 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SKILL, MSG_TYPE_SKILL_ERROR, |
| 1378 |
"You have no ready weapon to attack with!"); |
| 1379 |
return; |
| 1380 |
} |
| 1381 |
skill_attack(NULL, op, dir, string, skill); |
| 1382 |
} |