Purpose

Each tier has a list of accounts belonging to that tier and its rewards: one-time, daily, weekly, monthly. The module creates two NPCs: talk to the first NPC to claim the one-time reward; the second NPC hands out all periodic rewards currently available. Rewards can be coins (WCoin, Goblin Point, Ruud, Zen), item bags and buffs. Buffs marked OnLogin = true are granted again on every login while the account still belongs to the tier.

How to enable

  1. Run the file Includes\CumulativeRecharge\CumulativeRecharge.sql once on the game DB (creates the table).
  2. Remove the -- in front of LoadModule("CumulativeRecharge\\CumulativeRecharge") in Main.lua.
  3. Edit Config.lua: the positions of the 2 NPCs, tiers, accounts, rewards.
  4. Click Reload LuaAPI.

The module attaches OnReadScript (creates the NPCs), OnNpcTalk, OnSQLAsyncResult, OnCharacterEntry. The NPCs are removed when LuaAPI is reloaded and created again, so they are not duplicated.

SQL to create (SQL Server)

IF OBJECT_ID(N'dbo.CumulativeRewardLog', N'U') IS NULL
CREATE TABLE dbo.CumulativeRewardLog (
    Account NVARCHAR(10) NOT NULL,
    Tier INT NOT NULL,
    RewardType NVARCHAR(10) NOT NULL,
    LastClaimTime BIGINT NOT NULL,
    CONSTRAINT PK_CumulativeRewardLog PRIMARY KEY (Account, Tier, RewardType)
);

The table stores the most recent claim time of each reward type (OneTime, Daily, Weekly, Monthly) per account and tier. The claim is written to the DB before the reward is granted.

Configuration (Config.lua, CumulativeRechargeConfig table)

KeyValueDefaultMeaning
Enabletrue / falsetrueTurns the module on / off.
TableNamestring"CumulativeRewardLog"DB table name.
MinFreeSlotsnumber8Number of free inventory slots required when the reward includes an item bag.
DailyResetHourhour 0..234Hour at which a new day starts for daily rewards.
WeeklyResetDay0..61Day the week starts (0 = Sunday ... 6 = Saturday), at 00:00. The month starts on the 1st at 00:00.
OneTimeNpctableClass 247, LorenciaNPC for the one-time reward: Class, Map, X, Y, Dir.
PeriodicNpctableClass 249, LorenciaNPC for periodic rewards: same fields as above.
Tierstable2 sample tiers[tier number] = { Accounts, OneTime, Daily, Weekly, Monthly }. The tier number is the name shown to the player.
Texttable(built in)The notice messages.

Structure of a reward:

  • Coins = { WCoin = 0, GoblinPoint = 0, Ruud = 0, Zen = 0 }
  • Bags = { bag number / name, ... } (GUID or name per the files in Data\ItemBags)
  • Buffs = { { Id = buff number, Seconds = duration, OnLogin = true / false }, ... }
CumulativeRechargeConfig.Tiers = {
	[500] = {
		Accounts = { "account1" },
		OneTime = {
			Coins = { WCoin = 10000, GoblinPoint = 50000, Ruud = 1000, Zen = 100000000 },
			Bags = { 15 },
			Buffs = { { Id = 3, Seconds = 3600, OnLogin = true } },
		},
		Daily = { Coins = { WCoin = 50, GoblinPoint = 250 } },
	},
}