From 9f4c55c17788d0deccb6dbc5a6eca11ef0f0c3d3 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sat, 20 Jul 2013 20:16:26 +0200 Subject: [PATCH] More new Lua functions. - shot_getMaxSpeed() - shot_setMaxSpeed() - shot_getHomingness() - shot_setHomingness() - shot_getLifeTime() - shot_setLifeTime() - getScreenVirtualSize() --- Aquaria/ScriptInterface.cpp | 57 +++++++++++++++++++++++++++++++++++-- Aquaria/Shot.h | 15 +++++----- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 4c885ab..2b5d1d6 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -2105,6 +2105,48 @@ luaFunc(shot_getDamageType) luaReturnNum(shot ? shot->getDamageType() : DT_NONE); } +luaFunc(shot_getMaxSpeed) +{ + Shot *shot = getShot(L); + luaReturnNum(shot ? shot->maxSpeed : 0.0f); +} + +luaFunc(shot_setMaxSpeed) +{ + Shot *shot = getShot(L); + if (shot) + shot->homingness = lua_tonumber(L, 2); + luaReturnNil(); +} + +luaFunc(shot_getHomingness) +{ + Shot *shot = getShot(L); + luaReturnNum(shot ? shot->homingness : 0.0f); +} + +luaFunc(shot_setHomingness) +{ + Shot *shot = getShot(L); + if (shot) + shot->homingness = lua_tonumber(L, 2); + luaReturnNil(); +} + +luaFunc(shot_getLifeTime) +{ + Shot *shot = getShot(L); + luaReturnNum(shot ? shot->lifeTime : 0.0f); +} + +luaFunc(shot_setLifeTime) +{ + Shot *shot = getShot(L); + if (shot) + shot->lifeTime = lua_tonumber(L, 2); + luaReturnNil(); +} + luaFunc(entity_setVel) { Entity *e = entity(L); @@ -7968,6 +8010,11 @@ luaFunc(getScreenSize) luaReturnVec2(core->width, core->height); } +luaFunc(getScreenVirtualSize) +{ + luaReturnVec2(core->getVirtualWidth(), core->getVirtualHeight()); +} + luaFunc(inv_isFull) { IngredientData *data = dsq->continuity.getIngredientDataByName(getString(L, 1)); @@ -8821,6 +8868,12 @@ static const struct { luaRegister(shot_getDamage), luaRegister(shot_getDamageType), luaRegister(shot_getName), + luaRegister(shot_getMaxSpeed), + luaRegister(shot_setMaxSpeed), + luaRegister(shot_getHomingness), + luaRegister(shot_setHomingness), + luaRegister(shot_getLifeTime), + luaRegister(shot_setLifeTime), luaRegister(entity_pathBurst), luaRegister(entity_handleShotCollisions), luaRegister(entity_handleShotCollisionsSkeletal), @@ -8933,9 +8986,6 @@ static const struct { luaRegister(entity_watchEntity), - luaRegister(entity_setCollideRadius), - luaRegister(entity_getCollideRadius), - luaRegister(entity_isEntityInRange), luaRegister(entity_isPositionInRange), @@ -9051,6 +9101,7 @@ static const struct { luaRegister(getScreenVirtualOff), luaRegister(getScreenSize), + luaRegister(getScreenVirtualSize), luaRegister(inv_isFull), luaRegister(inv_getMaxAmount), diff --git a/Aquaria/Shot.h b/Aquaria/Shot.h index 3864dd2..32f0da5 100644 --- a/Aquaria/Shot.h +++ b/Aquaria/Shot.h @@ -37,7 +37,7 @@ struct ShotData int blendType; bool segments; float damage; - int maxSpeed, homing, homingMax; + float maxSpeed, homing, homingMax; double homingIncr; DamageType damageType; Vector scale; @@ -46,7 +46,7 @@ struct ShotData float effectTime; - int collideRadius; + float collideRadius; float lifeTime; int numSegs, segDist; @@ -61,7 +61,7 @@ struct ShotData float spinSpeed; bool invisible, checkDamageTarget, hitWalls, hitEnts, alwaysDoHitEffects; - int rotIncr; + float rotIncr; float avatarKickBack, avatarKickBackTime; @@ -89,7 +89,8 @@ public: static void killAllShots(); static void clearShotGarbage(); Entity *target, *firer; - int maxSpeed, targetPt; + int targetPt; + float maxSpeed; void fire(bool playSfx = true); void hitEntity(Entity *e, Bone *b, bool isValid=true); @@ -125,6 +126,9 @@ public: inline const char *getName() const { return shotData ? shotData->name.c_str() : ""; } float extraDamage; + float homingness; + float lifeTime; + protected: float waveTimer; @@ -133,9 +137,6 @@ protected: ParticleEffect *emitter; - double homingness; - float lifeTime; - void onHitWall(); void onEndOfLife();