Skip to content

Commit

Permalink
Revert "[Revscriptsys] RevNpcSys version 1.0 (lua npcs / NpcType / ne…
Browse files Browse the repository at this point in the history
…w npc system) (#4671)"

This reverts commit 4a89502.
  • Loading branch information
ArturKnopik authored and nekiro committed Dec 5, 2024
1 parent 72ed4a2 commit 5bfda8f
Show file tree
Hide file tree
Showing 32 changed files with 129 additions and 3,065 deletions.
96 changes: 18 additions & 78 deletions data/cpplinter.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---@class os
---@field mtime fun(): number
os = {}
---@alias os.mtime fun(): number

---@class table
---@field create fun(arrayLength: number, keyLength: number): table
---@field pack fun(...): table
table = {}
---@alias table.create fun(arrayLength: number, keyLength: number): table
---@alias table.pack fun(...): table

---@class rawgetmetatable
---@field __index fun(self: table, key: any): any
Expand Down Expand Up @@ -96,7 +92,6 @@ configManager = {}
---@field createNpc fun(name: string, position: Position, extended?: boolean, force?: boolean, magicEffect?: MagicEffect_t): Npc
---@field createTile fun(position: Position): Tile
---@field createMonsterType fun(name: string): MonsterType
---@field createNpcType fun(name: string): NpcType
---@field startEvent fun(eventName: string): boolean
---@field getClientVersion fun(): string
---@field reload fun(reloadType: number): boolean
Expand Down Expand Up @@ -394,7 +389,7 @@ Creature = {}
---@field addOfflineTrainingTries fun(self: Player, skill: number, amount: number)
---@field getOfflineTrainingSkill fun(self: Player): number
---@field setOfflineTrainingSkill fun(self: Player, skill: number)
---@field getItemCount fun(self: Player, itemId: number, subType?: number, ignoreEquipped?: boolean): number
---@field getItemCount fun(self: Player, itemId: number): number
---@field getItemById fun(self: Player, itemId: number, subType?: number): Item
---@field getVocation fun(self: Player): Vocation
---@field setVocation fun(self: Player, vocationId: number)
Expand All @@ -419,7 +414,7 @@ Creature = {}
---@field setBankBalance fun(self: Player, balance: number)
---@field addItem fun(self: Player, itemId: number, count?: number): Item
---@field addItemEx fun(self: Player, item: Item, copyItem?: boolean): boolean
---@field removeItem fun(self: Player, itemId: number, count?: number, subtype?: number, ignoreEquipped?: boolean): boolean
---@field removeItem fun(self: Player, itemId: number, count?: number, subtype?: number): boolean
---@field sendSupplyUsed fun(self: Player, item: Item)
---@field getMoney fun(self: Player): number
---@field addMoney fun(self: Player, amount: number)
Expand Down Expand Up @@ -526,62 +521,6 @@ Monster = {}
---@field getSpectators fun(self: Npc, centerPos: Position, rangeX: number, rangeY: number, multifloor: boolean): table
Npc = {}

---@class NpcType
---@field create fun(): NpcType
---@field name fun(self: NpcType, name?: string): any
---@field setName fun(self: NpcType, name: string): boolean
---@field getName fun(self: NpcType): string
---@field eventType fun(self: NpcType, eventType?: string): any
---@field setEventType fun(self: NpcType, type: string): boolean
---@field getEventType fun(self: NpcType): string
---@field speechBubble fun(self: NpcType, speechBubble?: number): any
---@field setSpeechBubble fun(self: NpcType, bubble: number): boolean
---@field getSpeechBubble fun(self: NpcType): number
---@field walkInterval fun(self: NpcType, interval?: number): any
---@field setWalkInterval fun(self: NpcType, interval: number): boolean
---@field getWalkInterval fun(self: NpcType): number
---@field walkSpeed fun(self: NpcType, speed?: number): any
---@field setWalkSpeed fun(self: NpcType, speed: number): boolean
---@field getWalkSpeed fun(self: NpcType): number
---@field spawnRadius fun(self: NpcType, radius?: number): any
---@field setSpawnRadius fun(self: NpcType, radius: number): boolean
---@field getSpawnRadius fun(self: NpcType): number
---@field floorChange fun(self: NpcType, floorChange?: boolean): any
---@field setFloorChange fun(self: NpcType, floorChange: boolean): boolean
---@field getFloorChange fun(self: NpcType): boolean
---@field attackable fun(self: NpcType, attackable?: boolean): any
---@field setAttackable fun(self: NpcType, attackable: boolean): boolean
---@field getAttackable fun(self: NpcType): boolean
---@field ignoreHeight fun(self: NpcType, ignoreHeight?: boolean): any
---@field setIgnoreHeight fun(self: NpcType, ignoreHeight: boolean): boolean
---@field getIgnoreHeight fun(self: NpcType): boolean
---@field isIdle fun(self: NpcType, isIdle?: boolean): any
---@field setIsIdle fun(self: NpcType, isIdle: boolean): boolean
---@field getIsIdle fun(self: NpcType): boolean
---@field pushable fun(self: NpcType, pushable?: boolean): any
---@field setPushable fun(self: NpcType, pushable: boolean): boolean
---@field getPushable fun(self: NpcType): boolean
---@field outfit fun(self: NpcType, outfit?: Outfit|table): any
---@field setOutfit fun(self: NpcType, outfit: Outfit): boolean
---@field getOutfit fun(self: NpcType): Outfit
---@field parameters fun(self: NpcType, key?: any, value?: any): any
---@field setParameters fun(self: NpcType, key: any, value: any): boolean
---@field getParameters fun(self: NpcType, key: any): table
---@field health fun(self: NpcType, health?: number): any
---@field setHealth fun(self: NpcType, health: number): boolean
---@field getHealth fun(self: NpcType): number
---@field maxHealth fun(self: NpcType, maxHealth?: number): any
---@field setMaxHealth fun(self: NpcType, maxHealth: number): boolean
---@field getMaxHealth fun(self: NpcType): number
---@field onSay fun(self: NpcType, callback: function): boolean
---@field onDisappear fun(self: NpcType, callback: function): boolean
---@field onAppear fun(self: NpcType, callback: function): boolean
---@field onMove fun(self: NpcType, callback: function): boolean
---@field onPlayerCloseChannel fun(self: NpcType, callback: function): boolean
---@field onPlayerEndTrade fun(self: NpcType, callback: function): boolean
---@field onThink fun(self: NpcType, callback: function): boolean
NpcType = {}

---@class Guild
---@field create fun(): Guild
---@field __eq fun(self: Guild, other: Guild): boolean
Expand Down Expand Up @@ -779,18 +718,19 @@ Combat = {}
Condition = {}

---@class Outfit
---@field lookType number|nil
---@field lookHead number|nil
---@field lookBody number|nil
---@field lookLegs number|nil
---@field lookFeet number|nil
---@field lookAddons number|nil
---@field lookMount number|nil
---@field lookMountHead number|nil
---@field lookMountBody number|nil
---@field lookMountLegs number|nil
---@field lookMountFeet number|nil
---@field lookTypeEx number|nil
---@field create fun(): Outfit
---@field lookType number
---@field lookHead number
---@field lookBody number
---@field lookLegs number
---@field lookFeet number
---@field lookAddons number
---@field lookMount number
---@field lookMountHead number
---@field lookMountBody number
---@field lookMountLegs number
---@field lookMountFeet number
---@field lookTypeEx number
Outfit = {}

---@class MonsterType
Expand Down
38 changes: 2 additions & 36 deletions data/lib/compat/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,42 +132,6 @@ do
rawgetmetatable("Action").__newindex = ActionNewIndex
end

do
local function NpcTypeNewIndex(self, key, value)
if key == "onSay" then
self:eventType("say")
self:onSay(value)
return
elseif key == "onDisappear" then
self:eventType("disappear")
self:onDisappear(value)
return
elseif key == "onAppear" then
self:eventType("appear")
self:onAppear(value)
return
elseif key == "onMove" then
self:eventType("move")
self:onMove(value)
return
elseif key == "onPlayerCloseChannel" then
self:eventType("closechannel")
self:onPlayerCloseChannel(value)
return
elseif key == "onPlayerEndTrade" then
self:eventType("endtrade")
self:onPlayerEndTrade(value)
return
elseif key == "onThink" then
self:eventType("think")
self:onThink(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("NpcType").__newindex = NpcTypeNewIndex
end

do
local function TalkActionNewIndex(self, key, value)
if key == "onSay" then
Expand Down Expand Up @@ -628,6 +592,8 @@ function isPremium(cid) local p = Player(cid) return p and p:isPremium() or fals

STORAGEVALUE_EMPTY = -1
function Player:getStorageValue(key)
print("[Warning - " .. debug.getinfo(2).source:match("@?(.*)") .. "] Invoking Creature:getStorageValue will return nil to indicate absence in the future. Please update your scripts accordingly.")

local v = Creature.getStorageValue(self, key)
return v or STORAGEVALUE_EMPTY
end
Expand Down
12 changes: 0 additions & 12 deletions data/lib/core/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,11 @@ function Player.transferMoneyTo(self, target, amount)
local targetPlayer = Player(target.guid)
if targetPlayer then
targetPlayer:setBankBalance(targetPlayer:getBankBalance() + amount)
db.query("UPDATE `players` SET `balance` = " .. targetPlayer:getBankBalance() .. " WHERE `id` = '" .. targetPlayer:getGuid() .. "'")
else
db.query("UPDATE `players` SET `balance` = `balance` + " .. amount .. " WHERE `id` = '" .. target.guid .. "'")
end

self:setBankBalance(self:getBankBalance() - amount)
-- incase server crashes that we do not duplicate money
self:save()
return true
end

Expand Down Expand Up @@ -740,12 +737,3 @@ function Player.disableLoginMusic(self)
msg:delete()
return true
end

function Player.sendInboxItems(self, items, containerId)
local inbox = self:getInbox()
local container = Game.createItem(containerId, 1)
for _, item in pairs(items) do
container:addItem(item.item, item.count)
end
container:moveTo(inbox)
end
1 change: 0 additions & 1 deletion data/npc/lib/npc.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-- Including the Advanced NPC System
dofile('data/npc/lib/npcsystem/npcsystem.lua')
dofile("data/npc/lib/revnpcsys/npc.lua")

function msgcontains(message, keyword)
local message, keyword = message:lower(), keyword:lower()
Expand Down
123 changes: 0 additions & 123 deletions data/npc/lib/revnpcsys/constants.lua

This file was deleted.

Loading

0 comments on commit 5bfda8f

Please sign in to comment.