int cast_wtrigger(char_data *actor, char_data *vict, obj_data *obj, int spellnum) { room_data *room; trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_CAST)) return 1; room = &world[IN_ROOM(actor)]; for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) { if (TRIGGER_CHECK(t, WTRIG_CAST) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { ADD_UID_VAR(buf, t, actor, "actor", 0); if (vict) ADD_UID_VAR(buf, t, vict, "victim", 0); if (obj) ADD_UID_VAR(buf, t, obj, "object", 0); sprintf(buf, "%d", spellnum); add_var(&GET_TRIG_VARS(t), "spell", buf, 0); add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0); return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW); } } return 1; }
int consume_otrigger(obj_data *obj, char_data *actor, int cmd) { trig_data *t; char buf[MAX_INPUT_LENGTH]; int ret_val; if (!SCRIPT_CHECK(obj, OTRIG_CONSUME)) return 1; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (TRIGGER_CHECK(t, OTRIG_CONSUME)) { ADD_UID_VAR(buf, t, actor, "actor", 0); switch (cmd) { case OCMD_EAT: add_var(&GET_TRIG_VARS(t), "command", "eat", 0); break; case OCMD_DRINK: add_var(&GET_TRIG_VARS(t), "command", "drink", 0); break; case OCMD_QUAFF: add_var(&GET_TRIG_VARS(t), "command", "quaff", 0); break; } ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW); /* Don't allow a wear to take place, if the object is purged. */ if (!obj) return 0; else return ret_val; } } return 1; }
void speech_wtrigger(char_data *actor, char *str) { struct room_data *room; trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_SPEECH)) return; room = &world[IN_ROOM(actor)]; for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) { if (!TRIGGER_CHECK(t, WTRIG_SPEECH)) continue; if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) { sprintf(buf,"SYSERR: W-Speech Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); mudlog(buf, NRM, LVL_BUILDER, TRUE); continue; } if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) || (!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) { ADD_UID_VAR(buf, t, actor, "actor", 0); add_var(&GET_TRIG_VARS(t), "speech", str, 0); script_driver(room, t, WLD_TRIGGER, TRIG_NEW); break; } } }
int leave_otrigger(room_data *room, char_data *actor, int dir) { trig_data *t; char buf[MAX_INPUT_LENGTH]; int temp, final = 1; obj_data *obj, *obj_next; if (!valid_dg_target(actor, DG_ALLOW_GODS)) return 1; for (obj = room->contents; obj; obj = obj_next) { obj_next = obj->next_content; if (!SCRIPT_CHECK(obj, OTRIG_LEAVE)) continue; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (TRIGGER_CHECK(t, OTRIG_LEAVE) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { if (dir >= 0 && dir < DIR_COUNT) add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0); else add_var(&GET_TRIG_VARS(t), "direction", "none", 0); ADD_UID_VAR(buf, t, actor, "actor", 0); temp = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW); if (temp == 0) final = 0; } } } return final; }
int drop_wtrigger(obj_data *obj, char_data *actor) { struct room_data *room; trig_data *t; char buf[MAX_INPUT_LENGTH]; int ret_val; if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_DROP)) return 1; room = &world[IN_ROOM(actor)]; for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) if (TRIGGER_CHECK(t, WTRIG_DROP) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { ADD_UID_VAR(buf, t, actor, "actor", 0); ADD_UID_VAR(buf, t, obj, "object", 0); ret_val = script_driver(&room, t, WLD_TRIGGER, TRIG_NEW); if (obj->carried_by != actor) return 0; else return ret_val; break; } return 1; }
/* checks for command trigger on specific object. assumes obj has cmd trig */ int cmd_otrig(obj_data *obj, char_data *actor, char *cmd, char *argument, int type) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (obj && SCRIPT_CHECK(obj, OTRIG_COMMAND)) for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (!TRIGGER_CHECK(t, OTRIG_COMMAND)) continue; if (IS_SET(GET_TRIG_NARG(t), type) && (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t))) { mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: O-Command Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); continue; } if (IS_SET(GET_TRIG_NARG(t), type) && (*GET_TRIG_ARG(t) == '*' || !strn_cmp(GET_TRIG_ARG(t), cmd, strlen(GET_TRIG_ARG(t))))) { ADD_UID_VAR(buf, t, actor, "actor", 0); skip_spaces(&argument); add_var(&GET_TRIG_VARS(t), "arg", argument, 0); skip_spaces(&cmd); add_var(&GET_TRIG_VARS(t), "cmd", cmd, 0); if (script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW)) return 1; } } return 0; }
int remove_otrigger(obj_data *obj, char_data *actor) { trig_data *t; char buf[MAX_INPUT_LENGTH]; int ret_val; if (!SCRIPT_CHECK(obj, OTRIG_REMOVE)) return 1; if (!valid_dg_target(actor, 0)) return 1; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (TRIGGER_CHECK(t, OTRIG_REMOVE)) { ADD_UID_VAR(buf, t, actor, "actor", 0); ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW); /* Don't allow a remove to take place, if the object is purged. */ if (!obj) return 0; else return ret_val; } } return 1; }
void speech_mtrigger(char_data *actor, char *str) { char_data *ch, *ch_next; trig_data *t; char buf[MAX_INPUT_LENGTH]; for (ch = world[IN_ROOM(actor)].people; ch; ch = ch_next) { ch_next = ch->next_in_room; if (SCRIPT_CHECK(ch, MTRIG_SPEECH) && AWAKE(ch) && !AFF_FLAGGED(ch, AFF_CHARM) && (actor!=ch)) for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (!TRIGGER_CHECK(t, MTRIG_SPEECH)) continue; if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) { sprintf(buf,"SYSERR: Speech Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); mudlog(buf, NRM, LVL_BUILDER, TRUE); continue; } if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) || (!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) { ADD_UID_VAR(buf, t, actor, "actor", 0); add_var(&GET_TRIG_VARS(t), "speech", str, 0); script_driver(ch, t, MOB_TRIGGER, TRIG_NEW); break; } } } }
int command_wtrigger(char_data *actor, char *cmd, char *argument) { struct room_data *room; trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_COMMAND)) return 0; room = &world[IN_ROOM(actor)]; for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) { if (!TRIGGER_CHECK(t, WTRIG_COMMAND)) continue; if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) { sprintf(buf,"SYSERR: W-Command Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); mudlog(buf, NRM, LVL_BUILDER, TRUE); continue; } if (*GET_TRIG_ARG(t)=='*' || !strn_cmp(GET_TRIG_ARG(t), cmd, strlen(GET_TRIG_ARG(t)))) { ADD_UID_VAR(buf, t, actor, "actor", 0); skip_spaces(&argument); add_var(&GET_TRIG_VARS(t), "arg", argument, 0); skip_spaces(&cmd); add_var(&GET_TRIG_VARS(t), "cmd", cmd, 0); return script_driver(room, t, WLD_TRIGGER, TRIG_NEW); } } return 0; }
void random_wtrigger(struct room_data *room) { trig_data *t; if (!SCRIPT_CHECK(room, WTRIG_RANDOM)) return; for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) { if (TRIGGER_CHECK(t, WTRIG_RANDOM) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { script_driver(&room, t, WLD_TRIGGER, TRIG_NEW); break; } } }
/* Object triggers. */ void random_otrigger(obj_data *obj) { trig_data *t; if (!SCRIPT_CHECK(obj, OTRIG_RANDOM)) return; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (TRIGGER_CHECK(t, OTRIG_RANDOM) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW); break; } } }
void timer_otrigger(struct obj_data *obj) { trig_data *t; if (!SCRIPT_CHECK(obj, OTRIG_TIMER)) return; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (TRIGGER_CHECK(t, OTRIG_TIMER)) script_driver(obj, t, OBJ_TRIGGER, TRIG_NEW); } return; }
void load_mtrigger(char_data *ch) { trig_data *t; if (!SCRIPT_CHECK(ch, MTRIG_LOAD)) return; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_LOAD) && (number(1, 100) <= GET_TRIG_NARG(t))) { script_driver(ch, t, MOB_TRIGGER, TRIG_NEW); break; } } }
int entry_mtrigger(char_data *ch) { trig_data *t; if (!SCRIPT_CHECK(ch, MTRIG_ENTRY) || AFF_FLAGGED(ch, AFF_CHARM)) return 1; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_ENTRY) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); break; } } return 1; }
void random_mtrigger(char_data *ch) { trig_data *t; if (!SCRIPT_CHECK(ch, MTRIG_RANDOM) || AFF_FLAGGED(ch, AFF_CHARM)) return; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_RANDOM) && (number(1, 100) <= GET_TRIG_NARG(t))) { script_driver(ch, t, MOB_TRIGGER, TRIG_NEW); break; } } }
/*Mob triggers. */ void random_mtrigger(char_data *ch) { trig_data *t; /* This trigger is only called if a char is in the zone without nohassle. */ if (!SCRIPT_CHECK(ch, MTRIG_RANDOM) || AFF_FLAGGED(ch, AFF_CHARM)) return; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_RANDOM) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); break; } } }
void bribe_mtrigger(char_data *ch, char_data *actor, int amount) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_CHECK(ch, MTRIG_BRIBE) || AFF_FLAGGED(ch, AFF_CHARM)) return; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_BRIBE) && (amount >= GET_TRIG_NARG(t))) { snprintf(buf, sizeof (buf), "%d", amount); add_var(&GET_TRIG_VARS(t), "amount", buf, 0); ADD_UID_VAR(buf, t, actor, "actor", 0); script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); break; } } }
int login_wtrigger(struct room_data *room, char_data *actor) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_CHECK(room, WTRIG_LOGIN)) return 1; for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) { if (TRIGGER_CHECK(t, WTRIG_LOGIN) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { ADD_UID_VAR(buf, t, actor, "actor", 0); return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW); } } return 1; }
void time_otrigger(obj_data *obj) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_CHECK(obj, OTRIG_TIME)) return; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (TRIGGER_CHECK(t, OTRIG_TIME) && (time_info.hours == GET_TRIG_NARG(t))) { sprintf(buf, "%d", time_info.hours); add_var(&GET_TRIG_VARS(t), "time", buf, 0); script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW); break; } } }
int drop_otrigger(obj_data *obj, char_data *actor) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_CHECK(obj, OTRIG_DROP)) return 1; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (TRIGGER_CHECK(t, OTRIG_DROP) && (number(1, 100) <= GET_TRIG_NARG(t))) { ADD_UID_VAR(buf, t, actor, "actor", 0); return script_driver(obj, t, OBJ_TRIGGER, TRIG_NEW); } } return 1; }
void time_wtrigger(struct room_data *room) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_CHECK(room, WTRIG_TIME)) return; for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) { if (TRIGGER_CHECK(t, WTRIG_TIME) && (time_info.hours == GET_TRIG_NARG(t))) { sprintf(buf, "%d", time_info.hours); add_var(&GET_TRIG_VARS(t), "time", buf, 0); script_driver(&room, t, WLD_TRIGGER, TRIG_NEW); break; } } }
int remove_otrigger(obj_data *obj, char_data *actor) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_CHECK(obj, OTRIG_REMOVE)) return 1; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (TRIGGER_CHECK(t, OTRIG_REMOVE)) { ADD_UID_VAR(buf, t, actor, "actor", 0); return script_driver(obj, t, OBJ_TRIGGER, TRIG_NEW); } } return 1; }
int death_mtrigger(char_data *ch, char_data *actor) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_CHECK(ch, MTRIG_DEATH) || AFF_FLAGGED(ch, AFF_CHARM)) return 1; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_DEATH) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { if (actor) ADD_UID_VAR(buf, t, actor, "actor", 0); return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); } } return 1; }
void time_mtrigger(char_data *ch) { trig_data *t; char buf[MAX_INPUT_LENGTH]; /* This trigger is called if the hour is the same as specified in Narg. */ if (!SCRIPT_CHECK(ch, MTRIG_TIME) || AFF_FLAGGED(ch, AFF_CHARM)) return; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_TIME) && (time_info.hours == GET_TRIG_NARG(t))) { sprintf(buf, "%d", time_info.hours); add_var(&GET_TRIG_VARS(t), "time", buf, 0); script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); break; } } }
void hitprcnt_mtrigger(char_data *ch) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_CHECK(ch, MTRIG_HITPRCNT) || !FIGHTING(ch) || AFF_FLAGGED(ch, AFF_CHARM)) return; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_HITPRCNT) && GET_MAX_HIT(ch) && (((GET_HIT(ch) * 100) / GET_MAX_HIT(ch)) <= GET_TRIG_NARG(t))) { ADD_UID_VAR(buf, t, FIGHTING(ch), "actor", 0) script_driver(ch, t, MOB_TRIGGER, TRIG_NEW); break; } } }
void entry_memory_mtrigger(char_data *ch) { trig_data *t; char_data *actor; struct script_memory *mem; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_MEM(ch) || AFF_FLAGGED(ch, AFF_CHARM)) return; for (actor = world[IN_ROOM(ch)].people; actor && SCRIPT_MEM(ch); actor = actor->next_in_room) { if (actor!=ch && SCRIPT_MEM(ch)) { for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); mem = mem->next) { if (GET_ID(actor)==mem->id) { struct script_memory *prev; if (mem->cmd) command_interpreter(ch, mem->cmd); else { for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_MEMORY) && (number(1, 100) <= GET_TRIG_NARG(t))){ ADD_UID_VAR(buf, t, actor, "actor", 0); script_driver(ch, t, MOB_TRIGGER, TRIG_NEW); break; } } } /* delete the memory */ if (SCRIPT_MEM(ch)==mem) { SCRIPT_MEM(ch) = mem->next; } else { prev = SCRIPT_MEM(ch); while (prev->next != mem) prev = prev->next; prev->next = mem->next; } if (mem->cmd) free(mem->cmd); free(mem); } } /* for (mem =..... */ } } }
int enter_wtrigger(struct room_data *room, char_data *actor, int dir) { trig_data *t; char buf[MAX_INPUT_LENGTH]; int rev_dir[] = { SOUTH, WEST, NORTH, EAST, DOWN, UP }; if (!SCRIPT_CHECK(room, WTRIG_ENTER)) return 1; for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) { if (TRIGGER_CHECK(t, WTRIG_ENTER) && (number(1, 100) <= GET_TRIG_NARG(t))) { add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0); ADD_UID_VAR(buf, t, actor, "actor", 0); return script_driver(room, t, WLD_TRIGGER, TRIG_NEW); } } return 1; }
int receive_mtrigger(char_data *ch, char_data *actor, obj_data *obj) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!SCRIPT_CHECK(ch, MTRIG_RECEIVE) || AFF_FLAGGED(ch, AFF_CHARM)) return 1; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_RECEIVE) && (number(1, 100) <= GET_TRIG_NARG(t))){ ADD_UID_VAR(buf, t, actor, "actor", 0); ADD_UID_VAR(buf, t, obj, "object", 0); return script_driver(ch, t, MOB_TRIGGER, TRIG_NEW); } } return 1; }
int command_mtrigger(char_data *actor, char *cmd, char *argument) { char_data *ch, *ch_next; trig_data *t; char buf[MAX_INPUT_LENGTH]; /* prevent people we like from becoming trapped :P */ if (!valid_dg_target(actor, 0)) return 0; for (ch = world[IN_ROOM(actor)].people; ch; ch = ch_next) { ch_next = ch->next_in_room; if (SCRIPT_CHECK(ch, MTRIG_COMMAND) && !AFF_FLAGGED(ch, AFF_CHARM) && ((actor != ch) || CONFIG_SCRIPT_PLAYERS)) { for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (!TRIGGER_CHECK(t, MTRIG_COMMAND)) continue; if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) { mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: Command Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); continue; } if (*GET_TRIG_ARG(t) == '*' || !strn_cmp(GET_TRIG_ARG(t), cmd, strlen(GET_TRIG_ARG(t)))) { ADD_UID_VAR(buf, t, actor, "actor", 0); skip_spaces(&argument); add_var(&GET_TRIG_VARS(t), "arg", argument, 0); skip_spaces(&cmd); add_var(&GET_TRIG_VARS(t), "cmd", cmd, 0); if (script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW)) return 1; } } } } return 0; }
void act_mtrigger(const char_data *ch, char *str, char_data *actor, char_data *victim, obj_data *object, obj_data *target, char *arg) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (SCRIPT_CHECK(ch, MTRIG_ACT) && !AFF_FLAGGED(ch, AFF_CHARM) && (actor != ch)) for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (!TRIGGER_CHECK(t, MTRIG_ACT)) continue; if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) { mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: Act Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); continue; } if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) || (!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) { if (actor) ADD_UID_VAR(buf, t, actor, "actor", 0); if (victim) ADD_UID_VAR(buf, t, victim, "victim", 0); if (object) ADD_UID_VAR(buf, t, object, "object", 0); if (target) ADD_UID_VAR(buf, t, target, "target", 0); if (str) { /* we're guaranteed to have a string ending with \r\n\0 */ char *nstr = strdup(str), *fstr = nstr, *p = strchr(nstr, '\r'); skip_spaces(&nstr); *p = '\0'; add_var(&GET_TRIG_VARS(t), "arg", nstr, 0); free(fstr); } script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); break; } } }