void trigedit_disp_menu(struct descriptor_data *d) { struct trig_data *trig = OLC_TRIG(d); char *attach_type; char trgtypes[256]; get_char_colors(d->character); clear_screen(d); if (trig->attach_type==OBJ_TRIGGER) { attach_type = "Objects"; sprintbit(GET_TRIG_TYPE(trig), otrig_types, trgtypes, sizeof(trgtypes)); } else if (trig->attach_type==WLD_TRIGGER) { attach_type = "Rooms"; sprintbit(GET_TRIG_TYPE(trig), wtrig_types, trgtypes, sizeof(trgtypes)); } else { attach_type = "Mobiles"; sprintbit(GET_TRIG_TYPE(trig), trig_types, trgtypes, sizeof(trgtypes)); } write_to_output(d, TRUE, #if defined(CLEAR_SCREEN) "^[[H^[[J" #endif "Trigger Editor [%s%d%s]\r\n\r\n" "%s1)%s Name : %s%s\r\n" "%s2)%s Intended for : %s%s\r\n" "%s3)%s Trigger types: %s%s\r\n" "%s4)%s Numberic Arg : %s%d\r\n" "%s5)%s Arguments : %s%s\r\n" "%s6)%s Commands:\r\n%s", grn, OLC_NUM(d), nrm, /* vnum on the title line */ grn, nrm, yel, GET_TRIG_NAME(trig), /* name */ grn, nrm, yel, attach_type, /* attach type */ grn, nrm, yel, trgtypes, /* greet/drop/etc */ grn, nrm, yel, trig->narg, /* numeric arg */ grn, nrm, yel, trig->arglist?trig->arglist:"", /* strict arg */ grn, nrm, cyn ); write_to_output(d, FALSE, "%s\r\n", OLC_STORAGE(d) /* the command list */ ); write_to_output(d, TRUE, "%sQ)%s Quit\r\n" "Enter Choice :", grn, nrm /* quit colors */ ); OLC_MODE(d) = TRIGEDIT_MAIN_MENU; }
void do_dg_affect(void *go, struct script_data *sc, trig_data *trig, int script_type, char *cmd) { struct char_data *ch = NULL; int value=0, duration=0; char junk[MAX_INPUT_LENGTH]; /* will be set to "dg_affect" */ char charname[MAX_INPUT_LENGTH], property[MAX_INPUT_LENGTH]; char value_p[MAX_INPUT_LENGTH], duration_p[MAX_INPUT_LENGTH]; int index=0, type=0; struct affected_type af; half_chop(cmd, junk, cmd); half_chop(cmd, charname, cmd); half_chop(cmd, property, cmd); half_chop(cmd, value_p, duration_p); /* make sure all parameters are present */ if (!charname || !*charname || !property || !*property || !value_p || !*value_p || !duration_p || !*duration_p) { sprintf(buf2, "Trigger: %s, VNum %d. dg_affect usage: <target> <property> <value> <duration>", GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig)); script_log(buf2); return; } value = atoi(value_p); duration = atoi(duration_p); if (duration <= 0) { sprintf(buf2, "Trigger: %s, VNum %d. dg_affect: need positive duration!", GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig)); script_log(buf2); return; } /* find the property -- first search apply_types */ index = 0; while (str_cmp(apply_types[index], "\n")) { if (!str_cmp(apply_types[index], property)) { type=APPLY_TYPE; break; } index++; } if (!type) { /* search affect_types now */ index = 0; while (str_cmp(affected_bits[index], "\n")) { if (!str_cmp(affected_bits[index], property)) { type=AFFECT_TYPE; break; } index++; } } if (!type) { /* property not found */ sprintf(buf2, "Trigger: %s, VNum %d. dg_affect: unknown property '%s'!", GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), property); script_log(buf2); return; } /* locate the target */ ch = get_char(charname); if (!ch) { sprintf(buf2, "Trigger: %s, VNum %d. dg_affect: cannot locate target!", GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig)); script_log(buf2); return; } /* add the affect */ af.type = 0; af.duration = duration; af.modifier = value; af.location = 0; af.bitvector = (1<<type); affect_to_char(ch, &af); }
/* code borrowed from do_cast() */ void do_dg_cast(void *go, struct script_data *sc, trig_data *trig, int type, char *cmd) { struct char_data *caster = NULL; struct char_data *tch = NULL; struct obj_data *tobj = NULL; struct room_data *caster_room = NULL; char *s, *t; int spellnum, target = 0; /* need to get the caster or the room of the temporary caster */ switch (type) { case MOB_TRIGGER: caster = (struct char_data *)go; break; case WLD_TRIGGER: caster_room = (struct room_data *)go; break; case OBJ_TRIGGER: caster_room = dg_room_of_obj((struct obj_data *)go); if (!caster_room) { script_log("dg_do_cast: unknown room for object-caster!"); return; } break; default: script_log("dg_do_cast: unknown trigger type!"); return; } /* get: blank, spell name, target name */ s = strtok(cmd, "'"); if (s == NULL) { sprintf(buf2, "Trigger: %s, VNum %d. dg_cast needs spell name.", GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig)); script_log(buf2); return; } s = strtok(NULL, "'"); if (s == NULL) { sprintf(buf2, "Trigger: %s, VNum %d. dg_cast needs spell name in `'s.", GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig)); script_log(buf2); return; } t = strtok(NULL, "\0"); /* spellnum = search_block(s, spells, 0); */ spellnum = find_abil_num(s,spells); if ((spellnum < 1) || (spellnum > MAX_SPELLS)) { sprintf(buf2, "Trigger: %s, VNum %d. dg_cast: invalid spell name (%s)", GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), cmd); script_log(buf2); return; } /* Find the target */ if (t != NULL) { one_argument(strcpy(arg, t), t); skip_spaces(&t); } if (IS_SET(SINFO.targets, TAR_IGNORE)) { target = TRUE; } else if (t != NULL && *t) { if (!target && (IS_SET(SINFO.targets, TAR_CHAR_ROOM) || IS_SET(SINFO.targets, TAR_CHAR_WORLD))) { if ((tch = get_char(t)) != NULL) target = TRUE; } if (!target && (IS_SET(SINFO.targets, TAR_OBJ_INV) || IS_SET(SINFO.targets, TAR_OBJ_EQUIP) || IS_SET(SINFO.targets, TAR_OBJ_ROOM) || IS_SET(SINFO.targets, TAR_OBJ_WORLD))) { if ((tobj = get_obj(t)) != NULL) target = TRUE; } if (!target) { sprintf(buf2, "Trigger: %s, VNum %d. dg_cast: target not found (%s)", GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), cmd); script_log(buf2); return; } } if (IS_SET(SINFO.routines, MAG_GROUPS)) { sprintf(buf2, "Trigger: %s, VNum %d. dg_cast: group spells not permitted (%s)", GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), cmd); script_log(buf2); return; } if (!caster) { caster = read_mobile(DG_CASTER_PROXY, VIRTUAL); if (!caster) { script_log("dg_cast: Cannot load the caster mob!"); return; } /* set the caster's name to that of the object, or the gods.... */ /* take select pieces from char_to_room(); */ if (type==OBJ_TRIGGER) caster->player.short_descr = str_dup(((struct obj_data *)go)->short_description); else if (type==WLD_TRIGGER) caster->player.short_descr = str_dup("The gods"); caster->next_in_room = caster_room->people; caster_room->people = caster; caster->in_room = real_room(caster_room->number); call_magic(caster, tch, tobj, spellnum, ABT_SPELL, GET_LEVEL(caster), CAST_SPELL, FALSE); extract_char(caster); } else call_magic(caster, tch, tobj, spellnum, ABT_SPELL, GET_LEVEL(caster), CAST_SPELL, FALSE); }
/* * Save all the zone_table for this zone to disk. This function now * writes simple comments in the form of (<name>) to each record. A * header for each field is also there. */ int save_zone(zone_rnum zone_num) { int subcmd, arg1 = -1, arg2 = -1, arg3 = -1; char fname[128], oldname[128]; const char *comment = NULL; FILE *zfile; #if CIRCLE_UNSIGNED_INDEX if (zone_num == NOWHERE || zone_num > top_of_zone_table) { #else if (zone_num < 0 || zone_num > top_of_zone_table) { #endif log("SYSERR: GenOLC: save_zone: Invalid real zone number %d. (0-%d)", zone_num, top_of_zone_table); return FALSE; } snprintf(fname, sizeof(fname), "%s/%d.new", ZON_PREFIX, zone_table[zone_num].number); if (!(zfile = fopen(fname, "w"))) { mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: save_zones: Can't write zone %d.", zone_table[zone_num].number); return FALSE; } /* * Print zone header to file */ fprintf(zfile, "#%d\n" "%s~\n" "%s~\n" "%d %d %d %d\n", zone_table[zone_num].number, (zone_table[zone_num].builders && *zone_table[zone_num].builders) ? zone_table[zone_num].builders : "None.", (zone_table[zone_num].name && *zone_table[zone_num].name) ? zone_table[zone_num].name : "undefined", genolc_zone_bottom(zone_num), zone_table[zone_num].top, zone_table[zone_num].lifespan, zone_table[zone_num].reset_mode ); /* * Handy Quick Reference Chart for Zone Values. * * Field #1 Field #3 Field #4 Field #5 * ------------------------------------------------- * M (Mobile) Mob-Vnum Wld-Max Room-Vnum * O (Object) Obj-Vnum Wld-Max Room-Vnum * G (Give) Obj-Vnum Wld-Max Unused * E (Equip) Obj-Vnum Wld-Max EQ-Position * P (Put) Obj-Vnum Wld-Max Target-Obj-Vnum * D (Door) Room-Vnum Door-Dir Door-State * R (Remove) Room-Vnum Obj-Vnum Unused * T (Trigger) Trig-type Trig-Vnum Room-Vnum * V (var) Trig-type Context Room-Vnum Varname Value * ------------------------------------------------- */ for (subcmd = 0; ZCMD(zone_num, subcmd).command != 'S'; subcmd++) { switch (ZCMD(zone_num, subcmd).command) { case 'M': arg1 = mob_index[ZCMD(zone_num, subcmd).arg1].vnum; arg2 = ZCMD(zone_num, subcmd).arg2; arg3 = world[ZCMD(zone_num, subcmd).arg3].number; comment = mob_proto[ZCMD(zone_num, subcmd).arg1].player.short_descr; break; case 'O': arg1 = obj_index[ZCMD(zone_num, subcmd).arg1].vnum; arg2 = ZCMD(zone_num, subcmd).arg2; arg3 = world[ZCMD(zone_num, subcmd).arg3].number; comment = obj_proto[ZCMD(zone_num, subcmd).arg1].short_description; break; case 'G': arg1 = obj_index[ZCMD(zone_num, subcmd).arg1].vnum; arg2 = ZCMD(zone_num, subcmd).arg2; arg3 = -1; comment = obj_proto[ZCMD(zone_num, subcmd).arg1].short_description; break; case 'E': arg1 = obj_index[ZCMD(zone_num, subcmd).arg1].vnum; arg2 = ZCMD(zone_num, subcmd).arg2; arg3 = ZCMD(zone_num, subcmd).arg3; comment = obj_proto[ZCMD(zone_num, subcmd).arg1].short_description; break; case 'P': arg1 = obj_index[ZCMD(zone_num, subcmd).arg1].vnum; arg2 = ZCMD(zone_num, subcmd).arg2; arg3 = obj_index[ZCMD(zone_num, subcmd).arg3].vnum; comment = obj_proto[ZCMD(zone_num, subcmd).arg1].short_description; break; case 'D': arg1 = world[ZCMD(zone_num, subcmd).arg1].number; arg2 = ZCMD(zone_num, subcmd).arg2; arg3 = ZCMD(zone_num, subcmd).arg3; comment = world[ZCMD(zone_num, subcmd).arg1].name; break; case 'R': arg1 = world[ZCMD(zone_num, subcmd).arg1].number; arg2 = obj_index[ZCMD(zone_num, subcmd).arg2].vnum; comment = obj_proto[ZCMD(zone_num, subcmd).arg2].short_description; arg3 = -1; break; case 'T': arg1 = ZCMD(zone_num, subcmd).arg1; /* trigger type */ arg2 = trig_index[ZCMD(zone_num, subcmd).arg2]->vnum; /* trigger vnum */ arg3 = world[ZCMD(zone_num, subcmd).arg3].number; /* room num */ comment = GET_TRIG_NAME(trig_index[real_trigger(arg2)]->proto); break; case 'V': arg1 = ZCMD(zone_num, subcmd).arg1; /* trigger type */ arg2 = ZCMD(zone_num, subcmd).arg2; /* context */ arg3 = world[ZCMD(zone_num, subcmd).arg3].number; break; case '*': /* * Invalid commands are replaced with '*' - Ignore them. */ continue; default: mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: z_save_to_disk(): Unknown cmd '%c' - NOT saving", ZCMD(zone_num, subcmd).command); continue; } if (ZCMD(zone_num, subcmd).command != 'V') fprintf(zfile, "%c %d %d %d %d \t(%s)\n", ZCMD(zone_num, subcmd).command, ZCMD(zone_num, subcmd).if_flag, arg1, arg2, arg3, comment); else fprintf(zfile, "%c %d %d %d %d %s %s\n", ZCMD(zone_num, subcmd).command, ZCMD(zone_num, subcmd).if_flag, arg1, arg2, arg3, ZCMD(zone_num, subcmd).sarg1, ZCMD(zone_num, subcmd).sarg2); } fputs("S\n$\n", zfile); fclose(zfile); snprintf(oldname, sizeof(oldname), "%s/%d.zon", ZON_PREFIX, zone_table[zone_num].number); remove(oldname); rename(fname, oldname); if (in_save_list(zone_table[zone_num].number, SL_ZON)) remove_from_save_list(zone_table[zone_num].number, SL_ZON); return TRUE; } /*-------------------------------------------------------------------*/ /* * Some common code to count the number of comands in the list. */ int count_commands(struct reset_com *list) { int count = 0; while (list[count].command != 'S') count++; return count; }