-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d61f282
commit cb4c720
Showing
118 changed files
with
1,779 additions
and
2,163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
function Creature.getMonster(self) | ||
return self:isMonster() and self or nil | ||
return self:isMonster() and self or nil | ||
end | ||
|
||
function Creature.getPlayer(self) | ||
return self:isPlayer() and self or nil | ||
return self:isPlayer() and self or nil | ||
end | ||
|
||
function Creature.isContainer(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Creature.isItem(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Creature.isMonster(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Creature.isNpc(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Creature.isPlayer(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Creature.isTeleport(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Creature.isTile(self) | ||
return false | ||
return false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
function Item.getType(self) | ||
return ItemType(self:getId()) | ||
return ItemType(self:getId()) | ||
end | ||
|
||
function Item.isContainer(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Item.isCreature(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Item.isMonster(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Item.isNpc(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Item.isPlayer(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Item.isTeleport(self) | ||
return false | ||
return false | ||
end | ||
|
||
function Item.isTile(self) | ||
return false | ||
return false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
function Player.sendCancelMessage(self, message) | ||
if type(message) == "number" then | ||
message = Game.getReturnMessage(message) | ||
end | ||
return self:sendTextMessage(MESSAGE_STATUS_SMALL, message) | ||
if type(message) == "number" then | ||
message = Game.getReturnMessage(message) | ||
end | ||
return self:sendTextMessage(MESSAGE_STATUS_SMALL, message) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,72 @@ | ||
Position.directionOffset = { | ||
[DIRECTION_NORTH] = {x = 0, y = -1}, | ||
[DIRECTION_EAST] = {x = 1, y = 0}, | ||
[DIRECTION_SOUTH] = {x = 0, y = 1}, | ||
[DIRECTION_WEST] = {x = -1, y = 0}, | ||
[DIRECTION_SOUTHWEST] = {x = -1, y = 1}, | ||
[DIRECTION_SOUTHEAST] = {x = 1, y = 1}, | ||
[DIRECTION_NORTHWEST] = {x = -1, y = -1}, | ||
[DIRECTION_NORTHEAST] = {x = 1, y = -1} | ||
[DIRECTION_NORTH] = { x = 0, y = -1 }, | ||
[DIRECTION_EAST] = { x = 1, y = 0 }, | ||
[DIRECTION_SOUTH] = { x = 0, y = 1 }, | ||
[DIRECTION_WEST] = { x = -1, y = 0 }, | ||
[DIRECTION_SOUTHWEST] = { x = -1, y = 1 }, | ||
[DIRECTION_SOUTHEAST] = { x = 1, y = 1 }, | ||
[DIRECTION_NORTHWEST] = { x = -1, y = -1 }, | ||
[DIRECTION_NORTHEAST] = { x = 1, y = -1 } | ||
} | ||
|
||
function Position:getNextPosition(direction, steps) | ||
local offset = Position.directionOffset[direction] | ||
if offset then | ||
steps = steps or 1 | ||
self.x = self.x + offset.x * steps | ||
self.y = self.y + offset.y * steps | ||
end | ||
local offset = Position.directionOffset[direction] | ||
if offset then | ||
steps = steps or 1 | ||
self.x = self.x + offset.x * steps | ||
self.y = self.y + offset.y * steps | ||
end | ||
end | ||
|
||
function Position:moveUpstairs() | ||
local swap = function (lhs, rhs) | ||
lhs.x, rhs.x = rhs.x, lhs.x | ||
lhs.y, rhs.y = rhs.y, lhs.y | ||
lhs.z, rhs.z = rhs.z, lhs.z | ||
end | ||
local swap = function(lhs, rhs) | ||
lhs.x, rhs.x = rhs.x, lhs.x | ||
lhs.y, rhs.y = rhs.y, lhs.y | ||
lhs.z, rhs.z = rhs.z, lhs.z | ||
end | ||
|
||
self.z = self.z - 1 | ||
self.z = self.z - 1 | ||
|
||
local defaultPosition = self + Position.directionOffset[DIRECTION_SOUTH] | ||
local toTile = Tile(defaultPosition) | ||
if not toTile or not toTile:isWalkable() then | ||
for direction = DIRECTION_NORTH, DIRECTION_NORTHEAST do | ||
if direction == DIRECTION_SOUTH then | ||
direction = DIRECTION_WEST | ||
end | ||
local defaultPosition = self + Position.directionOffset[DIRECTION_SOUTH] | ||
local toTile = Tile(defaultPosition) | ||
if not toTile or not toTile:isWalkable() then | ||
for direction = DIRECTION_NORTH, DIRECTION_NORTHEAST do | ||
if direction == DIRECTION_SOUTH then | ||
direction = DIRECTION_WEST | ||
end | ||
|
||
local position = self + Position.directionOffset[direction] | ||
toTile = Tile(position) | ||
if toTile and toTile:isWalkable() then | ||
swap(self, position) | ||
return self | ||
end | ||
end | ||
end | ||
swap(self, defaultPosition) | ||
return self | ||
local position = self + Position.directionOffset[direction] | ||
toTile = Tile(position) | ||
if toTile and toTile:isWalkable() then | ||
swap(self, position) | ||
return self | ||
end | ||
end | ||
end | ||
swap(self, defaultPosition) | ||
return self | ||
end | ||
|
||
function Position:isInRange(from, to) | ||
-- No matter what corner from and to is, we want to make | ||
-- life easier by calculating north-west and south-east | ||
local zone = { | ||
nW = { | ||
x = (from.x < to.x and from.x or to.x), | ||
y = (from.y < to.y and from.y or to.y), | ||
z = (from.z < to.z and from.z or to.z) | ||
}, | ||
sE = { | ||
x = (to.x > from.x and to.x or from.x), | ||
y = (to.y > from.y and to.y or from.y), | ||
z = (to.z > from.z and to.z or from.z) | ||
} | ||
} | ||
-- No matter what corner from and to is, we want to make | ||
-- life easier by calculating north-west and south-east | ||
local zone = { | ||
nW = { | ||
x = (from.x < to.x and from.x or to.x), | ||
y = (from.y < to.y and from.y or to.y), | ||
z = (from.z < to.z and from.z or to.z) | ||
}, | ||
sE = { | ||
x = (to.x > from.x and to.x or from.x), | ||
y = (to.y > from.y and to.y or from.y), | ||
z = (to.z > from.z and to.z or from.z) | ||
} | ||
} | ||
|
||
if self.x >= zone.nW.x and self.x <= zone.sE.x | ||
and self.y >= zone.nW.y and self.y <= zone.sE.y | ||
and self.z >= zone.nW.z and self.z <= zone.sE.z then | ||
return true | ||
end | ||
return false | ||
if self.x >= zone.nW.x and self.x <= zone.sE.x | ||
and self.y >= zone.nW.y and self.y <= zone.sE.y | ||
and self.z >= zone.nW.z and self.z <= zone.sE.z then | ||
return true | ||
end | ||
return false | ||
end |
Oops, something went wrong.