Welcome to the Builder Academy

Question do_hit problem

More
05 Jun 2018 17:24 #8097 by JTP
do_hit problem was created by JTP
Hmm, if im flying and trying to kill something i get: You're fighting the best you can!

What is wrong ?
Code:
ACMD(do_hit) { char arg[MAX_INPUT_LENGTH]; struct char_data *vict; one_argument(argument, arg); if (!*arg) send_to_char(ch, "Hit who?\r\n"); else if (GET_MOVE(ch) <= 0) send_to_char(ch, "You are to tired to fight right now!\r\n"); else if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AFK)) { send_to_char(ch, "Try removing your AFK flag first.\r\n"); SET_BIT_AR(PLR_FLAGS(ch), PLR_KILLER); } else if (AFF_FLAGGED(ch, AFF_TREE)) send_to_char(ch, "You are not able to fight while in tree form!\r\n"); else if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM))) send_to_char(ch, "They don't seem to be here.\r\n"); else if (vict == ch) { send_to_char(ch, "You hit yourself...OUCH!.\r\n"); act("$n hits $mself, and says OUCH!", FALSE, ch, 0, vict, TO_ROOM); } else if (AFF_FLAGGED(ch, AFF_CHARM) && (ch->master == vict)) act("$N is just such a good friend, you simply can't hit $M.", FALSE, ch, 0, vict, TO_CHAR); else { if (!CONFIG_PK_ALLOWED && !IS_NPC(vict) && !IS_NPC(ch)) check_killer(ch, vict); if ((GET_POS(ch) == POS_STANDING) && (vict != FIGHTING(ch))) { if (GET_DEX(ch) > GET_DEX(vict) || (GET_DEX(ch) == GET_DEX(vict) && rand_number(1, 2) == 1)) /* if faster */ { hit(ch, vict, TYPE_UNDEFINED); /* first */ GET_MOVE(ch) -= 1; } else hit(vict, ch, TYPE_UNDEFINED); /* or the victim is first */ WAIT_STATE(ch, PULSE_VIOLENCE + 2); } else if (GET_POS(ch) == POS_FIGHTING && vict != FIGHTING(ch) && FIGHTING(vict) == ch) { if (GET_SKILL(ch, SKILL_SWITCH_TARGET) > rand_number(1, 110)) { send_to_char(ch, "You swith your target!\r\n"); act("$n switches target to $N!", FALSE, ch, 0, vict, TO_ROOM); FIGHTING(ch) = vict; WAIT_STATE(ch, PULSE_VIOLENCE + 1); } else { send_to_char(ch, "You failed to switch your target!\r\n"); act("$n failed to switch target!", FALSE, ch, 0, vict, TO_ROOM); improve_skill(ch, SKILL_SWITCH_TARGET); } } else send_to_char(ch, "You're fighting the best you can!\r\n"); } }

Please Log in or Create an account to join the conversation.

More
05 Jun 2018 17:45 #8098 by lacrc
Replied by lacrc on topic do_hit problem
The only two POS being checked are POS_STANDING and POS_FIGHTING, since you're POS_FLYING then none of the if()s that start the combat apply and you land on the else "You're fighting the best you can!".

Since the problem is to start the combat then you should change the first if and add POS_FLYING to the check:
Code:
if ((GET_POS(ch) == POS_STANDING || GET_POS(ch) == POS_FLYING) && (vict != FIGHTING(ch))) {
After that you'll be in POS_FIGHTING, so consecutive do_hit()s should work properly, just gotta remember that when combat stops to set the POS back to POS_FLYING instead of POS_STANDING.

Please Log in or Create an account to join the conversation.

More
05 Jun 2018 18:23 #8099 by JTP
Replied by JTP on topic do_hit problem
Ok now i can fight again...but how can i make make combat remember to set back flying if flying is on ?

My fly sets AFF_FLYING that stays on while fighting.

Please Log in or Create an account to join the conversation.

More
05 Jun 2018 18:30 #8100 by JTP
Replied by JTP on topic do_hit problem
Seems if i save after fight i get back to POS_FLYING

So it might just be a small chance ?

Please Log in or Create an account to join the conversation.

More
05 Jun 2018 18:53 #8101 by lacrc
Replied by lacrc on topic do_hit problem
I'm not sure why after do_save it is getting back to POS_FLYING, maybe your do_save or save_char functions have a call to update_pos?
It all depends on how POS_FLYING was implemented.

But IMO the correct place to check this would be in fight.c in the stop_fighting() function, in stock code is:
Code:
/* remove a char from the list of fighting chars */ void stop_fighting(struct char_data *ch) { struct char_data *temp; if (ch == next_combat_list) next_combat_list = ch->next_fighting; REMOVE_FROM_LIST(ch, combat_list, next_fighting); ch->next_fighting = NULL; FIGHTING(ch) = NULL; GET_POS(ch) = POS_STANDING; update_pos(ch); }
You would need to add a check before resetting the position to POS_STANDING, it could be a ternary cause I think they are really cool :)
Code:
/* remove a char from the list of fighting chars */ void stop_fighting(struct char_data *ch) { struct char_data *temp; if (ch == next_combat_list) next_combat_list = ch->next_fighting; REMOVE_FROM_LIST(ch, combat_list, next_fighting); ch->next_fighting = NULL; FIGHTING(ch) = NULL; GET_POS(ch) = AFF_FLAGGED(ch, AFF_FLYING) ? POS_FLYING : POS_STANDING; update_pos(ch); }

Please Log in or Create an account to join the conversation.

More
05 Jun 2018 19:08 #8102 by JTP
Replied by JTP on topic do_hit problem
Seems to work like a charm. Thanks

Please Log in or Create an account to join the conversation.

Time to create page: 0.236 seconds