mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-08-07 06:40:22 +00:00
Fixed some script interface functions, error handling & code cleanups
== Script interface changes: == Removed entity_setClampOnSwitchDir(), which was a no-op. Added entity_getFlag() function, for fairness, as nodes already have one. Added node_getLabel() function, which does not return the _full_ node string, but only the first part before parameters. dofile() supports relative paths now, and it is no longer necessary to use appendUserDataPath() + full path from a mod. entity_color() does now support all interpolation functions that similar vector-manipulation functions support (loop, ping-pong, ease). added entity_getVel() function (an entity_setVel() can be emulated with entity_clearVel(), followed by entity_addVel()). *_getNearestNode() and *_getNearestEntity() allow an optional ignore parameter. node_getNearestNode() allowed to specify a node to exclude from the search, the others not -- now the interface is more consistent. Deprecated entity_[incr/decr]TargetLeaches(entity) - the attached leach amount was never handled by any entity other than Naija. Replaced them with avatar_[incr/decr]Leaches(), but kept the old ames for now, too. Should be removed in a while. == Script interface & related fixes: == Added bool loudScriptErrors to control displaying script syntax error and global variable usage warnings. So far, syntax errors always went do debugLog(), but it is less time consuming when writing scripts to have them displayed right away. *_getNearestNode now scan by label, and not full name. This allows searching for nodes but ignoring its parameters. The original game scripts never search for nodes that have parameters, so this does not break anything, but allows modding without an exploding amount of specialized node scripts. entity_setBoneLock() failed for certain entites with throwLuaErrors=true, allowing to burst through them (gears, grouper, big mithalas jelly, probably more). Removed unnecessary int-casts in entity_setHealth(), entity_changeHealth(), and a few others, which truncated float fractional parts. Fixed possible crashes in many functions due to missing NULL-pointer checks, if wrong data were passed to Lua. Optimized entity_getNearestEntity() a little - do nocasecmp() after checking all other params UPPERCASE global variables as used in mod include files are now tolerated, even with all warnings on. This makes sense because it was impossible to include a custom flags definition file (which _must_ have globals, otherwise the including scripts won't see them) in a mod without beeing buried in spam. They won't change, or clobber any states, and UPPERCASE sort of implies a constant/#define, imho. Added better control over warnings about not-existing files. map_*.lua and premap_*.lua files are optional, and no warning should be given if they do not exist. Missing Entity scripts and mod-init.lua must be warned about, however. Fixed a crash in global variable access warning (NULL pushed into std::ostringstream) Fixed 2 random warnings i found in scrips == Misc stuff: == Related to the changes above, cleaned out unused variables from the Entity class, and removed the code that had to do with them somehow. Some parts of the removed code were still in use, although totally unnecessary. Saves a few bytes of memory per entity, and less code that can cause headache.
This commit is contained in:
parent
7d0c2351ed
commit
c78d4d7a11
23 changed files with 314 additions and 619 deletions
|
@ -4553,6 +4553,7 @@ Avatar::Avatar() : Entity(), ActionMapper()
|
||||||
pullTarget = 0;
|
pullTarget = 0;
|
||||||
revertTimer = 0;
|
revertTimer = 0;
|
||||||
currentSongIdx = -1;
|
currentSongIdx = -1;
|
||||||
|
leaches = 0;
|
||||||
|
|
||||||
|
|
||||||
debugLog("Avatar vars->");
|
debugLog("Avatar vars->");
|
||||||
|
@ -5987,11 +5988,6 @@ int Avatar::getBeamWidth()
|
||||||
return c * TILE_SIZE;
|
return c * TILE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::onGetEXP(unsigned int exp)
|
|
||||||
{
|
|
||||||
dsq->continuity.exp += exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Avatar::onEnterState(int action)
|
void Avatar::onEnterState(int action)
|
||||||
{
|
{
|
||||||
Entity::onEnterState(action);
|
Entity::onEnterState(action);
|
||||||
|
|
|
@ -354,6 +354,8 @@ public:
|
||||||
|
|
||||||
void revert();
|
void revert();
|
||||||
|
|
||||||
|
int leaches;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setSongIconPositions();
|
void setSongIconPositions();
|
||||||
|
|
||||||
|
@ -459,7 +461,6 @@ protected:
|
||||||
|
|
||||||
void onEnterState(int action);
|
void onEnterState(int action);
|
||||||
void onExitState(int action);
|
void onExitState(int action);
|
||||||
void onGetEXP(unsigned int exp);
|
|
||||||
std::vector<ParticleEffect*>targetQuads;
|
std::vector<ParticleEffect*>targetQuads;
|
||||||
Quad *blinder, *fader, *tripper;
|
Quad *blinder, *fader, *tripper;
|
||||||
void applyBlindEffects();
|
void applyBlindEffects();
|
||||||
|
|
|
@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
CollideEntity::CollideEntity() : Entity()
|
CollideEntity::CollideEntity() : Entity()
|
||||||
{
|
{
|
||||||
this->canBeTargetedByAvatar = true;
|
this->canBeTargetedByAvatar = true;
|
||||||
collideWithEntity = false;
|
|
||||||
weight = 0;
|
weight = 0;
|
||||||
bounceAmount = 0.5f;
|
bounceAmount = 0.5f;
|
||||||
bounceEntityAmount = 0.5f;
|
bounceEntityAmount = 0.5f;
|
||||||
|
|
|
@ -33,7 +33,6 @@ public:
|
||||||
void entityDied(Entity *e);
|
void entityDied(Entity *e);
|
||||||
protected:
|
protected:
|
||||||
virtual void onHitWall(){}
|
virtual void onHitWall(){}
|
||||||
virtual void onHitEntity(const CollideData &c){}
|
|
||||||
void onUpdateFrozen(float dt);
|
void onUpdateFrozen(float dt);
|
||||||
|
|
||||||
virtual void onBounce() {}
|
virtual void onBounce() {}
|
||||||
|
|
|
@ -3844,9 +3844,9 @@ void DSQ::runGesture(const std::string &line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DSQ::runScript(const std::string &name, const std::string &function)
|
bool DSQ::runScript(const std::string &name, const std::string &function, bool ignoremissing /* = false */)
|
||||||
{
|
{
|
||||||
if (!scriptInterface.runScript(name, function))
|
if (!scriptInterface.runScript(name, function, ignoremissing))
|
||||||
{
|
{
|
||||||
debugLog("Could not find script file [" + name + "]");
|
debugLog("Could not find script file [" + name + "]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1367,7 +1367,7 @@ public:
|
||||||
void doLoadMenu();
|
void doLoadMenu();
|
||||||
void onExitSaveSlotMenu();
|
void onExitSaveSlotMenu();
|
||||||
ScriptInterface scriptInterface;
|
ScriptInterface scriptInterface;
|
||||||
bool runScript(const std::string &name, const std::string &func="");
|
bool runScript(const std::string &name, const std::string &func="", bool ignoremissing = false);
|
||||||
bool runScriptNum(const std::string &name, const std::string &func="", float num=0);
|
bool runScriptNum(const std::string &name, const std::string &func="", float num=0);
|
||||||
void collectScriptGarbage();
|
void collectScriptGarbage();
|
||||||
|
|
||||||
|
|
|
@ -240,36 +240,21 @@ Entity::Entity() : StateMachine(), DFSprite()
|
||||||
swimPath = false;
|
swimPath = false;
|
||||||
currentEntityTarget = 0;
|
currentEntityTarget = 0;
|
||||||
deleteOnPathEnd = false;
|
deleteOnPathEnd = false;
|
||||||
shockTimer = 0;
|
|
||||||
overideMaxSpeedValue= 0;
|
overideMaxSpeedValue= 0;
|
||||||
overideMaxSpeedTime=0;
|
overideMaxSpeedTime=0;
|
||||||
followingPath = 0;
|
followingPath = 0;
|
||||||
multColor = Vector(1,1,1);
|
multColor = Vector(1,1,1);
|
||||||
collideRadius = 24;
|
collideRadius = 24;
|
||||||
entityType = EntityType(0);
|
entityType = EntityType(0);
|
||||||
behaviorType = BehaviorType(0);
|
|
||||||
targets.resize(10);
|
targets.resize(10);
|
||||||
attachedTo = 0;
|
attachedTo = 0;
|
||||||
currentPathNode = -1;
|
currentPathNode = -1;
|
||||||
notify = 0;
|
|
||||||
itemUseRange = 400;
|
|
||||||
flipScene = true;
|
|
||||||
collideWithEntity = false;
|
|
||||||
//target = 0;
|
//target = 0;
|
||||||
leaches = 0;
|
|
||||||
frozenTimer = 0;
|
frozenTimer = 0;
|
||||||
shockTimer = 0;
|
|
||||||
shockQuad = 0;
|
|
||||||
exp = 0;
|
|
||||||
manaBallTarget = 0;
|
|
||||||
wantManaBall = 0;
|
|
||||||
canBeTargetedByAvatar = false;
|
canBeTargetedByAvatar = false;
|
||||||
canTalkWhileMoving = false;
|
|
||||||
activationRange = 0;
|
activationRange = 0;
|
||||||
activationType = ACT_NONE;
|
activationType = ACT_NONE;
|
||||||
currentColor = Vector(1,1,1);
|
currentColor = Vector(1,1,1);
|
||||||
isStuckIn = false;
|
|
||||||
canStickInStream = false;
|
|
||||||
pushDamage = 0;
|
pushDamage = 0;
|
||||||
|
|
||||||
//debugLog("dsq->addEntity()");
|
//debugLog("dsq->addEntity()");
|
||||||
|
@ -498,11 +483,6 @@ void Entity::setName(const std::string &name)
|
||||||
this->name = name;
|
this->name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Path *Entity::getNode()
|
|
||||||
{
|
|
||||||
return &node;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Entity::followPath(Path *p, int speedType, int dir, bool deleteOnEnd)
|
void Entity::followPath(Path *p, int speedType, int dir, bool deleteOnEnd)
|
||||||
{
|
{
|
||||||
//Path *p = dsq->game->getPathByName(name);
|
//Path *p = dsq->game->getPathByName(name);
|
||||||
|
@ -561,7 +541,6 @@ void Entity::moveToNode(Path *path, int speedType, int dieOnPathEnd, bool swim)
|
||||||
position.data->path.clear();
|
position.data->path.clear();
|
||||||
position.stop();
|
position.stop();
|
||||||
|
|
||||||
ondulateTimer = 0;
|
|
||||||
swimPath = swim;
|
swimPath = swim;
|
||||||
debugLog("Generating path to: " + path->name);
|
debugLog("Generating path to: " + path->name);
|
||||||
dsq->pathFinding.generatePath(this, TileVector(start), TileVector(dest));
|
dsq->pathFinding.generatePath(this, TileVector(start), TileVector(dest));
|
||||||
|
@ -724,22 +703,6 @@ void Entity::warpToPathStart()
|
||||||
position = followingPath->nodes[0].position;
|
position = followingPath->nodes[0].position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::itemUsedOnMe(Entity *user, int item)
|
|
||||||
{
|
|
||||||
onItemUsedOnMe(user, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector Entity::getAvatarDiff()
|
|
||||||
{
|
|
||||||
return dsq->game->avatar->position - this->position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void Entity::onCollide(Entity *e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Entity::watchEntity(Entity *e)
|
void Entity::watchEntity(Entity *e)
|
||||||
{
|
{
|
||||||
watchingEntity = e;
|
watchingEntity = e;
|
||||||
|
@ -997,36 +960,12 @@ void Entity::revive(int a)
|
||||||
//health += a;
|
//health += a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::doMovementPattern(Entity *target, MovementPatternType type, int minDist, int maxDist, int spd1, int spd2, float dt)
|
|
||||||
{
|
|
||||||
Vector v = target->position - position;
|
|
||||||
int dist = v.getSquaredLength2D();
|
|
||||||
if (dist < sqr(minDist))
|
|
||||||
{
|
|
||||||
Vector sub = v;
|
|
||||||
sub.setLength2D(spd1);
|
|
||||||
Vector mov = v;
|
|
||||||
Vector para(mov.y, -mov.x);
|
|
||||||
|
|
||||||
vel -= (mov+para)*dt;
|
|
||||||
}
|
|
||||||
else if (dist > sqr(minDist) && dist < sqr(maxDist))
|
|
||||||
{
|
|
||||||
v.setLength2D(spd2 * dt);
|
|
||||||
vel += v;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vel -= vel*dt*0.5f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Entity::isGoingToBeEaten()
|
bool Entity::isGoingToBeEaten()
|
||||||
{
|
{
|
||||||
return (eatType != EAT_NONE && (lastDamage.damageType == DT_AVATAR_BITE || lastDamage.damageType == DT_AVATAR_PETBITE));
|
return (eatType != EAT_NONE && (lastDamage.damageType == DT_AVATAR_BITE || lastDamage.damageType == DT_AVATAR_PETBITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::doDeathEffects(int manaBallEnergy, int money, bool die)
|
void Entity::doDeathEffects(int manaBallEnergy, bool die)
|
||||||
{
|
{
|
||||||
if (deathScene || !isGoingToBeEaten())
|
if (deathScene || !isGoingToBeEaten())
|
||||||
{
|
{
|
||||||
|
@ -1784,7 +1723,10 @@ void Entity::clearDamageTargets()
|
||||||
|
|
||||||
void Entity::setDamageTarget(DamageType dt, bool v)
|
void Entity::setDamageTarget(DamageType dt, bool v)
|
||||||
{
|
{
|
||||||
disabledDamageTypes[dt] = !v;
|
if (v)
|
||||||
|
disabledDamageTypes.erase(dt);
|
||||||
|
else
|
||||||
|
disabledDamageTypes.insert(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setEatType(EatType et, const std::string &file)
|
void Entity::setEatType(EatType et, const std::string &file)
|
||||||
|
@ -1800,23 +1742,22 @@ void Entity::setEatType(EatType et, const std::string &file)
|
||||||
|
|
||||||
void Entity::setAllDamageTargets(bool v)
|
void Entity::setAllDamageTargets(bool v)
|
||||||
{
|
{
|
||||||
for (int i = DT_ENEMY; i < DT_ENEMY_REALMAX; i++)
|
if (v)
|
||||||
{
|
clearDamageTargets(); // clear all disabled -> all allowed now
|
||||||
disabledDamageTypes[(DamageType)i] = !v;
|
if (v)
|
||||||
}
|
{
|
||||||
for (int i = DT_AVATAR; i < DT_AVATAR_REALMAX; i++)
|
for (int i = DT_ENEMY; i < DT_ENEMY_REALMAX; i++)
|
||||||
{
|
setDamageTarget(DamageType(i), v);
|
||||||
disabledDamageTypes[(DamageType)i] = !v;
|
for (int i = DT_AVATAR; i < DT_AVATAR_REALMAX; i++)
|
||||||
}
|
setDamageTarget(DamageType(i), v);
|
||||||
for (int i = DT_AVATAR_MAX; i < DT_REALMAX; i++)
|
for (int i = DT_AVATAR_MAX; i < DT_REALMAX; i++)
|
||||||
{
|
setDamageTarget(DamageType(i), v);
|
||||||
disabledDamageTypes[(DamageType)i] = !v;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::isDamageTarget(DamageType dt)
|
bool Entity::isDamageTarget(DamageType dt)
|
||||||
{
|
{
|
||||||
return !disabledDamageTypes[dt];
|
return disabledDamageTypes.find(dt) == disabledDamageTypes.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
float Entity::getHealthPerc()
|
float Entity::getHealthPerc()
|
||||||
|
@ -1969,20 +1910,12 @@ void Entity::onUpdate(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.nodes.empty())
|
|
||||||
{
|
|
||||||
node.addNode(0);
|
|
||||||
}
|
|
||||||
node.nodes[0].position = position;
|
|
||||||
|
|
||||||
DFSprite::onUpdate(dt);
|
DFSprite::onUpdate(dt);
|
||||||
|
|
||||||
Vector v = position - lastPos;
|
Vector v = position - lastPos;
|
||||||
lastMove = v;
|
lastMove = v;
|
||||||
if (position.isFollowingPath() && swimPath)
|
if (position.isFollowingPath() && swimPath)
|
||||||
{
|
{
|
||||||
ondulateTimer += dt;
|
|
||||||
|
|
||||||
movementDetails(v);
|
movementDetails(v);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2011,8 +1944,6 @@ void Entity::onUpdate(float dt)
|
||||||
|
|
||||||
if (bubble)
|
if (bubble)
|
||||||
bubble->position = this->position;
|
bubble->position = this->position;
|
||||||
if (shockQuad)
|
|
||||||
shockQuad->position = this->position;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (frozenTimer > 0)
|
if (frozenTimer > 0)
|
||||||
|
@ -2025,15 +1956,6 @@ void Entity::onUpdate(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (shockTimer > 0)
|
|
||||||
{
|
|
||||||
shockTimer -= dt;
|
|
||||||
if (shockTimer <= 0)
|
|
||||||
{
|
|
||||||
shockTimer = 0;
|
|
||||||
endShock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (followingPath && currentPathNode != -1 && life == 1)
|
if (followingPath && currentPathNode != -1 && life == 1)
|
||||||
{
|
{
|
||||||
|
@ -2475,7 +2397,6 @@ void Entity::push(const Vector &vec, float time, int maxSpeed, float dmg)
|
||||||
{
|
{
|
||||||
if (!this->isEntityDead())
|
if (!this->isEntityDead())
|
||||||
{
|
{
|
||||||
isStuckIn = false;
|
|
||||||
pushDamage = dmg;
|
pushDamage = dmg;
|
||||||
if (maxSpeed == 0)
|
if (maxSpeed == 0)
|
||||||
{
|
{
|
||||||
|
@ -2518,35 +2439,6 @@ int Entity::getMaxSpeed()
|
||||||
return maxSpeed;
|
return maxSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::shock()
|
|
||||||
{
|
|
||||||
shockTimer = 0.33;
|
|
||||||
if (shockQuad)
|
|
||||||
{
|
|
||||||
//shockQuad->setLife(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
shockQuad = new Quad;
|
|
||||||
shockQuad->setTexture("shock-hit");
|
|
||||||
shockQuad->alpha = 0;
|
|
||||||
shockQuad->position = this->position;
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
//shockQuad->setLife(1);
|
|
||||||
//shockQuad->setDecayRate(1);
|
|
||||||
//shockQuad->fadeAlphaWithLife = 0.5;
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
shockQuad->setBlendType(BLEND_ADDITIVE);
|
|
||||||
shockQuad->alpha.interpolateTo(1, 0.5);
|
|
||||||
shockQuad->rotation.interpolateTo(Vector(0,0,360*5), 0.5, -1);
|
|
||||||
core->getTopStateData()->addRenderObject(shockQuad, LR_PARTICLES);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Entity::songNote(int note)
|
void Entity::songNote(int note)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -2566,19 +2458,6 @@ void Entity::sound(const std::string &sound, float freq, float fadeOut)
|
||||||
dsq->playPositionalSfx(sound, position, 1, fadeOut);
|
dsq->playPositionalSfx(sound, position, 1, fadeOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::endShock()
|
|
||||||
{
|
|
||||||
offset.x = 0;
|
|
||||||
if (shockQuad)
|
|
||||||
{
|
|
||||||
|
|
||||||
shockQuad->setLife(1);
|
|
||||||
shockQuad->setDecayRate(4);
|
|
||||||
shockQuad->fadeAlphaWithLife = 1;
|
|
||||||
shockQuad = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector Entity::getEnergyShotTargetPosition()
|
Vector Entity::getEnergyShotTargetPosition()
|
||||||
{
|
{
|
||||||
if (!energyShotTargetPosition.isZero())
|
if (!energyShotTargetPosition.isZero())
|
||||||
|
@ -2610,21 +2489,11 @@ void Entity::setEntityType(EntityType et)
|
||||||
entityType = et;
|
entityType = et;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setBehaviorType(BehaviorType bt)
|
|
||||||
{
|
|
||||||
behaviorType = bt;
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityType Entity::getEntityType()
|
EntityType Entity::getEntityType()
|
||||||
{
|
{
|
||||||
return entityType;
|
return entityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
BehaviorType Entity::getBehaviorType()
|
|
||||||
{
|
|
||||||
return behaviorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* types:
|
/* types:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -2764,7 +2633,6 @@ void Entity::onEnterState(int action)
|
||||||
{
|
{
|
||||||
sound("Gulp");
|
sound("Gulp");
|
||||||
}
|
}
|
||||||
endShock();
|
|
||||||
popBubble();
|
popBubble();
|
||||||
//dsq->game->avatar->entityDied(this);
|
//dsq->game->avatar->entityDied(this);
|
||||||
Shot::targetDied(this);
|
Shot::targetDied(this);
|
||||||
|
@ -2909,11 +2777,6 @@ bool Entity::onDamage(int amount, Spell *spell, Entity *attacker)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Entity::getEXP(unsigned int exp)
|
|
||||||
{
|
|
||||||
onGetEXP(exp);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Entity::isHit()
|
bool Entity::isHit()
|
||||||
{
|
{
|
||||||
return (damageTimer.isActive());
|
return (damageTimer.isActive());
|
||||||
|
@ -3104,14 +2967,9 @@ bool Entity::damage(const DamageData &dmgData)
|
||||||
this->multColor.interpolateTo(Vector(1, 0.1, 0.1), 0.1, 4, 1);
|
this->multColor.interpolateTo(Vector(1, 0.1, 0.1), 0.1, 4, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d.mult != 0)
|
health -= d.damage;
|
||||||
health -= d.damage * d.mult;
|
|
||||||
else
|
|
||||||
health -= d.damage;
|
|
||||||
if (health <= 0)
|
if (health <= 0)
|
||||||
{
|
{
|
||||||
if (d.attacker)
|
|
||||||
d.attacker->getEXP(exp);
|
|
||||||
health = 0;
|
health = 0;
|
||||||
entityDead = true;
|
entityDead = true;
|
||||||
if (deathScene)
|
if (deathScene)
|
||||||
|
@ -3135,11 +2993,6 @@ void Entity::clampToHit()
|
||||||
//setCrawling(true);
|
//setCrawling(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::hitEntity(Entity *e, const CollideData &c)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void Entity::damage(int amount, Spell *spell, Entity *attacker)
|
void Entity::damage(int amount, Spell *spell, Entity *attacker)
|
||||||
{
|
{
|
||||||
|
|
|
@ -150,14 +150,12 @@ struct DamageData
|
||||||
attacker = 0;
|
attacker = 0;
|
||||||
bone = 0;
|
bone = 0;
|
||||||
damageType = DT_TOUCH;
|
damageType = DT_TOUCH;
|
||||||
mult = 0;
|
|
||||||
form = (FormType)0;
|
form = (FormType)0;
|
||||||
shot = 0;
|
shot = 0;
|
||||||
effectTime = 0;
|
effectTime = 0;
|
||||||
useTimer = true;
|
useTimer = true;
|
||||||
}
|
}
|
||||||
FormType form;
|
FormType form;
|
||||||
float mult;
|
|
||||||
DamageType damageType;
|
DamageType damageType;
|
||||||
Entity *attacker;
|
Entity *attacker;
|
||||||
Bone *bone;
|
Bone *bone;
|
||||||
|
@ -168,33 +166,6 @@ struct DamageData
|
||||||
bool useTimer;
|
bool useTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CollideData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CollideData()
|
|
||||||
{
|
|
||||||
collision = false;
|
|
||||||
entity = 0;
|
|
||||||
bone = 0;
|
|
||||||
pushTime = 0;
|
|
||||||
damage = 0;
|
|
||||||
}
|
|
||||||
int damage;
|
|
||||||
Vector pushVector;
|
|
||||||
float pushTime;
|
|
||||||
bool collision;
|
|
||||||
Vector edgePoint;
|
|
||||||
Entity *entity;
|
|
||||||
Bone *bone;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
enum MovementPatternType
|
|
||||||
{
|
|
||||||
MOVEMENT_NONE = -1,
|
|
||||||
MOVEMENT_CIRCLE = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum EntityType
|
enum EntityType
|
||||||
{
|
{
|
||||||
ET_NOTYPE =-1,
|
ET_NOTYPE =-1,
|
||||||
|
@ -215,13 +186,6 @@ enum EntityProperty
|
||||||
EP_MAX =4
|
EP_MAX =4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BehaviorType
|
|
||||||
{
|
|
||||||
BT_NORMAL =0,
|
|
||||||
BT_MOTHER =1,
|
|
||||||
BT_ACTIVEPET =2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum BounceType
|
enum BounceType
|
||||||
{
|
{
|
||||||
BOUNCE_NONE = -1,
|
BOUNCE_NONE = -1,
|
||||||
|
@ -265,8 +229,6 @@ public:
|
||||||
void heal(float a, int type=0);
|
void heal(float a, int type=0);
|
||||||
|
|
||||||
void push(const Vector &vec, float time, int maxSpeed, float dmg);
|
void push(const Vector &vec, float time, int maxSpeed, float dmg);
|
||||||
bool canStickInStream;
|
|
||||||
bool isStuckIn;
|
|
||||||
|
|
||||||
bool canSetState(int state);
|
bool canSetState(int state);
|
||||||
|
|
||||||
|
@ -279,7 +241,6 @@ public:
|
||||||
|
|
||||||
virtual bool damage(const DamageData &d);
|
virtual bool damage(const DamageData &d);
|
||||||
|
|
||||||
virtual bool hitEntity(Entity *e, const CollideData &c);
|
|
||||||
virtual void songNote(int note);
|
virtual void songNote(int note);
|
||||||
virtual void songNoteDone(int note, float len);
|
virtual void songNoteDone(int note, float len);
|
||||||
virtual void lightFlare(){}
|
virtual void lightFlare(){}
|
||||||
|
@ -299,17 +260,13 @@ public:
|
||||||
|
|
||||||
ActivationType activationType;
|
ActivationType activationType;
|
||||||
int activationRange;
|
int activationRange;
|
||||||
bool canTalkWhileMoving;
|
|
||||||
Entity *followEntity;
|
Entity *followEntity;
|
||||||
Entity *ridingOnEntity;
|
Entity *ridingOnEntity;
|
||||||
bool canBeTargetedByAvatar;
|
bool canBeTargetedByAvatar;
|
||||||
virtual void saveExtraData(TiXmlElement *xml){}
|
virtual void saveExtraData(TiXmlElement *xml){}
|
||||||
virtual void loadExtraData(TiXmlElement *xml){}
|
virtual void loadExtraData(TiXmlElement *xml){}
|
||||||
Vector startPos;
|
Vector startPos;
|
||||||
int wantManaBall;
|
|
||||||
ManaBall *manaBallTarget;
|
|
||||||
virtual void onMessage(const std::string &msg){}
|
virtual void onMessage(const std::string &msg){}
|
||||||
unsigned int exp;
|
|
||||||
void getEXP(unsigned int exp);
|
void getEXP(unsigned int exp);
|
||||||
void rotateToVec(Vector addVec, float time, int offsetAngle=0);
|
void rotateToVec(Vector addVec, float time, int offsetAngle=0);
|
||||||
virtual void applyVariation(int variation){}
|
virtual void applyVariation(int variation){}
|
||||||
|
@ -317,15 +274,11 @@ public:
|
||||||
void popBubble();
|
void popBubble();
|
||||||
void sound(const std::string &sound, float freq=1, float fadeOut=0);
|
void sound(const std::string &sound, float freq=1, float fadeOut=0);
|
||||||
void soundFreq(const std::string &sound, float freq=1, float fadeOut=0);
|
void soundFreq(const std::string &sound, float freq=1, float fadeOut=0);
|
||||||
void shock();
|
|
||||||
void endShock();
|
|
||||||
|
|
||||||
void freeze(float time);
|
void freeze(float time);
|
||||||
|
|
||||||
int leaches;
|
int leaches;
|
||||||
bool collideWithEntity;
|
|
||||||
virtual void onSceneFlipped() {}
|
virtual void onSceneFlipped() {}
|
||||||
bool flipScene;
|
|
||||||
|
|
||||||
bool isNearObstruction(int sz, int type=0, TileVector *hitTile=0);
|
bool isNearObstruction(int sz, int type=0, TileVector *hitTile=0);
|
||||||
|
|
||||||
|
@ -352,9 +305,6 @@ public:
|
||||||
STATE_FOLLOW =23,
|
STATE_FOLLOW =23,
|
||||||
STATE_TITLE =24
|
STATE_TITLE =24
|
||||||
};
|
};
|
||||||
int itemUseRange;
|
|
||||||
void itemUsedOnMe(Entity *user, int item);
|
|
||||||
Entity *notify;
|
|
||||||
virtual void onNotify(Entity *notify){}
|
virtual void onNotify(Entity *notify){}
|
||||||
//void followPath(Path *p, int spd, int loop, bool deleteOnEnd = false);
|
//void followPath(Path *p, int spd, int loop, bool deleteOnEnd = false);
|
||||||
void followPath(Path *p, int speedType, int dir, bool deleteOnEnd = false);
|
void followPath(Path *p, int speedType, int dir, bool deleteOnEnd = false);
|
||||||
|
@ -394,9 +344,7 @@ public:
|
||||||
SkeletalSprite skeletalSprite;
|
SkeletalSprite skeletalSprite;
|
||||||
|
|
||||||
void setEntityType(EntityType et);
|
void setEntityType(EntityType et);
|
||||||
void setBehaviorType(BehaviorType bt);
|
|
||||||
EntityType getEntityType();
|
EntityType getEntityType();
|
||||||
BehaviorType getBehaviorType();
|
|
||||||
bool isOpposedTo(Entity *e);
|
bool isOpposedTo(Entity *e);
|
||||||
bool isCollideAgainst(Entity *e);
|
bool isCollideAgainst(Entity *e);
|
||||||
void flipToTarget(Vector pos);
|
void flipToTarget(Vector pos);
|
||||||
|
@ -411,7 +359,6 @@ public:
|
||||||
Timer burstTimer;
|
Timer burstTimer;
|
||||||
void revive(int a);
|
void revive(int a);
|
||||||
void setName(const std::string &name);
|
void setName(const std::string &name);
|
||||||
Path *getNode();
|
|
||||||
void doFriction(float dt);
|
void doFriction(float dt);
|
||||||
void doFriction(float dt, int len);
|
void doFriction(float dt, int len);
|
||||||
|
|
||||||
|
@ -465,13 +412,11 @@ public:
|
||||||
void setDamageTarget(DamageType dt, bool v);
|
void setDamageTarget(DamageType dt, bool v);
|
||||||
bool isDamageTarget(DamageType dt);
|
bool isDamageTarget(DamageType dt);
|
||||||
|
|
||||||
typedef std::map<DamageType, bool> DisabledDamageTypes;
|
typedef std::set<DamageType> DisabledDamageTypes;
|
||||||
|
|
||||||
|
|
||||||
int targetRange;
|
int targetRange;
|
||||||
int getTargetRange() { return targetRange; }
|
int getTargetRange() { return targetRange; }
|
||||||
|
|
||||||
|
|
||||||
Vector getEnergyShotTargetPosition();
|
Vector getEnergyShotTargetPosition();
|
||||||
int getRandomTargetPoint();
|
int getRandomTargetPoint();
|
||||||
|
|
||||||
|
@ -616,16 +561,13 @@ protected:
|
||||||
float slowingToStopPathTimer, slowingToStopPath;
|
float slowingToStopPathTimer, slowingToStopPath;
|
||||||
|
|
||||||
void movementDetails(Vector v);
|
void movementDetails(Vector v);
|
||||||
float ondulateTimer;
|
|
||||||
Entity *watchingEntity;
|
Entity *watchingEntity;
|
||||||
Path node;
|
|
||||||
virtual void onPathEnd();
|
virtual void onPathEnd();
|
||||||
bool swimPath;
|
bool swimPath;
|
||||||
bool deleteOnPathEnd;
|
bool deleteOnPathEnd;
|
||||||
int overideMaxSpeedValue;
|
int overideMaxSpeedValue;
|
||||||
float overideMaxSpeedTime;
|
float overideMaxSpeedTime;
|
||||||
InterpolatedVector multColor;
|
InterpolatedVector multColor;
|
||||||
BehaviorType behaviorType;
|
|
||||||
EntityType entityType;
|
EntityType entityType;
|
||||||
std::vector<Entity*> attachedEntities;
|
std::vector<Entity*> attachedEntities;
|
||||||
std::vector<Vector> attachedEntitiesOffsets;
|
std::vector<Vector> attachedEntitiesOffsets;
|
||||||
|
@ -635,24 +577,17 @@ protected:
|
||||||
int followingPathLoop;
|
int followingPathLoop;
|
||||||
|
|
||||||
|
|
||||||
virtual void onItemUsedOnMe(Entity *user, int item){}
|
|
||||||
virtual void onFreeze(){}
|
virtual void onFreeze(){}
|
||||||
void doMovementPattern(Entity *target, MovementPatternType type, int minDist, int maxDist, int spd1, int spd2, float dt);
|
|
||||||
|
|
||||||
|
|
||||||
//Entity *target;
|
//Entity *target;
|
||||||
std::vector<Entity*>targets;
|
std::vector<Entity*>targets;
|
||||||
virtual void onAlwaysUpdate(float dt){}
|
virtual void onAlwaysUpdate(float dt){}
|
||||||
virtual void onUpdateFrozen(float dt){}
|
virtual void onUpdateFrozen(float dt){}
|
||||||
float frozenTimer;
|
float frozenTimer;
|
||||||
float shockTimer;
|
|
||||||
Quad *shockQuad;
|
|
||||||
Quad *bubble;
|
Quad *bubble;
|
||||||
|
|
||||||
virtual void onGetEXP(unsigned int exp){}
|
void doDeathEffects(int manaBallEnergy=0, bool die=true);
|
||||||
void doDeathEffects(int manaBallEnergy=0, int money=0, bool die=true);
|
|
||||||
|
|
||||||
Vector getAvatarDiff();
|
|
||||||
Vector currentColor;
|
Vector currentColor;
|
||||||
bool takeDamage;
|
bool takeDamage;
|
||||||
void onEnterState(int action);
|
void onEnterState(int action);
|
||||||
|
|
149
Aquaria/Game.cpp
149
Aquaria/Game.cpp
|
@ -1075,10 +1075,7 @@ void Game::flipSceneVertical(int flipY)
|
||||||
FOR_ENTITIES(itr)
|
FOR_ENTITIES(itr)
|
||||||
{
|
{
|
||||||
Entity *e = *itr;
|
Entity *e = *itr;
|
||||||
if (e->flipScene)
|
flipRenderObjectVertical(e, flipY);
|
||||||
{
|
|
||||||
flipRenderObjectVertical(e, flipY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int flipTY = (flipY/TILE_SIZE)-1;
|
int flipTY = (flipY/TILE_SIZE)-1;
|
||||||
|
@ -2610,7 +2607,7 @@ int Game::getIdxForEntityType(std::string type)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity *Game::createEntity(int idx, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, BehaviorType bt, Entity::NodeGroups *nodeGroups, int gid, bool doPostInit)
|
Entity *Game::createEntity(int idx, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, Entity::NodeGroups *nodeGroups, int gid, bool doPostInit)
|
||||||
{
|
{
|
||||||
std::string type;
|
std::string type;
|
||||||
for (int i = 0; i < dsq->game->entityTypeList.size(); i++)
|
for (int i = 0; i < dsq->game->entityTypeList.size(); i++)
|
||||||
|
@ -2619,7 +2616,7 @@ Entity *Game::createEntity(int idx, int id, Vector position, int rot, bool creat
|
||||||
if (ec->idx == idx)
|
if (ec->idx == idx)
|
||||||
{
|
{
|
||||||
type = ec->name;
|
type = ec->name;
|
||||||
return createEntity(type, id, position, rot, createSaveData, name, et, bt, nodeGroups, gid, doPostInit);
|
return createEntity(type, id, position, rot, createSaveData, name, et, nodeGroups, gid, doPostInit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2658,7 +2655,7 @@ void Game::ensureLimit(Entity *e, int num, int state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, BehaviorType bt, Entity::NodeGroups *nodeGroups, int gid, bool doPostInit)
|
Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, Entity::NodeGroups *nodeGroups, int gid, bool doPostInit)
|
||||||
{
|
{
|
||||||
// e->layer must be set BEFORE calling this function!
|
// e->layer must be set BEFORE calling this function!
|
||||||
|
|
||||||
|
@ -2731,17 +2728,17 @@ Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity *Game::createEntity(const std::string &t, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, BehaviorType bt, Entity::NodeGroups *nodeGroups, int gid, bool doPostInit)
|
Entity *Game::createEntity(const std::string &t, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, Entity::NodeGroups *nodeGroups, int gid, bool doPostInit)
|
||||||
{
|
{
|
||||||
std::string type = t;
|
std::string type = t;
|
||||||
stringToLower(type);
|
stringToLower(type);
|
||||||
|
|
||||||
ScriptedEntity *e;
|
ScriptedEntity *e;
|
||||||
|
|
||||||
e = new ScriptedEntity(type, position, et, bt);
|
e = new ScriptedEntity(type, position, et);
|
||||||
|
|
||||||
|
|
||||||
return establishEntity(e, id, position, rot, createSaveData, name, et, bt, nodeGroups, gid, doPostInit);
|
return establishEntity(e, id, position, rot, createSaveData, name, et, nodeGroups, gid, doPostInit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::initEntities()
|
void Game::initEntities()
|
||||||
|
@ -3072,7 +3069,7 @@ Path *Game::getNearestPath(const Vector &pos, const std::string &s, const Path *
|
||||||
for (int i = 0; i < dsq->game->paths.size(); i++)
|
for (int i = 0; i < dsq->game->paths.size(); i++)
|
||||||
{
|
{
|
||||||
Path *cp = dsq->game->paths[i];
|
Path *cp = dsq->game->paths[i];
|
||||||
if (cp != ignore && !cp->nodes.empty() && (st.empty() || st == cp->name))
|
if (cp != ignore && !cp->nodes.empty() && (st.empty() || st == cp->label))
|
||||||
{
|
{
|
||||||
const Vector v = cp->nodes[0].position - pos;
|
const Vector v = cp->nodes[0].position - pos;
|
||||||
const float dist = v.getSquaredLength2D();
|
const float dist = v.getSquaredLength2D();
|
||||||
|
@ -3118,7 +3115,7 @@ Path *Game::getPathByName(std::string name)
|
||||||
stringToLowerUserData(name);
|
stringToLowerUserData(name);
|
||||||
for (int i = 0; i < paths.size(); i++)
|
for (int i = 0; i < paths.size(); i++)
|
||||||
{
|
{
|
||||||
if (paths[i]->name == name)
|
if (paths[i]->label == name)
|
||||||
return paths[i];
|
return paths[i];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5289,7 +5286,7 @@ bool Game::loadSceneXML(std::string scene)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY, BT_NORMAL, ng, groupID);
|
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY, ng, groupID);
|
||||||
// setting group ID
|
// setting group ID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5302,7 +5299,7 @@ bool Game::loadSceneXML(std::string scene)
|
||||||
{
|
{
|
||||||
is >> x >> y >> rot >> groupID >> id;
|
is >> x >> y >> rot >> groupID >> id;
|
||||||
|
|
||||||
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY, BT_NORMAL, 0, groupID);
|
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY, 0, groupID);
|
||||||
// setting group ID
|
// setting group ID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5320,9 +5317,9 @@ bool Game::loadSceneXML(std::string scene)
|
||||||
is >> x >> y >> rot >> groupID >> id;
|
is >> x >> y >> rot >> groupID >> id;
|
||||||
|
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
dsq->game->createEntity(name, id, Vector(x,y), rot, true, "", ET_ENEMY, BT_NORMAL, 0, groupID);
|
dsq->game->createEntity(name, id, Vector(x,y), rot, true, "", ET_ENEMY, 0, groupID);
|
||||||
else
|
else
|
||||||
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY, BT_NORMAL, 0, groupID);
|
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY, 0, groupID);
|
||||||
// setting group ID
|
// setting group ID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6987,7 +6984,7 @@ void Game::applyState()
|
||||||
core->sort();
|
core->sort();
|
||||||
|
|
||||||
|
|
||||||
dsq->runScript("scripts/maps/premap_"+sceneName+".lua", "init");
|
dsq->runScript("scripts/maps/premap_"+sceneName+".lua", "init", true);
|
||||||
|
|
||||||
std::string musicToPlay = this->musicToPlay;
|
std::string musicToPlay = this->musicToPlay;
|
||||||
if (!overrideMusic.empty())
|
if (!overrideMusic.empty())
|
||||||
|
@ -7079,7 +7076,7 @@ void Game::applyState()
|
||||||
dsq->subtitlePlayer.show(0.25);
|
dsq->subtitlePlayer.show(0.25);
|
||||||
|
|
||||||
if (verbose) debugLog("loading map init script");
|
if (verbose) debugLog("loading map init script");
|
||||||
dsq->runScript("scripts/maps/map_"+sceneName+".lua", "init");
|
dsq->runScript("scripts/maps/map_"+sceneName+".lua", "init", true);
|
||||||
|
|
||||||
if (!dsq->doScreenTrans && (dsq->overlay->alpha != 0 && !dsq->overlay->alpha.isInterpolating()))
|
if (!dsq->doScreenTrans && (dsq->overlay->alpha != 0 && !dsq->overlay->alpha.isInterpolating()))
|
||||||
{
|
{
|
||||||
|
@ -8742,120 +8739,6 @@ void Game::handleShotCollisionsHair(Entity *e, int num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CollideData Game::collideCircleWithAllEntities(Vector pos, float r, Entity *me, int spellType, bool checkAvatarFlag)
|
|
||||||
{
|
|
||||||
CollideData c;
|
|
||||||
//if (me && (checkHitEntitiesFlag && !me->hitEntity)) return 0;
|
|
||||||
//Avatar *a = dynamic_cast<Avatar*>(me);
|
|
||||||
FOR_ENTITIES(i)
|
|
||||||
{
|
|
||||||
Entity *e = *i;
|
|
||||||
|
|
||||||
if (me != e)
|
|
||||||
{
|
|
||||||
bool okay = true;
|
|
||||||
if (okay)
|
|
||||||
{
|
|
||||||
if (spellType == 0)
|
|
||||||
{
|
|
||||||
Bone *closest = 0;
|
|
||||||
float smallestDist = HUGE_VALF;
|
|
||||||
for (int i = 0; i < e->skeletalSprite.bones.size(); i++)
|
|
||||||
{
|
|
||||||
Bone *b = e->skeletalSprite.bones[i];
|
|
||||||
Vector bonePos = b->getWorldCollidePosition();
|
|
||||||
float dist = (bonePos - pos).getSquaredLength2D();
|
|
||||||
if (!b->collisionMask.empty() && b->alpha.x == 1)
|
|
||||||
{
|
|
||||||
if (dist < sqr(r + b->collisionMaskRadius))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < b->transformedCollisionMask.size(); i++)
|
|
||||||
{
|
|
||||||
//Vector collide = b->transformedCollisionMask[i];
|
|
||||||
|
|
||||||
// only do this work once per frame
|
|
||||||
|
|
||||||
//Vector bitPos = b->getWorldCollidePosition(collide);
|
|
||||||
Vector bitPos = b->transformedCollisionMask[i];
|
|
||||||
dist = (bitPos - pos).getSquaredLength2D();
|
|
||||||
if (dist < sqr(r+b->collideRadius))
|
|
||||||
{
|
|
||||||
closest = b;
|
|
||||||
smallestDist = dist;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (b->collideRadius && b->alpha.x == 1)
|
|
||||||
{
|
|
||||||
//Vector bonePos = b->getWorldCollidePosition();
|
|
||||||
//float dist = (bonePos - pos).getSquaredLength2D();
|
|
||||||
if (dist < sqr(r+b->collideRadius))
|
|
||||||
{
|
|
||||||
if (dist < smallestDist)
|
|
||||||
{
|
|
||||||
closest = b;
|
|
||||||
smallestDist = dist;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!closest)
|
|
||||||
{
|
|
||||||
if ((e->position - pos).getSquaredLength2D() < sqr(r+e->collideRadius))
|
|
||||||
{
|
|
||||||
c.entity = e;
|
|
||||||
if (e->pushAvatar)
|
|
||||||
{
|
|
||||||
c.pushVector = pos - e->position;
|
|
||||||
c.pushVector.normalize2D();
|
|
||||||
}
|
|
||||||
if (e->touchDamage)
|
|
||||||
{
|
|
||||||
c.damage = e->touchDamage;
|
|
||||||
}
|
|
||||||
///c.pushVector |= 500;
|
|
||||||
c.collision = true;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//debugLog("boneCollision!");
|
|
||||||
c.entity = e;
|
|
||||||
if (e->pushAvatar)
|
|
||||||
{
|
|
||||||
c.pushVector = pos - e->position;
|
|
||||||
c.pushVector.normalize2D();
|
|
||||||
}
|
|
||||||
//c.pushVector |= 500;
|
|
||||||
c.bone = closest;
|
|
||||||
if (c.bone->touchDamage!=0)
|
|
||||||
{
|
|
||||||
c.damage = c.bone->touchDamage;
|
|
||||||
}
|
|
||||||
else if (e->touchDamage!=0)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "entity touch damage: " << e->touchDamage;
|
|
||||||
debugLog(os.str());
|
|
||||||
*/
|
|
||||||
c.damage = e->touchDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
c.collision = true;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef AQUARIA_BUILD_SCENEEDITOR
|
#ifdef AQUARIA_BUILD_SCENEEDITOR
|
||||||
void Game::toggleSceneEditor()
|
void Game::toggleSceneEditor()
|
||||||
{
|
{
|
||||||
|
@ -10596,7 +10479,7 @@ void Game::update(float dt)
|
||||||
if (sqrLen < sqr(e->activationRadius)
|
if (sqrLen < sqr(e->activationRadius)
|
||||||
&& (avatar->position-e->position).getSquaredLength2D() < sqr(e->activationRange)
|
&& (avatar->position-e->position).getSquaredLength2D() < sqr(e->activationRange)
|
||||||
&& e->activationType == Entity::ACT_CLICK
|
&& e->activationType == Entity::ACT_CLICK
|
||||||
&& (e->canTalkWhileMoving || !e->position.isInterpolating())
|
&& !e->position.isInterpolating()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//if (trace(avatar->position, e->position))
|
//if (trace(avatar->position, e->position))
|
||||||
|
|
|
@ -152,7 +152,7 @@ public:
|
||||||
ParticleEffect healEmitter;
|
ParticleEffect healEmitter;
|
||||||
protected:
|
protected:
|
||||||
float lifeSpan;
|
float lifeSpan;
|
||||||
bool used, gone;
|
bool used;
|
||||||
float amount;
|
float amount;
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
};
|
};
|
||||||
|
@ -679,7 +679,6 @@ public:
|
||||||
bool collideCircleVsLine(Entity *ent, Vector start, Vector end, float radius);
|
bool collideCircleVsLine(Entity *ent, Vector start, Vector end, float radius);
|
||||||
bool collideCircleVsLineAngle(Entity *ent, float angle, float startLen, float endLen, float radius, Vector basePos);
|
bool collideCircleVsLineAngle(Entity *ent, float angle, float startLen, float endLen, float radius, Vector basePos);
|
||||||
Bone *collideSkeletalVsCircle(Entity *skeletal, Vector pos, float radius);
|
Bone *collideSkeletalVsCircle(Entity *skeletal, Vector pos, float radius);
|
||||||
CollideData collideCircleWithAllEntities(Vector pos, float r, Entity *me=0, int spellType=0, bool checkAvatarFlag=false);//, bool checkSpellFlag=0, bool checkHitEntitiesFlag=1);
|
|
||||||
void handleShotCollisions(Entity *e, bool hasShield=false);
|
void handleShotCollisions(Entity *e, bool hasShield=false);
|
||||||
void handleShotCollisionsSkeletal(Entity *e);
|
void handleShotCollisionsSkeletal(Entity *e);
|
||||||
void handleShotCollisionsHair(Entity *e, int num = 0);
|
void handleShotCollisionsHair(Entity *e, int num = 0);
|
||||||
|
@ -741,9 +740,9 @@ public:
|
||||||
MiniMapHint miniMapHint;
|
MiniMapHint miniMapHint;
|
||||||
void updateMiniMapHintPosition();
|
void updateMiniMapHintPosition();
|
||||||
EntitySaveData *getEntitySaveDataForEntity(Entity *e, Vector pos);
|
EntitySaveData *getEntitySaveDataForEntity(Entity *e, Vector pos);
|
||||||
Entity *createEntity(int idx, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType = ET_ENEMY, BehaviorType = BT_NORMAL, Entity::NodeGroups *nodeGroups=0, int groupID=0, bool doPostInit=false);
|
Entity *createEntity(int idx, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType = ET_ENEMY, Entity::NodeGroups *nodeGroups=0, int groupID=0, bool doPostInit=false);
|
||||||
Entity *createEntity(const std::string &type, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType = ET_ENEMY, BehaviorType = BT_NORMAL, Entity::NodeGroups *nodeGroups=0, int groupID=0, bool doPostInit=false);
|
Entity *createEntity(const std::string &type, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType = ET_ENEMY, Entity::NodeGroups *nodeGroups=0, int groupID=0, bool doPostInit=false);
|
||||||
Entity *establishEntity(Entity *e, int id=0, Vector position=Vector(0,0), int rot=0, bool createSaveData=false, std::string name="", EntityType = ET_ENEMY, BehaviorType = BT_NORMAL, Entity::NodeGroups *nodeGroups=0, int groupID=0, bool doPostInit=false);
|
Entity *establishEntity(Entity *e, int id=0, Vector position=Vector(0,0), int rot=0, bool createSaveData=false, std::string name="", EntityType = ET_ENEMY, Entity::NodeGroups *nodeGroups=0, int groupID=0, bool doPostInit=false);
|
||||||
void setCameraFollow(RenderObject *r);
|
void setCameraFollow(RenderObject *r);
|
||||||
void setCameraFollowEntity(Entity *e);
|
void setCameraFollowEntity(Entity *e);
|
||||||
void setMenuDescriptionText(const std::string &text);
|
void setMenuDescriptionText(const std::string &text);
|
||||||
|
|
|
@ -40,7 +40,6 @@ ManaBall::ManaBall(Vector pos, float amount) : Quad()
|
||||||
lifeSpan = 15;
|
lifeSpan = 15;
|
||||||
setBlendType(BLEND_ADD);
|
setBlendType(BLEND_ADD);
|
||||||
used = false;
|
used = false;
|
||||||
gone = false;
|
|
||||||
addChild(&healEmitter, PM_STATIC);
|
addChild(&healEmitter, PM_STATIC);
|
||||||
|
|
||||||
if (dsq->difficulty == DSQ::DIFF_EASY)
|
if (dsq->difficulty == DSQ::DIFF_EASY)
|
||||||
|
@ -52,15 +51,6 @@ ManaBall::ManaBall(Vector pos, float amount) : Quad()
|
||||||
void ManaBall::destroy()
|
void ManaBall::destroy()
|
||||||
{
|
{
|
||||||
Quad::destroy();
|
Quad::destroy();
|
||||||
FOR_ENTITIES(i)
|
|
||||||
{
|
|
||||||
Entity *e = *i;
|
|
||||||
if (e)
|
|
||||||
{
|
|
||||||
if (e->manaBallTarget == this)
|
|
||||||
e->manaBallTarget = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ManaBall::isUsed()
|
bool ManaBall::isUsed()
|
||||||
|
@ -79,15 +69,6 @@ void ManaBall::use(Entity *entity)
|
||||||
scale.startPath(1);
|
scale.startPath(1);
|
||||||
setLife(1.1);
|
setLife(1.1);
|
||||||
used = true;
|
used = true;
|
||||||
FOR_ENTITIES(i)
|
|
||||||
{
|
|
||||||
Entity *e = *i;
|
|
||||||
if (e)
|
|
||||||
{
|
|
||||||
if (e->manaBallTarget == this)
|
|
||||||
e->manaBallTarget = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManaBall::onUpdate(float dt)
|
void ManaBall::onUpdate(float dt)
|
||||||
|
@ -102,7 +83,6 @@ void ManaBall::onUpdate(float dt)
|
||||||
if (lifeSpan <= 0)
|
if (lifeSpan <= 0)
|
||||||
{
|
{
|
||||||
lifeSpan = 0;
|
lifeSpan = 0;
|
||||||
gone = true;
|
|
||||||
this->scale.interpolateTo(Vector(0,0),1);
|
this->scale.interpolateTo(Vector(0,0),1);
|
||||||
setLife(1);
|
setLife(1);
|
||||||
setDecayRate(1);
|
setDecayRate(1);
|
||||||
|
@ -111,23 +91,6 @@ void ManaBall::onUpdate(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gone && !used)
|
|
||||||
{
|
|
||||||
FOR_ENTITIES(i)
|
|
||||||
{
|
|
||||||
Entity *e = *i;
|
|
||||||
if (e)
|
|
||||||
{
|
|
||||||
if (e->wantManaBall)
|
|
||||||
{
|
|
||||||
if ((e->position - this->position).getSquaredLength2D() < sqr(e->wantManaBall))
|
|
||||||
{
|
|
||||||
e->manaBallTarget = this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dsq->game->avatar)
|
if (dsq->game->avatar)
|
||||||
{
|
{
|
||||||
if (!used)
|
if (!used)
|
||||||
|
|
|
@ -288,6 +288,7 @@ void Path::refreshScript()
|
||||||
{
|
{
|
||||||
amount = 0;
|
amount = 0;
|
||||||
content.clear();
|
content.clear();
|
||||||
|
label.clear();
|
||||||
|
|
||||||
// HACK: clean up
|
// HACK: clean up
|
||||||
/*+ dsq->game->sceneName + "_"*/
|
/*+ dsq->game->sceneName + "_"*/
|
||||||
|
@ -297,9 +298,8 @@ void Path::refreshScript()
|
||||||
|
|
||||||
stringToLower(name);
|
stringToLower(name);
|
||||||
|
|
||||||
std::string label;
|
|
||||||
{
|
{
|
||||||
SimpleIStringStream is(name);
|
SimpleIStringStream is(name.c_str(), SimpleIStringStream::REUSE);
|
||||||
is >> label >> content >> amount;
|
is >> label >> content >> amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,8 @@ public:
|
||||||
void songNote(int note);
|
void songNote(int note);
|
||||||
void songNoteDone(int note, float len);
|
void songNoteDone(int note, float len);
|
||||||
bool hasScript();
|
bool hasScript();
|
||||||
std::string name;
|
std::string name; // full node string
|
||||||
|
std::string label; // first part only (the actual node name)
|
||||||
std::vector<PathNode>nodes;
|
std::vector<PathNode>nodes;
|
||||||
void removeNode(int idx);
|
void removeNode(int idx);
|
||||||
void addNode(int idx);
|
void addNode(int idx);
|
||||||
|
|
|
@ -3126,9 +3126,9 @@ void SceneEditor::placeElement()
|
||||||
else if (editType == ET_ENTITIES)
|
else if (editType == ET_ENTITIES)
|
||||||
{
|
{
|
||||||
if (!selectedEntity.nameBased)
|
if (!selectedEntity.nameBased)
|
||||||
dsq->game->createEntity(selectedEntity.index, 0, dsq->getGameCursorPosition(), 0, true, "", ET_ENEMY, BT_NORMAL, 0, 0, true);
|
dsq->game->createEntity(selectedEntity.index, 0, dsq->getGameCursorPosition(), 0, true, "", ET_ENEMY, 0, 0, true);
|
||||||
else
|
else
|
||||||
dsq->game->createEntity(selectedEntity.name, 0, dsq->getGameCursorPosition(), 0, true, "", ET_ENEMY, BT_NORMAL, 0, 0, true);
|
dsq->game->createEntity(selectedEntity.name, 0, dsq->getGameCursorPosition(), 0, true, "", ET_ENEMY, 0, 0, true);
|
||||||
}
|
}
|
||||||
else if (editType == ET_PATHS)
|
else if (editType == ET_PATHS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -117,7 +117,7 @@ void SchoolFish::onEnterState(int action)
|
||||||
oldFlockID = flock ? flock->flockID : -1;
|
oldFlockID = flock ? flock->flockID : -1;
|
||||||
removeFromFlock();
|
removeFromFlock();
|
||||||
|
|
||||||
doDeathEffects(0,0,0);
|
doDeathEffects(0, false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
|
|
|
@ -36,11 +36,18 @@ extern "C"
|
||||||
|
|
||||||
#include "../BBGE/MathFunctions.h"
|
#include "../BBGE/MathFunctions.h"
|
||||||
|
|
||||||
|
|
||||||
|
// If true, send all sort of script errors to errorLog instead of debugLog.
|
||||||
|
// On win32, this pops up message boxes which help to locate errors easily,
|
||||||
|
// but can be annoying for regular gameplay.
|
||||||
|
const bool loudScriptErrors = false;
|
||||||
|
|
||||||
const bool throwLuaErrors = false;
|
const bool throwLuaErrors = false;
|
||||||
|
|
||||||
// Set this to true to complain (via errorLog()) whenever a script tries to
|
// Set this to true to complain (via errorLog()) whenever a script tries to
|
||||||
// get or set a global variable.
|
// get or set a global variable.
|
||||||
const bool complainOnGlobalVar = false;
|
const bool complainOnGlobalVar = false;
|
||||||
|
|
||||||
// Set this to true to complain whenever a script tries to get an undefined
|
// Set this to true to complain whenever a script tries to get an undefined
|
||||||
// thread-local variable.
|
// thread-local variable.
|
||||||
const bool complainOnUndefLocal = false;
|
const bool complainOnUndefLocal = false;
|
||||||
|
@ -271,6 +278,14 @@ static const char * const interfaceFunctions[] = {
|
||||||
// S C R I P T C O M M A N D S
|
// S C R I P T C O M M A N D S
|
||||||
//============================================================================================
|
//============================================================================================
|
||||||
|
|
||||||
|
static void scriptError(const std::string& msg)
|
||||||
|
{
|
||||||
|
if(loudScriptErrors)
|
||||||
|
errorLog(msg);
|
||||||
|
else
|
||||||
|
debugLog(msg);
|
||||||
|
}
|
||||||
|
|
||||||
static void luaErrorMsg(lua_State *L, const char *msg)
|
static void luaErrorMsg(lua_State *L, const char *msg)
|
||||||
{
|
{
|
||||||
debugLog(msg);
|
debugLog(msg);
|
||||||
|
@ -472,6 +487,14 @@ static SkeletalSprite *getSkeletalSprite(Entity *e)
|
||||||
return skel;
|
return skel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool looksLikeGlobal(const char *s)
|
||||||
|
{
|
||||||
|
for( ; *s; ++s)
|
||||||
|
if( !((*s >= 'A' && *s <= 'Z') || *s == '_' || (*s >= '0' && *s <= '9')) ) // accept any uppercase, number, and _ char
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------//
|
//----------------------------------//
|
||||||
|
|
||||||
#define luaFunc(func) static int l_##func(lua_State *L)
|
#define luaFunc(func) static int l_##func(lua_State *L)
|
||||||
|
@ -529,8 +552,8 @@ luaFunc(indexWarnGlobal)
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "WARNING: " << ar.short_src << ":" << ar.currentline
|
os << "WARNING: " << ar.short_src << ":" << ar.currentline
|
||||||
<< ": script tried to get/call undefined global variable "
|
<< ": script tried to get/call undefined global variable "
|
||||||
<< lua_tostring(L, -2);
|
<< varname;
|
||||||
errorLog(os.str());
|
scriptError(os.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
@ -546,7 +569,7 @@ luaFunc(newindexWarnGlobal)
|
||||||
// Don't warn on "v" or known interface functions.
|
// Don't warn on "v" or known interface functions.
|
||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
const char *varname = lua_tostring(L, -1);
|
const char *varname = lua_tostring(L, -1);
|
||||||
bool doWarn = (strcmp(varname, "v") != 0);
|
bool doWarn = (strcmp(varname, "v") != 0) && !looksLikeGlobal(varname);
|
||||||
for (unsigned int i = 0; doWarn && interfaceFunctions[i] != NULL; i++)
|
for (unsigned int i = 0; doWarn && interfaceFunctions[i] != NULL; i++)
|
||||||
{
|
{
|
||||||
doWarn = (strcmp(varname, interfaceFunctions[i]) != 0);
|
doWarn = (strcmp(varname, interfaceFunctions[i]) != 0);
|
||||||
|
@ -570,7 +593,7 @@ luaFunc(newindexWarnGlobal)
|
||||||
<< ": script set global "
|
<< ": script set global "
|
||||||
<< (lua_type(L, -2) == LUA_TFUNCTION ? "function" : "variable")
|
<< (lua_type(L, -2) == LUA_TFUNCTION ? "function" : "variable")
|
||||||
<< " " << lua_tostring(L, -1);
|
<< " " << lua_tostring(L, -1);
|
||||||
errorLog(os.str());
|
scriptError(os.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
@ -609,14 +632,33 @@ luaFunc(indexWarnInstance)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dofile_helper(lua_State *L, const char *fname)
|
||||||
|
{
|
||||||
|
int n = lua_gettop(L);
|
||||||
|
if (luaL_loadfile(L, fname) != 0) lua_error(L);
|
||||||
|
lua_call(L, 0, LUA_MULTRET);
|
||||||
|
return lua_gettop(L) - n;
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(dofile_caseinsensitive)
|
luaFunc(dofile_caseinsensitive)
|
||||||
{
|
{
|
||||||
// This is Lua's dofile(), with some tweaks. --ryan.
|
// This is Lua's dofile(), with some tweaks. --ryan.
|
||||||
std::string fname(core->adjustFilenameCase(luaL_checkstring(L, 1)));
|
const char *rawname = luaL_checkstring(L, 1);
|
||||||
int n = lua_gettop(L);
|
std::string fname;
|
||||||
if (luaL_loadfile(L, fname.c_str()) != 0) lua_error(L);
|
|
||||||
lua_call(L, 0, LUA_MULTRET);
|
if (dsq->mod.isActive())
|
||||||
return lua_gettop(L) - n;
|
{
|
||||||
|
fname += dsq->mod.getPath();
|
||||||
|
fname += '/';
|
||||||
|
fname += rawname;
|
||||||
|
fname = core->adjustFilenameCase(fname);
|
||||||
|
if (exists(fname))
|
||||||
|
return dofile_helper(L, fname.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// try absolute path
|
||||||
|
fname = core->adjustFilenameCase(rawname);
|
||||||
|
return dofile_helper(L, fname.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(randRange)
|
luaFunc(randRange)
|
||||||
|
@ -996,7 +1038,9 @@ luaFunc(entity_setBoneLock)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
Entity *e2 = entity(L, 2);
|
Entity *e2 = entity(L, 2);
|
||||||
Bone *b = bone(L, 3);
|
Bone *b = 0;
|
||||||
|
if (lua_isuserdata(L, 3))
|
||||||
|
b = bone(L, 3);
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
|
@ -1994,7 +2038,7 @@ luaFunc(entity_createEntity)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
if (e)
|
if (e)
|
||||||
dsq->game->createEntity(dsq->getEntityTypeIndexByName(lua_tostring(L, 2)), 0, e->position, 0, false, "", ET_ENEMY, BT_NORMAL, 0, 0, true);
|
dsq->game->createEntity(dsq->getEntityTypeIndexByName(lua_tostring(L, 2)), 0, e->position, 0, false, "", ET_ENEMY, 0, 0, true);
|
||||||
luaReturnInt(0);
|
luaReturnInt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2253,8 +2297,9 @@ luaFunc(entity_setColor)
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
//e->color = Vector(lua_tonumber(L, 2), lua_tonumber(L, 3), lua_tonumber(L, 4));
|
//e->color = Vector(lua_tonumber(L, 2), lua_tonumber(L, 3), lua_tonumber(L, 4));
|
||||||
e->color.interpolateTo(Vector(lua_tonumber(L, 2), lua_tonumber(L, 3), lua_tonumber(L, 4)), lua_tonumber(L, 5));
|
e->color.interpolateTo(Vector(lua_tonumber(L, 2), lua_tonumber(L, 3), lua_tonumber(L, 4)),
|
||||||
}
|
lua_tonumber(L, 5), lua_tonumber(L, 6), lua_tointeger(L, 7), lua_tointeger(L, 8));
|
||||||
|
}
|
||||||
luaReturnInt(0);
|
luaReturnInt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2749,20 +2794,8 @@ luaFunc(createEntity)
|
||||||
int y = lua_tointeger(L, 4);
|
int y = lua_tointeger(L, 4);
|
||||||
|
|
||||||
Entity *e = 0;
|
Entity *e = 0;
|
||||||
e = dsq->game->createEntity(type, 0, Vector(x, y), 0, false, name, ET_ENEMY, BT_NORMAL, 0, 0, true);
|
e = dsq->game->createEntity(type, 0, Vector(x, y), 0, false, name, ET_ENEMY, 0, 0, true);
|
||||||
|
|
||||||
/*
|
|
||||||
int idx = dsq->game->getIdxForEntityType(type);
|
|
||||||
Entity *e = 0;
|
|
||||||
if (idx == -1)
|
|
||||||
{
|
|
||||||
errorLog("Unknown entity type [" + type + "]");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e = dsq->game->createEntity(idx, 0, Vector(x,y), 0, false, name, ET_ENEMY, BT_NORMAL, 0, 0, true);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
luaReturnPtr(e);
|
luaReturnPtr(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2899,23 +2932,16 @@ luaFunc(entity_setRenderPass)
|
||||||
luaFunc(entity_setHealth)
|
luaFunc(entity_setHealth)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L, 1);
|
Entity *e = entity(L, 1);
|
||||||
int h = lua_tonumber(L, 2);
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
e->health = e->maxHealth = lua_tonumber(L, 2);
|
||||||
e->health = e->maxHealth = h;
|
|
||||||
}
|
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// intended to be used for setting max health and refilling it all
|
|
||||||
luaFunc(entity_changeHealth)
|
luaFunc(entity_changeHealth)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L, 1);
|
Entity *e = entity(L, 1);
|
||||||
int h = lua_tonumber(L, 2);
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
e->health += lua_tonumber(L, 2);
|
||||||
e->health += h;
|
|
||||||
}
|
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3261,6 +3287,17 @@ luaFunc(node_getName)
|
||||||
luaReturnStr(s);
|
luaReturnStr(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(node_getLabel)
|
||||||
|
{
|
||||||
|
Path *p = path(L);
|
||||||
|
const char *s = "";
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
s = p->label.c_str();
|
||||||
|
}
|
||||||
|
luaReturnStr(s);
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(node_getPathPosition)
|
luaFunc(node_getPathPosition)
|
||||||
{
|
{
|
||||||
Path *p = path(L);
|
Path *p = path(L);
|
||||||
|
@ -3529,20 +3566,16 @@ luaFunc(entity_warpSegments)
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//entity_incrTargetLeaches
|
luaFunc(avatar_incrLeaches)
|
||||||
luaFunc(entity_incrTargetLeaches)
|
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
dsq->game->avatar->leaches++;
|
||||||
if (e && e->getTargetEntity())
|
|
||||||
e->getTargetEntity()->leaches++;
|
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(entity_decrTargetLeaches)
|
luaFunc(avatar_decrLeaches)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
if(dsq->game->avatar->leaches)
|
||||||
if (e && e->getTargetEntity())
|
dsq->game->avatar->leaches--;
|
||||||
e->getTargetEntity()->leaches--;
|
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3705,7 +3738,7 @@ luaFunc(setNaijaHeadTexture)
|
||||||
Avatar *a = dsq->game->avatar;
|
Avatar *a = dsq->game->avatar;
|
||||||
if (a)
|
if (a)
|
||||||
{
|
{
|
||||||
a->setHeadTexture(lua_tostring(L, 1));
|
a->setHeadTexture(lua_tostring(L, 1), lua_tonumber(L, 2));
|
||||||
}
|
}
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
@ -5045,7 +5078,8 @@ luaFunc(updateMusic)
|
||||||
luaFunc(entity_grabTarget)
|
luaFunc(entity_grabTarget)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
e->attachEntity(e->getTargetEntity(), Vector(lua_tointeger(L, 2), lua_tointeger(L, 3)));
|
if (e)
|
||||||
|
e->attachEntity(e->getTargetEntity(), Vector(lua_tointeger(L, 2), lua_tointeger(L, 3)));
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5060,7 +5094,7 @@ luaFunc(entity_clampToHit)
|
||||||
luaFunc(entity_clampToSurface)
|
luaFunc(entity_clampToSurface)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
bool ret = e->clampToSurface(lua_tonumber(L, 2));
|
bool ret = e && e->clampToSurface(lua_tonumber(L, 2));
|
||||||
|
|
||||||
luaReturnBool(ret);
|
luaReturnBool(ret);
|
||||||
}
|
}
|
||||||
|
@ -5081,6 +5115,9 @@ luaFunc(entity_checkSurface)
|
||||||
luaFunc(entity_switchSurfaceDirection)
|
luaFunc(entity_switchSurfaceDirection)
|
||||||
{
|
{
|
||||||
ScriptedEntity *e = scriptedEntity(L);
|
ScriptedEntity *e = scriptedEntity(L);
|
||||||
|
if (!e)
|
||||||
|
luaReturnNum(0);
|
||||||
|
|
||||||
int n = -1;
|
int n = -1;
|
||||||
if (lua_isnumber(L, 2))
|
if (lua_isnumber(L, 2))
|
||||||
{
|
{
|
||||||
|
@ -5125,7 +5162,7 @@ luaFunc(entity_switchSurfaceDirection)
|
||||||
luaFunc(entity_adjustPositionBySurfaceNormal)
|
luaFunc(entity_adjustPositionBySurfaceNormal)
|
||||||
{
|
{
|
||||||
ScriptedEntity *e = scriptedEntity(L);
|
ScriptedEntity *e = scriptedEntity(L);
|
||||||
if (!e->ridingOnEntity)
|
if (e && !e->ridingOnEntity)
|
||||||
{
|
{
|
||||||
Vector v = dsq->game->getWallNormal(e->position);
|
Vector v = dsq->game->getWallNormal(e->position);
|
||||||
if (v.x != 0 || v.y != 0)
|
if (v.x != 0 || v.y != 0)
|
||||||
|
@ -5144,7 +5181,7 @@ luaFunc(entity_moveAlongSurface)
|
||||||
{
|
{
|
||||||
ScriptedEntity *e = scriptedEntity(L);
|
ScriptedEntity *e = scriptedEntity(L);
|
||||||
|
|
||||||
if (e->isv(EV_CLAMPING,0))
|
if (e && e->isv(EV_CLAMPING,0))
|
||||||
{
|
{
|
||||||
e->lastPosition = e->position;
|
e->lastPosition = e->position;
|
||||||
|
|
||||||
|
@ -5299,7 +5336,8 @@ luaFunc(entity_rotateToSurfaceNormal)
|
||||||
luaFunc(entity_releaseTarget)
|
luaFunc(entity_releaseTarget)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
e->detachEntity(e->getTargetEntity());
|
if (e)
|
||||||
|
e->detachEntity(e->getTargetEntity());
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5317,7 +5355,10 @@ luaFunc(egetv)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
EV ev = (EV)lua_tointeger(L, 2);
|
EV ev = (EV)lua_tointeger(L, 2);
|
||||||
luaReturnNum(e->getv(ev));
|
int v = 0;
|
||||||
|
if (e)
|
||||||
|
v = e->getv(ev);
|
||||||
|
luaReturnNum(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(esetvf)
|
luaFunc(esetvf)
|
||||||
|
@ -5333,8 +5374,13 @@ luaFunc(esetvf)
|
||||||
luaFunc(egetvf)
|
luaFunc(egetvf)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
EV ev = (EV)lua_tointeger(L, 2);
|
float vf = 0;
|
||||||
luaReturnNum(e->getvf(ev));
|
if (e)
|
||||||
|
{
|
||||||
|
EV ev = (EV)lua_tointeger(L, 2);
|
||||||
|
vf = e->getvf(ev);
|
||||||
|
}
|
||||||
|
luaReturnNum(vf);
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(eisv)
|
luaFunc(eisv)
|
||||||
|
@ -5348,12 +5394,6 @@ luaFunc(eisv)
|
||||||
luaReturnBool(b);
|
luaReturnBool(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(entity_setClampOnSwitchDir)
|
|
||||||
{
|
|
||||||
debugLog("_setClampOnSwitchDir is old");
|
|
||||||
luaReturnNum(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
luaFunc(entity_setWidth)
|
luaFunc(entity_setWidth)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
|
@ -5616,14 +5656,16 @@ luaFunc(entity_setProperty)
|
||||||
luaFunc(entity_setActivation)
|
luaFunc(entity_setActivation)
|
||||||
{
|
{
|
||||||
ScriptedEntity *e = scriptedEntity(L);
|
ScriptedEntity *e = scriptedEntity(L);
|
||||||
//if (!e) return;
|
if (e)
|
||||||
int type = lua_tonumber(L, 2);
|
{
|
||||||
// cursor radius
|
int type = lua_tonumber(L, 2);
|
||||||
int activationRadius = lua_tonumber(L, 3);
|
// cursor radius
|
||||||
int range = lua_tonumber(L, 4);
|
int activationRadius = lua_tonumber(L, 3);
|
||||||
e->activationType = (Entity::ActivationType)type;
|
int range = lua_tonumber(L, 4);
|
||||||
e->activationRange = range;
|
e->activationType = (Entity::ActivationType)type;
|
||||||
e->activationRadius = activationRadius;
|
e->activationRange = range;
|
||||||
|
e->activationRadius = activationRadius;
|
||||||
|
}
|
||||||
|
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
@ -5641,8 +5683,8 @@ luaFunc(entity_setCullRadius)
|
||||||
luaFunc(entity_setActivationType)
|
luaFunc(entity_setActivationType)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
int type = lua_tonumber(L, 2);
|
if (e)
|
||||||
e->activationType = (Entity::ActivationType)type;
|
e->activationType = (Entity::ActivationType)lua_tointeger(L, 2);
|
||||||
|
|
||||||
luaReturnInt(0);
|
luaReturnInt(0);
|
||||||
}
|
}
|
||||||
|
@ -5784,7 +5826,7 @@ luaFunc(entity_moveTowardsTarget)
|
||||||
luaFunc(entity_setVelLen)
|
luaFunc(entity_setVelLen)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
int len = lua_tonumber(L, 2);
|
float len = lua_tonumber(L, 2);
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
e->vel.setLength2D(len);
|
e->vel.setLength2D(len);
|
||||||
|
@ -5792,6 +5834,15 @@ luaFunc(entity_setVelLen)
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(entity_getVel)
|
||||||
|
{
|
||||||
|
Entity *e = entity(L);
|
||||||
|
Vector v;
|
||||||
|
if (e)
|
||||||
|
v = e->vel;
|
||||||
|
luaReturnVec2(v.x, v.y);
|
||||||
|
}
|
||||||
|
|
||||||
// entity dt speed dir
|
// entity dt speed dir
|
||||||
luaFunc(entity_moveAroundTarget)
|
luaFunc(entity_moveAroundTarget)
|
||||||
{
|
{
|
||||||
|
@ -5921,7 +5972,8 @@ luaFunc(getEntityByID)
|
||||||
luaFunc(node_setEffectOn)
|
luaFunc(node_setEffectOn)
|
||||||
{
|
{
|
||||||
Path *p = path(L, 1);
|
Path *p = path(L, 1);
|
||||||
p->setEffectOn(getBool(L, 2));
|
if (p)
|
||||||
|
p->setEffectOn(getBool(L, 2));
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5941,16 +5993,19 @@ luaFunc(node_activate)
|
||||||
luaFunc(node_setElementsInLayerActive)
|
luaFunc(node_setElementsInLayerActive)
|
||||||
{
|
{
|
||||||
Path *p = path(L);
|
Path *p = path(L);
|
||||||
int l = lua_tonumber(L, 2);
|
if (p)
|
||||||
bool v = getBool(L, 3);
|
{
|
||||||
for (Element *e = dsq->getFirstElementOnLayer(l); e; e = e->bgLayerNext)
|
int l = lua_tonumber(L, 2);
|
||||||
{
|
bool v = getBool(L, 3);
|
||||||
if (e && p->isCoordinateInside(e->position))
|
for (Element *e = dsq->getFirstElementOnLayer(l); e; e = e->bgLayerNext)
|
||||||
{
|
{
|
||||||
debugLog("setting an element to the value");
|
if (e && p->isCoordinateInside(e->position))
|
||||||
e->setElementActive(v);
|
{
|
||||||
}
|
debugLog("setting an element to the value");
|
||||||
}
|
e->setElementActive(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5991,7 +6046,6 @@ luaFunc(node_getNumEntitiesIn)
|
||||||
|
|
||||||
luaFunc(node_getNearestEntity)
|
luaFunc(node_getNearestEntity)
|
||||||
{
|
{
|
||||||
//Entity *me = entity(L);
|
|
||||||
Path *p = path(L);
|
Path *p = path(L);
|
||||||
Entity *closest=0;
|
Entity *closest=0;
|
||||||
|
|
||||||
|
@ -6000,14 +6054,17 @@ luaFunc(node_getNearestEntity)
|
||||||
|
|
||||||
Vector pos = p->nodes[0].position;
|
Vector pos = p->nodes[0].position;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
Entity *ignore = 0;
|
||||||
if (lua_isstring(L, 2))
|
if (lua_isstring(L, 2))
|
||||||
name = lua_tostring(L, 2);
|
name = lua_tostring(L, 2);
|
||||||
|
if (lua_isuserdata(L, 3))
|
||||||
|
ignore = entity(L, 3);
|
||||||
|
|
||||||
float smallestDist = HUGE_VALF;
|
float smallestDist = HUGE_VALF;
|
||||||
FOR_ENTITIES(i)
|
FOR_ENTITIES(i)
|
||||||
{
|
{
|
||||||
Entity *e = *i;
|
Entity *e = *i;
|
||||||
if (e->isPresent() && e->isNormalLayer())
|
if (e != ignore && e->isPresent() && e->isNormalLayer())
|
||||||
{
|
{
|
||||||
if (name.empty() || (nocasecmp(e->name, name)==0))
|
if (name.empty() || (nocasecmp(e->name, name)==0))
|
||||||
{
|
{
|
||||||
|
@ -6026,7 +6083,6 @@ luaFunc(node_getNearestEntity)
|
||||||
|
|
||||||
luaFunc(node_getNearestNode)
|
luaFunc(node_getNearestNode)
|
||||||
{
|
{
|
||||||
//Entity *me = entity(L);
|
|
||||||
Path *p = path(L);
|
Path *p = path(L);
|
||||||
Path *closest = 0;
|
Path *closest = 0;
|
||||||
if (p && !p->nodes.empty())
|
if (p && !p->nodes.empty())
|
||||||
|
@ -6034,7 +6090,8 @@ luaFunc(node_getNearestNode)
|
||||||
std::string name;
|
std::string name;
|
||||||
if (lua_isstring(L, 2))
|
if (lua_isstring(L, 2))
|
||||||
name = lua_tostring(L, 2);
|
name = lua_tostring(L, 2);
|
||||||
closest = dsq->game->getNearestPath(p->nodes[0].position, name);
|
Path *ignore = path(L, 3);
|
||||||
|
closest = dsq->game->getNearestPath(p->nodes[0].position, name, ignore);
|
||||||
}
|
}
|
||||||
luaReturnPtr(closest);
|
luaReturnPtr(closest);
|
||||||
}
|
}
|
||||||
|
@ -6064,25 +6121,31 @@ luaFunc(entity_getNearestBoneToPosition)
|
||||||
luaFunc(entity_getNearestNode)
|
luaFunc(entity_getNearestNode)
|
||||||
{
|
{
|
||||||
Entity *me = entity(L);
|
Entity *me = entity(L);
|
||||||
std::string name;
|
Path *closest = 0;
|
||||||
if (lua_isstring(L, 2))
|
if (me)
|
||||||
name = lua_tostring(L, 2);
|
{
|
||||||
Path *ignore = path(L, 3);
|
std::string name;
|
||||||
|
if (lua_isstring(L, 2))
|
||||||
Path *closest = dsq->game->getNearestPath(me->position, name, ignore);
|
name = lua_tostring(L, 2);
|
||||||
|
Path *ignore = path(L, 3);
|
||||||
|
closest = dsq->game->getNearestPath(me->position, name, ignore);
|
||||||
|
}
|
||||||
luaReturnPtr(closest);
|
luaReturnPtr(closest);
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(ing_hasIET)
|
luaFunc(ing_hasIET)
|
||||||
{
|
{
|
||||||
Ingredient *i = getIng(L, 1);
|
Ingredient *i = getIng(L, 1);
|
||||||
bool has = i->hasIET((IngredientEffectType)lua_tointeger(L, 2));
|
bool has = i && i->hasIET((IngredientEffectType)lua_tointeger(L, 2));
|
||||||
luaReturnBool(has);
|
luaReturnBool(has);
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(entity_getNearestEntity)
|
luaFunc(entity_getNearestEntity)
|
||||||
{
|
{
|
||||||
Entity *me = entity(L);
|
Entity *me = entity(L);
|
||||||
|
if (!me)
|
||||||
|
luaReturnPtr(0);
|
||||||
|
|
||||||
const char *name = 0;
|
const char *name = 0;
|
||||||
if (lua_isstring(L, 2))
|
if (lua_isstring(L, 2))
|
||||||
{
|
{
|
||||||
|
@ -6098,21 +6161,25 @@ luaFunc(entity_getNearestEntity)
|
||||||
nameCheck = false;
|
nameCheck = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int range = lua_tointeger(L, 3);
|
float range = lua_tointeger(L, 3);
|
||||||
int type = lua_tointeger(L, 4);
|
int type = lua_tointeger(L, 4);
|
||||||
int damageTarget = lua_tointeger(L, 5);
|
int damageTarget = lua_tointeger(L, 5);
|
||||||
Entity *closest = 0;
|
Entity *closest = 0;
|
||||||
|
Entity *ignore = 0;
|
||||||
|
if (lua_isuserdata(L, 6))
|
||||||
|
ignore = entity(L, 6);
|
||||||
|
|
||||||
float smallestDist = range ? sqr(range) : HUGE_VALF;
|
float smallestDist = range ? sqr(range) : HUGE_VALF;
|
||||||
FOR_ENTITIES(i)
|
FOR_ENTITIES(i)
|
||||||
{
|
{
|
||||||
Entity *e = *i;
|
Entity *e = *i;
|
||||||
if (e != me && e->isPresent() && e->isNormalLayer())
|
if (e != me && e != ignore && e->isPresent() && e->isNormalLayer())
|
||||||
{
|
{
|
||||||
if (!name || ((nocasecmp(e->name, name)==0) == nameCheck))
|
if (type == 0 || e->getEntityType() == type)
|
||||||
{
|
{
|
||||||
if (type == 0 || e->getEntityType() == type)
|
if (damageTarget == 0 || e->isDamageTarget((DamageType)damageTarget))
|
||||||
{
|
{
|
||||||
if (damageTarget == 0 || e->isDamageTarget((DamageType)damageTarget))
|
if (!name || ((nocasecmp(e->name, name)==0) == nameCheck))
|
||||||
{
|
{
|
||||||
float dist = (me->position - e->position).getSquaredLength2D();
|
float dist = (me->position - e->position).getSquaredLength2D();
|
||||||
if (dist < smallestDist)
|
if (dist < smallestDist)
|
||||||
|
@ -6235,15 +6302,17 @@ luaFunc(entity_alpha)
|
||||||
luaFunc(entity_partAlpha)
|
luaFunc(entity_partAlpha)
|
||||||
{
|
{
|
||||||
ScriptedEntity *e = scriptedEntity(L);
|
ScriptedEntity *e = scriptedEntity(L);
|
||||||
RenderObject *r = e->partMap[lua_tostring(L, 2)];
|
if (e)
|
||||||
if (r)
|
{
|
||||||
{
|
RenderObject *r = e->partMap[lua_tostring(L, 2)];
|
||||||
|
if (r)
|
||||||
float start = lua_tonumber(L, 3);
|
{
|
||||||
if (start != -1)
|
float start = lua_tonumber(L, 3);
|
||||||
r->alpha = start;
|
if (start != -1)
|
||||||
r->alpha.interpolateTo(lua_tonumber(L, 4), lua_tonumber(L, 5), lua_tointeger(L, 6), lua_tointeger(L, 7), lua_tointeger(L, 8));
|
r->alpha = start;
|
||||||
}
|
r->alpha.interpolateTo(lua_tonumber(L, 4), lua_tonumber(L, 5), lua_tointeger(L, 6), lua_tointeger(L, 7), lua_tointeger(L, 8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
@ -6251,18 +6320,22 @@ luaFunc(entity_partAlpha)
|
||||||
luaFunc(entity_partBlendType)
|
luaFunc(entity_partBlendType)
|
||||||
{
|
{
|
||||||
ScriptedEntity *e = scriptedEntity(L);
|
ScriptedEntity *e = scriptedEntity(L);
|
||||||
e->partMap[lua_tostring(L, 2)]->setBlendType(lua_tointeger(L, 3));
|
if (e)
|
||||||
|
e->partMap[lua_tostring(L, 2)]->setBlendType(lua_tointeger(L, 3));
|
||||||
luaReturnInt(0);
|
luaReturnInt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(entity_partRotate)
|
luaFunc(entity_partRotate)
|
||||||
{
|
{
|
||||||
ScriptedEntity *e = scriptedEntity(L);
|
ScriptedEntity *e = scriptedEntity(L);
|
||||||
RenderObject *r = e->partMap[lua_tostring(L, 2)];
|
if (e)
|
||||||
if (r)
|
{
|
||||||
{
|
RenderObject *r = e->partMap[lua_tostring(L, 2)];
|
||||||
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));
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
@ -6302,24 +6375,30 @@ luaFunc(entity_offsetUpdate)
|
||||||
luaFunc(entity_scale)
|
luaFunc(entity_scale)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
float time = lua_tonumber(L, 4);
|
if (e)
|
||||||
//e->scale = Vector(lua_tonumber(L, 2), lua_tonumber(L, 3));
|
{
|
||||||
e->scale.interpolateTo(Vector(lua_tonumber(L, 2), lua_tonumber(L, 3), 0), time, lua_tonumber(L, 5), lua_tonumber(L, 6), lua_tonumber(L, 7));
|
float time = lua_tonumber(L, 4);
|
||||||
luaReturnNum(0);
|
//e->scale = Vector(lua_tonumber(L, 2), lua_tonumber(L, 3));
|
||||||
|
e->scale.interpolateTo(Vector(lua_tonumber(L, 2), lua_tonumber(L, 3), 0), time, lua_tonumber(L, 5), lua_tonumber(L, 6), lua_tonumber(L, 7));
|
||||||
|
}
|
||||||
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(entity_switchLayer)
|
luaFunc(entity_switchLayer)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
int lcode = lua_tonumber(L, 2);
|
if (e)
|
||||||
int toLayer = LR_ENTITIES;
|
{
|
||||||
|
int lcode = lua_tonumber(L, 2);
|
||||||
|
int toLayer = LR_ENTITIES;
|
||||||
|
|
||||||
toLayer = dsq->getEntityLayerToLayer(lcode);
|
toLayer = dsq->getEntityLayerToLayer(lcode);
|
||||||
|
|
||||||
if (e->getEntityType() == ET_AVATAR)
|
if (e->getEntityType() == ET_AVATAR)
|
||||||
toLayer = LR_ENTITIES;
|
toLayer = LR_ENTITIES;
|
||||||
|
|
||||||
core->switchRenderObjectLayer(e, toLayer);
|
core->switchRenderObjectLayer(e, toLayer);
|
||||||
|
}
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6428,22 +6507,24 @@ luaFunc(entity_initPart)
|
||||||
|
|
||||||
|
|
||||||
ScriptedEntity *e = scriptedEntity(L);
|
ScriptedEntity *e = scriptedEntity(L);
|
||||||
|
if (e)
|
||||||
Quad *q = new Quad;
|
{
|
||||||
q->setTexture(partTex);
|
Quad *q = new Quad;
|
||||||
q->renderBeforeParent = !renderAfter;
|
q->setTexture(partTex);
|
||||||
|
q->renderBeforeParent = !renderAfter;
|
||||||
|
|
||||||
|
|
||||||
q->position = partPosition;
|
q->position = partPosition;
|
||||||
if (offsetInterpolateTo.x != 0 || offsetInterpolateTo.y != 0)
|
if (offsetInterpolateTo.x != 0 || offsetInterpolateTo.y != 0)
|
||||||
q->offset.interpolateTo(offsetInterpolateTo, offsetInterpolateTime, -1, 1, 1);
|
q->offset.interpolateTo(offsetInterpolateTo, offsetInterpolateTime, -1, 1, 1);
|
||||||
if (partFlipH)
|
if (partFlipH)
|
||||||
q->flipHorizontal();
|
q->flipHorizontal();
|
||||||
if (partFlipV)
|
if (partFlipV)
|
||||||
q->flipVertical();
|
q->flipVertical();
|
||||||
|
|
||||||
e->addChild(q, PM_POINTER);
|
e->addChild(q, PM_POINTER);
|
||||||
e->registerNewPart(q, partName);
|
e->registerNewPart(q, partName);
|
||||||
|
}
|
||||||
|
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
@ -7021,6 +7102,18 @@ luaFunc(entity_setFlag)
|
||||||
luaReturnNum(0);
|
luaReturnNum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(entity_getFlag)
|
||||||
|
{
|
||||||
|
Entity *e = entity(L);
|
||||||
|
int v = lua_tonumber(L, 2);
|
||||||
|
int ret = 0;
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
|
ret = dsq->continuity.getEntityFlag(dsq->game->sceneName, e->getID());
|
||||||
|
}
|
||||||
|
luaReturnNum(ret);
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(isFlag)
|
luaFunc(isFlag)
|
||||||
{
|
{
|
||||||
int v = 0;
|
int v = 0;
|
||||||
|
@ -7211,9 +7304,6 @@ static const struct {
|
||||||
luaRegister(entity_setIngredient),
|
luaRegister(entity_setIngredient),
|
||||||
luaRegister(entity_setDeathScene),
|
luaRegister(entity_setDeathScene),
|
||||||
|
|
||||||
|
|
||||||
luaRegister(entity_setClampOnSwitchDir),
|
|
||||||
|
|
||||||
luaRegister(entity_setBeautyFlip),
|
luaRegister(entity_setBeautyFlip),
|
||||||
luaRegister(entity_setInvincible),
|
luaRegister(entity_setInvincible),
|
||||||
|
|
||||||
|
@ -7477,8 +7567,8 @@ static const struct {
|
||||||
luaRegister(entity_getTargetPositionX),
|
luaRegister(entity_getTargetPositionX),
|
||||||
luaRegister(entity_getTargetPositionY),
|
luaRegister(entity_getTargetPositionY),
|
||||||
|
|
||||||
luaRegister(entity_incrTargetLeaches),
|
luaRegister(avatar_incrLeaches),
|
||||||
luaRegister(entity_decrTargetLeaches),
|
luaRegister(avatar_decrLeaches),
|
||||||
luaRegister(entity_rotateToVel),
|
luaRegister(entity_rotateToVel),
|
||||||
luaRegister(entity_rotateToVec),
|
luaRegister(entity_rotateToVec),
|
||||||
|
|
||||||
|
@ -7548,6 +7638,7 @@ static const struct {
|
||||||
luaRegister(entity_moveAround),
|
luaRegister(entity_moveAround),
|
||||||
|
|
||||||
luaRegister(entity_setVelLen),
|
luaRegister(entity_setVelLen),
|
||||||
|
luaRegister(entity_getVel),
|
||||||
|
|
||||||
luaRegister(entity_setMaxSpeed),
|
luaRegister(entity_setMaxSpeed),
|
||||||
luaRegister(entity_getMaxSpeed),
|
luaRegister(entity_getMaxSpeed),
|
||||||
|
@ -7736,6 +7827,7 @@ static const struct {
|
||||||
|
|
||||||
luaRegister(entity_isFlag),
|
luaRegister(entity_isFlag),
|
||||||
luaRegister(entity_setFlag),
|
luaRegister(entity_setFlag),
|
||||||
|
luaRegister(entity_getFlag),
|
||||||
|
|
||||||
luaRegister(node_isFlag),
|
luaRegister(node_isFlag),
|
||||||
luaRegister(node_setFlag),
|
luaRegister(node_setFlag),
|
||||||
|
@ -7909,6 +8001,7 @@ static const struct {
|
||||||
|
|
||||||
luaRegister(node_activate),
|
luaRegister(node_activate),
|
||||||
luaRegister(node_getName),
|
luaRegister(node_getName),
|
||||||
|
luaRegister(node_getLabel),
|
||||||
luaRegister(node_getPathPosition),
|
luaRegister(node_getPathPosition),
|
||||||
luaRegister(node_getPosition),
|
luaRegister(node_getPosition),
|
||||||
luaRegister(node_setPosition),
|
luaRegister(node_setPosition),
|
||||||
|
@ -8079,6 +8172,12 @@ static const struct {
|
||||||
|
|
||||||
luaRegister(getWallNormal),
|
luaRegister(getWallNormal),
|
||||||
luaRegister(getLastCollidePosition),
|
luaRegister(getLastCollidePosition),
|
||||||
|
|
||||||
|
|
||||||
|
// -- deprecated/compatibility related functions below here --
|
||||||
|
|
||||||
|
{"entity_incrTargetLeaches", l_avatar_incrLeaches},
|
||||||
|
{"entity_decrTargetLeaches", l_avatar_decrLeaches},
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================================================
|
//============================================================================================
|
||||||
|
@ -8341,11 +8440,6 @@ static const struct {
|
||||||
luaConstant(EP_BATTERY),
|
luaConstant(EP_BATTERY),
|
||||||
luaConstant(EP_BLOCKER),
|
luaConstant(EP_BLOCKER),
|
||||||
|
|
||||||
// Entity Behaviors
|
|
||||||
luaConstant(BT_NORMAL),
|
|
||||||
luaConstant(BT_MOTHER),
|
|
||||||
luaConstant(BT_ACTIVEPET),
|
|
||||||
|
|
||||||
// ACTIVATION TYPES
|
// ACTIVATION TYPES
|
||||||
{"AT_NONE", -1},
|
{"AT_NONE", -1},
|
||||||
{"AT_NORMAL", 0},
|
{"AT_NORMAL", 0},
|
||||||
|
@ -8905,7 +8999,7 @@ void ScriptInterface::shutdown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Script *ScriptInterface::openScript(const std::string &file)
|
Script *ScriptInterface::openScript(const std::string &file, bool ignoremissing /* = false */)
|
||||||
{
|
{
|
||||||
std::string realFile = core->adjustFilenameCase(file);
|
std::string realFile = core->adjustFilenameCase(file);
|
||||||
bool loadedScript = false;
|
bool loadedScript = false;
|
||||||
|
@ -8944,8 +9038,9 @@ Script *ScriptInterface::openScript(const std::string &file)
|
||||||
int result = luaL_loadfile(baseState, realFile.c_str());
|
int result = luaL_loadfile(baseState, realFile.c_str());
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
debugLog("Error loading script [" + realFile + "]: " + lua_tostring(baseState, -1));
|
if(result != LUA_ERRFILE || (result == LUA_ERRFILE && !ignoremissing))
|
||||||
lua_pop(baseState, 2);
|
scriptError("Error loading script [" + realFile + "]: " + lua_tostring(baseState, -1));
|
||||||
|
lua_pop(baseState, 2);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8964,7 +9059,7 @@ Script *ScriptInterface::openScript(const std::string &file)
|
||||||
lua_pop(baseState, 1);
|
lua_pop(baseState, 1);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
debugLog("Error doing initial run of script [" + realFile + "]: " + lua_tostring(baseState, -1));
|
scriptError("Error doing initial run of script [" + realFile + "]: " + lua_tostring(baseState, -1));
|
||||||
lua_pop(baseState, 2);
|
lua_pop(baseState, 2);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -9006,7 +9101,7 @@ Script *ScriptInterface::openScript(const std::string &file)
|
||||||
lua_State *thread = createLuaThread(realFile.c_str());
|
lua_State *thread = createLuaThread(realFile.c_str());
|
||||||
if (!thread)
|
if (!thread)
|
||||||
{
|
{
|
||||||
debugLog("Unable to create new thread for script [" + realFile + "]");
|
scriptError("Unable to create new thread for script [" + realFile + "]");
|
||||||
if (loadedScript)
|
if (loadedScript)
|
||||||
{
|
{
|
||||||
lua_getglobal(baseState, "_scriptfuncs");
|
lua_getglobal(baseState, "_scriptfuncs");
|
||||||
|
@ -9066,12 +9161,12 @@ bool ScriptInterface::runScriptNum(const std::string &file, const std::string &f
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptInterface::runScript(const std::string &file, const std::string &func)
|
bool ScriptInterface::runScript(const std::string &file, const std::string &func, bool ignoremissing /* = false */)
|
||||||
{
|
{
|
||||||
std::string realFile = file;
|
std::string realFile = file;
|
||||||
if (file.find('/')==std::string::npos)
|
if (file.find('/')==std::string::npos)
|
||||||
realFile = "scripts/" + file + ".lua";
|
realFile = "scripts/" + file + ".lua";
|
||||||
Script *script = openScript(realFile);
|
Script *script = openScript(realFile, ignoremissing);
|
||||||
if (!script)
|
if (!script)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -81,10 +81,10 @@ public:
|
||||||
void collectGarbage();
|
void collectGarbage();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
Script *openScript(const std::string &file);
|
Script *openScript(const std::string &file, bool ignoremissing = false);
|
||||||
void closeScript(Script *script);
|
void closeScript(Script *script);
|
||||||
|
|
||||||
bool runScript(const std::string &file, const std::string &func);
|
bool runScript(const std::string &file, const std::string &func, bool ignoremissing = false);
|
||||||
bool runScriptNum(const std::string &file, const std::string &func, int num);
|
bool runScriptNum(const std::string &file, const std::string &func, int num);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
bool ScriptedEntity::runningActivation = false;
|
bool ScriptedEntity::runningActivation = false;
|
||||||
|
|
||||||
ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, EntityType et, BehaviorType bt) : CollideEntity(), Segmented(2, 26)
|
ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, EntityType et) : CollideEntity(), Segmented(2, 26)
|
||||||
{
|
{
|
||||||
crushDelay = 0;
|
crushDelay = 0;
|
||||||
autoSkeletalSpriteUpdate = true;
|
autoSkeletalSpriteUpdate = true;
|
||||||
|
@ -41,21 +41,14 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
|
||||||
preUpdateFunc = true;
|
preUpdateFunc = true;
|
||||||
//runningActivation = false;
|
//runningActivation = false;
|
||||||
|
|
||||||
expType = -1;
|
|
||||||
eggSpawnRate = 10;
|
|
||||||
motherDelay = 0;
|
|
||||||
|
|
||||||
setEntityType(et);
|
setEntityType(et);
|
||||||
setBehaviorType(bt);
|
|
||||||
eggDataIdx = -1;
|
|
||||||
//behavior = BT_NORMAL;
|
|
||||||
myTimer = 0;
|
myTimer = 0;
|
||||||
layer = LR_ENTITIES;
|
layer = LR_ENTITIES;
|
||||||
surfaceMoveDir = 1;
|
surfaceMoveDir = 1;
|
||||||
this->position = position;
|
this->position = position;
|
||||||
numSegments = 0;
|
numSegments = 0;
|
||||||
reverseSegments = false;
|
reverseSegments = false;
|
||||||
manaBallAmount = moneyAmount = 1;
|
manaBallAmount = 1;
|
||||||
this->name = scriptName;
|
this->name = scriptName;
|
||||||
|
|
||||||
std::string file;
|
std::string file;
|
||||||
|
@ -83,7 +76,7 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
|
||||||
script = dsq->scriptInterface.openScript(file);
|
script = dsq->scriptInterface.openScript(file);
|
||||||
if (!script)
|
if (!script)
|
||||||
{
|
{
|
||||||
errorLog("Could not load script [" + file + "]");
|
debugLog("Could not load script [" + file + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,8 +243,7 @@ void ScriptedEntity::setupEntity(const std::string &tex, int lcode)
|
||||||
setTexture(tex);
|
setTexture(tex);
|
||||||
|
|
||||||
updateCull = -1;
|
updateCull = -1;
|
||||||
manaBallAmount = moneyAmount = 0;
|
manaBallAmount = 0;
|
||||||
expType = -1;
|
|
||||||
setState(STATE_IDLE);
|
setState(STATE_IDLE);
|
||||||
|
|
||||||
this->layer = dsq->getEntityLayerToLayer(lcode);
|
this->layer = dsq->getEntityLayerToLayer(lcode);
|
||||||
|
@ -261,7 +253,6 @@ void ScriptedEntity::setupBasicEntity(std::string texture, int health, int manaB
|
||||||
{
|
{
|
||||||
//this->updateCull = updateCull;
|
//this->updateCull = updateCull;
|
||||||
updateCull = -1;
|
updateCull = -1;
|
||||||
this->collideWithEntity = hitEntity;
|
|
||||||
|
|
||||||
if (texture.empty())
|
if (texture.empty())
|
||||||
renderQuad = false;
|
renderQuad = false;
|
||||||
|
@ -271,11 +262,8 @@ void ScriptedEntity::setupBasicEntity(std::string texture, int health, int manaB
|
||||||
this->collideRadius = collideRadius;
|
this->collideRadius = collideRadius;
|
||||||
setState(state);
|
setState(state);
|
||||||
this->manaBallAmount = manaBall;
|
this->manaBallAmount = manaBall;
|
||||||
this->exp = exp;
|
|
||||||
this->moneyAmount = money;
|
|
||||||
width = w;
|
width = w;
|
||||||
height = h;
|
height = h;
|
||||||
this->expType = expType;
|
|
||||||
|
|
||||||
setEntityLayer(layer);
|
setEntityLayer(layer);
|
||||||
}
|
}
|
||||||
|
@ -782,16 +770,6 @@ bool ScriptedEntity::damage(const DamageData &d)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptedEntity::onHitEntity(const CollideData &c)
|
|
||||||
{
|
|
||||||
CollideEntity::onHitEntity(c);
|
|
||||||
|
|
||||||
if (script)
|
|
||||||
{
|
|
||||||
script->call("hitEntity", this, c.entity, c.bone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptedEntity::songNote(int note)
|
void ScriptedEntity::songNote(int note)
|
||||||
{
|
{
|
||||||
Entity::songNote(note);
|
Entity::songNote(note);
|
||||||
|
@ -996,14 +974,14 @@ void ScriptedEntity::onEnterState(int action)
|
||||||
case STATE_DEAD:
|
case STATE_DEAD:
|
||||||
if (!isGoingToBeEaten())
|
if (!isGoingToBeEaten())
|
||||||
{
|
{
|
||||||
doDeathEffects(manaBallAmount, moneyAmount);
|
doDeathEffects(manaBallAmount);
|
||||||
dsq->spawnParticleEffect(deathParticleEffect, position);
|
dsq->spawnParticleEffect(deathParticleEffect, position);
|
||||||
onDieNormal();
|
onDieNormal();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// eaten
|
// eaten
|
||||||
doDeathEffects(0, 0);
|
doDeathEffects(0);
|
||||||
onDieEaten();
|
onDieEaten();
|
||||||
}
|
}
|
||||||
destroySegments(1);
|
destroySegments(1);
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct lua_State;
|
||||||
class ScriptedEntity : public CollideEntity, public Segmented
|
class ScriptedEntity : public CollideEntity, public Segmented
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScriptedEntity(const std::string &scriptName, Vector position, EntityType et = ET_ENEMY, BehaviorType bt = BT_NORMAL);
|
ScriptedEntity(const std::string &scriptName, Vector position, EntityType et = ET_ENEMY);
|
||||||
void init();
|
void init();
|
||||||
void postInit();
|
void postInit();
|
||||||
void destroy();
|
void destroy();
|
||||||
|
@ -42,7 +42,6 @@ public:
|
||||||
typedef std::map<std::string, RenderObject*> PartMap;
|
typedef std::map<std::string, RenderObject*> PartMap;
|
||||||
PartMap partMap;
|
PartMap partMap;
|
||||||
bool surfaceMoveDir;
|
bool surfaceMoveDir;
|
||||||
Vector lastWallOffset;
|
|
||||||
void activate();
|
void activate();
|
||||||
void warpSegments();
|
void warpSegments();
|
||||||
void lightFlare();
|
void lightFlare();
|
||||||
|
@ -103,16 +102,10 @@ protected:
|
||||||
bool animKeyFunc;
|
bool animKeyFunc;
|
||||||
//void onPathEnd();
|
//void onPathEnd();
|
||||||
|
|
||||||
float motherDelay;
|
|
||||||
float eggSpawnRate;
|
|
||||||
int eggDataIdx;
|
|
||||||
|
|
||||||
void onExitTimer();
|
void onExitTimer();
|
||||||
void onHitEntity(const CollideData &c);
|
|
||||||
float myTimer;
|
float myTimer;
|
||||||
void onHitWall();
|
void onHitWall();
|
||||||
bool reverseSegments;
|
bool reverseSegments;
|
||||||
int moneyAmount, expType;
|
|
||||||
Script *script;
|
Script *script;
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
void onEnterState(int action);
|
void onEnterState(int action);
|
||||||
|
|
|
@ -512,7 +512,7 @@ void Shot::onHitWall()
|
||||||
{
|
{
|
||||||
if (!shotData->spawnEntity.empty())
|
if (!shotData->spawnEntity.empty())
|
||||||
{
|
{
|
||||||
dsq->game->createEntity(shotData->spawnEntity, 0, position, 0, false, "", ET_ENEMY, BT_NORMAL, 0, 0, true);
|
dsq->game->createEntity(shotData->spawnEntity, 0, position, 0, false, "", ET_ENEMY, 0, 0, true);
|
||||||
//(shotData->spawnEntity, 0, position, 0, false, "");
|
//(shotData->spawnEntity, 0, position, 0, false, "");
|
||||||
if (shotData->spawnEntity == "NatureFormFlowers")
|
if (shotData->spawnEntity == "NatureFormFlowers")
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,7 @@ v.spawnTimes = 1
|
||||||
v.sfxVol = 1
|
v.sfxVol = 1
|
||||||
|
|
||||||
function v.commonInit(me, fle, cr, h, num, snd, ignoreSets, stimes, svol)
|
function v.commonInit(me, fle, cr, h, num, snd, ignoreSets, stimes, svol)
|
||||||
if svol ~= 0 then
|
if svol and svol ~= 0 then
|
||||||
v.sfxVol = svol
|
v.sfxVol = svol
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ function enterState(me)
|
||||||
elseif entity_getState(me)==STATE_ATTACHED then
|
elseif entity_getState(me)==STATE_ATTACHED then
|
||||||
entity_setEntityType(me, ET_NEUTRAL)
|
entity_setEntityType(me, ET_NEUTRAL)
|
||||||
entity_setMaxSpeed(me, 0)
|
entity_setMaxSpeed(me, 0)
|
||||||
entity_incrTargetLeaches(me)
|
avatar_incrLeaches()
|
||||||
entity_sound(me, "Leach")
|
entity_sound(me, "Leach")
|
||||||
v.attachBone = entity_getNearestBoneToPosition(entity_getTarget(me), entity_getPosition(me))
|
v.attachBone = entity_getNearestBoneToPosition(entity_getTarget(me), entity_getPosition(me))
|
||||||
--[[
|
--[[
|
||||||
|
@ -132,7 +132,7 @@ end
|
||||||
function exitState(me)
|
function exitState(me)
|
||||||
if entity_getState(me)==STATE_ATTACHED then
|
if entity_getState(me)==STATE_ATTACHED then
|
||||||
-- entity_setState(STATE_IDLE)
|
-- entity_setState(STATE_IDLE)
|
||||||
entity_decrTargetLeaches(me)
|
avatar_decrLeaches()
|
||||||
elseif entity_isState(me, STATE_FLYOFF) then
|
elseif entity_isState(me, STATE_FLYOFF) then
|
||||||
entity_setState(me, STATE_IDLE)
|
entity_setState(me, STATE_IDLE)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1213,7 +1213,7 @@ function enterState(me, state)
|
||||||
|
|
||||||
entity_setNaijaReaction(me, "")
|
entity_setNaijaReaction(me, "")
|
||||||
-- FIXME: There's no "shock" expression; what was intended? --achurch
|
-- FIXME: There's no "shock" expression; what was intended? --achurch
|
||||||
expression(me, shock, 1)
|
--expression(me, shock, 1) -- removed for now to prevent warnings in strict mode --fg
|
||||||
|
|
||||||
entity_clearVel(me)
|
entity_clearVel(me)
|
||||||
entity_clearVel(v.n)
|
entity_clearVel(v.n)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue