Switch target skill

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 3 weeks ago #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
10 months 3 weeks ago #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:
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.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 3 weeks ago - 10 months 3 weeks ago #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: 10 months 3 weeks ago by JTP.

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

More
10 months 3 weeks ago #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.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 3 weeks ago #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.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 2 weeks ago - 10 months 2 weeks ago #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: 10 months 2 weeks ago by JTP.

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 2 weeks ago #6847 by JTP
Replied by JTP on topic Switch target skill
Hope someone can help see whats wrong.

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

More
10 months 2 weeks ago #6848 by thomas
Replied by thomas on topic Switch target skill
Oh, but there's nothing wrong, per se. The code does exactly what I designed it to do. It is not currently designed to let you add another person to the fight, just switch between the ones who are already fighting you.

However, though it is reasonably easy to change the logic here, we must avoid getting in an illegal state.
Something like this would work, I think:
    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);
+              damage(ch, vict, 1, TYPE_UNDEFINED);
+     if (FIGHTING(vict) == ch) {
         FIGHTING(ch) = vict;
+    }
	  } else {
The damage() call causes the opponent to be set_fighting if it isn't already. Then we switch.
The following user(s) said Thank You: JTP

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 2 weeks ago #6849 by JTP
Replied by JTP on topic Switch target skill
Working now..thanks alot.

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

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
9 months 2 weeks ago #6941 by zusuk
Replied by zusuk on topic Switch target skill
I do not remember if it is absolutely necessary, but I think it may save you some heartache in the future if you add a "stop_fighting" then just hit the new target with zero damage. To switch targets in our MUD it takes an 'action' and will present opponents that are attacking you with an 'attack of opportunity', so you can ignore those parts :) Oh and ignore the event stuff, we use events to run combat.

Because you are running the damage() function, you and the new target will automatically engage (if he/she can, if he/she is already targeting someone else, they will continue to do so), and the previous target will continue to fight you because you are not messing with their target.
    } else {
      /* don't forget to remove the fight event! */
      if (char_has_mud_event(ch, eCOMBAT_ROUND)) {
        event_cancel_specific(ch, eCOMBAT_ROUND);
      }

      USE_STANDARD_ACTION(ch);
      stop_fighting(ch);
      send_to_char(ch, "You switch opponents!\r\n");
      act("$n switches opponents!", FALSE, ch, 0, vict, TO_ROOM);

      hit(ch, vict, TYPE_UNDEFINED, DAM_RESERVED_DBC, 0, FALSE);

      //everyone gets a free shot at you unless you make a acrobatics check
      //15 is DC
      if (FIGHTING(ch) && FIGHTING(vict)) {
        if (!skill_check(ch, ABILITY_ACROBATICS, 15))
          attacks_of_opportunity(ch, 0);
      }

    }

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

Time to create page: 1.621 seconds