bool quest_wolves_death_hook(char *fmt) { int i, mcnt = 0; if (p_ptr->inside_quest != QUEST_WOLVES) return FALSE; /* Process the monsters (backwards) */ for (i = m_max - 1; i >= 1; i--) { /* Access the monster */ monster_type *m_ptr = &m_list[i]; /* Ignore "dead" monsters */ if (!m_ptr->r_idx) continue; if (m_ptr->status <= MSTATUS_ENEMY) mcnt++; } /* Nobody left ? */ if (mcnt <= 1) { quest[p_ptr->inside_quest].status = QUEST_STATUS_COMPLETED; del_hook(HOOK_MONSTER_DEATH, quest_wolves_death_hook); del_hook(HOOK_GEN_QUEST, quest_wolves_gen_hook); process_hooks_restart = TRUE; cmsg_print(TERM_YELLOW, "Lothlorien is safer now."); return (FALSE); } return FALSE; }
bool quest_invasion_turn_hook(char *fmt) { bool old_quick_messages = quick_messages; if (cquest.status != QUEST_STATUS_UNTAKEN) return (FALSE); if (p_ptr->lev < 45) return (FALSE); /* Wait until the end of the current quest */ if (p_ptr->inside_quest) return ( FALSE); /* Wait until the end of the astral mode */ if (p_ptr->astral) return ( FALSE); /* Ok give the quest */ quick_messages = FALSE; cmsg_print(TERM_YELLOW, "A Thunderlord appears in front of you and says:"); cmsg_print(TERM_YELLOW, "'Hello, noble hero. I am Liron, rider of Tolan. Turgon, King of Gondolin sent me.'"); cmsg_print(TERM_YELLOW, "'Gondolin is being invaded; he needs your help now or everything will be lost.'"); cmsg_print(TERM_YELLOW, "'I can bring you to Gondolin, but we must go now.'"); /* This is SO important a question that flush pending inputs */ flush(); if (!get_check("Will you come?")) { cmsg_print(TERM_YELLOW, "'Turgon overestimated you... Now Gondolin will fall.'"); cmsg_print(TERM_YELLOW, "'I will return alone and die there. May you be doomed!'"); cquest.status = QUEST_STATUS_FAILED; town_info[2].destroyed = TRUE; quick_messages = old_quick_messages; del_hook(HOOK_END_TURN, quest_invasion_turn_hook); process_hooks_restart = TRUE; return (FALSE); } cmsg_print(TERM_YELLOW, "'You made the right decision! Quickly, jump on Tolan!'"); cmsg_print(TERM_YELLOW, "'Here we are: Gondolin. You must speak with Turgon now.'"); p_ptr->wild_mode = FALSE; p_ptr->wilderness_x = 49; p_ptr->wilderness_y = 11; p_ptr->town_num = 2; p_ptr->oldpx = p_ptr->px = 117; p_ptr->oldpy = p_ptr->py = 24; dun_level = 0; p_ptr->leaving = TRUE; cmsg_print(TERM_YELLOW, "'Turgon hails you.'"); quest_describe(QUEST_INVASION); cquest.status = QUEST_STATUS_TAKEN; quick_messages = old_quick_messages; quest_invasion_init_hook(QUEST_INVASION); del_hook(HOOK_END_TURN, quest_invasion_turn_hook); process_hooks_restart = TRUE; return (FALSE); }
bool quest_spider_death_hook(char *fmt) { int i, mcnt = 0; if (p_ptr->inside_quest != QUEST_SPIDER) return FALSE; for (i = m_max - 1; i >= 1; i--) { /* Access the monster */ monster_type *m_ptr = &m_list[i]; /* Ignore "dead" monsters */ if (!m_ptr->r_idx) continue; if (m_ptr->status <= MSTATUS_ENEMY) mcnt++; } if (mcnt <= 1) { cmsg_print(TERM_YELLOW, "The forest is now safer, thanks to you."); /* Yavanna LOVES saving forests */ GOD(GOD_YAVANNA) { cmsg_print(TERM_L_GREEN, "You feel the gentle touch of Yavanna, as she smiles at you."); inc_piety(GOD_YAVANNA, 6000); } cquest.status = QUEST_STATUS_COMPLETED; del_hook(HOOK_MONSTER_DEATH, quest_spider_death_hook); process_hooks_restart = TRUE; return (FALSE); }
static char *channels_close() { write_channels(); free_udef(udef); if (lastdeletedmask) nfree(lastdeletedmask); rem_builtins(H_chon, my_chon); rem_builtins(H_dcc, C_dcc_irc); rem_tcl_commands(channels_cmds); rem_tcl_strings(my_tcl_strings); rem_tcl_ints(my_tcl_ints); rem_tcl_coups(mychan_tcl_coups); del_hook(HOOK_USERFILE, (Function) channels_writeuserfile); del_hook(HOOK_BACKUP, (Function) backup_chanfile); del_hook(HOOK_REHASH, (Function) channels_rehash); del_hook(HOOK_PRE_REHASH, (Function) channels_prerehash); del_hook(HOOK_MINUTELY, (Function) check_expired_bans); del_hook(HOOK_MINUTELY, (Function) check_expired_exempts); del_hook(HOOK_MINUTELY, (Function) check_expired_invites); Tcl_UntraceVar(interp, "global-chanset", TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS, traced_globchanset, NULL); rem_help_reference("channels.help"); rem_help_reference("chaninfo.help"); module_undepend(MODULE_NAME); return NULL; }
void check_minutely() { minutes++; if (minutes >= next_minutes) { /* We're down to zero minutes. Now do the seconds. */ del_hook(HOOK_MINUTELY, (Function) check_minutely); add_hook(HOOK_SECONDLY, (Function) check_secondly); } }
static char *dns_close() { int i; del_hook(HOOK_DNS_HOSTBYIP, (Function) dns_lookup); del_hook(HOOK_DNS_IPBYHOST, (Function) dns_forward); del_hook(HOOK_SECONDLY, (Function) dns_check_expires); for (i = 0; i < dcc_total; i++) { if (dcc[i].type == &DCC_DNS && dcc[i].sock == resfd) { killsock(dcc[i].sock); lostdcc(i); break; } } dns_free_cache(); module_undepend(MODULE_NAME); return NULL; }
static char *irc_close() { struct chanset_t *chan; /* Force bot to part all channels */ dprintf(DP_MODE, "JOIN 0\n"); for (chan = chanset; chan; chan = chan->next) clear_channel(chan, 1); del_bind_table(H_topc); del_bind_table(H_splt); del_bind_table(H_sign); del_bind_table(H_rejn); del_bind_table(H_part); del_bind_table(H_nick); del_bind_table(H_mode); del_bind_table(H_kick); del_bind_table(H_join); del_bind_table(H_pubm); del_bind_table(H_pub); del_bind_table(H_need); rem_tcl_strings(mystrings); rem_tcl_ints(myints); rem_builtins(H_dcc, irc_dcc); rem_builtins(H_msg, C_msg); rem_builtins(H_raw, irc_raw); rem_tcl_commands(tclchan_cmds); rem_help_reference("irc.help"); del_hook(HOOK_MINUTELY, (Function) check_expired_chanstuff); del_hook(HOOK_5MINUTELY, (Function) status_log); del_hook(HOOK_ADD_MODE, (Function) real_add_mode); del_hook(HOOK_IDLE, (Function) flush_modes); Tcl_UntraceVar(interp, "rfc-compliant", TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS, traced_rfccompliant, NULL); Tcl_UntraceVar(interp, "net-type", TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS, traced_nettype, NULL); module_undepend(MODULE_NAME); return NULL; }
bool quest_poison_drop_hook(char *fmt) { s32b mcnt = 0, i, x, y, o_idx; object_type *o_ptr; o_idx = get_next_arg(fmt); o_ptr = &p_ptr->inventory[o_idx]; if (cquest.status != QUEST_STATUS_TAKEN) return FALSE; if (p_ptr->wilderness_y != wild_locs[cquest.data[0]][0]) return FALSE; if (p_ptr->wilderness_x != wild_locs[cquest.data[0]][1]) return FALSE; if (p_ptr->wild_mode) return FALSE; if (o_ptr->tval != TV_POTION2) return FALSE; if (o_ptr->sval != SV_POTION2_CURE_WATER) return FALSE; for (i = m_max - 1; i >= 1; i--) { /* Access the monster */ monster_type *m_ptr = &m_list[i]; /* Ignore "dead" monsters */ if (!m_ptr->r_idx) continue; if (m_ptr->status <= MSTATUS_NEUTRAL) mcnt++; } if (mcnt < 10) { for (x = 1; x < cur_wid - 1; x++) for (y = 1; y < cur_hgt - 1; y++) { if (!in_bounds(y, x)) continue; if (cave[y][x].feat == FEAT_TAINTED_WATER) cave_set_feat(y, x, FEAT_SHAL_WATER); } cmsg_print(TERM_YELLOW, "Well done! The water seems to be clean now."); cquest.status = QUEST_STATUS_COMPLETED; del_hook(HOOK_DROP, quest_poison_drop_hook); process_hooks_restart = TRUE; return FALSE; } else { msg_print("There are too many monsters left to cure the water."); return TRUE; } return FALSE; }
static char *notes_close() { p_tcl_bind_list H_temp; rem_tcl_ints(notes_ints); rem_tcl_strings(notes_strings); rem_tcl_commands(notes_tcls); if ((H_temp = find_bind_table("msg"))) rem_builtins(H_temp, notes_msgs); if ((H_temp = find_bind_table("join"))) rem_builtins(H_temp, notes_join); rem_builtins(H_dcc, notes_cmds); rem_builtins(H_chon, notes_chon); rem_builtins(H_away, notes_away); rem_builtins(H_nkch, notes_nkch); rem_builtins(H_load, notes_load); rem_help_reference("notes.help"); del_hook(HOOK_MATCH_NOTEREJ, (Function) match_note_ignore); del_hook(HOOK_HOURLY, (Function) notes_hourly); del_entry_type(&USERENTRY_FWD); del_lang_section("notes"); module_undepend(MODULE_NAME); return NULL; }
void check_secondly() { seconds++; if (seconds >= next_seconds) { /* DING! */ del_hook(HOOK_SECONDLY, (Function) check_secondly); send_uptime(); minutes = 0; /* Reset for the next countdown. */ seconds = 0; next_minutes = rand() % update_interval; next_seconds = rand() % 59; next_update = (time_t) ((time(NULL) / 60 * 60) + (next_minutes * 60) + next_seconds); /* Go back to checking every minute. */ add_hook(HOOK_MINUTELY, (Function) check_minutely); } }
bool quest_invasion_stair_hook(char *fmt) { cptr down; down = get_next_arg_str(fmt); if (p_ptr->inside_quest != QUEST_INVASION) return FALSE; if (cave[p_ptr->py][p_ptr->px].feat != FEAT_LESS) return TRUE; if (!strcmp(down, "up")) { if (cquest.status == QUEST_STATUS_FAILED) { cmsg_print(TERM_YELLOW, "The armies of Morgoth totally devastated Gondolin, leaving nothing but ruins..."); } else if (cquest.status == QUEST_STATUS_COMPLETED) { cmsg_print(TERM_YELLOW, "Turgon appears before you and speaks:"); cmsg_print(TERM_YELLOW, "'I will never be able to thank you enough.'"); cmsg_print(TERM_YELLOW, "'My most powerful mages will cast a powerful spell for you, giving you extra life.'"); p_ptr->hp_mod += 150; p_ptr->update |= (PU_HP); cquest.status = QUEST_STATUS_FINISHED; } else { /* Flush input */ flush(); if (!get_check("Really abandon the quest?")) return TRUE; cmsg_print(TERM_YELLOW, "You flee away from Maeglin and his army..."); cquest.status = QUEST_STATUS_FAILED; town_info[2].destroyed = TRUE; } del_hook(HOOK_STAIR, quest_invasion_stair_hook); process_hooks_restart = TRUE; return (FALSE); } return TRUE; }
bool quest_invasion_death_hook(char *fmt) { s32b r_idx, m_idx; m_idx = get_next_arg(fmt); r_idx = m_list[m_idx].r_idx; if (p_ptr->inside_quest != QUEST_INVASION) return FALSE; if (r_idx == test_monster_name("Maeglin, the Traitor of Gondolin")) { cmsg_print(TERM_YELLOW, "You did it! Gondolin will remain hidden."); cquest.status = QUEST_STATUS_COMPLETED; del_hook(HOOK_MONSTER_DEATH, quest_invasion_death_hook); process_hooks_restart = TRUE; return (FALSE); } return FALSE; }
bool quest_poison_quest_hook(char *fmt) { object_type forge, *q_ptr; s32b q_idx; q_idx = get_next_arg(fmt); if (q_idx != QUEST_POISON) return FALSE; q_ptr = &forge; object_prep(q_ptr, lookup_kind(TV_POTION2, SV_POTION2_CURE_WATER)); q_ptr->number = 99; object_aware(q_ptr); object_known(q_ptr); q_ptr->ident |= IDENT_STOREB; q_ptr->note = quark_add("quest"); (void)inven_carry(q_ptr, FALSE); del_hook(HOOK_INIT_QUEST, quest_poison_quest_hook); process_hooks_restart = TRUE; return FALSE; }
bool quest_poison_gen_hook(char *fmt) { int cy = 1, cx = 1, x, y, try = 10000, r_idx; bool (*old_get_mon_num_hook)(int r_idx); if (cquest.status != QUEST_STATUS_TAKEN) return FALSE; if (p_ptr->wilderness_y != wild_locs[cquest.data[0]][0]) return FALSE; if (p_ptr->wilderness_x != wild_locs[cquest.data[0]][1]) return FALSE; if (p_ptr->wild_mode) return FALSE; /* Find a good position */ while (try) { /* Get a random spot */ cy = randint(cur_hgt - 24) + 22; cx = randint(cur_wid - 34) + 32; /* Is it a good spot ? */ if (cave_empty_bold(cy, cx)) break; /* One less try */ try--; } /* Place the baddies */ /* Backup the old hook */ old_get_mon_num_hook = get_mon_num_hook; /* Require "okay" monsters */ get_mon_num_hook = create_molds_hook; /* Prepare allocation table */ get_mon_num_prep(); /* Pick a monster, using the level calculation */ for (x = cx - 25; x <= cx + 25; x++) for (y = cy - 25; y <= cy + 25; y++) { if (!in_bounds(y, x)) continue; if (distance(cy, cx, y, x) > 25) continue; if (magik(80) && ((cave[y][x].feat == FEAT_DEEP_WATER) || (cave[y][x].feat == FEAT_SHAL_WATER))) cave_set_feat(y, x, FEAT_TAINTED_WATER); if (distance(cy, cx, y, x) > 10) continue; if (magik(60)) { int m_idx; r_idx = get_mon_num(30); m_idx = place_monster_one(y, x, r_idx, 0, FALSE, MSTATUS_ENEMY); /* Sometimes make it up some levels */ if (magik(80) && m_idx) { monster_type *m_ptr = &m_list[m_idx]; if (m_ptr->level < p_ptr->lev) { m_ptr->exp = MONSTER_EXP(m_ptr->level + randint(p_ptr->lev - m_ptr->level)); monster_check_experience(m_idx, TRUE); } } } } /* Reset restriction */ get_mon_num_hook = old_get_mon_num_hook; /* Prepare allocation table */ get_mon_num_prep(); return FALSE; } bool quest_poison_finish_hook(char *fmt) { object_type forge, *q_ptr; s32b q_idx; q_idx = get_next_arg(fmt); if (q_idx != QUEST_POISON) return FALSE; c_put_str(TERM_YELLOW, "The water is clean again! Thank you so much.", 8, 0); c_put_str(TERM_YELLOW, "The beautiful Mallorns are safe. Take this as a proof of our gratitude.", 9, 0); q_ptr = &forge; object_prep(q_ptr, lookup_kind(TV_DRAG_ARMOR, SV_DRAGON_BLUE)); q_ptr->found = OBJ_FOUND_REWARD; q_ptr->number = 1; q_ptr->name2 = EGO_ELVENKIND; apply_magic(q_ptr, 1, FALSE, FALSE, FALSE); object_aware(q_ptr); object_known(q_ptr); q_ptr->ident |= IDENT_STOREB; (void)inven_carry(q_ptr, FALSE); /* Continue the plot */ *(quest[q_idx].plot) = QUEST_NULL; del_hook(HOOK_QUEST_FINISH, quest_poison_finish_hook); process_hooks_restart = TRUE; return TRUE; }