Added components to jumpgate, to allow it to be targetted.
This commit is contained in:
parent
648ea2e0a7
commit
64b85f122e
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -24,20 +24,25 @@ static void think(void);
|
|||
static void draw(void);
|
||||
static void handleFleeingEntities(void);
|
||||
static void addEscapeEffect(Entity *ent);
|
||||
static void addNodes(Entity *jumpgate, long flags);
|
||||
static void nodeDie(void);
|
||||
|
||||
static SDL_Texture *portal;
|
||||
static float portalAngle;
|
||||
|
||||
Entity *spawnJumpgate(void)
|
||||
Entity *spawnJumpgate(int side, long flags)
|
||||
{
|
||||
Entity *jumpgate = spawnEntity();
|
||||
|
||||
jumpgate->type = ET_JUMPGATE;
|
||||
jumpgate->health = jumpgate->maxHealth = FPS;
|
||||
jumpgate->health = jumpgate->maxHealth = 1;
|
||||
jumpgate->texture = getTexture("gfx/entities/jumpgate.png");
|
||||
jumpgate->action = think;
|
||||
jumpgate->draw = draw;
|
||||
jumpgate->flags |= EF_NO_MT_BOX;
|
||||
jumpgate->side = side;
|
||||
jumpgate->flags = EF_NO_MT_BOX+EF_IMMORTAL+EF_AI_IGNORE;
|
||||
|
||||
addNodes(jumpgate, flags);
|
||||
|
||||
portal = getTexture("gfx/entities/portal.png");
|
||||
portalAngle = 0;
|
||||
|
@ -47,6 +52,58 @@ Entity *spawnJumpgate(void)
|
|||
return jumpgate;
|
||||
}
|
||||
|
||||
static void addNodes(Entity *jumpgate, long flags)
|
||||
{
|
||||
Entity *node;
|
||||
SDL_Texture *nodeTexture;
|
||||
int i;
|
||||
|
||||
nodeTexture = getTexture("gfx/entities/jumpgateNode.png");
|
||||
|
||||
for (i = 0 ; i < 360 ; i += 36)
|
||||
{
|
||||
node = spawnEntity();
|
||||
STRNCPY(node->name, _("Jumpgate System Node"), MAX_NAME_LENGTH);
|
||||
node->health = node->maxHealth = 75;
|
||||
node->type = ET_COMPONENT;
|
||||
node->offsetX = sin(TO_RAIDANS(i)) * 215;
|
||||
node->offsetY = -cos(TO_RAIDANS(i)) * 215;
|
||||
node->owner = jumpgate;
|
||||
node->side = jumpgate->side;
|
||||
node->texture = nodeTexture;
|
||||
node->flags = EF_TAKES_DAMAGE;
|
||||
node->die = nodeDie;
|
||||
SDL_QueryTexture(node->texture, NULL, NULL, &node->w, &node->h);
|
||||
|
||||
if (flags != -1)
|
||||
{
|
||||
node->flags |= flags;
|
||||
}
|
||||
|
||||
jumpgate->maxHealth++;
|
||||
}
|
||||
|
||||
jumpgate->health = jumpgate->maxHealth;
|
||||
}
|
||||
|
||||
static void nodeDie(void)
|
||||
{
|
||||
self->alive = ALIVE_DEAD;
|
||||
addSmallExplosion();
|
||||
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
|
||||
addDebris(self->x, self->y, 3 + rand() % 4);
|
||||
|
||||
if (--battle.jumpgate->health == 1)
|
||||
{
|
||||
battle.jumpgate->flags |= EF_DISABLED;
|
||||
|
||||
updateObjective("Jumpgate", TT_DESTROY);
|
||||
updateCondition("Jumpgate", TT_DESTROY);
|
||||
}
|
||||
|
||||
runScriptFunction("JUMPGATE_HEALTH %d", battle.jumpgate->health);
|
||||
}
|
||||
|
||||
int jumpgateEnabled(void)
|
||||
{
|
||||
return (battle.jumpgate && (!(battle.jumpgate->flags & EF_DISABLED)));
|
||||
|
@ -54,7 +111,7 @@ int jumpgateEnabled(void)
|
|||
|
||||
void activateJumpgate(int activate)
|
||||
{
|
||||
if (battle.jumpgate)
|
||||
if (battle.jumpgate && battle.jumpgate->health > 1)
|
||||
{
|
||||
if (activate)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,13 @@ extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
|||
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||
extern void playBattleSound(int id, int x, int y);
|
||||
extern void blitRotated(SDL_Texture *texture, int x, int y, float angle);
|
||||
extern char *getTranslatedString(char *string);
|
||||
extern void addSmallExplosion(void);
|
||||
extern void playBattleSound(int id, int x, int y);
|
||||
extern void addDebris(int x, int y, int amount);
|
||||
extern void runScriptFunction(char *format, ...);
|
||||
extern void updateObjective(char *name, int type);
|
||||
extern void updateCondition(char *name, int type);
|
||||
|
||||
extern Battle battle;
|
||||
extern Entity *self;
|
||||
|
|
13
src/defs.h
13
src/defs.h
|
@ -98,7 +98,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define EF_ROPED_ATTACHED (2 << 15)
|
||||
#define EF_NO_KILL_INC (2 << 16)
|
||||
#define EF_SHORT_RADAR_RANGE (2 << 17)
|
||||
#define EF_NO_TARGET (2 << 18)
|
||||
#define EF_NO_PLAYER_TARGET (2 << 18)
|
||||
#define EF_AI_IGNORE (2 << 19)
|
||||
|
||||
#define AIF_NONE 0
|
||||
#define AIF_FOLLOWS_PLAYER (2 << 0)
|
||||
|
@ -153,12 +154,12 @@ enum
|
|||
ET_FIGHTER,
|
||||
ET_ITEM,
|
||||
ET_WAYPOINT,
|
||||
ET_COMPONENT,
|
||||
ET_COMPONENT_GUN,
|
||||
ET_COMPONENT_ENGINE,
|
||||
ET_CAPITAL_SHIP,
|
||||
ET_JUMPGATE,
|
||||
ET_MINE,
|
||||
ET_CAPITAL_SHIP_GUN,
|
||||
ET_CAPITAL_SHIP_COMPONENT,
|
||||
ET_CAPITAL_SHIP_ENGINE,
|
||||
ET_CAPITAL_SHIP
|
||||
ET_MINE
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
|
@ -343,7 +343,7 @@ static void loadEntities(cJSON *node)
|
|||
number = getJSONValue(node, "number", 1);
|
||||
active = getJSONValue(node, "active", 1);
|
||||
scatter = getJSONValue(node, "scatter", 1);
|
||||
side = getJSONValue(node, "side", SIDE_NONE);
|
||||
side = lookup(getJSONValueStr(node, "side", "SIDE_NONE"));
|
||||
|
||||
if (cJSON_GetObjectItem(node, "flags"))
|
||||
{
|
||||
|
@ -360,7 +360,7 @@ static void loadEntities(cJSON *node)
|
|||
break;
|
||||
|
||||
case ET_JUMPGATE:
|
||||
e = spawnJumpgate();
|
||||
e = spawnJumpgate(side, flags);
|
||||
break;
|
||||
|
||||
case ET_MINE:
|
||||
|
@ -383,7 +383,7 @@ static void loadEntities(cJSON *node)
|
|||
STRNCPY(e->groupName, groupName, MAX_NAME_LENGTH);
|
||||
}
|
||||
|
||||
if (flags != -1)
|
||||
if (type != ET_JUMPGATE && flags != -1)
|
||||
{
|
||||
if (addFlags)
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ extern void initPlayer(void);
|
|||
extern long flagsToLong(char *flags, int *add);
|
||||
extern Entity *spawnWaypoint(void);
|
||||
extern void selectWidget(const char *name, const char *group);
|
||||
extern Entity *spawnJumpgate(void);
|
||||
extern Entity *spawnJumpgate(int side, long flags);
|
||||
extern void failIncompleteObjectives(void);
|
||||
extern void completeConditions(void);
|
||||
extern void retreatEnemies(void);
|
||||
|
|
Loading…
Reference in New Issue