1/* 2 * 3 * Copyright (C) 2006 The Exult Team 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * 20 * This source file contains modified code for Mariah to allow her 21 * to cast spells and join after the tetrahedron generator is destroyed. 22 * 23 * Author: Marzo Junior 24 * Last Modified: 2006-02-27 25 */ 26 27extern void mariahSellSpells 0x8BB (var var0000); 28extern void mariahSellReagents 0x8BC (var var0000); 29 30void Mariah object#(0x499) () 31{ 32 static var did_post_tetrahedron; 33 if (event == DOUBLECLICK) 34 { 35 var avatartitle = getPoliteTitle(); 36 var avatarname = getAvatarName(); 37 var party = UI_get_party_list(); 38 39 if (!gflags[MET_MARIAH]) 40 { 41 MARIAH.say("You see your old friend Mariah."); 42 gflags[MET_MARIAH] = true; 43 } 44 else 45 { 46 if (gflags[BROKE_TETRAHEDRON]) 47 MARIAH.say("@Yes, ", avatarname, 48 "? How may I help thee?@ Mariah greets you."); 49 else 50 MARIAH.say("@Yes, ", avatartitle, 51 "?@ Mariah smiles, a trifle too sweetly."); 52 } 53 54 if (!did_post_tetrahedron) 55 { 56 did_post_tetrahedron = true; 57 //Give an exp boost to Mariah, so she won't be so far outclassed by other companions 58 var totalexp; 59 60 //Calculate the average exp of all party members 61 for (npc in party) 62 totalexp = totalexp + npc->get_npc_prop(EXPERIENCE); 63 64 totalexp = totalexp / UI_get_array_size(party); 65 set_npc_prop(EXPERIENCE, totalexp - get_npc_prop(EXPERIENCE)); 66 } 67 68 add(["name", "job", "bye"]); 69 if (gflags[BROKE_TETRAHEDRON]) 70 { 71 if (item in party) 72 { 73 add("leave"); 74 add("Cast spell"); 75 } 76 else 77 add("join"); 78 79 converse (0) 80 { 81 case "name" (remove): 82 if (isNearby(IOLO)) 83 { 84 IOLO.say("@Surely thou dost recognize thine old companion, Mariah?@*"); 85 IOLO.hide(); 86 MARIAH->show_npc_face(0); 87 } 88 else 89 say("@Hast thou already forgotten me, ", avatarname, 90 "? I am Mariah.@"); 91 92 93 case "job": 94 add("spells"); 95 if (item in party) 96 say("@I am one of thy travelling conpanions, ", 97 avatarname, ". I am also a mage, as thou shouldst remember.@"); 98 else if (get_schedule_type() == WAIT) 99 say("@I am waiting to join thy company again.@"); 100 else 101 { 102 say("@I sell spells, reagents, and sometimes a few potions here at the Lycaeum. Dost thou wish to buy any of these, ", 103 avatarname, "?@"); 104 add(["reagents", "potions", "Lycaeum"]); 105 } 106 107 case "Cast spell": 108 var spellbook = get_cont_items(SHAPE_SPELL_SPELLBOOK, -get_npc_number(), FRAME_ANY); 109 if (!spellbook) 110 { 111 // Extra safeguard: 112 spellbook = get_cont_items(SHAPE_SPELL_SPELLBOOK, QUALITY_ANY, 1); 113 if (spellbook) 114 spellbook->set_item_quality(-get_npc_number()); 115 } 116 if (spellbook) 117 { 118 event = DOUBLECLICK; 119 spellbook->spellitem_Spellbook(); 120 } 121 else 122 say("@I would be happy to, but thou hast taken away my spellbook.@"); 123 124 case "join": 125 var partysize = UI_get_array_size(party); 126 if (partysize < 8) 127 { 128 say("@I would be honored to join thee, ", 129 avatartitle, "!@"); 130 add_to_party(); 131 add("leave"); 132 remove("join"); 133 } 134 else 135 say("@I do believe thou dost have enough members in thy group. I shall await until someone leaves and thou dost ask me again.@"); 136 137 case "leave": 138 say("@Dost thou want me to wait here or should I go home?@"); 139 UI_clear_answers(); 140 var choice = askForResponse(["wait here", "go home"]); 141 if (choice == "wait here") 142 { 143 say("@Very well. I shall wait until thou dost return.@*"); 144 remove_from_party(); 145 set_schedule_type(WAIT); 146 abort; 147 } 148 else 149 { 150 say("@I shall obey thy wish. I would be happy to re-join if thou shouldst ask. Fair days ahead, friend ", 151 avatarname, ".@*"); 152 remove_from_party(); 153 set_schedule_type(LOITER); 154 abort; 155 } 156 157 case "spells": 158 mariahSellSpells(MARIAH); 159 160 case "reagents": 161 mariahSellReagents("Reagents"); 162 163 case "potions": 164 say("@I am afraid, ", avatarname, 165 ", that I have a very meager selection.@"); 166 mariahSellReagents("Potions"); 167 168 case "Lycaeum" (remove): 169 say("She shakes her head sadly. @I have not been `myself' for so long that I no longer recognize this town.@ Her eyes widen.", 170 "~~ @There are so many buildings around the Lycaeum now, hast thou seen them?@", 171 "~~She pauses, looking at you.", 172 "~~@By the way, old friend. I assume thou art responsible for returning the ether to its normal state. I thank thee.@"); 173 174 case "bye": 175 say("@Fair days ahead, friend ", avatarname, ".@*"); 176 abort; 177 178 } 179 } 180 else 181 { 182 converse (0) 183 { 184 case "name" (remove): 185 if (isNearby(IOLO)) 186 { 187 IOLO.say("@Surely thou dost recognize thine old companion, Mariah?@*"); 188 IOLO.hide(); 189 MARIAH.say("@Yes, dost thou not recognize me?@ She pauses, glaring at you. @But who art thou, and where are my pastries?@"); 190 } 191 else 192 say("@Yes, thou mayest tell me thy name,@ she says, glancing around the building. @Are not the many books beautiful?@"); 193 194 case "job": 195 say("She smiles. @I have a very important job, I do. My, are not those shelves lovely? So neat and orderly.@ She looks back at you.", 196 "~~@Be careful! The ink wells are full, and the quills so sharp.@ She giggles."); 197 add(["shelves", "ink wells", "quills"]); 198 199 case "shelves" (remove): 200 say("@Are not they the neatest, most orderly, and well-kept shelves thou hast seen? They do an excellent job of maintaining them!@"); 201 add("they"); 202 203 case "ink wells" (remove): 204 say("@They are always so full and ready for use. They are so good about keeping them filled and clean!@"); 205 add("they"); 206 207 case "quills" (remove): 208 say("@Oh, yes, they are quite sharp! Always there when one needs to scribe a missive. They do an excellent job of having many ready at a moment's notice!@"); 209 add("they"); 210 211 case "they" (remove): 212 say("@Yes, they do!@ Her face turns sad. @But I only sell.@"); 213 add("sell"); 214 215 case "sell" (remove): 216 say("@Yes,@ she agrees, @I do indeed sell. I even spell. In fact, I even sell spells! But, if thou desirest reagents, thou art out of luck, for I only sell those during one of the seven weekdays. Wouldst thou like to know which day?", 217 "~~@What a lovely set of books thou must have! I have just the item for thee to match thy shelves -- a potion. If thou wilt buy a spell or reagent from me, I will sell thee a potion for only its normal price!@"); 218 add(["which day", "reagents", "potions"]); 219 220 case "which day" (remove): 221 say("@Why, today. Thou art in luck. Buy a spell.@"); 222 mariahSellSpells(MARIAH); 223 224 case "reagents": 225 mariahSellReagents("Reagents"); 226 227 case "potions": 228 mariahSellReagents("Potions"); 229 230 case "bye": 231 say("@Certainly, come back anytime and buy.@*"); 232 abort; 233 } 234 } 235 } 236 else if (event == PROXIMITY) 237 { 238 if ((MARIAH->get_schedule_type() == LOITER) && !gflags[BROKE_TETRAHEDRON]) 239 { 240 var barks = ["@Where -are- those pastries!@", 241 "@Lovely, lovely shelves!@", 242 "@Lovely, lovely ink wells!@", 243 "@Magic is in the air...@"]; 244 MARIAH->item_say(barks[UI_get_random(UI_get_array_size(barks))]); 245 } 246 else 247 scheduleBarks(MARIAH); 248 } 249} 250