mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-10-10 08:23:22 +00:00
== 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.
113 lines
3.5 KiB
C++
113 lines
3.5 KiB
C++
/*
|
|
Copyright (C) 2007, 2010 - Bit-Blot
|
|
|
|
This file is part of Aquaria.
|
|
|
|
Aquaria is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
#pragma once
|
|
#include "CollideEntity.h"
|
|
#include "Segmented.h"
|
|
#include "Hair.h"
|
|
struct lua_State;
|
|
|
|
class ScriptedEntity : public CollideEntity, public Segmented
|
|
{
|
|
public:
|
|
ScriptedEntity(const std::string &scriptName, Vector position, EntityType et = ET_ENEMY);
|
|
void init();
|
|
void postInit();
|
|
void destroy();
|
|
void stopTimer();
|
|
void resetTimer(float t);
|
|
void setEntityLayer(int layer);
|
|
void setupEntity(const std::string &tex, int layer=0);
|
|
void setupBasicEntity(std::string texture, int health, int manaBall, int exp, int money, int collideRadius, int state, int w, int h, int expType, bool hitEntity, int updateCull, int layer);
|
|
void initHair(int numSegments, int segmentLength, int width, const std::string &tex);
|
|
void initSegments(int numSegments, int minDist, int maxDist, std::string bodyTex, std::string tailTex, int w, int h, float taper, bool reverseSegments);
|
|
void registerNewPart(RenderObject *r, const std::string &name);
|
|
typedef std::map<std::string, RenderObject*> PartMap;
|
|
PartMap partMap;
|
|
bool surfaceMoveDir;
|
|
void activate();
|
|
void warpSegments();
|
|
void lightFlare();
|
|
void entityDied(Entity *e);
|
|
void message(const std::string &msg, int v);
|
|
void message(const std::string &msg, void *v);
|
|
|
|
static bool runningActivation;
|
|
|
|
void sporesDropped(const Vector &pos, int type);
|
|
|
|
bool damage(const DamageData &d);
|
|
void song(SongType songType);
|
|
|
|
void startPull();
|
|
void stopPull();
|
|
|
|
void songNote(int note);
|
|
void songNoteDone(int note, float len);
|
|
void onAnimationKeyPassed(int key);
|
|
|
|
void initStrands(int num, int segs, int dist, int spacing, Vector color);
|
|
typedef std::vector<Strand*> Strands;
|
|
Strands strands;
|
|
int strandSpacing;
|
|
bool isEntityInside();
|
|
void becomeSolid();
|
|
|
|
void updateHair(float dt);
|
|
void setHairHeadPosition(const Vector &pos);
|
|
void exertHairForce(const Vector &force, float dt);
|
|
std::string deathParticleEffect;
|
|
|
|
ParticleEffect pullEmitter;
|
|
int manaBallAmount;
|
|
|
|
void initEmitter(int emit, const std::string &file);
|
|
void startEmitter(int emit);
|
|
void stopEmitter(int emit);
|
|
|
|
void shiftWorlds(WorldType lastWorld, WorldType worldType);
|
|
void setAutoSkeletalUpdate(bool v);
|
|
|
|
void shotHitEntity(Entity *hit, Shot *shot, Bone *b);
|
|
protected:
|
|
void onDieNormal();
|
|
void onDieEaten();
|
|
void luaDebugMsg(const std::string &func, const std::string &msg);
|
|
float crushDelay;
|
|
bool autoSkeletalSpriteUpdate;
|
|
int beforePullMaxSpeed;
|
|
bool songNoteFunction, preUpdateFunc;
|
|
bool songNoteDoneFunction;
|
|
std::vector<ParticleEffect*> emitters;
|
|
bool becomeSolidDelay;
|
|
void onAlwaysUpdate(float dt);
|
|
void updateStrands(float dt);
|
|
bool animKeyFunc;
|
|
//void onPathEnd();
|
|
|
|
void onExitTimer();
|
|
float myTimer;
|
|
void onHitWall();
|
|
bool reverseSegments;
|
|
Script *script;
|
|
void onUpdate(float dt);
|
|
void onEnterState(int action);
|
|
void onExitState(int action);
|
|
};
|