1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-25 14:15:46 +00:00

Merge branch 'master' of /home/fg/fgone/Aquaria_fg_clean

This commit is contained in:
fgenesis 2012-03-17 17:50:20 +00:00
commit 3fb9e41349
19 changed files with 112 additions and 239 deletions

View file

@ -4664,8 +4664,6 @@ Avatar::Avatar() : Entity(), ActionMapper()
text = 0;
burstBar = 0;
/*
chargeGraphic = new Particle;
{
@ -9286,15 +9284,6 @@ void Avatar::onUpdate(float dt)
if (ignoreInputDelay < 0)
ignoreInputDelay = 0;
}
if (burstBar && burstBar->alpha == 1)
{
float amount = burst;
if (amount > 1) amount = 1;
if (amount < 0) amount = 0;
burstBar->frame = (19-(amount*19));
}
//checkSpecial();
}
//fuuugly

View file

@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/Particles.h"
#include "../BBGE/BitmapFont.h"
#include "../BBGE/DFSprite.h"
#include "DSQ.h"
#include "Hair.h"
@ -156,7 +155,6 @@ public:
bool isCharging();
void slowToRest();
void debugMsg(const std::string &msg);
DFSprite *burstBar;
void setBlind(float time);
void onBlindTest();

View file

@ -125,12 +125,10 @@ static void Linux_CopyTree(const char *src, const char *dst)
#endif
float titTimer = 0;
const int saveSlotPageSize = 4;
int maxPages = 15;
#ifdef AQUARIA_BUILD_CONSOLE
const int MAX_CONSOLELINES = 14;
const int MAX_CONSOLELINES = 18;
#endif
DSQ *dsq = 0;
@ -2476,7 +2474,7 @@ void DSQ::clickRingEffect(Vector pos, int type, Vector color, float ut)
}
}
Entity *DSQ::getEntityByName(std::string name)
Entity *DSQ::getEntityByName(const std::string& name)
{
Entity *e = 0;
FOR_ENTITIES(i)
@ -4737,61 +4735,6 @@ void DSQ::playVisualEffect(int vfx, Vector position, Entity *target)
}
}
// get the closest, active, in range element to the vector
/*
Element *DSQ::getElementAtVector(const Vector &vec)
{
Element *returnElement = 0;
int smallestDistance = 9999;
for (int i = 0; i < elements.size(); i++)
{
if (elements[i]->isActive() && elements[i]->getTotalInteractions() > 0)
{
int distanceToElementI = elements[i]->getFakeDistanceFromCenterToVector(vec);
if (elements[i]->isVectorInActivationRange(vec) && distanceToElementI < smallestDistance)
{
smallestDistance = distanceToElementI;
returnElement = elements[i];
}
}
}
return returnElement;
}
*/
Element *DSQ::getElementWithType(Element::Type type)
{
for (int i = 0; i < elements.size(); i++)
{
if (elements[i]->getElementType() == type)
{
return elements[i];
}
}
return 0;
}
/*
Element *DSQ::getClosestElementWithType(Element::Type type, Element *e)
{
Element *returnElement = 0;
long smallestDistance = 999999;
for (int i = 0; i < elements.size(); i++)
{
if (elements[i]->isActive() && elements[i]->getElementType() == type)
{
long distanceToElementI = elements[i]->getFakeDistanceFromCenterToVector(e->position);
if (distanceToElementI < smallestDistance)
{
smallestDistance = distanceToElementI;
returnElement = elements[i];
}
}
}
return returnElement;
}
*/
void DSQ::addElement(Element *e)
{
elements.push_back(e);

View file

@ -1307,7 +1307,6 @@ public:
int getNumElements() const {return elements.size();}
Element *getElement(int idx) const {return elements[idx];}
Element *getFirstElementOnLayer(int layer) const {return layer<0 || layer>15 ? 0 : firstElementOnLayer[layer];}
Element *getElementWithType(Element::Type type);
void clearElements();
// Used only by scene editor:
void removeElement(int idx);
@ -1353,7 +1352,7 @@ public:
void toggleInputMode();
void shakeCamera(float mag, float time);
Vector avStart;
Entity *getEntityByName(std::string name);
Entity *getEntityByName(const std::string &name);
Entity *getEntityByNameNoCase(std::string name);
void doSavePoint(const Vector &position);

View file

@ -22,25 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Game.h"
#include "Avatar.h"
ElementActivationRange::ElementActivationRange() : radius(64), type(CIRCLE)
{
}
ElementActivationRange::Type ElementActivationRange::getType()
{
return type;
}
Element::Element(Element::Type elementType) : Quad(), type(elementType)
Element::Element() : Quad()
{
elementFlag = EF_NONE;
angleFromGroupCenter = distFromGroupCenter = 0;
wavyFlip = false;
parallax = 1;
elementEffectIndex = -1;
elementActive = true;
bgLayer = 0;
dontSave = false;
wavyAngleOffset=0;
wavyMagnitude=0;
@ -52,7 +40,6 @@ Element::Element(Element::Type elementType) : Quad(), type(elementType)
wavyRadius = 0;
wavyMin = 0;
wavyMax = 0;
oldRotation = 0;
templateIdx = -1;
setStatic(true);
@ -429,11 +416,6 @@ void Element::fillGrid()
}
}
Element::Type Element::getElementType()
{
return type;
}
// override this functionality as needed
bool Element::canSeeAvatar(Avatar *avatar)
{

View file

@ -25,22 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class Avatar;
class ElementActivationRange
{
public:
ElementActivationRange();
void isVectorInRange();
enum Type
{
CIRCLE,
RECT
};
float radius;
Type getType();
protected:
Type type;
};
enum ElementFlag
{
@ -61,26 +45,18 @@ enum ElementFlag
class Element : public Quad
{
public:
enum Type
{
UNDEFINED,
BOX
};
Element(Type elementType);
Element();
~Element();
void destroy();
//void interact(Interaction::Type interactionType, Avatar *avatar);
bool canSeeAvatar(Avatar *avatar);
void update(float dt);
bool isActive();
Type getElementType();
//InteractionContainer interactions;
int templateIdx;
int bgLayer;
Element *bgLayerNext;
float getSortDepth();
bool dontSave;
void render();
//Flags elementFlags;
ElementFlag elementFlag;
@ -89,8 +65,6 @@ public:
int getElementEffectIndex();
void setElementEffectByIndex(int e);
void setElementActive(bool v) { elementActive = v; }
float parallax;
float angleFromGroupCenter, distFromGroupCenter, oldRotation;
protected:
void setGridFromWavy();
float wavyAngleOffset, wavyMagnitude, wavyLerpIn;
@ -101,10 +75,8 @@ protected:
void updateEffects(float dt);
int elementEffectIndex, elementEffectType;
bool elementActive;
ElementActivationRange activationRange;
Type type;
};
/*
class BoxElement : public Element
{
public:
@ -113,6 +85,7 @@ public:
protected:
int ww,hh;
};
*/
typedef std::vector<Element*> ElementContainer;

View file

@ -165,7 +165,7 @@ bool Entity::canSetBoneLock()
return true;
}
Entity::Entity() : StateMachine(), DFSprite()
Entity::Entity()
{
addType(SCO_ENTITY);
poison = 0.0f;
@ -1266,7 +1266,7 @@ void Entity::update(float dt)
//skeletalSprite.setFreeze(true);
if (frozenTimer == 0 || getState() == STATE_PUSH)
DFSprite::update(dt);
AnimatedSprite::update(dt);
onAlwaysUpdate(dt);
// always, always update:
@ -1873,7 +1873,7 @@ void Entity::onUpdate(float dt)
}
}
DFSprite::onUpdate(dt);
AnimatedSprite::onUpdate(dt);
Vector v = position - lastPos;
lastMove = v;
@ -2971,7 +2971,7 @@ void Entity::render()
blurShader.bind();
set = true;
}
DFSprite::render();
AnimatedSprite::render();
//if (beautyFlip && blurShader.isLoaded() && flipScale.isInterpolating())
if (set)
blurShader.unbind();

View file

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#pragma once
#include "../BBGE/DFSprite.h"
#include "../BBGE/AnimatedSprite.h"
#include "../BBGE/StateMachine.h"
#include "../ExternalLibs/tinyxml.h"
#include "../BBGE/SkeletalSprite.h"
@ -194,7 +194,7 @@ enum BounceType
BOUNCE_REAL = 1
};
class Entity : public DFSprite, public StateMachine
class Entity : public AnimatedSprite, public StateMachine
{
public:
Entity();
@ -234,7 +234,7 @@ public:
bool canSetState(int state);
virtual void message(const std::string &msg, int v) {}
virtual void messageVariadic(lua_State *L, int nparams) {}
virtual int messageVariadic(lua_State *L, int nparams) { return 0; }
bool isUnderWater(const Vector &o=Vector());

View file

@ -1898,7 +1898,7 @@ Element* Game::createElement(int idx, Vector position, int bgLayer, RenderObject
if (!et)
et = this->getElementTemplateByIdx(idx);
Element *element = new Element(Element::UNDEFINED);
Element *element = new Element();
if (et)
{
element->setTexture(et->gfx);
@ -4951,7 +4951,7 @@ bool Game::loadSceneXML(std::string scene)
saveFile->InsertEndChild(newSF);
}
/*
TiXmlElement *boxElement = doc.FirstChildElement("BoxElement");
while (boxElement)
{
@ -4962,7 +4962,7 @@ bool Game::loadSceneXML(std::string scene)
dsq->addElement(b);
boxElement = boxElement->NextSiblingElement("BoxElement");
}
*/
TiXmlElement *simpleElements = doc.FirstChildElement("SE");
while (simpleElements)
{
@ -5620,13 +5620,8 @@ void Game::saveScene(std::string scene)
for (i = 0; i < dsq->getNumElements(); i++)
{
Element *e = dsq->getElement(i);
if (!e->dontSave)
{
if (e->getElementType() == Element::BOX) {}
else
simpleElements[e->bgLayer] << e->templateIdx << " " << int(e->position.x) << " " << int(e->position.y) << " " << int(e->rotation.z) << " " << e->scale.x << " " << e->scale.y << " " << int(e->isfh()) << " " << int(e->isfv()) << " " << e->elementFlag << " " << e->getElementEffectIndex() << " " << e->isRepeatingTextureToFill() << " ";
}
}
if (dsq->game->entitySaveData.size() > 0)
{

View file

@ -525,8 +525,8 @@ Bone *bone(lua_State *L, int slot = 1)
static inline
Path *pathFromName(lua_State *L, int slot = 1)
{
std::string s = lua_tostring(L, slot);
stringToLowerUserData(s);
std::string s = getString(L, slot);
stringToLower(s);
Path *p = dsq->game->getPathByName(s);
if (!p)
{
@ -1568,7 +1568,7 @@ luaFunc(cureAllStatus)
luaFunc(setMusicToPlay)
{
if (lua_isstring(L, 1))
dsq->game->setMusicToPlay(lua_tostring(L, 1));
dsq->game->setMusicToPlay(getString(L, 1));
luaReturnNil();
}
@ -2210,8 +2210,6 @@ luaFunc(debugLog)
const char *s = lua_tostring(L, 1);
if(s)
debugLog(s);
else
scriptError("debugLog() not a string");
luaReturnStr(s);
}
@ -2220,8 +2218,6 @@ luaFunc(errorLog)
const char *s = lua_tostring(L, 1);
if(s)
errorLog(s);
else
scriptError("errorLog() not a string");
luaReturnStr(s);
}
@ -2256,7 +2252,7 @@ luaFunc(entity_setSegmentTexture)
RenderObject *ro = e->getSegment(lua_tonumber(L, 2));
if (ro)
{
ro->setTexture(lua_tostring(L, 3));
ro->setTexture(getString(L, 3));
}
}
luaReturnNil();
@ -2295,7 +2291,6 @@ luaFunc(entity_findNearestEntityOfType)
luaFunc(createShot)
{
std::string shotData = lua_tostring(L, 1);
Entity *e = entity(L,2);
Entity *t = 0;
if (lua_touserdata(L, 3) != NULL)
@ -2308,7 +2303,7 @@ luaFunc(createShot)
aim.y = lua_tonumber(L, 7);
s = dsq->game->fireShot(shotData, e, t, pos, aim);
s = dsq->game->fireShot(getString(L, 1), e, t, pos, aim);
luaReturnPtr(s);
}
@ -2325,7 +2320,7 @@ luaFunc(entity_sound)
// so a cheap hack like this fixes it without changing older scripts. -- FG
if (freq >= 100)
freq *= 0.001f;
e->sound(lua_tostring(L, 2), freq, lua_tonumber(L, 4));
e->sound(getString(L, 2), freq, lua_tonumber(L, 4));
}
luaReturnNil();
}
@ -2337,7 +2332,7 @@ luaFunc(entity_playSfx)
if (e && !dsq->isSkippingCutscene())
{
PlaySfx sfx = dsq->calcPositionalSfx(e->position, lua_tonumber(L, 7));
sfx.name = lua_tostring(L, 2);
sfx.name = getString(L, 2);
sfx.freq = lua_tonumber(L, 3);
float vol = lua_tonumber(L, 4);
sfx.loops = lua_tonumber(L, 5);
@ -2572,7 +2567,7 @@ luaFunc(avatar_getSpellCharge)
luaFunc(jumpState)
{
dsq->enqueueJumpState(lua_tostring(L, 1), getBool(L, 2));
dsq->enqueueJumpState(getString(L, 1), getBool(L, 2));
luaReturnNil();
}
@ -2855,7 +2850,7 @@ luaFunc(entity_createEntity)
Entity *e = entity(L);
Entity *ret = NULL;
if (e)
ret = dsq->game->createEntity(dsq->getEntityTypeIndexByName(lua_tostring(L, 2)), 0, e->position, 0, false, "", ET_ENEMY, 0, 0, true);
ret = dsq->game->createEntity(dsq->getEntityTypeIndexByName(getString(L, 2)), 0, e->position, 0, false, "", ET_ENEMY, 0, 0, true);
luaReturnPtr(ret);
}
@ -2894,8 +2889,8 @@ luaFunc(entity_isBeingPulled)
luaFunc(avatar_setPullTarget)
{
Entity *e = 0;
if (lua_tonumber(L, 1) != 0)
e = entity(L);
if (lua_isuserdata(L, 1))
e = entity(L, 1);
if (dsq->game->avatar->pullTarget != 0)
dsq->game->avatar->pullTarget->stopPull();
@ -3241,15 +3236,10 @@ luaFunc(entity_initSkeletal)
ScriptedEntity *e = scriptedEntity(L);
e->renderQuad = false;
e->setWidthHeight(128, 128);
e->skeletalSprite.loadSkeletal(lua_tostring(L, 2));
if (lua_isstring(L, 3))
{
std::string s = lua_tostring(L, 3);
if (!s.empty())
{
e->skeletalSprite.loadSkeletal(getString(L, 2));
const char *s = lua_tostring(L, 3);
if (s && *s)
e->skeletalSprite.loadSkin(s);
}
}
luaReturnNil();
}
@ -3301,7 +3291,7 @@ luaFunc(entity_animate)
transition = 0;
else if (transition == 0)
transition = 0.2;
ret = skel->transitionAnimate(lua_tostring(L, 2), transition, lua_tointeger(L, 3), lua_tointeger(L, 4));
ret = skel->transitionAnimate(getString(L, 2), transition, lua_tointeger(L, 3), lua_tointeger(L, 4));
}
luaReturnNum(ret);
}
@ -3334,8 +3324,8 @@ luaFunc(spawnAroundEntity)
Entity *e = entity(L);
int num = lua_tonumber(L, 2);
int radius = lua_tonumber(L, 3);
std::string entType = lua_tostring(L, 4);
std::string name = lua_tostring(L, 5);
std::string entType = getString(L, 4);
std::string name = getString(L, 5);
int idx = dsq->game->getIdxForEntityType(entType);
if (e)
{
@ -3424,7 +3414,7 @@ luaFunc(isPlat)
luaFunc(createEntity)
{
std::string type = lua_tostring(L, 1);
std::string type = getString(L, 1);
std::string name;
if (lua_isstring(L, 2))
name = lua_tostring(L, 2);
@ -3483,7 +3473,7 @@ luaFunc(setCameraLerpDelay)
luaFunc(setControlHint)
{
std::string str = lua_tostring(L, 1);
std::string str = getString(L, 1);
bool left = getBool(L, 2);
bool right = getBool(L, 3);
bool middle = getBool(L, 4);
@ -3657,7 +3647,7 @@ luaFunc(getWallNormal)
luaFunc(incrFlag)
{
std::string f = lua_tostring(L, 1);
std::string f = getString(L, 1);
int v = 1;
if (lua_isnumber(L, 2))
v = lua_tointeger(L, 2);
@ -3667,7 +3657,7 @@ luaFunc(incrFlag)
luaFunc(decrFlag)
{
std::string f = lua_tostring(L, 1);
std::string f = getString(L, 1);
int v = 1;
if (lua_isnumber(L, 2))
v = lua_tointeger(L, 2);
@ -4129,7 +4119,7 @@ luaFunc(entity_initSegments)
{
ScriptedEntity *se = scriptedEntity(L);
if (se)
se->initSegments(lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tostring(L, 5), lua_tostring(L, 6), lua_tointeger(L, 7), lua_tointeger(L, 8), lua_tonumber(L, 9), lua_tointeger(L, 10));
se->initSegments(lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), getString(L, 5), getString(L, 6), lua_tointeger(L, 7), lua_tointeger(L, 8), lua_tonumber(L, 9), lua_tointeger(L, 10));
luaReturnNil();
}
@ -4212,10 +4202,10 @@ luaFunc(entity_msg)
Entity *e = entity(L);
if (e)
{
int top = lua_gettop(L);
// pass everything on the stack except the entity pointer
e->messageVariadic(L, top - 1);
return lua_gettop(L) - top; // return everything that was pushed on our stack
int res = e->messageVariadic(L, lua_gettop(L) - 1);
if (res >= 0)
return res;
}
luaReturnNil();
}
@ -4304,7 +4294,7 @@ luaFunc(setNaijaHeadTexture)
Avatar *a = dsq->game->avatar;
if (a)
{
a->setHeadTexture(lua_tostring(L, 1), lua_tonumber(L, 2));
a->setHeadTexture(getString(L, 1), lua_tonumber(L, 2));
}
luaReturnNil();
}
@ -4459,7 +4449,7 @@ luaFunc(setupBasicEntity)
ScriptedEntity *se = scriptedEntity(L);
//-- texture, health, manaballamount, exp, money, collideRadius, initState
if (se)
se->setupBasicEntity(lua_tostring(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5), lua_tointeger(L, 6), lua_tointeger(L, 7), lua_tointeger(L, 8), lua_tointeger(L, 9), lua_tointeger(L, 10), lua_tointeger(L, 11), lua_tointeger(L, 12), lua_tointeger(L, 13), lua_tointeger(L, 14));
se->setupBasicEntity(getString(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5), lua_tointeger(L, 6), lua_tointeger(L, 7), lua_tointeger(L, 8), lua_tointeger(L, 9), lua_tointeger(L, 10), lua_tointeger(L, 11), lua_tointeger(L, 12), lua_tointeger(L, 13), lua_tointeger(L, 14));
luaReturnNil();
}
@ -4497,7 +4487,7 @@ luaFunc(entity_setDeathSound)
Entity *e = entity(L);
if (e)
{
e->deathSound = lua_tostring(L, 2);
e->deathSound = getString(L, 2);
}
luaReturnNil();
}
@ -4767,7 +4757,7 @@ luaFunc(entity_getBoneByIdx)
luaFunc(entity_getBoneByName)
{
Entity *e = entity(L);
luaReturnPtr(e ? e->skeletalSprite.getBoneByName(lua_tostring(L, 2)) : NULL);
luaReturnPtr(e ? e->skeletalSprite.getBoneByName(getString(L, 2)) : NULL);
}
luaFunc(bone_getIndex)
@ -4794,9 +4784,10 @@ luaFunc(bone_isName)
{
Bone *b = bone(L);
bool v = false;
if (b)
const char *s = lua_tostring(L, 2);
if (b && s)
{
v = b->name == lua_tostring(L, 2);
v = b->name == s;
}
luaReturnBool(v);
}
@ -4911,7 +4902,7 @@ luaFunc(entity_setCurrentTarget)
luaFunc(setMiniMapHint)
{
std::istringstream is(lua_tostring(L, 1));
std::istringstream is(getString(L, 1));
is >> dsq->game->miniMapHint.scene >> dsq->game->miniMapHint.warpAreaType;
dsq->game->updateMiniMapHintPosition();
@ -4920,10 +4911,10 @@ luaFunc(setMiniMapHint)
luaFunc(entityFollowEntity)
{
Entity *e = dsq->getEntityByName(lua_tostring(L, 1));
Entity *e = dsq->getEntityByName(getString(L, 1));
if (e)
{
e->followEntity = dsq->getEntityByName(lua_tostring(L, 2));
e->followEntity = dsq->getEntityByName(getString(L, 2));
}
luaReturnNil();
@ -4967,7 +4958,7 @@ luaFunc(toggleInput)
luaFunc(warpAvatar)
{
dsq->game->positionToAvatar = Vector(lua_tointeger(L, 2),lua_tointeger(L, 3));
dsq->game->transitionToScene(lua_tostring(L, 1));
dsq->game->transitionToScene(getString(L, 1));
luaReturnNil();
}
@ -5165,7 +5156,7 @@ luaFunc(stopMusic)
luaFunc(playMusic)
{
float crossfadeTime = 0.8;
dsq->sound->playMusic(std::string(lua_tostring(L, 1)), SLT_LOOP, SFT_CROSS, crossfadeTime);
dsq->sound->playMusic(getString(L, 1), SLT_LOOP, SFT_CROSS, crossfadeTime);
luaReturnNil();
}
@ -5179,7 +5170,7 @@ luaFunc(playMusicStraight)
luaFunc(playMusicOnce)
{
float crossfadeTime = 0.8;
dsq->sound->playMusic(std::string(lua_tostring(L, 1)), SLT_NONE, SFT_CROSS, crossfadeTime);
dsq->sound->playMusic(getString(L, 1), SLT_NONE, SFT_CROSS, crossfadeTime);
luaReturnNil();
}
@ -5618,7 +5609,7 @@ luaFunc(wait)
luaFunc(warpNaijaToEntity)
{
Entity *e = dsq->getEntityByName(lua_tostring(L, 1));
Entity *e = dsq->getEntityByName(getString(L, 1));
if (e)
{
dsq->overlay->alpha.interpolateTo(1, 1);
@ -5914,7 +5905,7 @@ luaFunc(entity_rotateToTarget)
luaFunc(entity_partWidthHeight)
{
ScriptedEntity *e = scriptedEntity(L);
Quad *r = (Quad*)e->partMap[lua_tostring(L, 2)];
Quad *r = (Quad*)e->partMap[getString(L, 2)];
if (r)
{
int w = lua_tointeger(L, 3);
@ -5927,7 +5918,7 @@ luaFunc(entity_partWidthHeight)
luaFunc(entity_partSetSegs)
{
ScriptedEntity *e = scriptedEntity(L);
Quad *r = (Quad*)e->partMap[lua_tostring(L, 2)];
Quad *r = (Quad*)e->partMap[getString(L, 2)];
if (r)
{
r->setSegs(lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tonumber(L, 5), lua_tonumber(L, 6), lua_tonumber(L, 7), lua_tonumber(L, 8), lua_tonumber(L, 9), lua_tointeger(L, 10));
@ -6011,7 +6002,7 @@ luaFunc(node_setEffectOn)
Path *p = path(L, 1);
if (p)
p->setEffectOn(getBool(L, 2));
luaReturnNum(0);
luaReturnNil();
}
luaFunc(node_activate)
@ -6038,12 +6029,11 @@ luaFunc(node_setElementsInLayerActive)
{
if (e && p->isCoordinateInside(e->position))
{
debugLog("setting an element to the value");
e->setElementActive(v);
}
}
}
luaReturnNum(0);
luaReturnNil();
}
luaFunc(node_getNumEntitiesIn)
@ -6312,7 +6302,7 @@ luaFunc(entity_partAlpha)
ScriptedEntity *e = scriptedEntity(L);
if (e)
{
RenderObject *r = e->partMap[lua_tostring(L, 2)];
RenderObject *r = e->partMap[getString(L, 2)];
if (r)
{
float start = lua_tonumber(L, 3);
@ -6329,7 +6319,7 @@ luaFunc(entity_partBlendType)
{
ScriptedEntity *e = scriptedEntity(L);
if (e)
e->partMap[lua_tostring(L, 2)]->setBlendType(lua_tointeger(L, 3));
e->partMap[getString(L, 2)]->setBlendType(lua_tointeger(L, 3));
luaReturnInt(0);
}
@ -6338,7 +6328,7 @@ luaFunc(entity_partRotate)
ScriptedEntity *e = scriptedEntity(L);
if (e)
{
RenderObject *r = e->partMap[lua_tostring(L, 2)];
RenderObject *r = e->partMap[getString(L, 2)];
if (r)
{
r->rotation.interpolateTo(Vector(0,0,lua_tointeger(L, 3)), lua_tonumber(L, 4), lua_tointeger(L, 5), lua_tointeger(L, 6), lua_tointeger(L, 7));
@ -6405,7 +6395,7 @@ luaFunc(entity_initHair)
ScriptedEntity *se = scriptedEntity(L);
if (se)
{
se->initHair(lua_tonumber(L, 2), lua_tonumber(L, 3), lua_tonumber(L, 4), lua_tostring(L, 5));
se->initHair(lua_tonumber(L, 2), lua_tonumber(L, 3), lua_tonumber(L, 4), getString(L, 5));
}
luaReturnNil();
}
@ -6463,8 +6453,8 @@ luaFunc(entity_exertHairForce)
luaFunc(entity_initPart)
{
std::string partName(lua_tostring(L, 2));
std::string partTex(lua_tostring(L, 3));
std::string partName(getString(L, 2));
std::string partTex(getString(L, 3));
Vector partPosition(lua_tointeger(L, 4), lua_tointeger(L, 5));
int renderAfter = lua_tointeger(L, 6);
bool partFlipH = lua_tointeger(L, 7);
@ -6612,7 +6602,7 @@ luaFunc(entity_fireGas)
int radius = lua_tointeger(L, 2);
float life = lua_tonumber(L, 3);
float damage = lua_tonumber(L, 4);
std::string gfx = lua_tostring(L, 5);
std::string gfx = getString(L, 5);
float colorx = lua_tonumber(L, 6);
float colory = lua_tonumber(L, 7);
float colorz = lua_tonumber(L, 8);
@ -6730,7 +6720,7 @@ luaFunc(fade3)
luaFunc(vision)
{
dsq->vision(lua_tostring(L, 1), lua_tonumber(L, 2), getBool(L, 3));
dsq->vision(getString(L, 1), lua_tonumber(L, 2), getBool(L, 3));
luaReturnNil();
}
@ -6747,19 +6737,19 @@ luaFunc(voice)
vmod = -1;
else if (vmod == -1)
vmod = 0;
dsq->voice(lua_tostring(L, 1), vmod);
dsq->voice(getString(L, 1), vmod);
luaReturnNil();
}
luaFunc(voiceOnce)
{
dsq->voiceOnce(lua_tostring(L, 1));
dsq->voiceOnce(getString(L, 1));
luaReturnNil();
}
luaFunc(voiceInterupt)
{
dsq->voiceInterupt(lua_tostring(L, 1));
dsq->voiceInterupt(getString(L, 1));
luaReturnNil();
}
@ -9046,6 +9036,9 @@ bool Script::doCall(int nparams, int nrets)
else
{
lastError = lua_tostring(L, -1);
lastError += " [";
lastError += luaFormatStackInfo(L);
lastError += "]";
lua_pop(L, 1);
result = false;
}
@ -9184,32 +9177,27 @@ bool Script::call(const char *name, void *param1, void *param2, void *param3, fl
return true;
}
bool Script::callVariadic(const char *name, lua_State *fromL, int nparams, void *param)
int Script::callVariadic(const char *name, lua_State *fromL, int nparams, void *param)
{
// clone topmost nparams elements, they will be popped by xmove
int oldtop = lua_gettop(L);
lookupFunc(name);
luaPushPointer(L, param);
// If both stacks are the same, we already pushed 2 more entries to the stack.
int pos = (L == fromL) ? -(nparams+2) : -nparams;
for (int i = 0; i < nparams; ++i)
lua_pushvalue(fromL, -nparams);
lua_pushvalue(fromL, pos);
lookupFunc(name); // [f]
luaPushPointer(L, param); // [f, p]
// Move them to the other stack
lua_xmove(fromL, L, nparams); // [f, p, ...]
// Move them to the other stack. Ignored if L == fromL.
lua_xmove(fromL, L, nparams);
// Do the call
bool success = doCall(nparams + 1, LUA_MULTRET);
if (!doCall(nparams + 1, LUA_MULTRET))
return -1;
// after returning from the call, push everything that is left on the stack
// (= what the function returned) back onto the caller's stack.
if (success)
{
// clone elements again
int count = lua_gettop(L);
for (int i = 0; i < count; ++i)
lua_pushvalue(L, -count);
nparams = lua_gettop(L) - oldtop;
lua_xmove(L, fromL, nparams);
lua_xmove(L, fromL, count);
}
return success;
return nparams;
}

View file

@ -60,7 +60,8 @@ public:
// boolean = function(pointer, pointer, pointer, number, number, number, number, pointer)
bool call(const char *name, void *param1, void *param2, void *param3, float param4, float param5, float param6, float param7, void *param8, bool *ret1);
// function(pointer, ...) - anything that is already on the stack is forwarded. Results are left on the stack.
bool callVariadic(const char *name, lua_State *L, int nparams, void *param);
// Returns how many values the called function returned, or -1 in case of error.
int callVariadic(const char *name, lua_State *L, int nparams, void *param);
lua_State *getLuaState() {return L;}
const std::string &getFile() {return file;}

View file

@ -96,14 +96,17 @@ void ScriptedEntity::message(const std::string &msg, int v)
Entity::message(msg, v);
}
void ScriptedEntity::messageVariadic(lua_State *L, int nparams)
int ScriptedEntity::messageVariadic(lua_State *L, int nparams)
{
if (script)
{
if (!script->callVariadic("msg", L, nparams, this))
int res = script->callVariadic("msg", L, nparams, this);
if (res < 0)
luaDebugMsg("msg", script->getLastError());
else
return res;
}
Entity::messageVariadic(L, nparams);
return Entity::messageVariadic(L, nparams);
}
void ScriptedEntity::warpSegments()
@ -250,7 +253,7 @@ void ScriptedEntity::setupEntity(const std::string &tex, int lcode)
this->layer = dsq->getEntityLayerToLayer(lcode);
}
void ScriptedEntity::setupBasicEntity(std::string texture, int health, int manaBall, int exp, int money, int collideRadius, int state, int w, int h, int expType, bool hitEntity, int updateCull, int layer)
void ScriptedEntity::setupBasicEntity(const std::string& texture, int health, int manaBall, int exp, int money, int collideRadius, int state, int w, int h, int expType, bool hitEntity, int updateCull, int layer)
{
//this->updateCull = updateCull;
updateCull = -1;

View file

@ -35,7 +35,7 @@ public:
void resetTimer(float t);
void setEntityLayer(int layer);
void setupEntity(const std::string &tex, int layer=0);
void setupBasicEntity(std::string texture, int health, int manaBall, int exp, int money, int collideRadius, int state, int w, int h, int expType, bool hitEntity, int updateCull, int layer);
void setupBasicEntity(const std::string& texture, int health, int manaBall, int exp, int money, int collideRadius, int state, int w, int h, int expType, bool hitEntity, int updateCull, int layer);
void initHair(int numSegments, int segmentLength, int width, const std::string &tex);
void initSegments(int numSegments, int minDist, int maxDist, std::string bodyTex, std::string tailTex, int w, int h, float taper, bool reverseSegments);
void registerNewPart(RenderObject *r, const std::string &name);
@ -47,7 +47,7 @@ public:
void lightFlare();
void entityDied(Entity *e);
void message(const std::string &msg, int v);
void messageVariadic(lua_State *L, int nparams);
int messageVariadic(lua_State *L, int nparams);
static bool runningActivation;

View file

@ -740,7 +740,7 @@ void SkeletalSprite::animate(const std::string &animation, int loop, int layer)
animLayers[layer].animate(animation, loop);
}
float SkeletalSprite::transitionAnimate(std::string anim, float time, int loop, int layer)
float SkeletalSprite::transitionAnimate(const std::string& anim, float time, int loop, int layer)
{
AnimationLayer *animLayer = getAnimationLayer(layer);
if (animLayer)

View file

@ -217,7 +217,7 @@ public:
void stopAnimation(int layer=0);
void stopAllAnimations();
float transitionAnimate(std::string anim, float time, int loop=0, int layer=0);
float transitionAnimate(const std::string& anim, float time, int loop=0, int layer=0);
bool isAnimating(int layer=0);

View file

@ -294,7 +294,6 @@ SET(AQUARIA_SRCS
${SRCDIR}/Avatar.cpp
${SRCDIR}/Beam.cpp
${SRCDIR}/BitBlotLogo.cpp
${SRCDIR}/BoxElement.cpp
${SRCDIR}/CollideEntity.cpp
${SRCDIR}/Continuity.cpp
${SRCDIR}/Credits.cpp
@ -348,6 +347,7 @@ SET(AQUARIA_SRCS
# Apparently not used at the moment. Listed here just for completeness.
SET(AQUARIA_SRCS_UNUSED
${SRCDIR}/BoxElement.cpp
${SRCDIR}/BubbleRender.cpp
${SRCDIR}/FFTNotes.cpp
${SRCDIR}/StarRenderer.cpp
@ -370,10 +370,8 @@ SET(BBGE_SRCS
${BBGEDIR}/Core.cpp
${BBGEDIR}/Cube.cpp
${BBGEDIR}/DarkLayer.cpp
${BBGEDIR}/Datafile.cpp
${BBGEDIR}/DebugFont.cpp
${BBGEDIR}/DeflateCompressor.cpp
${BBGEDIR}/DFSprite.cpp
${BBGEDIR}/Effects.cpp
${BBGEDIR}/Emitter.cpp
${BBGEDIR}/Event.cpp
@ -450,6 +448,8 @@ SET(BBGE_SRCS_UNUSED
${BBGEDIR}/BloomEffect.cpp
${BBGEDIR}/CShim.cpp
${BBGEDIR}/Cutscene.cpp
${BBGEDIR}/Datafile.cpp
${BBGEDIR}/DFSprite.cpp
${BBGEDIR}/FileVars.cpp
${BBGEDIR}/Light.cpp
${BBGEDIR}/LightCone.cpp

View file

@ -174,7 +174,7 @@ function hitSurface(me)
end
function damage(me, attacker, bone, damageType, dmg)
if v.parasite and bone_isName(bone,"Parasite") then
if v.parasite and bone ~= 0 and bone_isName(bone,"Parasite") then
bone_damageFlash(bone)
v.paraHits = v.paraHits - dmg
if v.paraHits <= 0 then

View file

@ -123,7 +123,7 @@ function update(me, dt)
v.grabbedEnt = v.n
entity_setState(me, STATE_TRAP)
elseif entity_isEntityInRange(me, v.li, grabRange) then
elseif v.li ~= 0 and entity_isEntityInRange(me, v.li, grabRange) then
v.grabbedEnt = v.li
entity_setState(me, STATE_TRAP)

View file

@ -206,11 +206,13 @@ function enterState(me)
esetv(me, EV_LOOKAT,1)
entity_animate(me, "idle", LOOP_INF)
entity_setMaxSpeed(me, 400)
entity_setUpdateCull(me, 1500)
elseif entity_getState(me)==STATE_ATTACHED then
entity_setEntityType(me, ET_NEUTRAL)
esetv(me, EV_LOOKAT,0)
entity_setMaxSpeed(me, 0)
entity_setUpdateCull(me, -1)
entity_animate(me, "attached", LOOP_INF)
entity_sound(me, "Leach")
v.attachBone = entity_getNearestBoneToPosition(entity_getTarget(me), entity_getPosition(me))