summaryrefslogtreecommitdiff
path: root/npc/commands/zeny.txt
diff options
context:
space:
mode:
authormekolat <mekolat@users.noreply.github.com>2016-06-21 15:20:56 -0400
committermekolat <mekolat@users.noreply.github.com>2016-06-22 14:49:49 -0400
commit2293aa6b83e7893349a0f4ca7e76a77c7812b380 (patch)
treeb996e72cfdca4e4214c2961df9a7a1f24bf83bdf /npc/commands/zeny.txt
parent85712c4f2ccfa9c3cec4bd0c9f515f5061a9351c (diff)
downloadserverdata-2293aa6b83e7893349a0f4ca7e76a77c7812b380.tar.gz
serverdata-2293aa6b83e7893349a0f4ca7e76a77c7812b380.tar.bz2
serverdata-2293aa6b83e7893349a0f4ca7e76a77c7812b380.tar.xz
serverdata-2293aa6b83e7893349a0f4ca7e76a77c7812b380.zip
add atcommand `@esp` (manipulates Esperin)
aka zeny aka gp check for boundaries, use bank if purse is full
Diffstat (limited to 'npc/commands/zeny.txt')
-rw-r--r--npc/commands/zeny.txt90
1 files changed, 90 insertions, 0 deletions
diff --git a/npc/commands/zeny.txt b/npc/commands/zeny.txt
new file mode 100644
index 00000000..560c7a94
--- /dev/null
+++ b/npc/commands/zeny.txt
@@ -0,0 +1,90 @@
+// @esp atcommand
+// changes the number of Esperin
+//
+// group lv: 3
+// group char lv: 99
+// log: True
+//
+// usage:
+// @esp <delta>
+// #esp "char" <delta>
+//
+// example:
+// @esp +5
+// @esp -5
+// @esp +++
+
+- script @esp 32767,{
+ end;
+
+OnCall:
+ .@delta$ = .@atcmd_parameters$[0];
+
+ if (startswith(.@delta$, "--"))
+ {
+ Zeny = 0;
+ if (.@delta$ == "---")
+ {
+ #MerchantBank = 0;
+ }
+ }
+ else if (startswith(.@delta$, "++"))
+ {
+ Zeny = 0x7FFFFFFE;
+ if (.@delta$ == "+++")
+ {
+ #MerchantBank = 0x7FFFFFFF;
+ }
+ }
+ else
+ {
+ .@d = atoi(.@delta$);
+ if (.@d < 0)
+ {
+ .@a = Zeny + .@d; // The amount of zeny remaining after
+ if (.@a < 0) // If we can't remove that much zeny, try removing from bank too
+ {
+ Zeny = 0;
+ .@b = #MerchantBank + .@a; // amount remaining in bank after
+ if (.@b < 0)
+ {
+ #MerchantBank = 0;
+ }
+ else
+ {
+ #MerchantBank += .@a;
+ }
+ }
+ else // We can remove that much zeny
+ {
+ Zeny += .@d;
+ }
+ }
+ else
+ {
+ .@a = Zeny + .@d; // The amount of zeny after
+ if (.@a < 0 || .@a >= 0x7FFFFFFE) // If we can't add that much zeny, try adding to bank
+ {
+ .@c = .@d - (.@a - Zeny); // the amount to put in bank
+ Zeny = 0x7FFFFFFE;
+ .@b = #MerchantBank + .@c; // amout in bank after
+ if (.@b < 0 || .@b == 0x7FFFFFFF)
+ {
+ #MerchantBank = 0x7FFFFFFF;
+ }
+ else
+ {
+ #MerchantBank += .@c;
+ }
+ }
+ else // We can add that much zeny
+ {
+ Zeny += .@d;
+ }
+ }
+ }
+ end;
+
+OnInit:
+ bindatcmd "esp", "@esp::OnCall", 3, 99, 1;
+}