From 540acbbe28e697dba5d5e213c9815286e1f5b322 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 20 Mar 2021 17:19:28 -0300 Subject: Optmize Lua code for Contributors, including GM Logging. --- npc/003-2/lua.txt | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/npc/003-2/lua.txt b/npc/003-2/lua.txt index 3590f2c1e..18a4cf147 100644 --- a/npc/003-2/lua.txt +++ b/npc/003-2/lua.txt @@ -22,6 +22,7 @@ function luaAssignTask5; // Your Report, the plan function luaTask5; function luaCheckTask5; + function luaCReward; // Contributor Reward // Then we jump to L_Finish/L_Complete .@n = getq(General_Narrator); @@ -803,21 +804,21 @@ L_Contributor: mes ""; switch (@menu) { case 1: - getitem BugLeg, 30; #CRW=#CRW|128 ; break; + luaCReward(BugLeg, 128, false, 30); break; case 2: - Zeny=Zeny-10000; getitembound LegendaryMouboo, 1, 1; #CRW=#CRW|64 ; break; + Zeny=Zeny-10000; luaCReward(LegendaryMouboo, 64, true); break; case 3: - getitem DEVCap, 1; #CRW=#CRW|32 ; break; + luaCReward(DEVCap, 32); break; case 4: - getitem DeliciousCookie, 1; #CRW=#CRW|16 ; break; + luaCReward(DeliciousCookie, 16); break; case 5: - getitem BugLeg, 20; #CRW=#CRW|8 ; break; + luaCReward(BugLeg, 8, false, 20); break; case 6: - getitem ContributorSweater, 1; #CRW=#CRW|4 ; break; + luaCReward(ContributorSweater, 4); break; case 7: - getitem CommunityShirt, 1; #CRW=#CRW|2 ; break; + luaCReward(CommunityShirt, 2); break; case 8: - getitem StrangeCoin, 5; #CRW=#CRW|1 ; break; + luaCReward(StrangeCoin, 1, false, 5); break; case 9: mesf("250 - 30x %s", getitemlink(BugLeg)); mesf("100 (+10,000 GP) - %s", getitemlink(LegendaryMouboo)); @@ -833,6 +834,23 @@ L_Contributor: } close; +function luaCReward { + .@it=getarg(0); + .@cr=getarg(1); + .@bd=getarg(2, false); + .@am=getarg(3, 1); + if (!.@bd) + getitem .@it, .@am; + else + getitembound .@it, .@am; + #CRW=#CRW|.@cr; + logmes(sprintf("%s has claimed a(n) %s with Contributor Points.", + strcharinfo(0), getitemname(.@it))); + logmes(sprintf("%s has claimed a(n) %s with Contributor Points.", + strcharinfo(0), getitemname(.@it)), LOGMES_ATCOMMAND); + return; +} + L_Close: close; -- cgit v1.2.3-60-g2f50