… | |
… | |
65 | * This table translates the attack numbers as used within the |
65 | * This table translates the attack numbers as used within the |
66 | * program to the value we use when sending STATS command to the |
66 | * program to the value we use when sending STATS command to the |
67 | * client. If a value is -1, then we don't send that to the |
67 | * client. If a value is -1, then we don't send that to the |
68 | * client. |
68 | * client. |
69 | */ |
69 | */ |
70 | static short atnr_cs_stat[NROFATTACKS] = { CS_STAT_RES_PHYS, |
70 | static short atnr_cs_stat[NROFATTACKS] = |
71 | CS_STAT_RES_MAG, CS_STAT_RES_FIRE, CS_STAT_RES_ELEC, |
71 | { |
72 | CS_STAT_RES_COLD, CS_STAT_RES_CONF, CS_STAT_RES_ACID, |
72 | CS_STAT_RES_PHYS, |
73 | CS_STAT_RES_DRAIN, -1 /* weaponmagic */ , |
73 | CS_STAT_RES_MAG, |
74 | CS_STAT_RES_GHOSTHIT, CS_STAT_RES_POISON, |
74 | CS_STAT_RES_FIRE, |
75 | CS_STAT_RES_SLOW, CS_STAT_RES_PARA, CS_STAT_TURN_UNDEAD, |
75 | CS_STAT_RES_ELEC, |
76 | CS_STAT_RES_FEAR, -1 /* Cancellation */ , |
76 | CS_STAT_RES_COLD, |
77 | CS_STAT_RES_DEPLETE, CS_STAT_RES_DEATH, |
77 | CS_STAT_RES_CONF, |
78 | -1 /* Chaos */ , -1 /* Counterspell */ , |
78 | CS_STAT_RES_ACID, |
79 | -1 /* Godpower */ , CS_STAT_RES_HOLYWORD, |
79 | CS_STAT_RES_DRAIN, |
|
|
80 | -1 /* weaponmagic */, |
|
|
81 | CS_STAT_RES_GHOSTHIT, |
|
|
82 | CS_STAT_RES_POISON, |
|
|
83 | CS_STAT_RES_SLOW, |
|
|
84 | CS_STAT_RES_PARA, |
|
|
85 | CS_STAT_TURN_UNDEAD, |
|
|
86 | CS_STAT_RES_FEAR, |
|
|
87 | -1 /* Cancellation */, |
|
|
88 | CS_STAT_RES_DEPLETE, |
|
|
89 | CS_STAT_RES_DEATH, |
|
|
90 | -1 /* Chaos */, |
|
|
91 | -1 /* Counterspell */, |
|
|
92 | -1 /* Godpower */, |
|
|
93 | CS_STAT_RES_HOLYWORD, |
80 | CS_STAT_RES_BLIND, |
94 | CS_STAT_RES_BLIND, |
81 | -1, /* Internal */ |
95 | -1, /* Internal */ |
82 | -1, /* life stealing */ |
96 | -1, /* life stealing */ |
83 | -1 /* Disease - not fully done yet */ |
97 | -1 /* Disease - not fully done yet */ |
84 | }; |
98 | }; |
… | |
… | |
228 | send_skill_info (client *ns, char *params) |
242 | send_skill_info (client *ns, char *params) |
229 | { |
243 | { |
230 | packet sl; |
244 | packet sl; |
231 | sl << "replyinfo skill_info\n"; |
245 | sl << "replyinfo skill_info\n"; |
232 | |
246 | |
233 | for (int i = 1; i < NUM_SKILLS; i++) |
247 | for (int i = 0; i < skillvec.size (); ++i) |
234 | sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names [i]); |
248 | sl.printf ("%d:%s\n", CS_STAT_SKILLINFO + i, &skillvec [i]->name); |
235 | |
249 | |
236 | if (sl.length () > MAXSOCKBUF) |
250 | if (sl.length () > MAXSOCKBUF) |
237 | { |
251 | { |
238 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
252 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
239 | fatal (0); |
253 | fatal (0); |
… | |
… | |
445 | { |
459 | { |
446 | INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len)); |
460 | INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len)); |
447 | } |
461 | } |
448 | |
462 | |
449 | //+GPL |
463 | //+GPL |
450 | |
|
|
451 | /* |
|
|
452 | #define MSG_TYPE_BOOK 1 |
|
|
453 | #define MSG_TYPE_CARD 2 |
|
|
454 | #define MSG_TYPE_PAPER 3 |
|
|
455 | #define MSG_TYPE_SIGN 4 |
|
|
456 | #define MSG_TYPE_MONUMENT 5 |
|
|
457 | #define MSG_TYPE_SCRIPTED_DIALOG 6*/ |
|
|
458 | |
|
|
459 | /** Reply to ExtendedInfos command */ |
|
|
460 | void |
|
|
461 | ToggleExtendedText (char *buf, int len, client * ns) |
|
|
462 | { |
|
|
463 | char cmdback[MAX_BUF]; |
|
|
464 | char temp[10]; |
|
|
465 | char command[50]; |
|
|
466 | int info, nextinfo, i, flag; |
|
|
467 | |
|
|
468 | cmdback[0] = '\0'; |
|
|
469 | |
|
|
470 | nextinfo = 0; |
|
|
471 | while (1) |
|
|
472 | { |
|
|
473 | /* 1. Extract an info */ |
|
|
474 | info = nextinfo; |
|
|
475 | |
|
|
476 | while ((info < len) && (buf [info] == ' ')) |
|
|
477 | info++; |
|
|
478 | |
|
|
479 | if (info >= len) |
|
|
480 | break; |
|
|
481 | |
|
|
482 | nextinfo = info + 1; |
|
|
483 | |
|
|
484 | while ((nextinfo < len) && (buf [nextinfo] != ' ')) |
|
|
485 | nextinfo++; |
|
|
486 | |
|
|
487 | if (nextinfo - info >= 49) /*Erroneous info asked */ |
|
|
488 | continue; |
|
|
489 | |
|
|
490 | memcpy (command, buf + info, nextinfo - info); |
|
|
491 | command [nextinfo - info] = 0; |
|
|
492 | |
|
|
493 | /* 2. Interpret info */ |
|
|
494 | i = sscanf (command, "%d", &flag); |
|
|
495 | |
|
|
496 | if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) |
|
|
497 | ns->supported_readables |= (1 << flag); |
|
|
498 | /*3. Next info */ |
|
|
499 | } |
|
|
500 | |
|
|
501 | /* Send resulting state */ |
|
|
502 | strcpy (cmdback, "ExtendedTextSet"); |
|
|
503 | |
|
|
504 | for (i = 0; i <= MSG_TYPE_LAST; i++) |
|
|
505 | if (ns->supported_readables & (1 << i)) |
|
|
506 | { |
|
|
507 | strcat (cmdback, " "); |
|
|
508 | snprintf (temp, sizeof (temp), "%d", i); |
|
|
509 | strcat (cmdback, temp); |
|
|
510 | } |
|
|
511 | |
|
|
512 | ns->send_packet (cmdback); |
|
|
513 | } |
|
|
514 | |
464 | |
515 | /** |
465 | /** |
516 | * This handles the general commands from the client (ie, north, fire, cast, |
466 | * This handles the general commands from the client (ie, north, fire, cast, |
517 | * etc.) |
467 | * etc.) |
518 | */ |
468 | */ |
… | |
… | |
790 | AddIfShort (ns->last_stats.Int, ob->stats.Int, CS_STAT_INT); |
740 | AddIfShort (ns->last_stats.Int, ob->stats.Int, CS_STAT_INT); |
791 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
741 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
792 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
742 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
793 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
743 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
794 | |
744 | |
795 | for (int s = 0; s < NUM_SKILLS; s++) |
745 | for (int s = 0; s < CS_NUM_SKILLS; s++) |
796 | if (object *skill = opl->last_skill_ob [s]) |
746 | if (object *skill = opl->last_skill_ob [s]) |
797 | if (skill->stats.exp != ns->last_skill_exp [s]) |
747 | if (skill->stats.exp != ns->last_skill_exp [s]) |
798 | { |
748 | { |
799 | ns->last_skill_exp [s] = skill->stats.exp; |
749 | ns->last_skill_exp [s] = skill->stats.exp; |
800 | |
750 | |
801 | /* Always send along the level if exp changes. This is only |
751 | /* Always send along the level if exp changes. This is only |
802 | * 1 extra byte, but keeps processing simpler. |
752 | * 1 extra byte, but keeps processing simpler. |
803 | */ |
753 | */ |
804 | sl << uint8 (s + CS_STAT_SKILLINFO) |
754 | sl << uint8 (CS_STAT_SKILLINFO + s) |
805 | << uint8 (skill->level) |
755 | << uint8 (skill->level) |
806 | << uint64 (skill->stats.exp); |
756 | << uint64 (skill->stats.exp); |
807 | } |
757 | } |
808 | |
758 | |
809 | AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); |
759 | AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); |
… | |
… | |
814 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK); |
764 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK); |
815 | AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); |
765 | AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); |
816 | AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f / TICK); |
766 | AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f / TICK); |
817 | AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); |
767 | AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); |
818 | |
768 | |
819 | flags = 0; |
769 | flags = (opl->fire_on ? SF_FIREON : 0) |
820 | |
770 | | (opl->run_on ? SF_RUNON : 0); |
821 | if (opl->fire_on) |
|
|
822 | flags |= SF_FIREON; |
|
|
823 | |
|
|
824 | if (opl->run_on) |
|
|
825 | flags |= SF_RUNON; |
|
|
826 | |
771 | |
827 | AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); |
772 | AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); |
828 | |
773 | |
829 | for (int i = 0; i < NROFATTACKS; i++) |
774 | for (int i = 0; i < NROFATTACKS; i++) |
830 | { |
|
|
831 | /* Skip ones we won't send */ |
775 | /* Skip ones we won't send */ |
832 | if (atnr_cs_stat[i] == -1) |
776 | if (atnr_cs_stat[i] >= 0) |
833 | continue; |
|
|
834 | |
|
|
835 | AddIfShort (ns->last_resist[i], ob->resist[i], atnr_cs_stat[i]); |
777 | AddIfShort (ns->last_resist[i], ob->resist[i], atnr_cs_stat[i]); |
836 | } |
|
|
837 | |
778 | |
838 | if (pl->ns->monitor_spells) |
779 | if (pl->ns->monitor_spells) |
839 | { |
780 | { |
840 | AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); |
781 | AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); |
841 | AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); |
782 | AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); |
… | |
… | |
1126 | { |
1067 | { |
1127 | if (op->stats.maxhp > op->stats.hp |
1068 | if (op->stats.maxhp > op->stats.hp |
1128 | && op->stats.maxhp > 0 |
1069 | && op->stats.maxhp > 0 |
1129 | && (op->type == PLAYER |
1070 | && (op->type == PLAYER |
1130 | || op->type == DOOR // does not work, have maxhp 0 |
1071 | || op->type == DOOR // does not work, have maxhp 0 |
1131 | || QUERY_FLAG (op, FLAG_MONSTER) |
1072 | || op->flag [FLAG_MONSTER] |
1132 | || QUERY_FLAG (op, FLAG_ALIVE) |
1073 | || op->flag [FLAG_ALIVE] |
1133 | || QUERY_FLAG (op, FLAG_GENERATOR))) |
1074 | || op->flag [FLAG_GENERATOR])) |
1134 | { |
1075 | { |
1135 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
1076 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
1136 | stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge |
1077 | stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge |
1137 | } |
1078 | } |
1138 | |
1079 | |
… | |
… | |
1333 | spell->cached_eat = casting_level (pl->ob, spell); |
1274 | spell->cached_eat = casting_level (pl->ob, spell); |
1334 | |
1275 | |
1335 | /* figure out which skill it uses, if it uses one */ |
1276 | /* figure out which skill it uses, if it uses one */ |
1336 | if (spell->skill) |
1277 | if (spell->skill) |
1337 | if (object *tmp = pl->find_skill (spell->skill)) |
1278 | if (object *tmp = pl->find_skill (spell->skill)) |
1338 | skill = tmp->subtype + CS_STAT_SKILLINFO; |
1279 | skill = CS_STAT_SKILLINFO + SKILL_INDEX (tmp); |
1339 | |
1280 | |
1340 | // spells better have a face |
1281 | // spells better have a face |
1341 | if (!spell->face) |
1282 | if (!spell->face) |
1342 | { |
1283 | { |
1343 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |
1284 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |