|
| 1 | + |
| 2 | +#event Broke1 "#*#You cannot afford#*#" |
| 3 | +#event Broke2 "#*#You can't afford#*#" |
| 4 | +#event BuyFullInv "#*#Your inventory appears full! How can you buy more?#*#" |
| 5 | +#event Cursor "#*#You may not make a purchase while you have an item on your cursor.#*#" |
| 6 | + |
| 7 | +Sub Main |
| 8 | + /declare MerchTemp int outer 1 |
| 9 | + /declare PackTotal int outer 7 |
| 10 | + /declare PackSlot int outer 1 |
| 11 | + /declare BagSlot int outer 1 |
| 12 | + /declare j int outer |
| 13 | + /declare b int outer 0 |
| 14 | + /declare p int outer 1 |
| 15 | + /declare s int outer -1 |
| 16 | + /declare i int outer |
| 17 | + |
| 18 | + /declare MinLevel int local |
| 19 | + /declare MaxLevel int local |
| 20 | + |
| 21 | + /if (${Defined[Param0]}) { |
| 22 | + /varset MinLevel ${Param0} |
| 23 | + } else { |
| 24 | + /varset MinLevel 1 |
| 25 | + } |
| 26 | + /if (${Defined[Param1]}) { |
| 27 | + /varset MaxLevel ${Param1} |
| 28 | + } else { |
| 29 | + /varset MaxLevel ${Me.Level} |
| 30 | + } |
| 31 | + |
| 32 | + /declare startItem int local 1 |
| 33 | + /varset startItem ${Window[MerchantWnd].Child[MW_ItemList].List[Spell,2]} |
| 34 | + /if (${startItem} == NULL) { |
| 35 | + /varset startItem ${Window[MerchantWnd].Child[MW_ItemList].List[Skill,2]} |
| 36 | + } |
| 37 | + /if (${startItem} == NULL) { |
| 38 | + /varset startItem ${Window[MerchantWnd].Child[MW_ItemList].List[Tome,2]} |
| 39 | + } |
| 40 | + |/for MerchTemp ${Window[MerchantWnd].Child[MW_ItemList].List[Spell,2]} to ${Window[MerchantWnd].Child[MW_ItemList].Items} |
| 41 | + /for MerchTemp ${startItem} to ${Window[MerchantWnd].Child[MW_ItemList].Items} |
| 42 | + |
| 43 | + /notify MerchantWnd ItemList listselect ${MerchTemp} |
| 44 | + /delay 5 |
| 45 | + /notify MerchantWnd Itemlist rightmouse 1 |
| 46 | + /delay 5 |
| 47 | + |
| 48 | + /if (${DisplayItem.Name.Find[Spell]} == 1 || ${DisplayItem.Name.Find[Skill]} == 1 || ${DisplayItem.Name.Find[Tome]} == 1) { |
| 49 | + /if ( ${MinLevel} <= ${DisplayItem.Spell.Level} && ${DisplayItem.Spell.Level} <= ${MaxLevel} ) { |
| 50 | + /if ((${Me.Book[${DisplayItem.Spell}]}==NULL) && (${FindItem[${DisplayItem.Name}].ID}==NULL) && (${FindItemBank[${DisplayItem.Name}].ID}==NULL) && (${Me.CombatAbility[${DisplayItem.Spell}]})==NULL) { |
| 51 | + /echo Buying ${DisplayItem.Spell} for level ${DisplayItem.Spell.Level} |
| 52 | + /buyitem 1 |
| 53 | + |/doevents |
| 54 | + /delay 3s |
| 55 | + /if (${Cursor.ID}) /call Scribe_Spell |
| 56 | + |
| 57 | + } else /if (!${FindItemBank[${DisplayItem.Name}].ID}==NULL) { |
| 58 | + /echo ${Me.CleanName} has ${DisplayItem.Name} for level ${DisplayItem.Spell.Level} in the bank. |
| 59 | + } else /if (!${Me.Book[${DisplayItem.Spell}]}==NULL) { |
| 60 | + /echo ${Me.CleanName} has ${DisplayItem.Name} for level ${DisplayItem.Spell.Level} scribed. |
| 61 | + } else /if (!${FindItem[${DisplayItem.Name}].ID}==NULL) { |
| 62 | + /echo ${Me.CleanName} has ${DisplayItem.Name} for level ${DisplayItem.Spell.Level} in inventory. |
| 63 | + } |
| 64 | + } |
| 65 | + } else /if (!${DisplayItem.Name.Find[Spell]}) { |
| 66 | + /echo End of spells. |
| 67 | + /goto :Sbook |
| 68 | + } |
| 69 | + |
| 70 | + /if (${Cursor.ID}) /goto :Sbook |
| 71 | + |
| 72 | + /next MerchTemp |
| 73 | + |
| 74 | + :Sbook |
| 75 | + /notify MerchantWnd MW_Done_Button leftmouseup |
| 76 | + /delay 1s |
| 77 | + |
| 78 | + /if (${Cursor.ID}) /inventory |
| 79 | + |
| 80 | + /if (!${Window[SpellBookWnd].Open}) /squelch /windowstate SpellBookWnd open |
| 81 | + |
| 82 | + |
| 83 | + /for i 1 to 10 |
| 84 | + /if (${InvSlot[pack${i}].Item.Container}) { |
| 85 | + |
| 86 | + /if (!${Window[Pack${i}].Open}) /itemnotify pack${i} rightmouseup |
| 87 | + |
| 88 | + | need a small delay so bag content can load |
| 89 | + /delay 1 |
| 90 | + |
| 91 | + /for j 1 to ${InvSlot[pack${i}].Item.Container} |
| 92 | + /if (${InvSlot[pack${i}].Item.Item[${j}].Name.Find["Skill"]} || ${InvSlot[pack${i}].Item.Item[${j}].Name.Find["Tome"]}) { |
| 93 | + /echo Moving ${InvSlot[pack${i}].Item.Item[${j}].Spell.Name} to 10th inventory slot |
| 94 | + /itemnotify in pack${i} ${j} leftmouseup |
| 95 | + /delay 1s |
| 96 | + /itemnotify pack8 leftmouseup |
| 97 | + /delay 1s |
| 98 | + /itemnotify pack8 rightmouseup |
| 99 | + /delay 1s |
| 100 | + } else /if (${InvSlot[pack${i}].Item.Item[${j}].Type.Equal["Scroll"]} && ${InvSlot[pack${i}].Item.Item[${j}].Spell.Level} <= ${Me.Level} && !${Me.Book[${InvSlot[pack${i}].Item.Item[${j}].Spell.Name}]}) { |
| 101 | + |
| 102 | + /echo Please scribe ${InvSlot[pack${i}].Item.Item[${j}].Spell.Name} on cursor |
| 103 | + /itemnotify in pack${i} ${j} leftmouseup |
| 104 | + |
| 105 | + | Need a small delay so pickup event can happen |
| 106 | + /delay 1 |
| 107 | + |
| 108 | + /call Scribe_Spell |
| 109 | + } |
| 110 | + /next j |
| 111 | + |
| 112 | + /if (${Window[Pack${i}].Open}) /itemnotify pack${i} rightmouseup |
| 113 | + } |
| 114 | + /next i |
| 115 | + |
| 116 | + /if (${Window[SpellBookWnd].Open}) /squelch /windowstate SpellBookWnd close |
| 117 | +/return |
| 118 | + |
| 119 | +Sub Scribe_Spell |
| 120 | + /if (!${Window[SpellBookWnd].Open}) /squelch /windowstate SpellBookWnd open |
| 121 | + |
| 122 | + | Logic for finding which spell book page and slot next spell should go. |
| 123 | + :FindNextBlankSpot |
| 124 | + /varcalc b ${b}+1 |
| 125 | + /varcalc s ${s}+1 |
| 126 | + /if (${s}>15) { |
| 127 | + /varset s 0 |
| 128 | + /varcalc p ${p}+2 |
| 129 | + } |
| 130 | + |
| 131 | + /echo Me.Book[${b}] = page ${p} , slot ${s} = ${Me.Book[${b}]} |
| 132 | + /if (${Me.Book[${b}].Name.NotEqual[NULL]}) /goto :FindNextBlankSpot |
| 133 | + |
| 134 | + /book ${p} |
| 135 | + /delay 2 |
| 136 | + /notify SpellBookWnd SBW_Spell${s} leftmouseup |
| 137 | + |
| 138 | + | Loop while user scribes the spell |
| 139 | + :WaitForScribe |
| 140 | + /delay 1s |
| 141 | + /if (${Cursor.ID}) /goto :WaitForScribe |
| 142 | +/return |
| 143 | + |
| 144 | +Sub Event_Cursor |
| 145 | + /goto :Sbook |
| 146 | +/return |
| 147 | + |
| 148 | +Sub Event_Broke1 |
| 149 | + /echo You are out of money! |
| 150 | + /beep |
| 151 | + /end |
| 152 | +/return |
| 153 | + |
| 154 | +Sub Event_Broke2 |
| 155 | + /echo You are out of money! |
| 156 | + /beep |
| 157 | + /end |
| 158 | +/return |
0 commit comments