diff options
author | Haru <haru@dotalux.com> | 2013-12-26 01:34:12 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2013-12-30 16:08:20 +0100 |
commit | 21fa0901dc8723627c6970aa6eff97bc27e36533 (patch) | |
tree | 8890d4191c1ea44af96b6e51d8e149b1e885f043 /doc/sample/npc_dynamic_shop.txt | |
parent | a9156de759bc444a5f7256b86f6c4bac6a1ab47d (diff) | |
download | hercules-21fa0901dc8723627c6970aa6eff97bc27e36533.tar.gz hercules-21fa0901dc8723627c6970aa6eff97bc27e36533.tar.bz2 hercules-21fa0901dc8723627c6970aa6eff97bc27e36533.tar.xz hercules-21fa0901dc8723627c6970aa6eff97bc27e36533.zip |
Modernized syntax and fixed errors in the sample scripts
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'doc/sample/npc_dynamic_shop.txt')
-rw-r--r-- | doc/sample/npc_dynamic_shop.txt | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/doc/sample/npc_dynamic_shop.txt b/doc/sample/npc_dynamic_shop.txt index c3bc78293..1e4ac77e4 100644 --- a/doc/sample/npc_dynamic_shop.txt +++ b/doc/sample/npc_dynamic_shop.txt @@ -1,39 +1,37 @@ -//===== rAthena Script ======================================= +//===== Hercules Script ====================================== //= Sample: Dynamic Shop //===== By: ================================================== -//= rAthena Dev Team +//= Hercules Dev Team //===== Current Version: ===================================== -//= 20101219 -//===== Description: ========================================= +//= 20131225 +//===== Description: ========================================= //= Contains commands needed for a dynamic shop. //============================================================ // Dummy shop to insert items into: - shop dyn_shop1 -1,501:50. -prontera,181,200,4 script Dynamic Shop 123,{ +prontera,181,200,4 script Dynamic Shop 2_F_MAGICMASTER,{ callshop "dyn_shop1",0; npcshopattach "dyn_shop1"; end; OnSellItem: - for(set @i, 0; @i < getarraysize(@sold_nameid); set @i, @i + 1){ - if(countitem(@sold_nameid[@i]) < @sold_quantity[@i] || @sold_quantity[@i] <= 0){ + for (.@i = 0; .@i < getarraysize(@sold_nameid); ++.@i) { + if(countitem(@sold_nameid[.@i]) < @sold_quantity[.@i] || @sold_quantity[.@i] <= 0) { mes "omgh4x!"; close; - } else if(@sold_nameid[@i] == 501){ - delitem 501, @sold_quantity[@i]; - set $@rpotsleft, $@rpotsleft + @sold_quantity[@i]; - set Zeny, Zeny + @sold_quantity[@i]*20; + } else if (@sold_nameid[.@i] == Red_Potion) { + delitem Red_Potion, @sold_quantity[.@i]; + $@rpotsleft += @sold_quantity[.@i]; + Zeny += @sold_quantity[.@i]*20; + } else if (@sold_nameid[.@i] == Orange_Potion){ + delitem Orange_Potion, @sold_quantity[.@i]; + $@opotsleft += @sold_quantity[.@i]; + Zeny += @sold_quantity[.@i]*100; } else { - if(@sold_nameid[@i] == 502){ - delitem 502, @sold_quantity[@i]; - set $@opotsleft, $@opotsleft + @sold_quantity[@i]; - set Zeny, Zeny + @sold_quantity[@i]*100; - } else { - mes "Sorry, I don't need your items."; - close; - } + mes "Sorry, I don't need your items."; + close; } } deletearray @sold_quantity, getarraysize(@sold_quantity); @@ -42,40 +40,40 @@ OnSellItem: close; OnBuyItem: - for(set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1){ - if(@bought_quantity[@i] <= 0){ + for (.@i = 0; .@i < getarraysize(@bought_nameid); ++.@i) { + if (@bought_quantity[.@i] <= 0) { mes "omgh4x!"; close; - } else if(@bought_nameid[@i] == 501){ - if(@bought_quantity[@i] > $@rpotsleft){ - if($@rpotsleft > 0){ - set @bought_quantity[@i], $@rpotsleft; + } else if (@bought_nameid[.@i] == Red_Potion) { + if (@bought_quantity[.@i] > $@rpotsleft) { + if($@rpotsleft > 0) { + @bought_quantity[.@i] = $@rpotsleft; } else { mes "We are out of red potions!"; close; } } - if(Zeny >= 40*@bought_quantity[@i]){ - set Zeny, Zeny - 40*@bought_quantity[@i]; - getitem 501, @bought_quantity[@i]; - set $@rpotsleft, $@rpotsleft - @bought_quantity[@i]; + if(Zeny >= 40*@bought_quantity[.@i]) { + Zeny -= 40*@bought_quantity[.@i]; + getitem Red_Potion, @bought_quantity[.@i]; + $@rpotsleft -= @bought_quantity[.@i]; } else { mes "You have insufficient cash."; close; } - } else { - if(@bought_quantity[@i] > $@opotsleft){ - if($@opotsleft > 0){ - set @bought_quantity[@i], $@opotsleft; + } else /*if (@bought_nameid[.@i] == Orange_Potion)*/ { + if(@bought_quantity[.@i] > $@opotsleft) { + if($@opotsleft > 0) { + @bought_quantity[.@i] = $@opotsleft; } else { mes "We are out of orange potions!"; close; } } - if(Zeny >= 200*@bought_quantity[@i]){ - set Zeny, Zeny - 200*@bought_quantity[@i]; - getitem 502, @bought_quantity[@i]; - set $@opotsleft, $@opotsleft - @bought_quantity[@i]; + if(Zeny >= 200*@bought_quantity[.@i]) { + Zeny -= 200*@bought_quantity[.@i]; + getitem Orange_Potion, @bought_quantity[.@i]; + $@opotsleft -= @bought_quantity[.@i]; } else { mes "You have insufficient cash."; close; @@ -88,8 +86,8 @@ OnBuyItem: close; OnInit: - npcshopitem "dyn_shop1", 501,40,502,200; - set $@rpotsleft, 10; - set $@opotsleft, 10; + npcshopitem "dyn_shop1", Red_Potion, 40, Orange_Potion, 200; + $@rpotsleft = 10; + $@opotsleft = 10; end; } |