Welcome to the Builder Academy

Question Affect duration from skills

More
10 Jan 2022 20:35 #9972 by h3dg3hug
I have a "gouge" skill that occassionally blinds the opponent if they aren't wearing headgear. I don't want the blind to be permanent, just for a few combat rounds. I took either do_kick or do_bash (i don't remember which) and modified it for the new do_gouge.
Relevant code from act.offensive.c:

ACMD(do_gouge)
{
  char arg[MAX_INPUT_LENGTH];
  struct char_data *vict;
  struct affected_type af;
  int percent, prob;
  if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_GOUGE)) {
    send_to_char(ch, "You have no idea how.\r\n");
    return;
  }
  one_argument(argument, arg);
  if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM))) {
    if (FIGHTING(ch) && IN_ROOM(ch) == IN_ROOM(FIGHTING(ch))) {
      vict = FIGHTING(ch);
    } else {
      send_to_char(ch, "Gouge who?\r\n");
      return;
    }
  }
  if (vict == ch) {
    send_to_char(ch, "That is not a great idea...\r\n");
    return;
  }
  /* 101% is a complete failure */
  percent = ((10 - (compute_armor_class(vict) / 10)) * 2) + rand_number(1, 101);
  prob = GET_SKILL(ch, SKILL_GOUGE);
  if (AFF_FLAGGED(ch, AFF_HIDE)) {
    prob = (prob + ((GET_SKILL(ch, SKILL_GOUGE)) / 4));
  }
  if (percent > prob) {
    damage(ch, vict, 0, SKILL_GOUGE);
  } else if (prob >= percent) {
    damage(ch, vict, GET_LEVEL(ch) / 2, SKILL_GOUGE);
    if (!AFF_FLAGGED(vict, AFF_BLIND))
    {
      if (MOB_FLAGGED(vict, MOB_NOBLIND) || GET_LEVEL(vict) >= LVL_IMMORT) {
        send_to_char(ch, "Your opponent cannot be blinded.\r\n");
      } else if (GET_EQ(vict, 6) != NULL) {
        send_to_char(ch, "Your victim's headwear prevents you from blinding them.\r\n");
      } else {
        new_affect(&af);
        af.spell = SKILL_GOUGE;      
        af.location = APPLY_HITROLL;
        af.modifier = -3;
        af.duration = PULSE_VIOLENCE * 4;
        SET_BIT_AR(af.bitvector, AFF_BLIND);
        affect_to_char(vict, &af);
        new_affect(&af);
        af.spell = SKILL_GOUGE;
        af.location = APPLY_AC;
        af.modifier = 20;
        af.duration = PULSE_VIOLENCE * 4;
        SET_BIT_AR(af.bitvector, AFF_BLIND);
        affect_to_char(vict, &af);
        GET_WAIT_STATE(vict) = PULSE_VIOLENCE * 3;
        act("\tgYou temporarily \tWblind\tg $N\tn.", FALSE, ch, 0, vict, TO_CHAR);
        act("\tg$N is temporarily \tWblinded\tn.", TRUE, ch, 0, vict, TO_NOTVICT);
        //act("\tgYou viciously gouge $N's face, blinding him!\tn.", FALSE, ch, 0, vict, TO_CHAR);
      }
    }
  }
  GET_WAIT_STATE(ch) = PULSE_VIOLENCE * 2;
}

As it sits now, the blind lasts 80-something hours. I can't figure out where that's coming from, but my guess it that it has to do with PULSE_VIOLENCE?
Forgive me, C isn't my native language. I'm really hacking things together through a combination of snippets, docs, and inference from reading the code, with help from VS Code's "Peek Definition" context option.
Any thoughts on how to set a proper affect duration are greatly appreciated =)

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

More
11 Jan 2022 21:19 #9973 by thomas
Replied by thomas on topic Affect duration from skills
PULSE_VIOLENCE is used exclusively for wait_states.
Durations are in "in-game hours", so it figures the results are a little off.

What you are trying to achieve will require events instead. Have a look at the whirlwind function for an idea about how. Also, there's something in the docs, iirc.

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

Time to create page: 0.175 seconds