diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index 4bfb56f..7587178 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -744,7 +744,7 @@ void Avatar::toggleMovement(bool on) bool Avatar::isLockable() { - return (bursting || !_isUnderWater) && (boneLockDelay == 0) && (dsq->continuity.form != FORM_FISH); + return (bursting || !_isUnderWater) && (boneLockDelay == 0) && canLockToWall(); } bool Avatar::isSinging() @@ -1590,6 +1590,7 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF //rotationOffset.interpolateTo(Vector(0,0,0), 0.5); collideRadius = COLLIDE_RADIUS_NORMAL; + setCanLockToWall(true); } break; case FORM_SUN: @@ -1601,9 +1602,13 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF position = bodyPosition; dsq->continuity.warpLiToAvatar(); spiritBeaconEmitter.start(); + setCanActivateStuff(true); + setCanLockToWall(true); + setCanBurst(true); + setDamageTarget(DT_WALLHURT, true); break; case FORM_BEAST: - //dsq->game->sceneColor3.interpolateTo(Vector(1, 1, 1), 0.5); + setCanSwimAgainstCurrents(false); break; case FORM_DUAL: if (dsq->continuity.hasLi()) @@ -1613,6 +1618,9 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF dsq->game->li->setState(STATE_IDLE); } break; + case FORM_NATURE: + setDamageTarget(DT_WALLHURT, true); + break; default: if (leftHandEmitter && rightHandEmitter) { @@ -1722,6 +1730,7 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF //refreshModel("NaijaFish", ""); collideRadius = COLLIDE_RADIUS_FISH; + setCanLockToWall(false); } break; case FORM_SUN: @@ -1753,42 +1762,13 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF hair->setTexture("Naija/Cape-NatureForm"); hair->alphaMod = 1.0; } - /* - skeletalSprite.loadSkin("ChildTeira"); - refreshModel(); - */ - /* - if (dsq->game->sceneNatureForm == "forest") - { - debugLog("Forest Form"); - dsq->continuity.form = FORM_NATURE_FOREST; - } - else if (dsq->game->sceneNatureForm == "sun") - { - dsq->continuity.form = FORM_NATURE_SUN; - debugLog("Sun Form"); - } - else if (dsq->game->sceneNatureForm == "fire") - { - dsq->continuity.form = FORM_NATURE_FIRE; - debugLog("Fire Form"); - } - else if (dsq->game->sceneNatureForm == "dark") - { - dsq->continuity.form = FORM_NATURE_DARK; - debugLog("Dark Form"); - } - else if (dsq->game->sceneNatureForm == "rock" || dsq->game->sceneNatureForm.empty()) - { - dsq->continuity.form = FORM_NATURE_ROCK; - debugLog("Rock Form"); - } - */ + setDamageTarget(DT_WALLHURT, false); break; case FORM_BEAST: { refreshModel("Naija", "BeastForm"); + setCanSwimAgainstCurrents(true); } break; case FORM_SPIRIT: @@ -1796,6 +1776,10 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF bodyOffset = offset; fallOffWall(); dsq->continuity.shiftWorlds(); + setCanActivateStuff(false); + setCanLockToWall(false); + setCanBurst(false); + setDamageTarget(DT_WALLHURT, false); if (onInit) { @@ -3490,8 +3474,8 @@ void Avatar::lockToWallCommon() void Avatar::lockToWall() { if (riding) return; - if (inCurrent && dsq->continuity.form != FORM_BEAST) return; - if (dsq->continuity.form == FORM_FISH || dsq->continuity.form == FORM_SPIRIT) return; + if (inCurrent && !canSwimAgainstCurrents()) return; + if (!canLockToWall()) return; if (state.lockedToWall) return; if (vel.x == 0 && vel.y == 0) return; if (dsq->game->isPaused()) return; @@ -3589,7 +3573,7 @@ void Avatar::lockToWall() } } - if (dsq->game->getGrid(t)==OT_HURT && dsq->continuity.form != FORM_NATURE) + if (dsq->game->getGrid(t)==OT_HURT && isDamageTarget(DT_WALLHURT)) { good = false; } @@ -4123,6 +4107,12 @@ Avatar::Avatar() : Entity(), ActionMapper() collideRadius = COLLIDE_RADIUS_FISH; else collideRadius = COLLIDE_RADIUS_NORMAL; + + // defaults for normal form + _canActivateStuff = true; + _canBurst = true; + _canLockToWall = true; + _canSwimAgainstCurrents = false; } void Avatar::revert() @@ -4319,7 +4309,7 @@ void Avatar::startBurstCommon() void Avatar::startBurst() { - if (!riding && dsq->continuity.form != FORM_SPIRIT && (joystickMove || getVectorToCursor().getSquaredLength2D() > sqr(BURST_DISTANCE)) + if (!riding && canBurst() && (joystickMove || getVectorToCursor().getSquaredLength2D() > sqr(BURST_DISTANCE)) && getState() != STATE_PUSH && (!skeletalSprite.getCurrentAnimation() || (skeletalSprite.getCurrentAnimation()->name != "spin")) && _isUnderWater && !isActing(ACTION_ROLL)) { @@ -5409,7 +5399,12 @@ void Avatar::setWasUnderWater() bool Avatar::canActivateStuff() { - return dsq->continuity.form != FORM_SPIRIT; + return _canActivateStuff; +} + +void Avatar::setCanActivateStuff(bool on) +{ + _canActivateStuff = on; } bool Avatar::canQuickSong() @@ -7142,7 +7137,6 @@ void Avatar::onUpdate(float dt) else omov -= mov; - lastLastPosition = position; lastPosition = position; Vector newPosition = position + mov; //Vector testPosition = position + (vel *dt)*2; @@ -7151,11 +7145,11 @@ void Avatar::onUpdate(float dt) if (dsq->game->collideCircleWithGrid(position, collideRadius)) { if (dsq->game->lastCollideTileType == OT_HURT - && !dsq->game->isWorldPaused() - && dsq->continuity.form != FORM_NATURE) + && isDamageTarget(DT_WALLHURT)) { DamageData d; d.damage = 1; + d.damageType = DT_WALLHURT; damage(d); vel2 = Vector(0,0,0); //doCollisionAvoidance(1, 3, 1); @@ -7338,7 +7332,7 @@ void Avatar::checkNearWall() { t.x = oT.x + v.x*i; t.y = oT.y + v.y*i; - if (dsq->game->isObstructed(t) && dsq->game->getGrid(t) != OT_HURT) + if (dsq->game->isObstructed(t, ~OT_HURT)) { obs = true; break; diff --git a/Aquaria/Avatar.h b/Aquaria/Avatar.h index f7be754..d93c2e4 100644 --- a/Aquaria/Avatar.h +++ b/Aquaria/Avatar.h @@ -283,6 +283,7 @@ public: void endOfGameState(); bool canQuickSong(); bool canActivateStuff(); + void setCanActivateStuff(bool on); bool hasThingToActivate(); float biteTimer; @@ -319,6 +320,15 @@ public: void doBindSong(); void doShieldSong(); + bool canBurst() const { return _canBurst; } + void setCanBurst(bool b) { _canBurst = b; } + + bool canLockToWall() const { return _canLockToWall; } + void setCanLockToWall(bool b) { _canLockToWall = b; } + + bool canSwimAgainstCurrents() const { return _canSwimAgainstCurrents; } + void setCanSwimAgainstCurrents(bool b) { _canSwimAgainstCurrents = b; } + int leaches; protected: @@ -451,7 +461,10 @@ protected: void lockToWall(); void doShock(const std::string &shotName); - Vector lastLastPosition; + bool _canActivateStuff; + bool _canBurst; + bool _canLockToWall; + bool _canSwimAgainstCurrents; }; diff --git a/Aquaria/Continuity.cpp b/Aquaria/Continuity.cpp index 8d58c58..18ee693 100644 --- a/Aquaria/Continuity.cpp +++ b/Aquaria/Continuity.cpp @@ -2024,7 +2024,7 @@ void Continuity::applyWorldEffects(WorldType type, bool transition, bool affectM dsq->game->avatar->enableInput(); */ } - //worldType = type; + worldType = type; } void Continuity::eatBeast(const EatData &eatData) diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 6f0079e..77343d0 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -4564,6 +4564,10 @@ void DSQ::onUpdate(float dt) os << " headRot: " << b->rotation.z; os << std::endl; os << "fh: " << dsq->game->avatar->isfh() << " fv: " << dsq->game->avatar->isfv() << std::endl; + os << "canActivate: " << dsq->game->avatar->canActivateStuff(); + os << " canBurst: " << dsq->game->avatar->canBurst(); + os << " canLTW: " << dsq->game->avatar->canLockToWall(); + os << " canSAC: " << dsq->game->avatar->canSwimAgainstCurrents() << std::endl; } // DO NOT CALL AVATAR-> beyond this point diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index e4d464d..67cfd20 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -1419,7 +1419,7 @@ bool Entity::updateCurrents(float dt) float useLen = len; if (useLen < 500) useLen = 500; - if (!(this->getEntityType() == ET_AVATAR && dsq->continuity.form == FORM_BEAST && dsq->game->avatar->bursting)) + if (!(this->getEntityType() == ET_AVATAR && dsq->game->avatar->canSwimAgainstCurrents() && dsq->game->avatar->bursting)) { doCollisionAvoidance(1, 4, 1, &vel2, useLen); } @@ -1439,7 +1439,7 @@ bool Entity::updateCurrents(float dt) } } } - if (this->getEntityType() == ET_AVATAR && dsq->continuity.form == FORM_BEAST) + if (this->getEntityType() == ET_AVATAR && dsq->game->avatar->canSwimAgainstCurrents()) { int cap = 100; if (!vel.isZero()) diff --git a/Aquaria/Entity.h b/Aquaria/Entity.h index d89154e..2cd38c6 100644 --- a/Aquaria/Entity.h +++ b/Aquaria/Entity.h @@ -123,6 +123,7 @@ enum DamageType DT_CRUSH = 1032, DT_SPIKES = 1033, DT_STEAM = 1034, + DT_WALLHURT = 1035, DT_REALMAX }; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index f6f9ed0..3de9180 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -1580,6 +1580,7 @@ luaFunc(quad_setSegs) RO_FUNC(getter, prefix, disableMotionBlur ) \ RO_FUNC(getter, prefix, collideCircleVsLine) \ RO_FUNC(getter, prefix, collideCircleVsLineAngle) \ + RO_FUNC(getter, prefix, getVectorToObj ) \ MK_ALIAS(prefix, fh, flipHorizontal ) \ MK_ALIAS(prefix, fv, flipVertical ) @@ -2352,6 +2353,14 @@ luaFunc(getWorldType) luaReturnNum((int)dsq->continuity.getWorldType()); } +luaFunc(setWorldType) +{ + WorldType wt = (WorldType)lua_tointeger(L, 1); + bool trans = getBool(L, 2); + dsq->continuity.applyWorldEffects(wt, trans, 1); // last arg is not used + luaReturnNil(); +} + luaFunc(isWorldPaused) { luaReturnBool(dsq->game->isWorldPaused()); @@ -2709,6 +2718,47 @@ luaFunc(avatar_setCanDie) luaReturnNil(); } +// not naming this avatar_* because it rather belongs into the UI category... +luaFunc(setCanActivate) +{ + dsq->game->avatar->setCanActivateStuff(getBool(L, 1)); + luaReturnNil(); +} + +luaFunc(avatar_setCanBurst) +{ + dsq->game->avatar->setCanBurst(getBool(L, 1)); + luaReturnNil(); +} + +luaFunc(avatar_canBurst) +{ + luaReturnBool(dsq->game->avatar->canBurst()); +} + +luaFunc(avatar_setCanLockToWall) +{ + dsq->game->avatar->setCanBurst(getBool(L, 1)); + luaReturnNil(); +} + +luaFunc(avatar_canLockToWall) +{ + luaReturnBool(dsq->game->avatar->canBurst()); +} + +luaFunc(avatar_setCanSwimAgainstCurrents) +{ + dsq->game->avatar->setCanSwimAgainstCurrents(getBool(L, 1)); + luaReturnNil(); +} + +luaFunc(avatar_canSwimAgainstCurrents) +{ + luaReturnBool(dsq->game->avatar->canSwimAgainstCurrents()); +} + + luaFunc(avatar_toggleCape) { dsq->game->avatar->toggleCape(getBool(L,1)); @@ -3773,6 +3823,12 @@ luaFunc(setSceneColor) luaReturnNil(); } +luaFunc(getSceneColor) +{ + const Vector& c = dsq->game->sceneColor3; + luaReturnVec3(c.x, c.y, c.z); +} + luaFunc(setCameraLerpDelay) { dsq->game->cameraLerpDelay = lua_tonumber(L, 1); @@ -7626,6 +7682,7 @@ static const struct { luaRegister(getNoteName), luaRegister(getWorldType), + luaRegister(setWorldType), luaRegister(setWorldPaused), luaRegister(isWorldPaused), @@ -7704,9 +7761,16 @@ static const struct { luaRegister(avatar_setCanDie), + luaRegister(setCanActivate), luaRegister(avatar_toggleCape), luaRegister(avatar_setPullTarget), + luaRegister(avatar_setCanLockToWall), + luaRegister(avatar_canLockToWall), + luaRegister(avatar_setCanBurst), + luaRegister(avatar_canBurst), + luaRegister(avatar_setCanSwimAgainstCurrents), + luaRegister(avatar_canSwimAgainstCurrents), luaRegister(avatar_clampPosition), luaRegister(avatar_updatePosition), @@ -8318,7 +8382,7 @@ static const struct { luaRegister(setSceneColor), - + luaRegister(getSceneColor), luaRegister(entity_watchEntity), @@ -9129,6 +9193,7 @@ static const struct { luaConstant(DT_CRUSH), luaConstant(DT_SPIKES), luaConstant(DT_STEAM), + luaConstant(DT_WALLHURT), luaConstant(FRAME_TIME),