void check_thief(struct creature *ch, struct creature *victim) { struct creature *perp; // First we need to find the perp perp = find_responsible_party(ch, victim); int gain = pk_reputation_gain(perp, victim); if (!gain) return; gain = MAX(1, gain / 10); gain_reputation(perp, gain); send_to_char(perp, "%sYou have gained %d reputation for stealing from %s.%s\r\n", CCRED(perp, C_NRM), gain, GET_NAME(victim), CCNRM(perp, C_NRM)); send_to_char(victim, "%s%s has gained %d reputation for stealing from you.%s\r\n", CCYEL(victim, C_NRM), GET_NAME(perp), gain, CCNRM(victim, C_NRM)); mudlog(LVL_IMMORT, CMP, true, "%s gained %d reputation for stealing from %s", GET_NAME(perp), gain, GET_NAME(victim)); create_grievance(victim, perp, gain, THEFT); if (is_arena_combat(ch, victim)) mudlog(LVL_POWER, CMP, true, "%s pstealing from %s in arena", GET_NAME(perp), GET_NAME(victim)); }
void perform_pardon(struct creature *ch, struct creature *pardoned) { for (GList *it = GET_GRIEVANCES(ch);it;it = it->next) { struct grievance *grievance = it->data; if (grievance->player_id == GET_IDNUM(pardoned)) { if (grievance->grievance == MURDER) { mudlog(LVL_IMMORT, CMP, true, "%s recovered %d reputation for murdering %s", GET_NAME(pardoned), grievance->rep, GET_NAME(ch)); } else if (grievance->grievance == ATTACK) { mudlog(LVL_IMMORT, CMP, true, "%s recovered %d reputation for attacking %s", GET_NAME(pardoned), grievance->rep, GET_NAME(ch)); } else { mudlog(LVL_IMMORT, CMP, true, "%s recovered %d reputation for stealing from %s", GET_NAME(pardoned), grievance->rep, GET_NAME(ch)); } gain_reputation(pardoned, -(grievance->rep)); } } GET_GRIEVANCES(ch) = g_list_remove_if(GET_GRIEVANCES(ch), (GCompareFunc) matches_grievance, GINT_TO_POINTER(GET_IDNUM(pardoned))); }
void tedit_string_cleanup(struct descriptor_data *d, int terminator) { FILE *fl; char *storage = OLC_STORAGE(d); if (!storage) terminator = STRINGADD_ABORT; switch (terminator) { case STRINGADD_SAVE: if (!(fl = fopen(storage, "w"))) mudlog(CMP, LVL_IMPL, TRUE, "SYSERR: Can't write file '%s'.", storage); else { if (*d->str) { strip_cr(*d->str); fputs(*d->str, fl); } fclose(fl); mudlog(CMP, LVL_GOD, TRUE, "OLC: %s saves '%s'.", GET_NAME(d->character), storage); write_to_output(d, "Saved.\r\n"); } break; case STRINGADD_ABORT: write_to_output(d, "Edit aborted.\r\n"); act("$n stops editing some scrolls.", TRUE, d->character, 0, 0, TO_ROOM); break; default: log("SYSERR: tedit_string_cleanup: Unknown terminator status."); break; } /* Common cleanup code. */ cleanup_olc(d, CLEANUP_ALL); STATE(d) = CON_PLAYING; }
// such as 2.grape .. will return 2 and replace the argument with "grape" // if not a numbered arg, it will return 1 meaning first object long numbered_arg(char *argument) { char realarg[MAX_BUFFER]; char cnum[8]; long x, y; if(argument && isdigit(argument[0])) { for(x = 0; argument[x] != '.' && argument[x] != '\0'; x++) { if(x >= 7) return 0; cnum[x] = argument[x]; } cnum[x] = '\0'; if(argument[x] == '.') x++; else return 1; for(y = 0; argument[x] != '\0'; y++, x++) realarg[y] = argument[x]; realarg[y] = '\0'; strcpy(argument,realarg); mudlog("numbered_arg: arg[%s] num: %li", argument, atol(cnum)); return atol(cnum); } mudlog("numbered_arg: got default, arg is [%s]", argument); return 1; }
// str_cut(3,4,"123456789") would return 3456 // if spots + start > strlen it just returns from start to end of str char *str_cut(long start, long spots, char *str) { char xbuf[MAX_BUFFER]; static char buf[MAX_BUFFER]; long x; if (start > 0) start--; // start position does not have to take into account 0 pos. if (strlen(str) < start) { mudlog("str_cut: trying to start cutting past the string's end!"); mudlog("START: %li - SPOTS: %li - STR: %s",start,spots,str); return str; } for (x = start; x < strlen(str) && x - start < spots; x++) { if (x == start) { sprintf(xbuf,"%c",str[x]); strcpy(buf,xbuf); } else { sprintf(xbuf,"%c",str[x]); strcat(buf,xbuf); } } return buf; }
bool summon_criminal_demons(struct creature *vict) { struct creature *mob; int vnum_base = (IS_EVIL(vict)) ? ARCHONIC_BASE : DEMONIC_BASE; int demon_num = GET_REMORT_GEN(vict) / 2 + 1; int idx; for (idx = 0; idx < demon_num; idx++) { mob = read_mobile(vnum_base + MIN(4, (GET_LEVEL(vict) / 9)) + number(0, 1)); if (!mob) { errlog("Unable to load mob in demonic_overmind"); return false; } start_hunting(mob, vict); SET_BIT(NPC_FLAGS(mob), NPC_SPIRIT_TRACKER); CREATE(mob->mob_specials.func_data, int, 1); *((int *)mob->mob_specials.func_data) = GET_IDNUM(vict); char_to_room(mob, vict->in_room, true); act("The air suddenly cracks open and $n steps out!", false, mob, NULL, NULL, TO_ROOM); } if (IS_EVIL(vict)) mudlog(GET_INVIS_LVL(vict), NRM, true, "%d archons dispatched to hunt down %s", demon_num, GET_NAME(vict)); else mudlog(GET_INVIS_LVL(vict), NRM, true, "%d demons dispatched to hunt down %s", demon_num, GET_NAME(vict)); return true; }
// юзается исключительно в act.wizards.cpp в имм командах "advance" и "set exp". void gain_exp_regardless(CHAR_DATA * ch, int gain) { int is_altered = FALSE; int num_levels = 0; ch->set_exp(ch->get_exp() + gain); if (!IS_NPC(ch)) { if (gain > 0) { while (GET_LEVEL(ch) < LVL_IMPL && GET_EXP(ch) >= level_exp(ch, GET_LEVEL(ch) + 1)) { ch->set_level(ch->get_level() + 1); num_levels++; sprintf(buf, "%sВы достигли следующего уровня!%s\r\n", CCWHT(ch, C_NRM), CCNRM(ch, C_NRM)); send_to_char(buf, ch); advance_level(ch); is_altered = TRUE; } if (is_altered) { sprintf(buf, "%s advanced %d level%s to level %d.", GET_NAME(ch), num_levels, num_levels == 1 ? "" : "s", GET_LEVEL(ch)); mudlog(buf, BRF, LVL_IMPL, SYSLOG, TRUE); } } else if (gain < 0) { // Pereplut: глупый участок кода. // gain = MAX(-max_exp_loss_pc(ch), gain); // Cap max exp lost per death // GET_EXP(ch) += gain; // if (GET_EXP(ch) < 0) // GET_EXP(ch) = 0; while (GET_LEVEL(ch) > 1 && GET_EXP(ch) < level_exp(ch, GET_LEVEL(ch))) { ch->set_level(ch->get_level() - 1); num_levels++; sprintf(buf, "%sВы потеряли уровень!%s\r\n", CCIRED(ch, C_NRM), CCNRM(ch, C_NRM)); send_to_char(buf, ch); decrease_level(ch); is_altered = TRUE; } if (is_altered) { sprintf(buf, "%s decreases %d level%s to level %d.", GET_NAME(ch), num_levels, num_levels == 1 ? "" : "s", GET_LEVEL(ch)); mudlog(buf, BRF, LVL_IMPL, SYSLOG, TRUE); } } } }
///////////////////// // LOCAL FUNCTIONS // ///////////////////// // pauses the mud for # of microseconds..... // strangely enough.. windows _requires_ you have at least one fd_set // with at least one socket in it, to use select.. linux does not void mudsleep(long microseconds) { static unsigned long sleep_socket = 0; fd_set fd_sleep; struct timeval wait_time; if( tick % (LOOPS_PER_SECOND*60*15) == 0 ) { CREATURE *crit; OBJECT *obj; long players = 0, creatures = 0, objects = 0; for(crit = creature_list; crit; crit = crit->next) { if(IsPlayer(crit)) players++; else creatures++; } for(obj = object_list; obj; obj = obj->next) objects++; // not a true representation of a tick.. it gets called twice in a row // mudlog("Tick %d -- Players:%li Creatures:%li Objects:%li", // tick, // players, creatures, objects); } if( !sleep_socket ) // initialize { if( (sleep_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { mudlog("mudsleep: Error creating sleep_socket"); mud_exit(); return; } } if( microseconds < 0 ) microseconds = 0; wait_time.tv_usec = microseconds; wait_time.tv_sec = 0; FD_ZERO(&fd_sleep); FD_SET(sleep_socket,&fd_sleep); if(select(0, 0, 0, &fd_sleep, &wait_time) < 0) { #ifdef WIN32 mudlog("select: error #%d",WSAGetLastError()); #else perror("mudsleep: select"); #endif // mud_exit(); } }
int add_shop(struct shop_data *nshp) { shop_rnum rshop; int found = 0; zone_rnum rznum = real_zone_by_thing(S_NUM(nshp)); /* * The shop already exists, just update it. */ if ((rshop = real_shop(S_NUM(nshp))) != NOWHERE) { free_shop_strings(&shop_index[rshop]); copy_shop(&shop_index[rshop], nshp); if (rznum != NOWHERE) add_to_save_list(zone_table[rznum].number, SL_SHP); else mudlog("SYSERR: GenOLC: Cannot determine shop zone.", BRF, LVL_BUILDER, TRUE); return rshop; } top_shop++; RECREATE(shop_index, struct shop_data, top_shop + 1); for (rshop = top_shop; rshop > 0; rshop--) { if (nshp->vnum > SHOP_NUM(rshop - 1)) { found = rshop; /* Make a "nofree" variant and remove these later. */ shop_index[rshop].in_room = NULL; shop_index[rshop].producing = NULL; shop_index[rshop].type = NULL; copy_shop(&shop_index[rshop], nshp); break; } shop_index[rshop] = shop_index[rshop - 1]; } if (!found) { /* Make a "nofree" variant and remove these later. */ shop_index[rshop].in_room = NULL; shop_index[rshop].producing = NULL; shop_index[rshop].type = NULL; copy_shop(&shop_index[0], nshp); } if (rznum != NOWHERE) add_to_save_list(zone_table[rznum].number, SL_SHP); else mudlog("SYSERR: GenOLC: Cannot determine shop zone.", BRF, LVL_BUILDER, TRUE); return rshop; }
int KyussSon( struct char_data *pChar, int nCmd, const char *szArg, struct char_data *pMob, int nType ) { struct char_data *pTar; struct room_data *pRoom; if( pMob == NULL ) { mudlog( LOG_SYSERR, "pMob == NULL in KyussSon( carceri.c )" ); return FALSE; } if( nType == EVENT_TICK ) { UpdateList( (CharElem **)&pMob->act_ptr ); if( ( pRoom = real_roomp( pMob->in_room ) ) != NULL ) { struct char_data *pNext; for( pTar = pRoom->people; pTar; pTar = pNext ) { pNext = pTar->next_in_room; if( CAN_SEE( pTar, pMob ) && !IsInList( (CharElem *)pMob->act_ptr, pTar ) && ( ( IS_PC( pTar ) && !IS_SET( pTar->specials.act, PLR_NOHASSLE ) ) || ( IS_NPC( pTar ) && ( ( pTar->specials.zone != pMob->specials.zone && !strchr( zone_table[ pTar->specials.zone ].races, GET_RACE( pTar ) ) ) || IS_SET( pTar->specials.act, ACT_ANNOYING ) ) ) ) ) { if( !saves_spell( pTar, SAVING_PARA ) ) { act( "Quando vedi $N, sei preso da un incontrollabile panico!", TRUE, pTar, 0, pMob, TO_CHAR ); do_flee( pTar, "", 0 ); } else { InsertInList( (CharElem **)&pMob->act_ptr, pTar, ( SECS_PER_MUD_HOUR * 48 ) / PULSE_MOBILE ); } } } } else mudlog( LOG_SYSERR, "pMob in invalid room in KyussSon( carceri.c )" ); } else if( nType == EVENT_DEATH ) FreeList( (CharElem **)&pMob->act_ptr ); return FALSE; }
void cast_energy_drain( byte level, struct char_data *ch, const char *arg, int type, struct char_data *victim, struct obj_data *tar_obj ) { switch (type) { case SPELL_TYPE_SPELL: spell_energy_drain(level, ch, victim, 0); break; case SPELL_TYPE_POTION: spell_energy_drain(level, ch, ch, 0); break; case SPELL_TYPE_SCROLL: if(victim) spell_energy_drain(level, ch, victim, 0); else if(!tar_obj) spell_energy_drain(level, ch, ch, 0); break; case SPELL_TYPE_WAND: if(victim) spell_energy_drain(level, ch, victim, 0); break; case SPELL_TYPE_STAFF: for( victim = real_roomp(ch->in_room)->people ; victim ; victim = victim->next_in_room ) if (!in_group(ch,victim)) if (victim != ch) spell_energy_drain(level, ch, victim, 0); break; default : mudlog( LOG_SYSERR, "Serious screw-up in energy drain!"); break; } }
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; } } }
void zedit_new_zone(struct char_data *ch, int vzone_num) { int result; const char *error; struct descriptor_data *dsc; if ((result = create_new_zone(vzone_num, &error)) < 0) { SEND_TO_Q(error, ch->desc); return; } for (dsc = descriptor_list; dsc; dsc = dsc->next) { switch (STATE(dsc)) { case CON_REDIT: OLC_ROOM(dsc)->zone += (OLC_ZNUM(dsc) >= result); /* Fall through. */ case CON_ZEDIT: case CON_MEDIT: case CON_SEDIT: case CON_OEDIT: OLC_ZNUM(dsc) += (OLC_ZNUM(dsc) >= result); break; default: break; } } sprintf(buf, "OLC: %s creates new zone #%d", GET_NAME(ch), vzone_num); mudlog(buf, BRF, MAX(LVL_BUILDER, GET_INVIS_LEV(ch)), TRUE); SEND_TO_Q("Zone create successfully\r\n", ch->desc); }
void run_autowiz(void) { #if defined(CIRCLE_UNIX) || defined(CIRCLE_WINDOWS) if (CONFIG_USE_AUTOWIZ) { size_t res; char buf[256]; int i; #if defined(CIRCLE_UNIX) res = snprintf(buf, sizeof(buf), "nice ../bin/autowiz %d %s %d %s %d &", CONFIG_MIN_WIZLIST_LEV, WIZLIST_FILE, LVL_IMMORT, IMMLIST_FILE, (int) getpid()); #elif defined(CIRCLE_WINDOWS) res = snprintf(buf, sizeof(buf), "autowiz %d %s %d %s", CONFIG_MIN_WIZLIST_LEV, WIZLIST_FILE, LVL_IMMORT, IMMLIST_FILE); #endif /* CIRCLE_WINDOWS */ /* Abusing signed -> unsigned conversion to avoid '-1' check. */ if (res < sizeof(buf)) { mudlog(CMP, LVL_IMMORT, FALSE, "Initiating autowiz."); i = system(buf); reboot_wizlists(); } else mlog("Cannot run autowiz: command-line doesn't fit in buffer."); } #endif /* CIRCLE_UNIX || CIRCLE_WINDOWS */ }
void check_attack(struct creature *attacker, struct creature *victim) { bool is_bountied(struct creature *hunter, struct creature *vict); struct creature *perp; // No reputation for attacking in arena if (is_arena_combat(attacker, victim)) return; perp = find_responsible_party(attacker, victim); // no reputation for attacking a bountied person if (is_bountied(perp, victim)) return; int gain = pk_reputation_gain(perp, victim); if (!gain) return; gain = MAX(1, gain / 5); gain_reputation(perp, gain); send_to_char(perp, "%sYou have gained %d reputation for viciously attacking %s.%s\r\n", CCRED(perp, C_NRM), gain, GET_NAME(victim), CCNRM(perp, C_NRM)); send_to_char(victim, "%s%s has gained %d reputation for viciously attacking you.%s\r\n", CCYEL(victim, C_NRM), GET_NAME(perp), gain, CCNRM(victim, C_NRM)); mudlog(LVL_IMMORT, CMP, true, "%s gained %d reputation for attacking %s", GET_NAME(perp), gain, GET_NAME(victim)); create_grievance(victim, perp, gain, ATTACK); }
void muckle_over(int awardQP) { CharData *i; int reward = 0; for(i = character_list; i; i = i->next) { sendChar(i, "The quest is over.\r\n"); REMOVE_BIT_AR(PRF_FLAGS(i), PRF_QUEST); if(!awardQP) break; reward = i->muckleTime/60 + (i->muckleTime % 60 > 0 ? 1:0); if(i->muckleTime == muckle_duration * 60) reward += 2; if(!IS_NPC(i) && reward) { sendChar(i, "You have been awarded %d quest points for your effort.\r\n", reward); GET_QP(i) += reward; mudlog(BRF, LVL_IMMORT, TRUE, "%s has received %d quest points for %s efforts in muckle.", GET_NAME(i), reward, HSHR(i)); } i->muckleTime = 0; } CONFIG_QUEST_ACTIVE = 0; }
/* 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; }
/* code for skill improvement through use */ void improve_skill(struct char_data *ch, int skill, int chance) { int percent = GET_SKILL(ch, skill); int newpercent, max; char skillbuf[MAX_STRING_LENGTH]; char mybuf[256]; max = max_lvl_skill[1][spells[find_skill_num_def(skill)].difficulty][(int) GET_LEVEL(ch)]; if (percent >= max || IS_NPC(ch)) return; if (number(1, (chance * 50)) > (GET_WIS(ch) + GET_INT(ch))) return; newpercent = 1; if (number(1, 120) <= GET_WIS(ch)) newpercent++; if (number(1, 120) <= GET_INT(ch)) newpercent++; percent += newpercent; percent = MIN(percent, max); SET_SKILL(ch, skill, percent); if (newpercent) { sprintf(mybuf, "SKILLIMPROVE: %s improved skill %s, int = %d, wis = %d, improved by = %d, now = %d", GET_NAME(ch), spells[find_skill_num_def(skill)].command, GET_INT(ch), GET_WIS(ch), newpercent, percent); mudlog(mybuf, 'D', COM_IMMORT, TRUE); sprintf(skillbuf, "{RYou feel your skill in {W%s {Rimproving.{x\r\n", spells[find_skill_num_def(skill)].command); send_to_char(skillbuf, ch); } }
void init_rand() { // rand_seed(current_time-s1, current_time, current_time+s3); // rand_seed(s1, s2, s3); rand_seed(randseed(),randseed(),randseed()); mudlog("Random number generator initialized."); }
void count_pkill(struct creature *killer, struct creature *victim) { bool award_bounty(struct creature *, struct creature *); struct creature *perp; if (is_arena_combat(killer, victim)) return; perp = find_responsible_party(killer, victim); GET_PKILLS(perp)++; if (award_bounty(perp, victim)) return; int gain = pk_reputation_gain(perp, victim); if (!gain) return; gain_reputation(perp, gain); send_to_char(perp, "%sYou have gained %d reputation for heinously murdering %s.%s\r\n", CCRED(killer, C_NRM), gain, GET_NAME(victim), CCNRM(perp, C_NRM)); send_to_char(victim, "%s%s has gained %d reputation for heinously murdering you.%s\r\n", CCYEL(killer, C_NRM), GET_NAME(perp), gain, CCNRM(victim, C_NRM)); mudlog(LVL_IMMORT, CMP, true, "%s gained %d reputation for murdering %s", GET_NAME(perp), gain, GET_NAME(victim)); create_grievance(victim, perp, gain, MURDER); }
/* * Print the appropriate message for the command type for arg2 and set * up the input catch clause. */ void zedit_disp_arg2(struct descriptor_data *d) { int i; switch (OLC_CMD(d).command) { case 'M': case 'O': case 'E': case 'P': case 'G': SEND_TO_Q("Input the maximum number that can exist on the mud : ", d); break; case 'D': for (i = 0; *dirs[i] != '\n'; i++) { sprintf(buf, "%d) Exit %s.\r\n", i, dirs[i]); SEND_TO_Q(buf, d); } SEND_TO_Q("Enter exit number for door : ", d); break; case 'R': SEND_TO_Q("Input object's vnum : ", d); break; default: /* * We should never get here, but just in case... */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: zedit_disp_arg2(): Help!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); return; } OLC_MODE(d) = ZEDIT_ARG2; }
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; } } } }
/* * Print the appropriate message for the command type for arg1 and set * up the input catch clause */ void zedit_disp_arg1(struct descriptor_data *d) { switch (OLC_CMD(d).command) { case 'M': SEND_TO_Q("Input mob's vnum : ", d); OLC_MODE(d) = ZEDIT_ARG1; break; case 'O': case 'E': case 'P': case 'G': SEND_TO_Q("Input object vnum : ", d); OLC_MODE(d) = ZEDIT_ARG1; break; case 'D': case 'R': /* * Arg1 for these is the room number, skip to arg2 */ OLC_CMD(d).arg1 = real_room(OLC_NUM(d)); zedit_disp_arg2(d); break; default: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: zedit_disp_arg1(): Help!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); return; } }
void cast_cause_critic( byte level, struct char_data *ch, const char *arg, int type, struct char_data *victim, struct obj_data *tar_obj ) { switch (type) { case SPELL_TYPE_SPELL: spell_cause_critical(level, ch, victim, 0); break; case SPELL_TYPE_SCROLL: if (!victim) victim = ch; spell_cause_critical(level,ch,victim,0); break; case SPELL_TYPE_WAND: if (!victim) victim = ch; spell_cause_critical(level,ch,victim,0); break; case SPELL_TYPE_POTION: if (!victim) victim = ch; spell_cause_critical(level, ch, victim, 0); break; case SPELL_TYPE_STAFF: for( victim = real_roomp(ch->in_room)->people ; victim ; victim = victim->next_in_room ) if (!in_group(ch,victim)) spell_cause_critical(level, ch, victim, 0); break; default : mudlog( LOG_SYSERR, "Serious screw-up in cause critical!"); break; } }
void zedit_disp_arg4(struct descriptor_data *d) { switch (OLC_CMD(d).command) { case 'M': case 'O': case 'E': case 'G': SEND_TO_Q("Enter The Load % : ", d); break; case 'P': case 'D': case 'R': break; default: /* * We should never get here, but just in case... */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: zedit_disp_arg4(): Help!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); return; } OLC_MODE(d) = ZEDIT_ARG4; }
void load_flags(void *what) { long num=0; long i; long *newflags; long *copyflags; switch(*(unsigned int*)what) { case TYPE_CREATURE: num = CFLAG_LAST; newflags = ((CREATURE*)what)->flags = malloc(sizeof(long)*((num/32)+1)); copyflags = hashfind_creature(((CREATURE*)what)->vnum)->flags; break; case TYPE_OBJECT: num = OFLAG_LAST; newflags = ((OBJECT*)what)->flags = malloc(sizeof(long)*((num/32)+1)); copyflags = hashfind_object(((OBJECT*)what)->vnum)->flags; break; default: mudlog("LOAD_FLAGS: no such type!"); return; } for(i = 0; i < (num/32)+1; i++) newflags[i] = copyflags[i]; }
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 backup_mud(void) { FILE *fp; char buf[MAX_BUFFER]; char timebuf[MAX_BUFFER]; fp = fopen("mysqldump.exe","w"); strftime(timebuf, MAX_BUFFER, "%b%d-%Y", localtime(¤t_time)); mudlog("BACKING UP SQL DATABASE [%s%s]", DB_NAME, timebuf ); sprintf(buf,"mysqldump -c -h%s -u%s -p%s %s > %s%s.sql", DB_HOST, DB_LOGIN, DB_PASSWORD, DB_NAME, DB_NAME, timebuf ); // create a file and write the mysqldump command to securely run it, // hiding the password from peekers on PS fwrite(buf,1,strlen(buf),fp); fclose(fp); chmod("mysqldump.exe",S_IRUSR|S_IXUSR|S_IWUSR); system("./mysqldump.exe"); system("rm mysqldump.exe"); sprintf(buf,"tar czhf %s%s.tgz %s%s.sql", DB_NAME, timebuf, DB_NAME, timebuf ); system(buf); sprintf(buf,"rm %s%s.sql", DB_NAME, timebuf); system(buf); sprintf(buf,"mv %s%s.tgz ../backup", DB_NAME, timebuf); system(buf); mudtime.backup = current_time; }
void gain_exp_regardless(struct char_data * ch, int gain) { int is_altered = FALSE; int num_levels = 0; GET_EXP(ch) += gain; if (GET_EXP(ch) < 0) GET_EXP(ch) = 0; if (!IS_NPC(ch)) { while (GET_LEVEL(ch) < LVL_IMPL && GET_EXP(ch) >= level_exp(GET_CLASS(ch), GET_LEVEL(ch) + 1)) { GET_LEVEL(ch) += 1; num_levels++; advance_level(ch); is_altered = TRUE; } if (is_altered) { sprintf(buf, "%s advanced %d level%s to level %d.", GET_NAME(ch), num_levels, num_levels == 1 ? "" : "s", GET_LEVEL(ch)); mudlog(buf, BRF, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE); if (num_levels == 1) send_to_char("You rise a level!\r\n", ch); else { sprintf(buf, "You rise %d levels!\r\n", num_levels); send_to_char(buf, ch); } set_title(ch, NULL); check_autowiz(ch); } } }
int BestThiefClass(struct char_data *ch) { if (GET_LEVEL(ch, THIEF_LEVEL_IND)) return(THIEF_LEVEL_IND); if (GET_LEVEL(ch, MONK_LEVEL_IND)) return(MONK_LEVEL_IND); if (GET_LEVEL(ch, PSI_LEVEL_IND)) return(PSI_LEVEL_IND); if (GET_LEVEL(ch, MAGE_LEVEL_IND)) return(MAGE_LEVEL_IND); if (GET_LEVEL(ch, SORCERER_LEVEL_IND)) return(SORCERER_LEVEL_IND); if (GET_LEVEL(ch, WARRIOR_LEVEL_IND)) return(WARRIOR_LEVEL_IND); if (GET_LEVEL(ch, BARBARIAN_LEVEL_IND)) return(BARBARIAN_LEVEL_IND); if (GET_LEVEL(ch, RANGER_LEVEL_IND)) return(RANGER_LEVEL_IND); if (GET_LEVEL(ch, PALADIN_LEVEL_IND)) return(PALADIN_LEVEL_IND); if (GET_LEVEL(ch, DRUID_LEVEL_IND)) return(DRUID_LEVEL_IND); if (GET_LEVEL(ch, CLERIC_LEVEL_IND)) return(CLERIC_LEVEL_IND); mudlog( LOG_SYSERR, "Character %s has no recognized class.", GET_NAME( ch ) ); assert(0); return(1); }