mirror of
https://github.com/tbamud/tbamud.git
synced 2026-02-28 06:21:45 +01:00
Added a new trigger type for mobs, called "Damage", that triggers every (#151)
time the mob is harmed, through any means. Valid return values: -1: prevents damage from occurring. Will also prevent a fight from starting. 0: forces a miss. >0 : the damage the mob will endure. Available variables: %actor%: the one doing the damage %victim%: typically the same as %self% - the one being attacked %damage%: the damage inflicted. Always a non-negative number. %attacktype%: The attack type. Will be UNDEFINED when hitting with a weapon.
This commit is contained in:
@@ -554,6 +554,33 @@ int cast_mtrigger(char_data *actor, char_data *ch, int spellnum)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int damage_mtrigger(char_data *actor, char_data *victim, int dam, int attacktype)
|
||||
{
|
||||
trig_data *t;
|
||||
char buf[MAX_INPUT_LENGTH];
|
||||
|
||||
if (victim == NULL)
|
||||
return dam;
|
||||
|
||||
if (!SCRIPT_CHECK(victim, MTRIG_DAMAGE) || AFF_FLAGGED(victim, AFF_CHARM))
|
||||
return dam;
|
||||
|
||||
for (t = TRIGGERS(SCRIPT(victim)); t; t = t->next) {
|
||||
if (TRIGGER_CHECK(t, MTRIG_DAMAGE) &&
|
||||
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
||||
ADD_UID_VAR(buf, t, char_script_id(actor), "actor", 0);
|
||||
ADD_UID_VAR(buf, t, char_script_id(victim), "victim", 0);
|
||||
sprintf(buf, "%d", dam);
|
||||
add_var(&GET_TRIG_VARS(t), "damage", buf, 0);
|
||||
add_var(&GET_TRIG_VARS(t), "attacktype", skill_name(attacktype), 0);
|
||||
return script_driver(&victim, t, MOB_TRIGGER, TRIG_NEW);
|
||||
}
|
||||
}
|
||||
|
||||
return dam;
|
||||
}
|
||||
|
||||
|
||||
int leave_mtrigger(char_data *actor, int dir)
|
||||
{
|
||||
trig_data *t;
|
||||
|
||||
Reference in New Issue
Block a user