diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index fbfcb89..e9e180e 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -3107,7 +3107,7 @@ bool Entity::doCollisionAvoidance(float dt, int search, float mod, Vector *vp, i return false; } -void Entity::initHair(int numSegments, int segmentLength, int width, const std::string &tex) +void Entity::initHair(int numSegments, float segmentLength, float width, const std::string &tex) { if (hair) { diff --git a/Aquaria/Hair.cpp b/Aquaria/Hair.cpp index 80cc0f0..09f5177 100644 --- a/Aquaria/Hair.cpp +++ b/Aquaria/Hair.cpp @@ -25,13 +25,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // nodes = 40 // segmentLength = 3 -Hair::Hair(int nodes, int segmentLength, int hairWidth) : RenderObject() +Hair::Hair(int nodes, float segmentLength, float hairWidth) : RenderObject() { this->segmentLength = segmentLength; this->hairWidth = hairWidth; - waveTimer = 0; - waveAmount = 5; - //hairWidth = 10; cull = false; @@ -46,7 +43,6 @@ Hair::Hair(int nodes, int segmentLength, int hairWidth) : RenderObject() hairNodes[i].percent = 1.0f-perc; hairNodes[i].position = hairNodes[i].originalPosition = hairNodes[i].defaultPosition = Vector(0, i*segmentLength, 0); } - hairTimer = 0; } void Hair::exertWave(float dt) @@ -196,15 +192,6 @@ void Hair::onRender() #endif } -void Hair::updateWaveTimer(float dt) -{ - waveTimer += dt; - for (int i = 1; i < hairNodes.size(); i++) - { - hairNodes[i].defaultPosition = hairNodes[i].originalPosition + Vector(cosf(waveTimer+i)*waveAmount*hairNodes[i].percent, 0, 0); - } -} - void Hair::onUpdate(float dt) { RenderObject::onUpdate(dt); diff --git a/Aquaria/Hair.h b/Aquaria/Hair.h index 14ae3c9..2bb495f 100644 --- a/Aquaria/Hair.h +++ b/Aquaria/Hair.h @@ -38,13 +38,13 @@ struct HairNode class Hair : public RenderObject { public: - Hair(int nodes=40, int segmentLength=3, int width=18); + Hair(int nodes=40, float segmentLength=3, float width=18); void exertForce(const Vector &force, float dt, int usePerc=0); void updatePositions(); void returnToDefaultPositions(float dt); - int hairWidth; + float hairWidth; std::vector hairNodes; @@ -54,10 +54,6 @@ public: void exertGravityWave(float dt); HairNode *getHairNode(int idx); protected: - float hairTimer; - void updateWaveTimer(float dt); - int waveAmount; - float waveTimer; float segmentLength; void onUpdate(float dt); void onRender(); diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 22b627e..2a5fdd9 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -3815,17 +3815,29 @@ luaFunc(entity_getAnimationLength) { Entity *e = entity(L); float ret=0; - int layer = lua_tonumber(L, 2); if (e) { - if (Animation *anim = e->skeletalSprite.getCurrentAnimation(layer)) + Animation *anim = 0; + if (lua_isstring(L, 2)) + anim = e->skeletalSprite.getAnimation(lua_tostring(L, 2)); + else { - ret = anim->getAnimationLength(); + int layer = lua_tointeger(L, 2); + anim = e->skeletalSprite.getCurrentAnimation(layer); } + if (anim) + ret = anim->getAnimationLength(); } luaReturnNum(ret); } +luaFunc(entity_hasAnimation) +{ + Entity *e = entity(L); + Animation *anim = e->skeletalSprite.getAnimation(getString(L, 2)); + luaReturnBool(anim != NULL); +} + luaFunc(entity_isFollowingPath) { Entity *e = entity(L); @@ -4233,6 +4245,15 @@ luaFunc(beam_setPosition_override) luaReturnNil(); } +luaFunc(beam_getEndPos) +{ + Beam *b = beam(L); + Vector v; + if (b) + v = b->endPos; + luaReturnVec2(v.x, v.y); +} + luaFunc(getStringBank) { luaReturnStr(dsq->continuity.stringBank.get(lua_tointeger(L, 1)).c_str()); @@ -4411,6 +4432,8 @@ luaFunc(entity_damage) d.damageType = (DamageType)lua_tointeger(L, 4); d.effectTime = lua_tonumber(L, 5); d.useTimer = !getBool(L, 6); + d.shot = lua_isuserdata(L, 7) ? getShot(L, 7) : NULL; + d.hitPos = Vector(lua_tonumber(L, 8), lua_tonumber(L, 9)); didDamage = e->damage(d); } luaReturnBool(didDamage); @@ -4448,6 +4471,22 @@ luaFunc(entity_setHealth) luaReturnNil(); } +luaFunc(entity_setCurrentHealth) +{ + Entity *e = entity(L, 1); + if (e) + e->health = lua_tonumber(L, 2); + luaReturnNil(); +} + +luaFunc(entity_setMaxHealth) +{ + Entity *e = entity(L, 1); + if (e) + e->maxHealth = lua_tonumber(L, 2); + luaReturnNil(); +} + luaFunc(entity_changeHealth) { Entity *e = entity(L, 1); @@ -8716,6 +8755,7 @@ static const struct { luaRegister(beam_setBeamWidth), luaRegister(beam_setFirer), luaRegister(beam_setDamageType), + luaRegister(beam_getEndPos), luaRegister(getStringBank), @@ -9297,6 +9337,8 @@ static const struct { luaRegister(entity_setHealth), + luaRegister(entity_setCurrentHealth), + luaRegister(entity_setMaxHealth), luaRegister(entity_changeHealth), luaRegister(node_setActive), @@ -9325,6 +9367,7 @@ static const struct { luaRegister(entity_isAnimating), luaRegister(entity_getAnimationName), luaRegister(entity_getAnimationLength), + luaRegister(entity_hasAnimation), luaRegister(entity_setCull),