1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-06-09 01:52:02 +00:00

Merge branch 'experimental' of file:///Users/User/code/coding/Aquaria_fg_clean into experimental

This commit is contained in:
fgenesis 2014-04-01 17:26:31 +01:00
commit ac034fc708
10 changed files with 62 additions and 20 deletions

View file

@ -243,6 +243,7 @@ public:
//virtual void onCollide(Entity *e);
virtual bool damage(const DamageData &d);
virtual bool canShotHit(const DamageData &d) { return true; }
virtual void songNote(int note);
virtual void songNoteDone(int note, float len);

View file

@ -8191,11 +8191,9 @@ bool Game::collideHairVsCircle(Entity *a, int num, const Vector &pos2, float rad
}
// NOTE THIS FUNCTION ASSUMES THAT IF A BONE ISN'T AT FULL ALPHA (1.0) IT IS DISABLED
Bone *Game::collideSkeletalVsCircle(Entity *skeletal, Entity *circle)
Bone *Game::collideSkeletalVsCircle(Entity *skeletal, RenderObject *circle)
{
Vector pos = circle->position;
return collideSkeletalVsCircle(skeletal, pos, circle->collideRadius);
return collideSkeletalVsCircle(skeletal, circle->position, circle->collideRadius);
}
Bone *Game::collideSkeletalVsLine(Entity *skeletal, Vector start, Vector end, float radius)
@ -8416,7 +8414,6 @@ bool Game::isEntityCollideWithShot(Entity *e, Shot *shot)
void Game::handleShotCollisions(Entity *e, bool hasShield)
{
BBGE_PROF(Game_handleShotCollisions);
bool isRegValid=true;
for (size_t i = 0; i < Shot::shots.size(); ++i)
{
Shot *shot = Shot::shots[i];
@ -8430,7 +8427,7 @@ void Game::handleShotCollisions(Entity *e, bool hasShield)
if ((collidePoint - shot->position).isLength2DIn(shot->collideRadius + e->collideRadius))
{
lastCollidePosition = shot->position;
shot->hitEntity(e,0,isRegValid);
shot->hitEntity(e,0);
}
}
}
@ -8464,14 +8461,14 @@ void Game::handleShotCollisionsSkeletal(Entity *e)
}
}
void Game::handleShotCollisionsHair(Entity *e, int num)
void Game::handleShotCollisionsHair(Entity *e, int num, float perc)
{
for (size_t i = 0; i < Shot::shots.size(); ++i)
{
Shot *shot = Shot::shots[i];
if (shot->isActive() && isEntityCollideWithShot(e, shot))
{
bool b = collideHairVsCircle(e, num, shot->position, 8);
bool b = collideHairVsCircle(e, num, shot->position, 8, perc);
if (b)
{
lastCollidePosition = shot->position;

View file

@ -661,14 +661,14 @@ public:
bool collideHairVsCircle(Entity *a, int num, const Vector &pos2, float radius, float perc=0, int *colSegment=0);
bool collideCircleVsCircle(Entity *a, Entity *b);
Bone *collideSkeletalVsCircle(Entity *skeletal, Entity *circle);
Bone *collideSkeletalVsCircle(Entity *skeletal, RenderObject *circle);
Bone *collideSkeletalVsLine(Entity *skeletal, Vector start, Vector end, float radius);
bool collideCircleVsLine(RenderObject *r, Vector start, Vector end, float radius);
bool collideCircleVsLineAngle(RenderObject *r, float angle, float startLen, float endLen, float radius, Vector basePos);
Bone *collideSkeletalVsCircle(Entity *skeletal, Vector pos, float radius);
void handleShotCollisions(Entity *e, bool hasShield=false);
void handleShotCollisionsSkeletal(Entity *e);
void handleShotCollisionsHair(Entity *e, int num = 0);
void handleShotCollisionsHair(Entity *e, int num = 0, float perc = 0);
std::vector<ElementTemplate> elementTemplates;
std::string sceneName;

View file

@ -58,6 +58,8 @@ void PathFinding::forceMinimumPath(VectorPath &path, const Vector &start, const
void PathFinding::molestPath(VectorPath &path)
{
int sz=path.getNumPathNodes();
if(!sz)
return;
int i = 0;
// make normals

View file

@ -740,6 +740,7 @@ void SceneEditor::init()
addAction(ACTION_BGLAYER14, KEY_COMMA);
addAction(ACTION_BGLAYER15, KEY_PERIOD);
addAction(ACTION_BGLAYER16, KEY_SLASH);
addAction(ACTION_BGLAYER16, KEY_MINUS); // HACK: for german keyboard layout -- FG
addAction(ACTION_MULTISELECT, KEY_LALT);

View file

@ -67,6 +67,7 @@ static const char * const interfaceFunctions[] = {
"activate",
"animationKey",
"castSong",
"canShotHit",
"cookFailure",
"damage",
"deathNotify",
@ -5075,7 +5076,7 @@ luaFunc(entity_handleShotCollisionsHair)
Entity *e = entity(L);
if (e)
{
dsq->game->handleShotCollisionsHair(e, lua_tonumber(L, 2));
dsq->game->handleShotCollisionsHair(e, lua_tointeger(L, 2), lua_tonumber(L, 3));
}
luaReturnNil();
}
@ -5083,7 +5084,7 @@ luaFunc(entity_handleShotCollisionsHair)
luaFunc(entity_collideSkeletalVsCircle)
{
Entity *e = entity(L);
Entity *e2 = entity(L,2);
RenderObject *e2 = robj(L,2);
Bone *b = 0;
if (e && e2)
{
@ -5092,6 +5093,17 @@ luaFunc(entity_collideSkeletalVsCircle)
luaReturnPtr(b);
}
luaFunc(entity_collideSkeletalVsCirclePos)
{
Entity *e = entity(L);
Bone *b = 0;
if (e)
{
b = dsq->game->collideSkeletalVsCircle(e, Vector(lua_tonumber(L, 2), lua_tonumber(L, 3)), lua_tonumber(L, 4));
}
luaReturnPtr(b);
}
luaFunc(entity_collideSkeletalVsLine)
{
Entity *e = entity(L);
@ -9598,6 +9610,7 @@ static const struct {
luaRegister(entity_handleShotCollisionsSkeletal),
luaRegister(entity_handleShotCollisionsHair),
luaRegister(entity_collideSkeletalVsCircle),
luaRegister(entity_collideSkeletalVsCirclePos),
luaRegister(entity_collideSkeletalVsLine),
luaRegister(entity_collideSkeletalVsCircleForListByName),
luaRegister(entity_collideCircleVsLine),

View file

@ -38,6 +38,7 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
becomeSolidDelay = false;
strandSpacing = 10;
animKeyFunc = true;
canShotHitFunc = true;
//runningActivation = false;
setEntityType(et);
@ -562,6 +563,26 @@ void ScriptedEntity::lightFlare()
}
}
bool ScriptedEntity::canShotHit(const DamageData &d)
{
bool doDefault = true;
if (script && canShotHitFunc)
{
if (!script->call("canShotHit", this, d.attacker, d.bone, int(d.damageType), d.damage, d.hitPos.x, d.hitPos.y, d.shot, &doDefault))
{
debugLog(name + ": canShotHit function failed");
canShotHitFunc = false;
}
}
if (doDefault)
{
return Entity::canShotHit(d);
}
return false;
}
bool ScriptedEntity::damage(const DamageData &d)
{
if (d.damageType == DT_NONE) return false;

View file

@ -55,6 +55,8 @@ public:
void sporesDropped(const Vector &pos, int type);
bool damage(const DamageData &d);
bool canShotHit(const DamageData &d);
void song(SongType songType);
void startPull();
@ -109,6 +111,7 @@ protected:
void onEnterState(int action);
void onExitState(int action);
virtual void deathNotify(RenderObject *r);
bool canShotHitFunc;
};
#endif

View file

@ -558,7 +558,7 @@ bool Shot::isHitEnts() const
return false;
}
void Shot::hitEntity(Entity *e, Bone *b, bool isValid)
void Shot::hitEntity(Entity *e, Bone *b)
{
if (!dead)
{
@ -567,12 +567,6 @@ void Shot::hitEntity(Entity *e, Bone *b, bool isValid)
if (e)
{
if (damageType == DT_AVATAR_BITE)
{
//debugLog("Shot::hitEntity bittenEntities.push_back");
dsq->game->avatar->bittenEntities.push_back(e);
}
DamageData d;
d.attacker = firer;
d.bone = b;
@ -585,6 +579,16 @@ void Shot::hitEntity(Entity *e, Bone *b, bool isValid)
if ((firer && firer->getEntityType() == ET_AVATAR))
d.form = dsq->continuity.form;
if (!e->canShotHit(d))
return;
if (damageType == DT_AVATAR_BITE)
{
//debugLog("Shot::hitEntity bittenEntities.push_back");
dsq->game->avatar->bittenEntities.push_back(e);
}
bool damaged = e->damage(d);
// doesn't have anything to do with effectTime

View file

@ -94,7 +94,7 @@ public:
float maxSpeed;
void fire(bool playSfx = true);
void hitEntity(Entity *e, Bone *b, bool isValid=true);
void hitEntity(Entity *e, Bone *b);
void noSegs();