1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-03 06:24:32 +00:00

Lua functions:

- Change entity_handleShotCollisionsHair(): Allow setting hair collision width percent
- Change entity_collideSkeletalVsCircle(): Allow colliding with any RenderObject
- Add entity_collideSkeletalVsCirclePos(): Allow specifying (x,y,radius)
This commit is contained in:
fgenesis 2014-03-28 03:54:58 +01:00
parent b8af382bd9
commit 664b2bd5f2
3 changed files with 20 additions and 10 deletions

View file

@ -8191,11 +8191,9 @@ bool Game::collideHairVsCircle(Entity *a, int num, const Vector &pos2, float rad
}
// NOTE THIS FUNCTION ASSUMES THAT IF A BONE ISN'T AT FULL ALPHA (1.0) IT IS DISABLED
Bone *Game::collideSkeletalVsCircle(Entity *skeletal, Entity *circle)
Bone *Game::collideSkeletalVsCircle(Entity *skeletal, RenderObject *circle)
{
Vector pos = circle->position;
return collideSkeletalVsCircle(skeletal, pos, circle->collideRadius);
return collideSkeletalVsCircle(skeletal, circle->position, circle->collideRadius);
}
Bone *Game::collideSkeletalVsLine(Entity *skeletal, Vector start, Vector end, float radius)
@ -8464,14 +8462,14 @@ void Game::handleShotCollisionsSkeletal(Entity *e)
}
}
void Game::handleShotCollisionsHair(Entity *e, int num)
void Game::handleShotCollisionsHair(Entity *e, int num, float perc)
{
for (size_t i = 0; i < Shot::shots.size(); ++i)
{
Shot *shot = Shot::shots[i];
if (shot->isActive() && isEntityCollideWithShot(e, shot))
{
bool b = collideHairVsCircle(e, num, shot->position, 8);
bool b = collideHairVsCircle(e, num, shot->position, 8, perc);
if (b)
{
lastCollidePosition = shot->position;

View file

@ -661,14 +661,14 @@ public:
bool collideHairVsCircle(Entity *a, int num, const Vector &pos2, float radius, float perc=0, int *colSegment=0);
bool collideCircleVsCircle(Entity *a, Entity *b);
Bone *collideSkeletalVsCircle(Entity *skeletal, Entity *circle);
Bone *collideSkeletalVsCircle(Entity *skeletal, RenderObject *circle);
Bone *collideSkeletalVsLine(Entity *skeletal, Vector start, Vector end, float radius);
bool collideCircleVsLine(RenderObject *r, Vector start, Vector end, float radius);
bool collideCircleVsLineAngle(RenderObject *r, float angle, float startLen, float endLen, float radius, Vector basePos);
Bone *collideSkeletalVsCircle(Entity *skeletal, Vector pos, float radius);
void handleShotCollisions(Entity *e, bool hasShield=false);
void handleShotCollisionsSkeletal(Entity *e);
void handleShotCollisionsHair(Entity *e, int num = 0);
void handleShotCollisionsHair(Entity *e, int num = 0, float perc = 0);
std::vector<ElementTemplate> elementTemplates;
std::string sceneName;

View file

@ -5075,7 +5075,7 @@ luaFunc(entity_handleShotCollisionsHair)
Entity *e = entity(L);
if (e)
{
dsq->game->handleShotCollisionsHair(e, lua_tonumber(L, 2));
dsq->game->handleShotCollisionsHair(e, lua_tointeger(L, 2), lua_tonumber(L, 3));
}
luaReturnNil();
}
@ -5083,7 +5083,7 @@ luaFunc(entity_handleShotCollisionsHair)
luaFunc(entity_collideSkeletalVsCircle)
{
Entity *e = entity(L);
Entity *e2 = entity(L,2);
RenderObject *e2 = robj(L,2);
Bone *b = 0;
if (e && e2)
{
@ -5092,6 +5092,17 @@ luaFunc(entity_collideSkeletalVsCircle)
luaReturnPtr(b);
}
luaFunc(entity_collideSkeletalVsCirclePos)
{
Entity *e = entity(L);
Bone *b = 0;
if (e)
{
b = dsq->game->collideSkeletalVsCircle(e, Vector(lua_tonumber(L, 2), lua_tonumber(L, 3)), lua_tonumber(L, 4));
}
luaReturnPtr(b);
}
luaFunc(entity_collideSkeletalVsLine)
{
Entity *e = entity(L);
@ -9598,6 +9609,7 @@ static const struct {
luaRegister(entity_handleShotCollisionsSkeletal),
luaRegister(entity_handleShotCollisionsHair),
luaRegister(entity_collideSkeletalVsCircle),
luaRegister(entity_collideSkeletalVsCirclePos),
luaRegister(entity_collideSkeletalVsLine),
luaRegister(entity_collideSkeletalVsCircleForListByName),
luaRegister(entity_collideCircleVsLine),