Welcome to the Builder Academy

Question Combat Damage Trigger

More
11 Nov 2017 20:31 #7081 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[]
Code:
"CombatDamage",


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

In dg_triggers.c just before void hitprcnt_mtrigger(char_data *ch) add:
Code:
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:
Code:
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:
Code:
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: 0.295 seconds