Some improvements to some things.

This commit is contained in:
BenDol 2014-06-02 10:04:56 +12:00
parent a7d7667491
commit 2df51622ba
7 changed files with 34 additions and 15 deletions

View File

@ -284,10 +284,6 @@ function numbertoboolean(number)
end end
end end
function postostring(pos)
return pos.x .. " " .. pos.y .. " " .. pos.z
end
function signalcall(param, ...) function signalcall(param, ...)
if type(param) == 'function' then if type(param) == 'function' then
local status, ret = pcall(param, ...) local status, ret = pcall(param, ...)

View File

@ -34,14 +34,25 @@ EmblemOther = 5
VipIconFirst = 0 VipIconFirst = 0
VipIconLast = 10 VipIconLast = 10
North = 0 Directions = {
East = 1 North = 0,
South = 2 East = 1,
West = 3 South = 2,
NorthEast = 4 West = 3,
SouthEast = 5 NorthEast = 4,
SouthWest = 6 SouthEast = 5,
NorthWest = 7 SouthWest = 6,
NorthWest = 7
}
North = Directions.North
East = Directions.East
South = Directions.South
West = Directions.West
NorthEast = Directions.NorthEast
SouthEast = Directions.SouthEast
SouthWest = Directions.SouthWest
NorthWest = Directions.NorthWest
FightOffensive = 1 FightOffensive = 1
FightBalanced = 2 FightBalanced = 2

View File

@ -9,6 +9,7 @@ Module
@onLoad: | @onLoad: |
dofile 'const' dofile 'const'
dofile 'util'
dofile 'protocol' dofile 'protocol'
dofile 'protocollogin' dofile 'protocollogin'
dofile 'protocolgame' dofile 'protocolgame'

View File

@ -19,3 +19,8 @@ function Position.lessThan(pos1, pos2, orEqualTo)
return pos1.x < pos2.x or pos1.y < pos2.y or pos1.z < pos2.z return pos1.x < pos2.x or pos1.y < pos2.y or pos1.z < pos2.z
end end
end end
function Position.isInRange(pos1, pos2, minXRange, maxXRange, minYRange, maxYRange)
return (pos2.x >= pos1.x-minXRange and pos2.x <= pos1.x+maxXRange and pos2.y
>= pos1.y-minYRange and pos2.y <= pos1.y+maxYRange and pos2.z == pos1.z);
end

View File

@ -116,6 +116,7 @@ public:
bool isWalking() { return m_walking; } bool isWalking() { return m_walking; }
bool isRemoved() { return m_removed; } bool isRemoved() { return m_removed; }
bool isInvisible() { return m_outfit.getCategory() == ThingCategoryEffect && m_outfit.getAuxId() == 13; } bool isInvisible() { return m_outfit.getCategory() == ThingCategoryEffect && m_outfit.getAuxId() == 13; }
bool isDead() { return m_healthPercent <= 0; }
bool canBeSeen() { return !isInvisible() || isPlayer(); } bool canBeSeen() { return !isInvisible() || isPlayer(); }
bool isCreature() { return true; } bool isCreature() { return true; }

View File

@ -1597,10 +1597,12 @@ void Game::setClientVersion(int version)
void Game::setAttackingCreature(const CreaturePtr& creature) void Game::setAttackingCreature(const CreaturePtr& creature)
{ {
CreaturePtr oldCreature = m_attackingCreature; if(creature != m_attackingCreature) {
m_attackingCreature = creature; CreaturePtr oldCreature = m_attackingCreature;
m_attackingCreature = creature;
g_lua.callGlobalField("g_game", "onAttackingCreatureChange", creature, oldCreature); g_lua.callGlobalField("g_game", "onAttackingCreatureChange", creature, oldCreature);
}
} }
void Game::setFollowingCreature(const CreaturePtr& creature) void Game::setFollowingCreature(const CreaturePtr& creature)

View File

@ -376,6 +376,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<Thing>("isTranslucent", &Thing::isTranslucent); g_lua.bindClassMemberFunction<Thing>("isTranslucent", &Thing::isTranslucent);
g_lua.bindClassMemberFunction<Thing>("isFullGround", &Thing::isFullGround); g_lua.bindClassMemberFunction<Thing>("isFullGround", &Thing::isFullGround);
g_lua.bindClassMemberFunction<Thing>("isMarketable", &Thing::isMarketable); g_lua.bindClassMemberFunction<Thing>("isMarketable", &Thing::isMarketable);
g_lua.bindClassMemberFunction<Thing>("isLyingCorpse", &Thing::isLyingCorpse);
g_lua.bindClassMemberFunction<Thing>("getParentContainer", &Thing::getParentContainer); g_lua.bindClassMemberFunction<Thing>("getParentContainer", &Thing::getParentContainer);
g_lua.bindClassMemberFunction<Thing>("getMarketData", &Thing::getMarketData); g_lua.bindClassMemberFunction<Thing>("getMarketData", &Thing::getMarketData);
@ -457,6 +458,8 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<Creature>("hideStaticSquare", &Creature::hideStaticSquare); g_lua.bindClassMemberFunction<Creature>("hideStaticSquare", &Creature::hideStaticSquare);
g_lua.bindClassMemberFunction<Creature>("isWalking", &Creature::isWalking); g_lua.bindClassMemberFunction<Creature>("isWalking", &Creature::isWalking);
g_lua.bindClassMemberFunction<Creature>("isInvisible", &Creature::isInvisible); g_lua.bindClassMemberFunction<Creature>("isInvisible", &Creature::isInvisible);
g_lua.bindClassMemberFunction<Creature>("isDead", &Creature::isDead);
g_lua.bindClassMemberFunction<Creature>("isRemoved", &Creature::isRemoved);
g_lua.bindClassMemberFunction<Creature>("canBeSeen", &Creature::canBeSeen); g_lua.bindClassMemberFunction<Creature>("canBeSeen", &Creature::canBeSeen);
g_lua.bindClassMemberFunction<Creature>("jump", &Creature::jump); g_lua.bindClassMemberFunction<Creature>("jump", &Creature::jump);