mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-04 06:54:39 +00:00
Forms decoupling #2.
Added Lua functions: + avatar_setCanCollideWithShots() + avatar_canCollideWithShots() + avatar_setCollisionAvoidanceData()
This commit is contained in:
parent
e8a7889f82
commit
ec7dd94a1c
3 changed files with 51 additions and 7 deletions
|
@ -120,6 +120,12 @@ const float NOTE_ACCEPT_ANGLE_OFFSET = 15;
|
|||
const int COLLIDE_RADIUS_NORMAL = 10;
|
||||
const int COLLIDE_RADIUS_FISH = 8;
|
||||
|
||||
const int COLLIDE_RANGE_NORMAL = 2;
|
||||
const int COLLIDE_RANGE_FISH = 1;
|
||||
|
||||
const float COLLIDE_MOD_NORMAL = 1.0f;
|
||||
const float COLLIDE_MOD_FISH = 0.1f;
|
||||
|
||||
const int requiredDualFormCharge = 3;
|
||||
|
||||
bool usingDigital = false;
|
||||
|
@ -1591,6 +1597,7 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF
|
|||
|
||||
collideRadius = COLLIDE_RADIUS_NORMAL;
|
||||
setCanLockToWall(true);
|
||||
setCollisionAvoidanceData(COLLIDE_RANGE_NORMAL, COLLIDE_MOD_NORMAL);
|
||||
}
|
||||
break;
|
||||
case FORM_SUN:
|
||||
|
@ -1731,6 +1738,7 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF
|
|||
|
||||
collideRadius = COLLIDE_RADIUS_FISH;
|
||||
setCanLockToWall(false);
|
||||
setCollisionAvoidanceData(COLLIDE_RANGE_FISH, COLLIDE_MOD_FISH);
|
||||
}
|
||||
break;
|
||||
case FORM_SUN:
|
||||
|
@ -4113,6 +4121,10 @@ Avatar::Avatar() : Entity(), ActionMapper()
|
|||
_canBurst = true;
|
||||
_canLockToWall = true;
|
||||
_canSwimAgainstCurrents = false;
|
||||
_canCollideWithShots = true;
|
||||
|
||||
_collisionAvoidMod = COLLIDE_MOD_NORMAL;
|
||||
_collisionAvoidRange = COLLIDE_RANGE_NORMAL;
|
||||
}
|
||||
|
||||
void Avatar::revert()
|
||||
|
@ -5407,6 +5419,12 @@ void Avatar::setCanActivateStuff(bool on)
|
|||
_canActivateStuff = on;
|
||||
}
|
||||
|
||||
void Avatar::setCollisionAvoidanceData(int range, float mod)
|
||||
{
|
||||
_collisionAvoidRange = range;
|
||||
_collisionAvoidMod = mod;
|
||||
}
|
||||
|
||||
bool Avatar::canQuickSong()
|
||||
{
|
||||
return !isSinging() && !isEntityDead() && isInputEnabled() && quickSongCastDelay <= 0;
|
||||
|
@ -7073,13 +7091,9 @@ void Avatar::onUpdate(float dt)
|
|||
|
||||
}
|
||||
|
||||
if (!state.lockedToWall && !bursting && _isUnderWater && swimming && !isFollowingPath())
|
||||
if (!state.lockedToWall && !bursting && _isUnderWater && swimming && !isFollowingPath() && _collisionAvoidRange > 0)
|
||||
{
|
||||
//debugLog("collision avoidance");
|
||||
if (dsq->continuity.form == FORM_FISH)
|
||||
doCollisionAvoidance(dt, 1, 0.1, 0, 800, OT_HURT);
|
||||
else
|
||||
doCollisionAvoidance(dt, 2, 1.0, 0, 800, OT_HURT);
|
||||
doCollisionAvoidance(dt, _collisionAvoidRange, _collisionAvoidMod, 0, 800, OT_HURT);
|
||||
}
|
||||
|
||||
if (!game->isShuttingDownGameState())
|
||||
|
@ -7312,6 +7326,7 @@ void Avatar::onUpdate(float dt)
|
|||
rightHandEmitter->position = boneRightHand->getWorldCollidePosition(Vector(0,16));
|
||||
}
|
||||
|
||||
if(canCollideWithShots())
|
||||
dsq->game->handleShotCollisions(this, (activeAura == AURA_SHIELD));
|
||||
}
|
||||
|
||||
|
|
|
@ -329,6 +329,11 @@ public:
|
|||
bool canSwimAgainstCurrents() const { return _canSwimAgainstCurrents; }
|
||||
void setCanSwimAgainstCurrents(bool b) { _canSwimAgainstCurrents = b; }
|
||||
|
||||
bool canCollideWithShots() const { return _canCollideWithShots; }
|
||||
void setCollideWithShots(bool b) { _canCollideWithShots = b; }
|
||||
|
||||
void setCollisionAvoidanceData(int range, float mod);
|
||||
|
||||
int leaches;
|
||||
|
||||
protected:
|
||||
|
@ -465,6 +470,10 @@ protected:
|
|||
bool _canBurst;
|
||||
bool _canLockToWall;
|
||||
bool _canSwimAgainstCurrents;
|
||||
bool _canCollideWithShots;
|
||||
|
||||
int _collisionAvoidRange;
|
||||
float _collisionAvoidMod;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -2758,6 +2758,23 @@ luaFunc(avatar_canSwimAgainstCurrents)
|
|||
luaReturnBool(dsq->game->avatar->canSwimAgainstCurrents());
|
||||
}
|
||||
|
||||
luaFunc(avatar_setCanCollideWithShots)
|
||||
{
|
||||
dsq->game->avatar->setCollideWithShots(getBool(L, 1));
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(avatar_canCollideWithShots)
|
||||
{
|
||||
luaReturnBool(dsq->game->avatar->canCollideWithShots());
|
||||
}
|
||||
|
||||
luaFunc(avatar_setCollisionAvoidanceData)
|
||||
{
|
||||
dsq->game->avatar->setCollisionAvoidanceData(lua_tointeger(L, 1), lua_tonumber(L, 2));
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
|
||||
luaFunc(avatar_toggleCape)
|
||||
{
|
||||
|
@ -7771,6 +7788,9 @@ static const struct {
|
|||
luaRegister(avatar_canBurst),
|
||||
luaRegister(avatar_setCanSwimAgainstCurrents),
|
||||
luaRegister(avatar_canSwimAgainstCurrents),
|
||||
luaRegister(avatar_setCanCollideWithShots),
|
||||
luaRegister(avatar_canCollideWithShots),
|
||||
luaRegister(avatar_setCollisionAvoidanceData),
|
||||
|
||||
luaRegister(avatar_clampPosition),
|
||||
luaRegister(avatar_updatePosition),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue