mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-26 16:03:58 +00:00
Minor refactor & add Lua funcs:
+ avatar_setShieldActive() + entity_isFillGrid() * entity_setBoneLock() code made easier to read and not warn on no lock entity + entity_getMaxSpeedLerp() + entity_isEntityInside()
This commit is contained in:
parent
035ad963f5
commit
3ed40e73d3
9 changed files with 90 additions and 70 deletions
|
@ -4686,6 +4686,35 @@ void Avatar::action(int id, int state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Avatar::doBindSong()
|
||||||
|
{
|
||||||
|
if (pullTarget)
|
||||||
|
{
|
||||||
|
pullTarget->stopPull();
|
||||||
|
pullTarget = 0;
|
||||||
|
core->sound->playSfx("Denied");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dsq->game->bindIngredients();
|
||||||
|
setNearestPullTarget();
|
||||||
|
if (!pullTarget)
|
||||||
|
{
|
||||||
|
core->sound->playSfx("Denied");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
core->sound->playSfx("Bind");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Avatar::doShieldSong()
|
||||||
|
{
|
||||||
|
core->sound->playSfx("Shield-On");
|
||||||
|
activateAura(AURA_SHIELD);
|
||||||
|
}
|
||||||
|
|
||||||
void Avatar::render()
|
void Avatar::render()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -317,6 +317,8 @@ public:
|
||||||
bool canSetBoneLock();
|
bool canSetBoneLock();
|
||||||
|
|
||||||
void revert();
|
void revert();
|
||||||
|
void doBindSong();
|
||||||
|
void doShieldSong();
|
||||||
|
|
||||||
int leaches;
|
int leaches;
|
||||||
|
|
||||||
|
|
|
@ -1347,16 +1347,6 @@ Song *Continuity::getSongByIndex(int idx)
|
||||||
return &songBank[idx];
|
return &songBank[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Continuity::getSongBankSize()
|
|
||||||
{
|
|
||||||
int c = 0;
|
|
||||||
for (SongMap::iterator i = songBank.begin(); i != songBank.end(); i++)
|
|
||||||
{
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Continuity::castSong(int num)
|
void Continuity::castSong(int num)
|
||||||
{
|
{
|
||||||
if (!dsq->continuity.hasSong((SongType)num)) return;
|
if (!dsq->continuity.hasSong((SongType)num)) return;
|
||||||
|
@ -1409,32 +1399,10 @@ void Continuity::castSong(int num)
|
||||||
switch((SongType)num)
|
switch((SongType)num)
|
||||||
{
|
{
|
||||||
case SONG_SHIELDAURA:
|
case SONG_SHIELDAURA:
|
||||||
core->sound->playSfx("Shield-On");
|
dsq->game->avatar->doShieldSong();
|
||||||
dsq->game->avatar->activateAura(AURA_SHIELD);
|
|
||||||
break;
|
break;
|
||||||
case SONG_BIND:
|
case SONG_BIND:
|
||||||
//debugLog("sang pull");
|
dsq->game->avatar->doBindSong();
|
||||||
if (dsq->game->avatar->pullTarget)
|
|
||||||
{
|
|
||||||
dsq->game->avatar->pullTarget->stopPull();
|
|
||||||
dsq->game->avatar->pullTarget = 0;
|
|
||||||
core->sound->playSfx("Denied");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dsq->game->bindIngredients();
|
|
||||||
dsq->game->avatar->setNearestPullTarget();
|
|
||||||
if (!dsq->game->avatar->pullTarget)
|
|
||||||
{
|
|
||||||
core->sound->playSfx("Denied");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
core->sound->playSfx("Bind");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//dsq->game->avatar->openPullTargetInterface();
|
|
||||||
//pickingPullTarget = true;
|
|
||||||
break;
|
break;
|
||||||
case SONG_ENERGYFORM:
|
case SONG_ENERGYFORM:
|
||||||
dsq->game->avatar->changeForm(FORM_ENERGY);
|
dsq->game->avatar->changeForm(FORM_ENERGY);
|
||||||
|
|
|
@ -996,7 +996,6 @@ public:
|
||||||
FormUpgrades formUpgrades;
|
FormUpgrades formUpgrades;
|
||||||
|
|
||||||
void loadSongBank();
|
void loadSongBank();
|
||||||
int getSongBankSize();
|
|
||||||
void loadIntoSongBank(const std::string &file);
|
void loadIntoSongBank(const std::string &file);
|
||||||
int checkSong(const Song &song);
|
int checkSong(const Song &song);
|
||||||
int checkSongAssisted(const Song &song);
|
int checkSongAssisted(const Song &song);
|
||||||
|
|
|
@ -3133,3 +3133,14 @@ void Entity::exertHairForce(const Vector &force, float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Entity::isEntityInside()
|
||||||
|
{
|
||||||
|
FOR_ENTITIES(i)
|
||||||
|
{
|
||||||
|
Entity *e = *i;
|
||||||
|
if (e && e->life == 1 && e != this && e->ridingOnEntity != this && isCoordinateInside(e->position))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -489,6 +489,8 @@ public:
|
||||||
void setHairHeadPosition(const Vector &pos);
|
void setHairHeadPosition(const Vector &pos);
|
||||||
void exertHairForce(const Vector &force, float dt);
|
void exertHairForce(const Vector &force, float dt);
|
||||||
|
|
||||||
|
bool isEntityInside();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool calledEntityDied;
|
bool calledEntityDied;
|
||||||
Path *waterBubble;
|
Path *waterBubble;
|
||||||
|
|
|
@ -2112,18 +2112,22 @@ luaFunc(entity_setRidingData)
|
||||||
luaFunc(entity_setBoneLock)
|
luaFunc(entity_setBoneLock)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
Entity *e2 = entity(L, 2);
|
|
||||||
Bone *b = 0;
|
|
||||||
if (lua_isuserdata(L, 3))
|
|
||||||
b = bone(L, 3);
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
BoneLock bl;
|
BoneLock bl;
|
||||||
bl.entity = e2;
|
if (lua_isuserdata(L, 2))
|
||||||
bl.bone = b;
|
{
|
||||||
bl.on = true;
|
Entity *e2 = entity(L, 2);
|
||||||
bl.collisionMaskIndex = dsq->game->lastCollideMaskIndex;
|
Bone *b = 0;
|
||||||
|
if (lua_isuserdata(L, 3))
|
||||||
|
b = bone(L, 3);
|
||||||
|
|
||||||
|
bl.entity = e2;
|
||||||
|
bl.bone = b;
|
||||||
|
bl.on = true;
|
||||||
|
bl.collisionMaskIndex = dsq->game->lastCollideMaskIndex;
|
||||||
|
}
|
||||||
ret = e->setBoneLock(bl);
|
ret = e->setBoneLock(bl);
|
||||||
}
|
}
|
||||||
luaReturnBool(ret);
|
luaReturnBool(ret);
|
||||||
|
@ -2553,6 +2557,12 @@ luaFunc(entity_setFillGrid)
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(entity_isFillGrid)
|
||||||
|
{
|
||||||
|
Entity *e = entity(L);
|
||||||
|
luaReturnBool(e ? e->fillGridFromQuad : false);
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(entity_getAimVector)
|
luaFunc(entity_getAimVector)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
|
@ -2731,6 +2741,16 @@ luaFunc(avatar_isShieldActive)
|
||||||
luaReturnBool(v);
|
luaReturnBool(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(avatar_setShieldActive)
|
||||||
|
{
|
||||||
|
bool on = getBool(L, 1);
|
||||||
|
if (on)
|
||||||
|
dsq->game->avatar->activateAura(AURA_SHIELD);
|
||||||
|
else
|
||||||
|
dsq->game->avatar->stopAura();
|
||||||
|
luaReturnNil();
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(avatar_getStillTimer)
|
luaFunc(avatar_getStillTimer)
|
||||||
{
|
{
|
||||||
luaReturnNum(dsq->game->avatar->stillTimer.getValue());
|
luaReturnNum(dsq->game->avatar->stillTimer.getValue());
|
||||||
|
@ -5049,6 +5069,12 @@ luaFunc(entity_setMaxSpeedLerp)
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(entity_getMaxSpeedLerp)
|
||||||
|
{
|
||||||
|
Entity *e = entity(L);
|
||||||
|
luaReturnNum(e ? e->maxSpeedLerp.x : 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
// note: this is a weaker setState than perform
|
// note: this is a weaker setState than perform
|
||||||
// this is so that things can override it
|
// this is so that things can override it
|
||||||
// for example getting PUSH-ed (Force) or FROZEN (bubbled)
|
// for example getting PUSH-ed (Force) or FROZEN (bubbled)
|
||||||
|
@ -6165,6 +6191,12 @@ luaFunc(entity_getDistanceToEntity)
|
||||||
luaReturnNum(d);
|
luaReturnNum(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(entity_isEntityInside)
|
||||||
|
{
|
||||||
|
Entity *e = entity(L);
|
||||||
|
luaReturnBool(e ? e->isEntityInside() : false);
|
||||||
|
}
|
||||||
|
|
||||||
// entity_istargetInRange
|
// entity_istargetInRange
|
||||||
luaFunc(entity_isTargetInRange)
|
luaFunc(entity_isTargetInRange)
|
||||||
{
|
{
|
||||||
|
@ -7844,6 +7876,7 @@ static const struct {
|
||||||
|
|
||||||
luaRegister(entity_isTargetInRange),
|
luaRegister(entity_isTargetInRange),
|
||||||
luaRegister(entity_getDistanceToEntity),
|
luaRegister(entity_getDistanceToEntity),
|
||||||
|
luaRegister(entity_isEntityInside),
|
||||||
|
|
||||||
luaRegister(entity_isInvincible),
|
luaRegister(entity_isInvincible),
|
||||||
|
|
||||||
|
@ -7860,6 +7893,7 @@ static const struct {
|
||||||
luaRegister(entity_setMaxSpeed),
|
luaRegister(entity_setMaxSpeed),
|
||||||
luaRegister(entity_getMaxSpeed),
|
luaRegister(entity_getMaxSpeed),
|
||||||
luaRegister(entity_setMaxSpeedLerp),
|
luaRegister(entity_setMaxSpeedLerp),
|
||||||
|
luaRegister(entity_getMaxSpeedLerp),
|
||||||
luaRegister(entity_setState),
|
luaRegister(entity_setState),
|
||||||
luaRegister(entity_getState),
|
luaRegister(entity_getState),
|
||||||
luaRegister(entity_getEnqueuedState),
|
luaRegister(entity_getEnqueuedState),
|
||||||
|
@ -8050,6 +8084,7 @@ static const struct {
|
||||||
luaRegister(avatar_isRolling),
|
luaRegister(avatar_isRolling),
|
||||||
luaRegister(avatar_isOnWall),
|
luaRegister(avatar_isOnWall),
|
||||||
luaRegister(avatar_isShieldActive),
|
luaRegister(avatar_isShieldActive),
|
||||||
|
luaRegister(avatar_setShieldActive),
|
||||||
luaRegister(avatar_getRollDirection),
|
luaRegister(avatar_getRollDirection),
|
||||||
|
|
||||||
luaRegister(avatar_fallOffWall),
|
luaRegister(avatar_fallOffWall),
|
||||||
|
@ -8278,6 +8313,7 @@ static const struct {
|
||||||
|
|
||||||
luaRegister(entity_setTexture),
|
luaRegister(entity_setTexture),
|
||||||
luaRegister(entity_setFillGrid),
|
luaRegister(entity_setFillGrid),
|
||||||
|
luaRegister(entity_isFillGrid),
|
||||||
|
|
||||||
luaRegister(entity_push),
|
luaRegister(entity_push),
|
||||||
|
|
||||||
|
|
|
@ -759,32 +759,6 @@ void ScriptedEntity::songNoteDone(int note, float len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptedEntity::isEntityInside()
|
|
||||||
{
|
|
||||||
bool v = false;
|
|
||||||
int avatars = 0;
|
|
||||||
FOR_ENTITIES(i)
|
|
||||||
{
|
|
||||||
Entity *e = *i;
|
|
||||||
if (e->getEntityType() == ET_AVATAR)
|
|
||||||
avatars ++;
|
|
||||||
if (e && e->life == 1 && e != this && e->ridingOnEntity != this)
|
|
||||||
{
|
|
||||||
if (isCoordinateInside(e->position))
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Vector diff = (e->position - position);
|
|
||||||
diff.setLength2D(100);
|
|
||||||
e->vel += diff;
|
|
||||||
*/
|
|
||||||
v = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptedEntity::becomeSolid()
|
void ScriptedEntity::becomeSolid()
|
||||||
{
|
{
|
||||||
//vel = 0;
|
//vel = 0;
|
||||||
|
|
|
@ -68,7 +68,6 @@ public:
|
||||||
typedef std::vector<Strand*> Strands;
|
typedef std::vector<Strand*> Strands;
|
||||||
Strands strands;
|
Strands strands;
|
||||||
int strandSpacing;
|
int strandSpacing;
|
||||||
bool isEntityInside();
|
|
||||||
void becomeSolid();
|
void becomeSolid();
|
||||||
|
|
||||||
std::string deathParticleEffect;
|
std::string deathParticleEffect;
|
||||||
|
|
Loading…
Add table
Reference in a new issue