Okay, please don't use this anyone, because it's my personal work. :-P
I was codin' something of my own for once, a new procedure for fighting. I
figured it out, got rid of the bugs, but haven't done the damage stuff
yet..but anyway. I was able to attack mobs and other players just fine, no
trouble. But then I got a friend to log in and try to attack me... KABOOM! The
MUD went down. I put it back in to test something else. Friend logged back in,
attacked a mob. KABOOM! So it seems I'm the only one who can attack anything
else. I looked and looked, but can't find the problem.
Here's the offending code.
ACMD(do_attack)
{
struct char_data *vict;
int ch_weapon, v_shield, v_armor, offense, defense;
float ch_stance, v_stance;
int off_roll, def_roll;
one_argument(argument, arg);
if (GET_POS(ch)!=POS_STANDING) {
send_to_char("Might be a bit easier if you stood up first...", ch);
return;
} else {
if (!*arg)
send_to_char("Syntax: ATTACK <player or monster>\r\nThe attacking of
anything within town will result in punishment.\r\n", ch);
else if (!(vict = get_char_room_vis(ch, arg)))
send_to_char("They don't seem to be here.\r\n", ch);
else if (vict == ch) {
send_to_char("Kinda like playing checkers against yourself, isn't it?\r\n",
ch);
} else if (AFF_FLAGGED(ch, AFF_CHARM) && (ch->master == vict))
act("You have been charmed by $N, and are therefore unable to do that.",
FALSE, ch, 0, vict, TO_CHAR);
else {
if (IS_NPC(vict)) {
GET_STANCE(vict)=3;
} else if (IS_NPC(ch)) {
GET_STANCE(ch)=3;
} else if (GET_STANCE(ch)==NULL) {
GET_STANCE(ch)=3;
} else if (GET_STANCE(vict)==NULL) {
GET_STANCE(ch)=3;
}
ch_weapon = 100;
v_shield = 100;
v_armor = 100;
if (GET_STANCE(ch) == STANCE_DEF) { ch_stance = 0.5; }
if (GET_STANCE(ch) == STANCE_BACK) { ch_stance = 0.75; }
if (GET_STANCE(ch) == STANCE_NEUT) { ch_stance = 1; }
if (GET_STANCE(ch) == STANCE_FOR) { ch_stance = 1.25; }
if (GET_STANCE(ch) == STANCE_OFF) { ch_stance = 1.5; }
off_roll = number(1, 100);
def_roll = number(1, 100);
offense = ((GET_STR(ch) * 0.3 + GET_DEX(ch) * 0.1
+ GET_STA(ch) * 0.1 + GET_CRD(ch) * 0.2
+ ch_weapon * 0.2 + GET_AGI(ch) * 0.1) * ch_stance) * off_roll;
sprintf(buf, "[OFF: ((%d+%d+%d)+(%d+%d)*2+%d*3)*%f)*ROLL:%d]\r\n",
GET_DEX(ch),
GET_STA(ch), GET_AGI(ch), ch_weapon, GET_CRD(ch), GET_STR(ch), ch_stance,
off_roll);
if (GET_STANCE(vict) == STANCE_DEF) { v_stance = 1.5; }
if (GET_STANCE(vict) == STANCE_BACK) { v_stance = 1.25; }
if (GET_STANCE(vict) == STANCE_NEUT) { v_stance = 1; }
if (GET_STANCE(vict) == STANCE_FOR) { v_stance = 0.75; }
if (GET_STANCE(vict) == STANCE_OFF) { v_stance = 0.5; }
defense = ((GET_STR(vict) * 0.1 + GET_DEX(vict) * 0.2
+ GET_STA(vict) * 0.1 + v_shield * 0.2
+ v_armor * 0.2 + GET_AGI(vict) * 0.1
+ GET_CONST(vict) * 0.1) * v_stance) * def_roll;
sprintf(buf, "%s[DEF: (((%d+%d+%d+%d)+(%d+%d+%d)*2)*%f)*ROLL:%d]\r\n", buf,
GET_STR(vict), GET_STA(vict), GET_AGI(vict), GET_CONST(vict),
GET_DEX(vict),
v_armor, v_shield, v_stance, def_roll);
if (offense/defense < 1) {
sprintf(buf, "%s[OFF/DEF < 1]\r\n\r\n***Not a hit.\r\n", buf);
} else if (offense/defense > 1) {
sprintf(buf, "%s[OFF/DEF > 1]\r\n\r\n***Hit!\r\n", buf);
} else {
sprintf(buf, "%s[OFF/DEF = 1]\r\n\r\n***%s parries with %s.\r\n", buf,
GET_NAME(ch), GET_NAME(vict));
}
send_to_char(buf, ch);
send_to_char(buf, vict);
}
}
}
BTW, he CAN attack himself or no one and it gives the correct messages..just
when he attacks someone else.
Thanks,
-Elrelet
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST