[1] | 1 | //===== eAthena Script ======================================= |
---|
| 2 | //= Kafra Express - Main Module |
---|
| 3 | //===== By: ================================================== |
---|
| 4 | //= Skotlex |
---|
| 5 | //===== Current Version: ===================================== |
---|
| 6 | //= 5.7 |
---|
| 7 | //===== Compatible With: ===================================== |
---|
| 8 | //= eAthena SVN R3424+ |
---|
| 9 | //===== Description: ========================================= |
---|
| 10 | //= Part of the Kafra Express Script Package. |
---|
| 11 | //= This module contains the main menu, plus the healing and |
---|
| 12 | //= storage services. |
---|
| 13 | //===== Additional Comments: ================================= |
---|
| 14 | //= See <http://www.eathena.deltaanime.net/board/index.php?showtopic=20290> |
---|
| 15 | //= for indepth explanation of the Kafra Express Script Package. |
---|
| 16 | //= Services available: comment/uncomment what you want (lines 37-104) |
---|
| 17 | //= See config.txt for per-module configuration. |
---|
| 18 | //============================================================ |
---|
| 19 | |
---|
| 20 | // F_KafraExpress (String "Kafra's name", String "kafra image file", |
---|
| 21 | //int location (0 = Town Kafra, 1 = Dungeon Kafra, 2 = Both), |
---|
| 22 | //String "save map", int save x, int save y) |
---|
| 23 | function script F_KafraExpress { |
---|
| 24 | set @name$,getarg(0); |
---|
| 25 | set @ke_type,getarg(2); |
---|
| 26 | if ($@kekp_reset && @kafraPass > 0) |
---|
| 27 | set @kafraPass,@kafraPass-1; |
---|
| 28 | if (getarg(1) != "") |
---|
| 29 | cutin getarg(1),2; |
---|
| 30 | callfunc "F_keIntro",-1,""; |
---|
| 31 | |
---|
| 32 | M_INIT: |
---|
| 33 | set @discount, callfunc("F_keCost",1,100); |
---|
| 34 | |
---|
| 35 | if (@ke_type == 1) goto MD_INIT; |
---|
| 36 | menu |
---|
| 37 | "- Leave",L_END, |
---|
| 38 | "- Heal Service ("+($@keh_hpCost*@discount)+"z/10HP - "+($@keh_spCost*@discount)+"z/10SP)",L_HEAL, |
---|
| 39 | "- Warp Service",M_WARP, |
---|
| 40 | "- Use Storage ("+($@kes_cost*@discount)+"z)",L_STORAGE, |
---|
| 41 | "- Use Guild Storage ("+($@kegs_cost*@discount)+"z)",L_GUILD_STORAGE, |
---|
| 42 | "- Job Services",M_JOB, |
---|
| 43 | "- Other Services",M_OTHER, |
---|
| 44 | "- Save Respawn point",L_SAVE; |
---|
| 45 | |
---|
| 46 | MD_INIT: |
---|
| 47 | menu |
---|
| 48 | "- Leave",L_END, |
---|
| 49 | "- Heal Service ("+($@keh_hpCost*@discount)+"z/10HP - "+($@keh_spCost*@discount)+"z/10SP)",L_HEAL, |
---|
| 50 | "- Warp Service",M_WARP, |
---|
| 51 | "- Use Storage ("+($@kes_cost*@discount)+"z)",L_STORAGE, |
---|
| 52 | "- Use Guild Storage ("+($@kegs_cost*@discount)+"z)",L_GUILD_STORAGE, |
---|
| 53 | "- Job Services",M_JOB, |
---|
| 54 | "- Other Services",M_OTHER, |
---|
| 55 | "- Save Respawn point",L_SAVE; |
---|
| 56 | |
---|
| 57 | M_WARP: |
---|
| 58 | if (@ke_type == 3 && nif_q_done != 1) |
---|
| 59 | goto L_DENIED; |
---|
| 60 | if (@ke_type == 1) |
---|
| 61 | goto MD_WARP; |
---|
| 62 | menu |
---|
| 63 | "- Return",M_INIT, |
---|
| 64 | "- Dungeons",L_DUNGEON, |
---|
| 65 | "- PvP Arena",L_PVP, |
---|
| 66 | "- Guild Wars",L_GUILD_DUNGEON, |
---|
| 67 | "- Towns",L_TOWN; |
---|
| 68 | |
---|
| 69 | MD_WARP: |
---|
| 70 | menu |
---|
| 71 | "- Return",M_INIT, |
---|
| 72 | "- Dungeons",L_DUNGEON, |
---|
| 73 | "- PvP Arena",L_PVP, |
---|
| 74 | "- Guild Wars",L_GUILD_DUNGEON, |
---|
| 75 | "- Towns",L_TOWN; |
---|
| 76 | |
---|
| 77 | M_JOB: |
---|
| 78 | if (@ke_type == 1) goto MD_JOB; |
---|
| 79 | menu |
---|
| 80 | "- Return", M_INIT, |
---|
| 81 | "- Change Job",L_JOB_CHANGE, |
---|
| 82 | "- Swap Job",L_JOB_SWAP, |
---|
| 83 | "- Stat/Skill Services",L_STATS, |
---|
| 84 | "- Stat/Skill Market",L_STAT_MARKET, |
---|
| 85 | "- Rental Service",L_RENT; |
---|
| 86 | |
---|
| 87 | MD_JOB: |
---|
| 88 | menu |
---|
| 89 | "- Return", M_INIT, |
---|
| 90 | "- Change Job",L_JOB_CHANGE, |
---|
| 91 | "- Swap Job",L_JOB_SWAP, |
---|
| 92 | "- Stat/Skill Services",L_STATS, |
---|
| 93 | "- Stat/Skill Market",L_STAT_MARKET, |
---|
| 94 | "- Rental Service",L_RENT; |
---|
| 95 | |
---|
| 96 | M_OTHER: |
---|
| 97 | if (@ke_type == 1) goto MD_OTHER; |
---|
| 98 | menu |
---|
| 99 | "- Return",M_INIT, |
---|
| 100 | "- Bank Services",L_BANK, |
---|
| 101 | "- Use Kafra Shop",L_SHOP, |
---|
| 102 | "- Broadcast a message",L_BROADCAST, |
---|
| 103 | "- Refine Services",L_REFINE, |
---|
| 104 | "- Uncard Services",L_UNCARD, |
---|
| 105 | "- Stylist Service",L_STYLE, |
---|
| 106 | "- Use a Kafra Pass",L_PASS; |
---|
| 107 | |
---|
| 108 | MD_OTHER: |
---|
| 109 | menu |
---|
| 110 | "- Return",M_INIT, |
---|
| 111 | "- Bank Services",L_BANK, |
---|
| 112 | "- Use Kafra Shop",L_SHOP, |
---|
| 113 | "- Broadcast a message",L_BROADCAST, |
---|
| 114 | "- Refine Services",L_REFINE, |
---|
| 115 | "- Uncard Services",L_UNCARD, |
---|
| 116 | "- Stylist Service",L_STYLE, |
---|
| 117 | "- Use a Kafra Pass",L_PASS; |
---|
| 118 | |
---|
| 119 | L_HEAL: |
---|
| 120 | callfunc "F_keHeal"; |
---|
| 121 | goto M_INIT; |
---|
| 122 | |
---|
| 123 | L_TOWN: |
---|
| 124 | callfunc "F_keWarpTown"; |
---|
| 125 | goto M_WARP; |
---|
| 126 | |
---|
| 127 | L_DUNGEON: |
---|
| 128 | callfunc "F_keDungeonWarps", getarg(3); |
---|
| 129 | goto M_WARP; |
---|
| 130 | |
---|
| 131 | L_GUILD_DUNGEON: |
---|
| 132 | callfunc "F_keWarpWOE"; |
---|
| 133 | goto M_WARP; |
---|
| 134 | |
---|
| 135 | L_PVP: |
---|
| 136 | callfunc "F_keWarpPvp"; |
---|
| 137 | goto M_WARP; |
---|
| 138 | |
---|
| 139 | L_STORAGE: |
---|
| 140 | callfunc "F_keStorage", getarg(1); |
---|
| 141 | goto M_INIT; |
---|
| 142 | |
---|
| 143 | L_GUILD_STORAGE: |
---|
| 144 | callfunc "F_keGuildStorage", getarg(1); |
---|
| 145 | goto M_INIT; |
---|
| 146 | |
---|
| 147 | L_BANK: |
---|
| 148 | callfunc "F_keBank"; |
---|
| 149 | goto M_OTHER; |
---|
| 150 | |
---|
| 151 | L_SHOP: |
---|
| 152 | callfunc "F_keShop",@ke_type, getarg(1); |
---|
| 153 | goto M_OTHER; |
---|
| 154 | |
---|
| 155 | L_BROADCAST: |
---|
| 156 | callfunc "F_keBroadcast",getarg(3); |
---|
| 157 | goto M_OTHER; |
---|
| 158 | |
---|
| 159 | L_PASS: |
---|
| 160 | callfunc "F_kePass"; |
---|
| 161 | goto M_OTHER; |
---|
| 162 | |
---|
| 163 | L_REFINE: |
---|
| 164 | callfunc "F_keRefine"; |
---|
| 165 | goto M_OTHER; |
---|
| 166 | |
---|
| 167 | L_UNCARD: |
---|
| 168 | callfunc "F_keUncard"; |
---|
| 169 | goto M_OTHER; |
---|
| 170 | |
---|
| 171 | L_STYLE: |
---|
| 172 | callfunc "F_keStylist"; |
---|
| 173 | goto M_OTHER; |
---|
| 174 | |
---|
| 175 | L_JOB_CHANGE: |
---|
| 176 | callfunc "F_keJobChange"; |
---|
| 177 | goto M_JOB; |
---|
| 178 | |
---|
| 179 | L_JOB_SWAP: |
---|
| 180 | callfunc "F_keJobSwap"; |
---|
| 181 | goto M_JOB; |
---|
| 182 | |
---|
| 183 | L_STATS: |
---|
| 184 | callfunc "F_keStats"; |
---|
| 185 | goto M_JOB; |
---|
| 186 | |
---|
| 187 | L_STAT_MARKET: |
---|
| 188 | callfunc "F_keStatMarket"; |
---|
| 189 | goto M_JOB; |
---|
| 190 | |
---|
| 191 | L_RENT: |
---|
| 192 | callfunc "F_keRent"; |
---|
| 193 | goto M_JOB; |
---|
| 194 | |
---|
| 195 | L_SAVE: |
---|
| 196 | if (@ke_type == 3 && nif_q_done != 1) |
---|
| 197 | goto L_DENIED; |
---|
| 198 | if ($@kewt_travel && @ke_type != 1) { |
---|
| 199 | callfunc "F_keAddTravelTown", getarg(3); |
---|
| 200 | } |
---|
| 201 | if ($@kewd_travel && @ke_type != 0) { |
---|
| 202 | callfunc "F_keAddTravelDungeon", getarg(3); |
---|
| 203 | } |
---|
| 204 | if ($@ke_saveOnSpot) { |
---|
| 205 | getmapxy @map$,@x,@y,0; |
---|
| 206 | savepoint @map$,@x,@y; |
---|
| 207 | } else { |
---|
| 208 | savepoint getarg(3),getarg(4),getarg(5); |
---|
| 209 | } |
---|
| 210 | emotion e_scissors; |
---|
| 211 | goto M_INIT; |
---|
| 212 | |
---|
| 213 | L_DENIED: |
---|
| 214 | callfunc "F_keIntro", e_gg, "...no."; |
---|
| 215 | goto M_INIT; |
---|
| 216 | |
---|
| 217 | L_END: |
---|
| 218 | mes "Thank you for using Kafra Services."; |
---|
| 219 | close2; |
---|
| 220 | cutin getarg(1), 255; |
---|
| 221 | end; |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | //Function F_keIntro (emotion, message) |
---|
| 225 | //Displays a message followed by an emotion, then a next button, and finally |
---|
| 226 | //shows the intro message. |
---|
| 227 | function script F_keIntro { |
---|
| 228 | if (getarg(0) >= 0) |
---|
| 229 | emotion getarg(0); |
---|
| 230 | if (getarg(1) != "") { |
---|
| 231 | mes getarg(1); |
---|
| 232 | next; |
---|
| 233 | } |
---|
| 234 | mes "["+@name$+"]"; |
---|
| 235 | mes "Welcome to Kafra Corp. Always by your side, wherever you go."; |
---|
| 236 | if(@kafraPass) mes "Your Kafra Pass is active,"; |
---|
| 237 | mes "How may I be of help?"; |
---|
| 238 | return; |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | //Function Heal, offers the heal subsystem. |
---|
| 242 | function script F_keHeal { |
---|
| 243 | set @qtyHP,MaxHp-Hp; |
---|
| 244 | set @qtySP,MaxSp-Sp; |
---|
| 245 | set @costHP, $@keh_hpCost*(MaxHp-Hp)/10; |
---|
| 246 | set @costSP, $@keh_spCost*(MaxSp-Sp)/10; |
---|
| 247 | set @costHPSP, @costHP+@costSP; |
---|
| 248 | set @discount, callfunc("F_keCost",1,100); |
---|
| 249 | |
---|
| 250 | if (@qtyHP + @qtySP == 0) { |
---|
| 251 | callfunc "F_keIntro", -1, "...you don't need to be healed."; |
---|
| 252 | return; |
---|
| 253 | } |
---|
| 254 | if (@qtyHP == 0) goto M_NO_HP; |
---|
| 255 | if (@qtySP == 0) goto M_NO_SP; |
---|
| 256 | menu "- Cancel",-, |
---|
| 257 | "- Heal HP ("+(@costHP*@discount)+"z)",L_HEAL_HP, |
---|
| 258 | "- Heal SP ("+(@costSP*@discount)+"z)",L_HEAL_SP, |
---|
| 259 | "- Heal Both ("+(@costHPSP*@discount)+"z)",L_HEAL_ALL; |
---|
| 260 | return; |
---|
| 261 | |
---|
| 262 | M_NO_HP: |
---|
| 263 | menu "- Cancel",-, |
---|
| 264 | "- Heal SP ("+(@costSP*@discount)+"z)",L_HEAL_SP; |
---|
| 265 | return; |
---|
| 266 | |
---|
| 267 | M_NO_SP: |
---|
| 268 | menu "- Cancel",-, |
---|
| 269 | "- Heal HP ("+(@costHP*@discount)+"z)",L_HEAL_HP; |
---|
| 270 | return; |
---|
| 271 | |
---|
| 272 | L_HEAL_HP: |
---|
| 273 | if (!(callfunc("F_keCharge",@costHP,100,0))) { |
---|
| 274 | callfunc "F_keIntro", e_sry, "Sorry, you don't have enough to be healed."; |
---|
| 275 | return; |
---|
| 276 | } |
---|
| 277 | emotion e_no1; |
---|
| 278 | heal @qtyHP,0; |
---|
| 279 | return; |
---|
| 280 | |
---|
| 281 | L_HEAL_SP: |
---|
| 282 | if (!(callfunc("F_keCharge",@costSP,100,0))) { |
---|
| 283 | callfunc "F_keIntro", e_sry, "Sorry, you don't have enough to be healed."; |
---|
| 284 | return; |
---|
| 285 | } |
---|
| 286 | emotion e_no1; |
---|
| 287 | heal 0,@qtySP; |
---|
| 288 | return; |
---|
| 289 | |
---|
| 290 | L_HEAL_ALL: |
---|
| 291 | if (!(callfunc("F_keCharge",@costHPSP,100,0))) { |
---|
| 292 | callfunc "F_keIntro", e_sry, "Sorry, you don't have enough to be healed."; |
---|
| 293 | return; |
---|
| 294 | } |
---|
| 295 | emotion e_no1; |
---|
| 296 | heal @qtyHP,@qtySP; |
---|
| 297 | return; |
---|
| 298 | } |
---|
| 299 | |
---|
| 300 | //Function storage: allows access to the storage facility |
---|
| 301 | //The sent argument is the displaying image, so we can clear it afterwards. |
---|
| 302 | function script F_keStorage { |
---|
| 303 | if(basicskillcheck() > 0 && getskilllv("NV_BASIC") < 6) { |
---|
| 304 | callfunc "F_keIntro", -1, "I am sorry, but you beed basic skill level 6 to use the storage."; |
---|
| 305 | return; |
---|
| 306 | } |
---|
| 307 | if (!(callfunc("F_keCharge",$@kes_cost,100,1))) { |
---|
| 308 | callfunc "F_keIntro", e_an, "Sorry, but you don't have enough Zeny."; |
---|
| 309 | return; |
---|
| 310 | } |
---|
| 311 | mes "Thank for you using Kafra services."; |
---|
| 312 | emotion e_thx; |
---|
| 313 | close2; |
---|
| 314 | openstorage; |
---|
| 315 | cutin getarg(0), 255; |
---|
| 316 | end; |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | //Function G Storage: Allows access to the Guild Storage |
---|
| 320 | function script F_keGuildStorage { |
---|
| 321 | if(basicskillcheck() > 0 && getskilllv("NV_BASIC") < 6) { |
---|
| 322 | callfunc "F_keIntro", -1, "I am sorry, but you beed basic skill level 6 to use the storage."; |
---|
| 323 | return; |
---|
| 324 | } |
---|
| 325 | if(getcharid(2) < 1) { |
---|
| 326 | callfunc "F_keIntro", e_swt, "You can't use the Guild Storage if you don't belong to a guild!"; |
---|
| 327 | return; |
---|
| 328 | } |
---|
| 329 | if (callfunc("F_keCost",$@kegs_cost,100) > Zeny) { |
---|
| 330 | callfunc "F_keIntro", e_an, "Sorry, but you don't have enough Zeny."; |
---|
| 331 | return; |
---|
| 332 | } |
---|
| 333 | if (guildopenstorage(0) == 1) { |
---|
| 334 | callfunc "F_keIntro", -1, "Sorry, the guild storage is currently in use by someone else. Try again later."; |
---|
| 335 | return; |
---|
| 336 | } |
---|
| 337 | callfunc "F_keCharge",$@kegs_cost,100,1; |
---|
| 338 | mes "Thank for you using Kafra services."; |
---|
| 339 | emotion e_thx; |
---|
| 340 | close2; |
---|
| 341 | cutin getarg(0), 255; |
---|
| 342 | end; |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | function script F_kePass { |
---|
| 346 | if (@kafraPass) { |
---|
| 347 | callfunc "F_keIntro", -1, "You already are using a Kafra Pass..."; |
---|
| 348 | return; |
---|
| 349 | } |
---|
| 350 | if (countitem(1084)<1) { |
---|
| 351 | callfunc "F_keIntro", -1, "You obviously need a 'Kafra Pass' if you want to activate it."; |
---|
| 352 | return; |
---|
| 353 | } |
---|
| 354 | delitem 1084,1; |
---|
| 355 | if ($@kekp_reset > 0) |
---|
| 356 | set @kafraPass,$@kekp_reset; |
---|
| 357 | else |
---|
| 358 | set @kafraPass,1; |
---|
| 359 | callfunc "F_keIntro", e_lv, "Your Kafra Pass has been activated."; |
---|
| 360 | return; |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | //F_keCost(int cost, int discount%) |
---|
| 364 | //Returns what would be the cost of a service considering the KafraPass. |
---|
| 365 | //The discount value should be between 0 and 100 |
---|
| 366 | function script F_keCost { |
---|
| 367 | if (@kafraPass) { |
---|
| 368 | return getarg(0)*(100-getarg(1))/100; |
---|
| 369 | } |
---|
| 370 | return getarg(0); |
---|
| 371 | } |
---|
| 372 | |
---|
| 373 | //F_keCharge(int cost, int discount%, bool appliesKP) |
---|
| 374 | //Charges for a service, using the KafraPass state and discount value. |
---|
| 375 | //appliesKP marks if the cost savings apply for stocking Kafra Reserve Points |
---|
| 376 | //Function returns 1 if successful, 0 if there's not enough zeny. |
---|
| 377 | function script F_keCharge { |
---|
| 378 | set @savings, 0; |
---|
| 379 | if (@kafraPass) |
---|
| 380 | set @savings, getarg(0)*getarg(1)/100; |
---|
| 381 | set @cost, getarg(0)-@savings; |
---|
| 382 | if (@cost > Zeny || @cost < 0) { // (@cost < 0) for overflow protection |
---|
| 383 | return 0; |
---|
| 384 | } |
---|
| 385 | set Zeny, Zeny-@cost; |
---|
| 386 | |
---|
| 387 | if (getarg(2) && @savings > 0 && $@kekp_reserveCost > 0) { |
---|
| 388 | set @savings, @savings/$@kekp_reserveCost; |
---|
| 389 | if (@savings < $@kekp_minReserve) |
---|
| 390 | set @savings, $@kekp_minReserve; |
---|
| 391 | if (@savings > $@kekp_maxReserve) |
---|
| 392 | set @savings, $@kekp_maxReserve; |
---|
| 393 | |
---|
| 394 | set RESRVPTS, RESRVPTS + @savings; |
---|
| 395 | } |
---|
| 396 | return 1; |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | //Function F_keWarp (int cost, int discount, int emotion, String map, int x, int y) |
---|
| 400 | function script F_keWarp { |
---|
| 401 | if (!(callfunc("F_keCharge",getarg(0),getarg(1),1))) { |
---|
| 402 | callfunc "F_keIntro", e_an, "You don't have enough Zeny..."; |
---|
| 403 | return; |
---|
| 404 | } |
---|
| 405 | emotion getarg(2); |
---|
| 406 | warp getarg(3),getarg(4),getarg(5); |
---|
| 407 | end; |
---|
| 408 | } |
---|