struct obj_data *unequip_char(struct char_data *ch, int pos) { int j; struct obj_data *obj; if ((pos < 0 || pos >= NUM_WEARS) || GET_EQ(ch, pos) == NULL) { core_dump(); return (NULL); } obj = GET_EQ(ch, pos); obj->worn_by = NULL; obj->worn_on = -1; if (GET_OBJ_TYPE(obj) == ITEM_ARMOR) GET_AC(ch) += apply_ac(ch, pos); if (IN_ROOM(ch) != NOWHERE) { if (pos == WEAR_LIGHT && GET_OBJ_TYPE(obj) == ITEM_LIGHT) if (GET_OBJ_VAL(obj, 2)) /* if light is ON */ world[IN_ROOM(ch)].light--; } else log("SYSERR: IN_ROOM(ch) = NOWHERE when unequipping char %s.", GET_NAME(ch)); GET_EQ(ch, pos) = NULL; for (j = 0; j < MAX_OBJ_AFFECT; j++) affect_modify_ar(ch, obj->affected[j].location, obj->affected[j].modifier, GET_OBJ_AFFECT(obj), FALSE); affect_total(ch); return (obj); }
/* Function: get_victim. Returns a pointer to a randomly chosen character in * the same room, fighting someone in the castle staff. Used by BANZAII-ing * characters and King Welmar... */ struct char_data *get_victim(struct char_data *chAtChar) { struct char_data *ch; int iNum_bad_guys = 0, iVictim; for (ch = world[IN_ROOM(chAtChar)].people; ch; ch = ch->next_in_room) if (FIGHTING(ch) && member_of_staff(FIGHTING(ch))) iNum_bad_guys++; if (!iNum_bad_guys) return (NULL); iVictim = rand_number(0, iNum_bad_guys); /* How nice, we give them a chance */ if (!iVictim) return (NULL); iNum_bad_guys = 0; for (ch = world[IN_ROOM(chAtChar)].people; ch; ch = ch->next_in_room) { if (FIGHTING(ch) == NULL) continue; if (!member_of_staff(FIGHTING(ch))) continue; if (++iNum_bad_guys != iVictim) continue; return (ch); } return (NULL); }
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; }
/* * Every spell that affects the group should run through here * perform_mag_groups contains the switch statement to send us to the right * magic. * * group spells affect everyone grouped with the caster who is in the room, * caster last. * * To add new group spells, you shouldn't have to change anything in * mag_groups -- just add a new case to perform_mag_groups. */ void mag_groups(int level, struct char_data *ch, int spellnum, int savetype) { struct char_data *tch, *k; struct follow_type *f, *f_next; if (ch == NULL) return; if (!AFF_FLAGGED(ch, AFF_GROUP)) return; if (ch->master != NULL) k = ch->master; else k = ch; for (f = k->followers; f; f = f_next) { f_next = f->next; tch = f->follower; if (IN_ROOM(tch) != IN_ROOM(ch)) continue; if (!AFF_FLAGGED(tch, AFF_GROUP)) continue; if (ch == tch) continue; perform_mag_groups(level, ch, tch, spellnum, savetype); } if ((k != ch) && AFF_FLAGGED(k, AFF_GROUP)) perform_mag_groups(level, ch, k, spellnum, savetype); perform_mag_groups(level, ch, ch, spellnum, savetype); }
/* place a character in a room */ void char_to_room(struct char_data *ch, room_rnum room) { if (ch == NULL || room == NOWHERE || room > top_of_world) log("SYSERR: Illegal value(s) passed to char_to_room. (Room: %d/%d Ch: %p", room, top_of_world, ch); else { ch->next_in_room = world[room].people; world[room].people = ch; IN_ROOM(ch) = room; autoquest_trigger_check(ch, 0, 0, AQ_ROOM_FIND); autoquest_trigger_check(ch, 0, 0, AQ_MOB_FIND); if (GET_EQ(ch, WEAR_LIGHT)) if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT) if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2)) /* Light ON */ world[room].light++; /* Stop fighting now, if we left. */ if (FIGHTING(ch) && IN_ROOM(ch) != IN_ROOM(FIGHTING(ch))) { stop_fighting(FIGHTING(ch)); stop_fighting(ch); } } }
void hunt_victim(struct char_data *ch) { int dir; byte found; struct char_data *tmp; if (!ch || !HUNTING(ch) || FIGHTING(ch)) return; /* make sure the char still exists */ for (found = FALSE, tmp = character_list; tmp && !found; tmp = tmp->next) if (HUNTING(ch) == tmp) found = TRUE; if (!found) { do_say(ch, "Damn! My prey is gone!", 0, 0); HUNTING(ch) = NULL; return; } if ((dir = find_first_step(IN_ROOM(ch), IN_ROOM(HUNTING(ch)))) < 0) { sprintf(buf, "Damn! I lost %s!", HMHR(HUNTING(ch))); do_say(ch, buf, 0, 0); HUNTING(ch) = NULL; } else { perform_move(ch, dir, 1); if (IN_ROOM(ch) == IN_ROOM(HUNTING(ch))) hit(ch, HUNTING(ch), TYPE_UNDEFINED); } }
struct char_data *get_char_world_vis(struct char_data *ch, char *name, int *number) { struct char_data *i; int num; if (!number) { number = # num = get_number(&name); } if ((i = get_char_room_vis(ch, name, number)) != NULL) return (i); if (*number == 0) return get_player_vis(ch, name, NULL, 0); for (i = character_list; i && *number; i = i->next) { if (IN_ROOM(ch) == IN_ROOM(i)) continue; if (!isname(name, i->player.name)) continue; if (!CAN_SEE(ch, i)) continue; if (--(*number) != 0) continue; return (i); } return (NULL); }
int perform_move(struct char_data *ch, int dir, int need_specials_check) { room_rnum was_in; struct follow_type *k, *next; if (ch == NULL || dir < 0 || dir >= NUM_OF_DIRS || FIGHTING(ch)) return (0); else if ((!EXIT(ch, dir) && !buildwalk(ch, dir)) || EXIT(ch, dir)->to_room == NOWHERE) send_to_char(ch, "Alas, you cannot go that way...\r\n"); else if (EXIT_FLAGGED(EXIT(ch, dir), EX_CLOSED)) { if (EXIT(ch, dir)->keyword) send_to_char(ch, "The %s seems to be closed.\r\n", fname(EXIT(ch, dir)->keyword)); else send_to_char(ch, "It seems to be closed.\r\n"); } else { if (!ch->followers) return (do_simple_move(ch, dir, need_specials_check)); was_in = IN_ROOM(ch); if (!do_simple_move(ch, dir, need_specials_check)) return (0); for (k = ch->followers; k; k = next) { next = k->next; if ((IN_ROOM(k->follower) == was_in) && (GET_POS(k->follower) >= POS_STANDING)) { act("You follow $N.\r\n", FALSE, k->follower, 0, ch, TO_CHAR); perform_move(k->follower, dir, 1); } } return (1); } return (0); }
/* Here follows high-level versions of some earlier routines, ie functions * which incorporate the actual player-data */ struct char_data *get_player_vis(struct char_data *ch, char *name, int *number, int inroom) { struct char_data *i; int num; if (!number) { number = # num = get_number(&name); } for (i = character_list; i; i = i->next) { if (IS_NPC(i)) continue; if (inroom == FIND_CHAR_ROOM && IN_ROOM(i) != IN_ROOM(ch)) continue; if (str_cmp(i->player.name, name)) /* If not same, continue */ continue; if (!CAN_SEE(ch, i)) continue; if (--(*number) != 0) continue; return (i); } return (NULL); }
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 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 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; }
void make_corpse(struct char_data * ch) { struct obj_data *corpse, *o; struct obj_data *money; int i; corpse = create_obj(); corpse->item_number = NOTHING; IN_ROOM(corpse) = NOWHERE; corpse->name = str_dup("corpse"); sprintf(buf2, "The corpse of %s is lying here.", GET_NAME(ch)); corpse->description = str_dup(buf2); sprintf(buf2, "the corpse of %s", GET_NAME(ch)); corpse->short_description = str_dup(buf2); GET_OBJ_TYPE(corpse) = ITEM_CONTAINER; GET_OBJ_WEAR(corpse) = ITEM_WEAR_TAKE; GET_OBJ_EXTRA(corpse) = ITEM_NODONATE; GET_OBJ_VAL(corpse, 0) = 0; /* You can't store stuff in a corpse */ GET_OBJ_VAL(corpse, 3) = 1; /* corpse identifier */ GET_OBJ_WEIGHT(corpse) = GET_WEIGHT(ch) + IS_CARRYING_W(ch); GET_OBJ_RENT(corpse) = 100000; if (IS_NPC(ch)) GET_OBJ_TIMER(corpse) = max_npc_corpse_time; else GET_OBJ_TIMER(corpse) = max_pc_corpse_time; /* transfer character's inventory to the corpse */ corpse->contains = ch->carrying; for (o = corpse->contains; o != NULL; o = o->next_content) o->in_obj = corpse; object_list_new_owner(corpse, NULL); /* transfer character's equipment to the corpse */ for (i = 0; i < NUM_WEARS; i++) if (GET_EQ(ch, i)) { remove_otrigger(GET_EQ(ch, i), ch); obj_to_obj(unequip_char(ch, i), corpse); } /* transfer gold */ if (GET_GOLD(ch) > 0) { /* following 'if' clause added to fix gold duplication loophole */ if (IS_NPC(ch) || (!IS_NPC(ch) && ch->desc)) { money = create_money(GET_GOLD(ch)); obj_to_obj(money, corpse); } GET_GOLD(ch) = 0; } ch->carrying = NULL; IS_CARRYING_N(ch) = 0; IS_CARRYING_W(ch) = 0; obj_to_room(corpse, IN_ROOM(ch)); }
int weather_skill_modifier(CHAR_DATA * ch, int skillnum, int type, int value) { int modi = value, sky = weather_info.sky; if (IS_NPC(ch) || SECT(IN_ROOM(ch)) == SECT_INSIDE || SECT(IN_ROOM(ch)) == SECT_CITY || ROOM_FLAGGED(IN_ROOM(ch), ROOM_INDOORS) || ROOM_FLAGGED(IN_ROOM(ch), ROOM_NOWEATHER)) return (modi); sky = GET_ROOM_SKY(IN_ROOM(ch)); switch (type) { case GAPPLY_SKILL_SUCCESS: switch (skillnum) { case SKILL_THAC0: if (weather_info.sunlight == SUN_SET || weather_info.sunlight == SUN_DARK) { switch (sky) { case SKY_CLOUDLESS: modi = modi * 90 / 100; break; case SKY_CLOUDY: modi = modi * 80 / 100; break; case SKY_RAINING: modi = modi * 70 / 30; break; } } else { switch (sky) { case SKY_CLOUDY: modi = modi * number(85, 95) / 100; break; case SKY_RAINING: modi = modi * number(75, 85) / 100; break; } } break; } break; } if (WAITLESS(ch)) modi = MAX(modi, value); return (modi); }
/* returns the real room number that the object or object's carrier is in */ room_rnum obj_room(obj_data *obj) { if (IN_ROOM(obj) != NOWHERE) return IN_ROOM(obj); else if (obj->carried_by) return IN_ROOM(obj->carried_by); else if (obj->worn_by) return IN_ROOM(obj->worn_by); else if (obj->in_obj) return obj_room(obj->in_obj); else return NOWHERE; }
void send_to_zone(char *messg, int zone_rnum) { struct descriptor_data *i; if (!messg || !*messg) return; for (i = descriptor_list; i; i = i->next) if (!i->connected && i->character && AWAKE(i->character) && (IN_ROOM(i->character) != NOWHERE) && (world[IN_ROOM(i->character)].zone == zone_rnum)) write_to_output(i, TRUE, "%s", messg); }
void send_to_zone(char *messg, int zone_rnum) { struct descriptor_data *i; if (!messg || !*messg) return; for (i = descriptor_list; i; i = i->next) if (STATE(i) == CON_PLAYING && i->character && AWAKE(i->character) && (IN_ROOM(i->character) != NOWHERE) && (world[IN_ROOM(i->character)].zone == zone_rnum)) SEND_TO_Q(messg, i); }
void equip_char(struct char_data *ch, struct obj_data *obj, int pos) { int j; if (pos < 0 || pos >= NUM_WEARS) { core_dump(); return; } if (GET_EQ(ch, pos)) { log("SYSERR: Char is already equipped: %s, %s", GET_NAME(ch), obj->short_description); return; } if (obj->carried_by) { log("SYSERR: EQUIP: Obj is carried_by when equip."); return; } if (IN_ROOM(obj) != NOWHERE) { log("SYSERR: EQUIP: Obj is in_room when equip."); return; } if (invalid_align(ch, obj) || invalid_class(ch, obj)) { act("You are zapped by $p and instantly let go of it.", FALSE, ch, obj, 0, TO_CHAR); act("$n is zapped by $p and instantly lets go of it.", FALSE, ch, obj, 0, TO_ROOM); /* Changed to drop in inventory instead of the ground. */ obj_to_char(obj, ch); return; } GET_EQ(ch, pos) = obj; obj->worn_by = ch; obj->worn_on = pos; if (GET_OBJ_TYPE(obj) == ITEM_ARMOR) GET_AC(ch) -= apply_ac(ch, pos); if (IN_ROOM(ch) != NOWHERE) { if (pos == WEAR_LIGHT && GET_OBJ_TYPE(obj) == ITEM_LIGHT) if (GET_OBJ_VAL(obj, 2)) /* if light is ON */ world[IN_ROOM(ch)].light++; } else log("SYSERR: IN_ROOM(ch) = NOWHERE when equipping char %s.", GET_NAME(ch)); for (j = 0; j < MAX_OBJ_AFFECT; j++) affect_modify_ar(ch, obj->affected[j].location, obj->affected[j].modifier, GET_OBJ_AFFECT(obj), TRUE); affect_total(ch); }
/** * @param obj_data *obj The item. * @return room_data* the real room that the object or object's carrier is in */ room_data *obj_room(obj_data *obj) { if (IN_ROOM(obj)) return IN_ROOM(obj); else if (obj->in_vehicle) { return IN_ROOM(obj->in_vehicle); } else if (obj->carried_by) return IN_ROOM(obj->carried_by); else if (obj->worn_by) return IN_ROOM(obj->worn_by); else if (obj->in_obj) return obj_room(obj->in_obj); else return NULL; }
/* Do_npc_rescue. Makes ch_hero rescue ch_victim. Used by Tim and Tom. */ int do_npc_rescue(struct char_data *ch_hero, struct char_data *ch_victim) { struct char_data *ch_bad_guy; for (ch_bad_guy = world[IN_ROOM(ch_hero)].people; ch_bad_guy && (FIGHTING(ch_bad_guy) != ch_victim); ch_bad_guy = ch_bad_guy->next_in_room); /* NO WAY I'll rescue the one I'm fighting! */ if (!ch_bad_guy || ch_bad_guy == ch_hero) return (FALSE); act("You bravely rescue $N.\r\n", FALSE, ch_hero, 0, ch_victim, TO_CHAR); act("You are rescued by $N, your loyal friend!\r\n", FALSE, ch_victim, 0, ch_hero, TO_CHAR); act("$n heroically rescues $N.", FALSE, ch_hero, 0, ch_victim, TO_NOTVICT); if (FIGHTING(ch_bad_guy)) stop_fighting(ch_bad_guy); if (FIGHTING(ch_hero)) stop_fighting(ch_hero); set_fighting(ch_hero, ch_bad_guy); set_fighting(ch_bad_guy, ch_hero); return (TRUE); }
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; }
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 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; }
struct char_data *get_char_room_vis(struct char_data *ch, char *name, int *number) { struct char_data *i; int num; if (!number) { number = # num = get_number(&name); } /* JE */ if (!str_cmp(name, "self") || !str_cmp(name, "me")) return (ch); /* 0.<name> means PC with name */ if (*number == 0) return (get_player_vis(ch, name, NULL, FIND_CHAR_ROOM)); for (i = world[IN_ROOM(ch)].people; i && *number; i = i->next_in_room) if (isname(name, i->player.name)) if (CAN_SEE(ch, i)) if (--(*number) == 0) return (i); return (NULL); }
/* manapoint gain per game hour */ int mana_gain(CharData * ch) { int malnourishCount = 0; struct affected_type *hjp, *next; if (IN_ROOM(ch) == -1) return 0; if(!IS_NPC(ch) && ((GET_COND(ch, HUNGER) == 0 && !IS_VAMPIRE(ch)) || GET_COND(ch, THIRST) == 0)) { if(ch->desc && percentSuccess(2)) { if(!affected_by_spell(ch, SKILL_EMACIATED)) add_affect( ch, ch, SKILL_EMACIATED, GET_LEVEL(ch), 0, 0, -1, 0, FALSE, FALSE, FALSE, FALSE); for (hjp = ch->affected; hjp; hjp = next) { next = hjp->next; if (hjp->type == SKILL_EMACIATED_MANA) malnourishCount++; } if(malnourishCount < 18) add_affect( ch, ch, SKILL_EMACIATED_MANA, GET_LEVEL(ch), APPLY_MANA, -MIN(50, GET_MANA(ch)/20), -1, 0, FALSE, FALSE, FALSE, FALSE); } } int base = calcManaBase(ch); int multiplier = calcManaMulti(ch); int bonus = calcManaBonus(ch); int gain = base*multiplier/100 + bonus; if (affected_by_spell(ch, SKILL_POTENCY)) gain *= 5; return (gain); }
/** * Determines the scale level for a vehicle, with a character target as a backup * for unscaled vehicles. * * @param vehicle_data *veh The vehicle to check. * @param char_data *targ Optional: A character target. * @return int A scale level. */ int get_vehicle_scale_level(vehicle_data *veh, char_data *targ) { struct instance_data *inst; int level = 1; room_data *orm = IN_ROOM(veh); if (VEH_SCALE_LEVEL(veh) > 0) { level = VEH_SCALE_LEVEL(veh); } else if (orm && COMPLEX_DATA(orm) && (inst = COMPLEX_DATA(orm)->instance)) { if (inst->level) { level = inst->level; } else if (GET_ADV_MIN_LEVEL(inst->adventure) > 0) { level = GET_ADV_MIN_LEVEL(inst->adventure); } else if (GET_ADV_MAX_LEVEL(inst->adventure) > 0) { level = GET_ADV_MAX_LEVEL(inst->adventure) / 2; // average? } } if (!level && targ) { // backup level = get_approximate_level(targ); } return level; }
/* search the entire world for an object, and return a pointer */ struct obj_data *get_obj_vis(struct char_data *ch, char *name, int *number) { struct obj_data *i; int num; if (!number) { number = # num = get_number(&name); } if (*number == 0) return (NULL); /* scan items carried */ if ((i = get_obj_in_list_vis(ch, name, number, ch->carrying)) != NULL) return (i); /* scan room */ if ((i = get_obj_in_list_vis(ch, name, number, world[IN_ROOM(ch)].contents)) != NULL) return (i); /* ok.. no luck yet. scan the entire obj list */ for (i = object_list; i && *number; i = i->next) if (isname(name, i->name)) if (CAN_SEE_OBJ(ch, i)) if (--(*number) == 0) return (i); return (NULL); }
void update_char_objects(struct char_data *ch) { int i; if (GET_EQ(ch, WEAR_LIGHT) != NULL) if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT) if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2) > 0) { i = --GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2); if (i == 1) { send_to_char(ch, "Your light begins to flicker and fade.\r\n"); act("$n's light begins to flicker and fade.", FALSE, ch, 0, 0, TO_ROOM); } else if (i == 0) { send_to_char(ch, "Your light sputters out and dies.\r\n"); act("$n's light sputters out and dies.", FALSE, ch, 0, 0, TO_ROOM); world[IN_ROOM(ch)].light--; } } for (i = 0; i < NUM_WEARS; i++) if (GET_EQ(ch, i)) update_object(GET_EQ(ch, i), 2); if (ch->carrying) update_object(ch->carrying, 1); }
/* returns the real room number, or NOWHERE if not found or invalid */ room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr) { int tmp; room_rnum location; char_data *target_mob; obj_data *target_obj; char roomstr[MAX_INPUT_LENGTH]; one_argument(rawroomstr, roomstr); if (!*roomstr) return NOWHERE; if (isdigit(*roomstr) && !strchr(roomstr, '.')) { tmp = atoi(roomstr); if ((location = real_room(tmp)) == NOWHERE) return NOWHERE; } else if ((target_mob = get_char_by_obj(obj, roomstr))) location = IN_ROOM(target_mob); else if ((target_obj = get_obj_by_obj(obj, roomstr))) { if (IN_ROOM(target_obj) != NOWHERE) location = IN_ROOM(target_obj); else return NOWHERE; } else return NOWHERE; /* a room has been found. Check for permission */ if (ROOM_FLAGGED(location, ROOM_GODROOM) || #ifdef ROOM_IMPROOM ROOM_FLAGGED(location, ROOM_IMPROOM) || #endif ROOM_FLAGGED(location, ROOM_HOUSE)) return NOWHERE; if (ROOM_FLAGGED(location, ROOM_PRIVATE) && world[location].people && world[location].people->next_in_room) return NOWHERE; return location; }