Combat Damage Trigger

  • WhiskyTest
  • WhiskyTest's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
10 months 1 week ago #7081 by WhiskyTest
Combat Damage Trigger was created by WhiskyTest
This snippet adds another trigger type, "combatdamage". Intended to trigger on a successful hit during combat. You can use it to simulate special combat effects like fire/ice/poison damage. You could stun or blind characters.. teleport them (hit so hard they fly through to the next room).. Heal someone, taunt characters, disarm them, oh so many fun things!

Here it is, very simple:

In constants.c add this to the end of const char *trig_typesp[]
"CombatDamage",


In dg_scripts.h below the last MTRIG definition add:
#define MTRIG_COMBATDAMAGE     (1 << 18)    /* triggers on combat damage */
then below void hitprcnt_mtrigger(char_data *ch); add
void combatdamage_mtrigger(char_data *ch);

In dg_triggers.c just before void hitprcnt_mtrigger(char_data *ch) add:
void combatdamage_mtrigger(char_data *ch)
{
  struct char_data *actor;
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (!SCRIPT_CHECK(ch, MTRIG_COMBATDAMAGE) || !FIGHTING(ch))
    return;

  for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
    if (TRIGGER_CHECK(t, MTRIG_COMBATDAMAGE) &&
        (rand_number(1, 100) <= GET_TRIG_NARG(t))){
      actor = FIGHTING(ch);
      if (actor)
        ADD_UID_VAR(buf, t, actor, "actor", 0);
      else
        add_var(&GET_TRIG_VARS(t), "actor", "nobody", 0);

      script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
      break;
    }
  }
}

In fight.c , just above where hitprcnt_mtrigger(tch); is called, add:
combatdamage_mtrigger(ch);

To use, write up your script as normal and set the trigger type to be CombatDamage. The num_arg is the percentage it will trigger per hit.
Example script:
Name: 'Spider Venom - 1d3',  VNum: [ 1000], RNum: [    0]
Trigger Intended Assignment: Mobiles
Trigger Type: CombatDamage , Numeric Arg: 100, Arg list: None
Commands:
%echoaround% %actor% %actor.name% winces as spider venom burns into %actor.hisher% body!
%send% %actor% You wince as spider venom burns through your veins!
%damage% %actor% %random.3%

This script will trigger whenever the mob successfully hits another character - in this case it adds an additional 1d3 damage to simulate a venom effect.

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

Time to create page: 1.359 seconds