/* Extract an object from the world */ void extract_obj(struct obj_data * obj) { struct obj_data *temp; if (obj->worn_by != NULL) if (unequip_char(obj->worn_by, obj->worn_on) != obj) log("SYSERR: Inconsistent worn_by and worn_on pointers!!"); if (obj->in_room != NOWHERE) obj_from_room(obj); else if (obj->carried_by) obj_from_char(obj); else if (obj->in_obj) obj_from_obj(obj); /* Get rid of the contents of the object, as well. */ while (obj->contains) extract_obj(obj->contains); REMOVE_FROM_LIST(obj, object_list, next); if (GET_OBJ_RNUM(obj) >= 0) (obj_index[GET_OBJ_RNUM(obj)].number)--; if (SCRIPT(obj)) extract_script(SCRIPT(obj)); free_obj(obj); }
ScriptSectionType * SCRIPT_AddSection(int32_t scripthandle, char * sectionname) { ScriptSectionType *s,*s2; if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return NULL; if (!sectionname) return NULL; if (!SC(scripthandle)) return NULL; s = SCRIPT_SectionExists(scripthandle, sectionname); if (s) return s; AllocSection(s); s->name = Bstrdup(sectionname); if (!SCRIPT(scripthandle,script)) { SCRIPT(scripthandle,script) = s; } else { s2 = SCRIPT(scripthandle,script); while (s2->nextsection != s2) s2=s2->nextsection; s2->nextsection = s; s->prevsection = s2; } return s; }
char * SCRIPT_Section( int32 scripthandle, int32 which ) { ScriptSectionType *s,*ls=NULL; if (!SC(scripthandle)) return ""; if (!SCRIPT(scripthandle,script)) return ""; for (s = SCRIPT(scripthandle,script); which>0 && ls != s; ls=s, s=s->nextsection, which--) ; return s->name; }
int32 SCRIPT_NumberSections( int32 scripthandle ) { int32 c=0; ScriptSectionType *s,*ls=NULL; if (!SC(scripthandle)) return 0; if (!SCRIPT(scripthandle,script)) return 0; for (s = SCRIPT(scripthandle,script); ls != s; ls=s,s=s->nextsection) c++; return c; }
ScriptSectionType * SCRIPT_SectionExists( int32 scripthandle, const char * sectionname ) { ScriptSectionType *s, *ls=NULL; if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return NULL; if (!sectionname) return NULL; if (!SC(scripthandle)) return NULL; if (!SCRIPT(scripthandle,script)) return NULL; for (s = SCRIPT(scripthandle,script); ls != s; ls=s,s=s->nextsection) if (!Bstrcasecmp(s->name, sectionname)) return s; return NULL; }
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 greet_mtrigger(char_data *actor, int dir) { trig_data *t; char_data *ch; char buf[MAX_INPUT_LENGTH]; int rev_dir[] = { SOUTH, WEST, NORTH, EAST, DOWN, UP }; int intermediate, final=TRUE; for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) { if (!SCRIPT_CHECK(ch, MTRIG_GREET | MTRIG_GREET_ALL) || !AWAKE(ch) || FIGHTING(ch) || (ch == actor) || AFF_FLAGGED(ch, AFF_CHARM)) continue; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (((IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET) && CAN_SEE(ch, actor)) || IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET_ALL)) && !GET_TRIG_DEPTH(t) && (number(1, 100) <= GET_TRIG_NARG(t))) { if (dir>=0) add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0); ADD_UID_VAR(buf, t, actor, "actor", 0); intermediate = script_driver(ch, t, MOB_TRIGGER, TRIG_NEW); if (!intermediate) final = FALSE; continue; } } } return final; }
void oedit_setup_existing(struct descriptor_data *d, int real_num) { struct obj_data *obj; /* * Allocate object in memory. */ CREATE(obj, struct obj_data, 1); copy_object(obj, &obj_proto[real_num]); /* * Attach new object to player's descriptor. */ OLC_OBJ(d) = obj; OLC_VAL(d) = 0; OLC_ITEM_TYPE(d) = OBJ_TRIGGER; dg_olc_script_copy(d); /* * The edited obj must not have a script. * It will be assigned to the updated obj later, after editing. */ SCRIPT(obj) = NULL; OLC_OBJ(d)->proto_script = NULL; oedit_disp_menu(d); }
/* 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 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_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 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; }
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 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; }
int greet_mtrigger(char_data *actor, int dir) { trig_data *t = NULL; char_data *ch = NULL; char buf[MAX_INPUT_LENGTH] = {'\0'}; int intermediate = 0, final = TRUE; if (!valid_dg_target(actor, DG_ALLOW_GODS)) return TRUE; for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) { if (!SCRIPT_CHECK(ch, MTRIG_GREET | MTRIG_GREET_ALL) || !AWAKE(ch) || FIGHTING(ch) || (ch == actor) || AFF_FLAGGED(ch, AFF_CHARM)) continue; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (((IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET) && CAN_SEE(ch, actor)) || IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET_ALL)) && !GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { if (dir >= 0 && dir < DIR_COUNT) add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0); else add_var(&GET_TRIG_VARS(t), "direction", "none", 0); ADD_UID_VAR(buf, t, actor, "actor", 0); intermediate = script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); if (!intermediate) final = FALSE; continue; } } } return final; }
int door_mtrigger(char_data *actor, int subcmd, int dir) { trig_data *t; char_data *ch; char buf[MAX_INPUT_LENGTH]; for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) { if (!SCRIPT_CHECK(ch, MTRIG_DOOR) || !AWAKE(ch) || FIGHTING(ch) || (ch == actor) || AFF_FLAGGED(ch, AFF_CHARM)) continue; for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (IS_SET(GET_TRIG_TYPE(t), MTRIG_DOOR) && CAN_SEE(ch, actor) && !GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) { add_var(&GET_TRIG_VARS(t), "cmd", cmd_door[subcmd], 0); 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); return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); } } } return 1; }
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; }
boolean SCRIPT_GetNumber( int32 scripthandle, const char * sectionname, const char * entryname, int32 * number ) { ScriptSectionType *s; ScriptEntryType *e; char *p; if (!SC(scripthandle)) return 1; if (!SCRIPT(scripthandle,script)) return 1; s = SCRIPT_SectionExists(scripthandle, sectionname); e = SCRIPT_EntryExists(s, entryname); if (!e) return 1;// *number = 0; else { if (e->value[0] == '0' && e->value[1] == 'x') { // hex *number = strtol(e->value+2, &p, 16); if (p == e->value || *p != 0 || *p != ' ' || *p != '\t') return 1; } else { // decimal *number = strtol(e->value, &p, 10); if (p == e->value || *p != 0 || *p != ' ' || *p != '\t') return 1; } } return 0; }
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; } } }
int32_t SCRIPT_Init(char * name) { int32_t h = SCRIPT_New(); if (h >= 0) Bstrncpy(SCRIPT(h,scriptfilename), name, 127); return h; }
int32 SCRIPT_Init( const char * name ) { int32 h = SCRIPT_New(); if (h >= 0) strncpy(SCRIPT(h,scriptfilename), name, 127); return h; }
int32_t SCRIPT_GetString(int32_t scripthandle, char * sectionname, char * entryname, char * dest) { ScriptSectionType *s; ScriptEntryType *e; char *p, ch; int32_t c; if (!SC(scripthandle)) return 1; if (!SCRIPT(scripthandle,script)) return 1; s = SCRIPT_SectionExists(scripthandle, sectionname); e = SCRIPT_EntryExists(s, entryname); //dest[0] = 0; if (!e) return 1; p = e->value; c = 0; if (*p == '\"') { // quoted string p++; while ((ch = *(p++))) { switch (ch) { case '\\': ch = *(p++); switch (ch) { case 0: return 0; case 'n': dest[c++] = '\n'; break; case 'r': dest[c++] = '\r'; break; case 't': dest[c++] = '\t'; break; default: dest[c++] = ch; break; } break; case '\"': dest[c] = 0; return 0; default: dest[c++] = ch; break; } } } else { while ((ch = *(p++))) { if (ch == ' ' || ch == '\t') { dest[c] = 0; break; } else dest[c++] = ch; } } return 0; }
/* Save new/edited mob to memory. */ void medit_save_internally(struct descriptor_data *d) { int i; mob_rnum new_rnum; struct descriptor_data *dsc; struct char_data *mob; i = (real_mobile(OLC_NUM(d)) == NOBODY); if ((new_rnum = add_mobile(OLC_MOB(d), OLC_NUM(d))) == NOBODY) { log("medit_save_internally: add_mobile failed."); return; } /* Update triggers and free old proto list */ if (mob_proto[new_rnum].proto_script && mob_proto[new_rnum].proto_script != OLC_SCRIPT(d)) free_proto_script(&mob_proto[new_rnum], MOB_TRIGGER); mob_proto[new_rnum].proto_script = OLC_SCRIPT(d); /* this takes care of the mobs currently in-game */ for (mob = character_list; mob; mob = mob->next) { if (GET_MOB_RNUM(mob) != new_rnum) continue; /* remove any old scripts */ if (SCRIPT(mob)) extract_script(mob, MOB_TRIGGER); free_proto_script(mob, MOB_TRIGGER); copy_proto_script(&mob_proto[new_rnum], mob, MOB_TRIGGER); assign_triggers(mob, MOB_TRIGGER); } /* end trigger update */ if (!i) /* Only renumber on new mobiles. */ return; /* Update keepers in shops being edited and other mobs being edited. */ for (dsc = descriptor_list; dsc; dsc = dsc->next) { if (STATE(dsc) == CON_SEDIT) S_KEEPER(OLC_SHOP(dsc)) += (S_KEEPER(OLC_SHOP(dsc)) != NOTHING && S_KEEPER(OLC_SHOP(dsc)) >= new_rnum); else if (STATE(dsc) == CON_MEDIT) GET_MOB_RNUM(OLC_MOB(dsc)) += (GET_MOB_RNUM(OLC_MOB(dsc)) != NOTHING && GET_MOB_RNUM(OLC_MOB(dsc)) >= new_rnum); } /* Update other people in zedit too. From: C.Raehl 4/27/99 */ for (dsc = descriptor_list; dsc; dsc = dsc->next) if (STATE(dsc) == CON_ZEDIT) for (i = 0; OLC_ZONE(dsc)->cmd[i].command != 'S'; i++) if (OLC_ZONE(dsc)->cmd[i].command == 'M') if (OLC_ZONE(dsc)->cmd[i].arg1 >= new_rnum) OLC_ZONE(dsc)->cmd[i].arg1++; }
/* Extract an object from the world */ void extract_obj(struct obj_data *obj) { struct char_data *ch, *next = NULL; struct obj_data *temp; if (obj->worn_by != NULL) if (unequip_char(obj->worn_by, obj->worn_on) != obj) log("SYSERR: Inconsistent worn_by and worn_on pointers!!"); if (IN_ROOM(obj) != NOWHERE) obj_from_room(obj); else if (obj->carried_by) obj_from_char(obj); else if (obj->in_obj) obj_from_obj(obj); if (OBJ_SAT_IN_BY(obj)){ for (ch = OBJ_SAT_IN_BY(obj); OBJ_SAT_IN_BY(obj); ch = next){ if (!NEXT_SITTING(ch)) OBJ_SAT_IN_BY(obj) = NULL; else OBJ_SAT_IN_BY(obj) = (next = NEXT_SITTING(ch)); SITTING(ch) = NULL; NEXT_SITTING(ch) = NULL; } } /* Get rid of the contents of the object, as well. */ while (obj->contains) extract_obj(obj->contains); REMOVE_FROM_LIST(obj, object_list, next); if (GET_OBJ_RNUM(obj) != NOTHING) (obj_index[GET_OBJ_RNUM(obj)].number)--; if (SCRIPT(obj)) extract_script(obj, OBJ_TRIGGER); if (obj->events != NULL) { if (obj->events->iSize > 0) { struct event * pEvent; while ((pEvent = simple_list(obj->events)) != NULL) event_cancel(pEvent); } free_list(obj->events); obj->events = NULL; } if (GET_OBJ_RNUM(obj) == NOTHING || obj->proto_script != obj_proto[GET_OBJ_RNUM(obj)].proto_script) free_proto_script(obj, OBJ_TRIGGER); free_obj(obj); }
/** * Ensures the "attach_to" thing (also called "go" in some scripting code) * has a SCRIPT() var, and sets up data that will be needed later. * * @param void *attach_to Any char/obj/room/vehicle that could have SCRIPT(). * @param int type _TRIGGER consts such as MOB_TRIGGER, corresponding to 'attach_to'. * @return struct script_data* A pointer to the script data (which is also attached to 'attach_to'), or NULL if it failed. */ struct script_data *create_script_data(void *attach_to, int type) { struct script_data *scr = NULL; // x_TRIGGER: attach types switch (type) { case MOB_TRIGGER: { char_data *mob = (char_data*)attach_to; if (!(scr = SCRIPT(mob))) { CREATE(scr, struct script_data, 1); SCRIPT(mob) = scr; } break; } case OBJ_TRIGGER: { obj_data *obj = (obj_data*)attach_to; if (!(scr = SCRIPT(obj))) { CREATE(scr, struct script_data, 1); SCRIPT(obj) = scr; } break; }
void greet_memory_mtrigger(char_data *actor) { trig_data *t; char_data *ch; struct script_memory *mem; char buf[MAX_INPUT_LENGTH]; int command_performed = 0; for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) { if (!SCRIPT_MEM(ch) || !AWAKE(ch) || FIGHTING(ch) || (ch == actor) || AFF_FLAGGED(ch, AFF_CHARM)) continue; /* find memory line with command only */ for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); mem=mem->next) { if (GET_ID(actor)!=mem->id) continue; if (mem->cmd) { command_interpreter(ch, mem->cmd); /* no script */ command_performed = 1; break; } } /* if a command was not performed execute the memory script */ if (mem && !command_performed) { for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (IS_SET(GET_TRIG_TYPE(t), MTRIG_MEMORY) && CAN_SEE(ch, actor) && !GET_TRIG_DEPTH(t) && 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 (mem) { if (SCRIPT_MEM(ch)==mem) { SCRIPT_MEM(ch) = mem->next; } else { struct script_memory *prev; prev = SCRIPT_MEM(ch); while (prev->next != mem) prev = prev->next; prev->next = mem->next; } if (mem->cmd) free(mem->cmd); free(mem); } } }
const char * SCRIPT_GetRaw(int32 scripthandle, const char * sectionname, const char * entryname) { ScriptSectionType *s; ScriptEntryType *e; if (!SC(scripthandle)) return 0; if (!SCRIPT(scripthandle,script)) return 0; s = SCRIPT_SectionExists(scripthandle, sectionname); e = SCRIPT_EntryExists(s, entryname); if (!e) return ""; return e->value; }
/* 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 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; } } }