Welcome to the Builder Academy

Question Switch target skill

More
26 Aug 2017 17:06 #6835 by JTP
Switch target skill was created by JTP
Hi

Anyone who has a switch target skill they wanna share ? Or wanna help make one ?

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

More
27 Aug 2017 10:52 #6836 by thomas
Replied by thomas on topic Switch target skill
Here's my first attempt at rewriting the logic in do_hit to accomplish what you want:
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 (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM))) send_to_char(ch, "That player is not 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 */ 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) > rand_number(1,95)) { + send_to_char(ch, "You switch your target!\r\n"); + act("$n switches target to $N!", FALSE, ch, 0, vict, TO_ROOM); + FIGHTING(ch) = vict; + } else { + send_to_char(ch, "You failed to switch your target!\r\n"); + act("$n misses a swing at $N!", FALSE, ch, 0, vict, TO_ROOM); + } } else send_to_char(ch, "You're fighting the best you can!\r\n"); } }
This is untested browser code - but it should work.

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

More
27 Aug 2017 18:29 - 27 Aug 2017 18:30 #6839 by JTP
Replied by JTP on topic Switch target skill
Ok code compiles..But i dont seem to be able to switch target. What do i type ?

If i type kill mouse, and wanna attack rat instead, then if i type kill rat while fighting mouse i get:

You're fighting the best you can!
Last edit: 27 Aug 2017 18:30 by JTP.

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

More
27 Aug 2017 18:46 #6840 by thomas
Replied by thomas on topic Switch target skill
The example code will not allow you to attack a "new" target, but only let you switch between the ones you are already fighting.
So, for instance you are fighting mob "A" and kick mob "B", both will be fighting you. You can then switch to hitting the other mob by issuing "kill B".

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

More
27 Aug 2017 19:34 #6841 by JTP
Replied by JTP on topic Switch target skill
I tried fighting A and then tried to kill B

and then got: You're fighting the best you can!

still just hitting A
So kill B dont work.


Switch needs to stop fighting A and then attack B, while A still ofc hits you and B also hits you.

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

More
28 Aug 2017 05:44 - 28 Aug 2017 09:07 #6843 by JTP
Replied by JTP on topic Switch target skill
Any ideas how to get it working ?

Will a stop_fighting(ch); not be needed before attacking the new ?
Last edit: 28 Aug 2017 09:07 by JTP.

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

Time to create page: 1.446 seconds