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_NORMAL = 10;
|
||||||
const int COLLIDE_RADIUS_FISH = 8;
|
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;
|
const int requiredDualFormCharge = 3;
|
||||||
|
|
||||||
bool usingDigital = false;
|
bool usingDigital = false;
|
||||||
|
@ -1591,6 +1597,7 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF
|
||||||
|
|
||||||
collideRadius = COLLIDE_RADIUS_NORMAL;
|
collideRadius = COLLIDE_RADIUS_NORMAL;
|
||||||
setCanLockToWall(true);
|
setCanLockToWall(true);
|
||||||
|
setCollisionAvoidanceData(COLLIDE_RANGE_NORMAL, COLLIDE_MOD_NORMAL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FORM_SUN:
|
case FORM_SUN:
|
||||||
|
@ -1731,6 +1738,7 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF
|
||||||
|
|
||||||
collideRadius = COLLIDE_RADIUS_FISH;
|
collideRadius = COLLIDE_RADIUS_FISH;
|
||||||
setCanLockToWall(false);
|
setCanLockToWall(false);
|
||||||
|
setCollisionAvoidanceData(COLLIDE_RANGE_FISH, COLLIDE_MOD_FISH);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FORM_SUN:
|
case FORM_SUN:
|
||||||
|
@ -4113,6 +4121,10 @@ Avatar::Avatar() : Entity(), ActionMapper()
|
||||||
_canBurst = true;
|
_canBurst = true;
|
||||||
_canLockToWall = true;
|
_canLockToWall = true;
|
||||||
_canSwimAgainstCurrents = false;
|
_canSwimAgainstCurrents = false;
|
||||||
|
_canCollideWithShots = true;
|
||||||
|
|
||||||
|
_collisionAvoidMod = COLLIDE_MOD_NORMAL;
|
||||||
|
_collisionAvoidRange = COLLIDE_RANGE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::revert()
|
void Avatar::revert()
|
||||||
|
@ -5407,6 +5419,12 @@ void Avatar::setCanActivateStuff(bool on)
|
||||||
_canActivateStuff = on;
|
_canActivateStuff = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Avatar::setCollisionAvoidanceData(int range, float mod)
|
||||||
|
{
|
||||||
|
_collisionAvoidRange = range;
|
||||||
|
_collisionAvoidMod = mod;
|
||||||
|
}
|
||||||
|
|
||||||
bool Avatar::canQuickSong()
|
bool Avatar::canQuickSong()
|
||||||
{
|
{
|
||||||
return !isSinging() && !isEntityDead() && isInputEnabled() && quickSongCastDelay <= 0;
|
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");
|
doCollisionAvoidance(dt, _collisionAvoidRange, _collisionAvoidMod, 0, 800, OT_HURT);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!game->isShuttingDownGameState())
|
if (!game->isShuttingDownGameState())
|
||||||
|
@ -7312,7 +7326,8 @@ void Avatar::onUpdate(float dt)
|
||||||
rightHandEmitter->position = boneRightHand->getWorldCollidePosition(Vector(0,16));
|
rightHandEmitter->position = boneRightHand->getWorldCollidePosition(Vector(0,16));
|
||||||
}
|
}
|
||||||
|
|
||||||
dsq->game->handleShotCollisions(this, (activeAura == AURA_SHIELD));
|
if(canCollideWithShots())
|
||||||
|
dsq->game->handleShotCollisions(this, (activeAura == AURA_SHIELD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -329,6 +329,11 @@ public:
|
||||||
bool canSwimAgainstCurrents() const { return _canSwimAgainstCurrents; }
|
bool canSwimAgainstCurrents() const { return _canSwimAgainstCurrents; }
|
||||||
void setCanSwimAgainstCurrents(bool b) { _canSwimAgainstCurrents = b; }
|
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;
|
int leaches;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -465,6 +470,10 @@ protected:
|
||||||
bool _canBurst;
|
bool _canBurst;
|
||||||
bool _canLockToWall;
|
bool _canLockToWall;
|
||||||
bool _canSwimAgainstCurrents;
|
bool _canSwimAgainstCurrents;
|
||||||
|
bool _canCollideWithShots;
|
||||||
|
|
||||||
|
int _collisionAvoidRange;
|
||||||
|
float _collisionAvoidMod;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2758,6 +2758,23 @@ luaFunc(avatar_canSwimAgainstCurrents)
|
||||||
luaReturnBool(dsq->game->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)
|
luaFunc(avatar_toggleCape)
|
||||||
{
|
{
|
||||||
|
@ -7771,6 +7788,9 @@ static const struct {
|
||||||
luaRegister(avatar_canBurst),
|
luaRegister(avatar_canBurst),
|
||||||
luaRegister(avatar_setCanSwimAgainstCurrents),
|
luaRegister(avatar_setCanSwimAgainstCurrents),
|
||||||
luaRegister(avatar_canSwimAgainstCurrents),
|
luaRegister(avatar_canSwimAgainstCurrents),
|
||||||
|
luaRegister(avatar_setCanCollideWithShots),
|
||||||
|
luaRegister(avatar_canCollideWithShots),
|
||||||
|
luaRegister(avatar_setCollisionAvoidanceData),
|
||||||
|
|
||||||
luaRegister(avatar_clampPosition),
|
luaRegister(avatar_clampPosition),
|
||||||
luaRegister(avatar_updatePosition),
|
luaRegister(avatar_updatePosition),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue