Add reactor #71

Place destroy objectives using strict mode initially
This commit is contained in:
Cong
2023-09-01 22:56:59 +10:00
parent 3d2bace0ae
commit f740890d91
12 changed files with 151 additions and 27 deletions

View File

@@ -446,7 +446,7 @@
"Sound": "explosion_small"
},
{
"Pic": "big_quake",
"Pic": "",
"Name": "big_quake",
"Sound": "",
"Shake": {

View File

@@ -331,6 +331,62 @@
"Range": 27,
"Persists": true,
"Hit": {}
},
{
"Name": "small_fireball1",
"Pic": {
"Type": "Animated",
"Sprites": "fireball",
"TicksPerFrame": 3
},
"Speed": 0,
"Range": 40,
"Power": 0,
"Size": [7, 5],
"Persists": true,
"Spark": "",
"Falling": {
"GravityFactor": 1,
"FallsDown": false
}
},
{
"Name": "small_fireball2",
"Pic": {
"Type": "Animated",
"Sprites": "fireball",
"Count": -8,
"TicksPerFrame": 3
},
"Speed": 0,
"Range": 48,
"Power": 0,
"Size": [7, 5],
"Persists": true,
"Spark": "",
"Falling": {
"GravityFactor": 1,
"FallsDown": false
}
},
{
"Name": "small_fireball3",
"Pic": {
"Type": "Animated",
"Sprites": "fireball",
"Count": -16,
"TicksPerFrame": 3
},
"Speed": 0,
"Range": 56,
"Power": 0,
"Size": [7, 5],
"Persists": true,
"Spark": "",
"Falling": {
"GravityFactor": 1,
"FallsDown": false
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -238,6 +238,28 @@
"Name": "explosion_ball",
"Bullet": "explosion_ball",
"Sound": ""
},
{
"Pic": "",
"Name": "small_explosion1",
"Bullet": "small_fireball1",
"ElevationLow": 14,
"ElevationHigh": 14,
"Sound": "explosion"
},
{
"Pic": "",
"Name": "small_explosion2",
"Bullet": "small_fireball2",
"ElevationLow": 22,
"ElevationHigh": 22
},
{
"Pic": "",
"Name": "small_explosion3",
"Bullet": "small_fireball3",
"ElevationLow": 30,
"ElevationHigh": 30
}
]
}

View File

@@ -1,5 +1,5 @@
{
"Version": 3,
"Version": 4,
"MapObjects": [
{
"Name": "crate",
@@ -7,7 +7,9 @@
"Type": "Normal",
"Pic": "crate"
},
"Wreck": "crate_wreck",
"Wreck": {
"MapObject": "crate_wreck"
},
"Health": 30,
"Flags": ["FreeInFront"]
},
@@ -17,7 +19,9 @@
"Type": "Normal",
"Pic": "box"
},
"Wreck": "box_wreck",
"Wreck": {
"MapObject": "box_wreck"
},
"Health": 20,
"Flags": ["FreeInFront"]
},
@@ -27,7 +31,9 @@
"Type": "Normal",
"Pic": "box3_gray"
},
"Wreck": "box3_gray_wreck",
"Wreck": {
"MapObject": "box3_gray_wreck"
},
"Health": 30,
"Flags": ["FreeInFront"]
},
@@ -38,9 +44,34 @@
"Sprites": "cabinet_server",
"TicksPerFrame": 20
},
"Wreck": "cabinet_server_wreck",
"Wreck": {
"MapObject": "cabinet_server_wreck"
},
"Health": 120,
"Flags": ["FreeInFront"]
},
{
"Name": "reactor",
"Pic": {
"Type": "Animated",
"Sprites": "reactor",
"TicksPerFrame": 4
},
"Wreck": {
"MapObject": "safe_wreck",
"Sound": "explosion"
},
"Health": 280,
"Flags": ["FreeInFront", "Inside"],
"DestroyGuns": [
"big_quake",
"small_explosion1",
"small_explosion2",
"small_explosion3"
],
"DamageSmoke": {
"HealthThreshold": 0.5
}
}
]
}

View File

@@ -29,6 +29,14 @@
"Count": 400,
"Required": 0,
"Flags": 1
},
{
"Description": "Destroy",
"Type": "Destroy",
"MapObjects": ["reactor"],
"Count": 1,
"Required": 1,
"Flags": 0
}],
"Enemies": [3],
"SpecialChars": [],

View File

@@ -50,14 +50,14 @@
"Flesh": "",
"Wall": ""
},
"SeekFactor": 11
"SeekFactor": 11
},
{
{
"Name": "grenade",
"Pic": {
"Type": "Animated",
"Sprites": "grenade",
"TicksPerFrame": 4
"TicksPerFrame": 4
},
"Speed": 340,
"Range": 80,
@@ -67,14 +67,14 @@
"Flesh": "",
"Wall": ""
},
"WallBounces": true,
"Falling": {
"WallBounces": true,
"Falling": {
"GravityFactor": 1
},
"OutOfRangeGuns": [
"OutOfRangeGuns": [
"grenade_explosion1",
"grenade_explosion2",
"grenade_explosion3"
"grenade_explosion2",
"grenade_explosion3"
],
"HitGuns": [
"grenade_explosion1",
@@ -103,7 +103,7 @@
},
"Falling": {
"GravityFactor": 1,
"FallsDown": false
"FallsDown": false
}
},
{
@@ -128,7 +128,7 @@
},
"Falling": {
"GravityFactor": 1,
"FallsDown": false
"FallsDown": false
}
},
{
@@ -153,10 +153,10 @@
},
"Falling": {
"GravityFactor": 1,
"FallsDown": false
"FallsDown": false
}
},
{
{
"Name": "laser_designator",
"Pic": {
"Type": "Normal",

View File

@@ -340,13 +340,13 @@ bool MapPosIsInLockedRoom(const Map *map, const struct vec2 pos)
}
bool MapTryPlaceDestroyObject(
MapBuilder *mb, const Mission *m, const int objective, const struct vec2i pos)
MapBuilder *mb, const Mission *m, const int objective, const struct vec2i pos, const bool strict)
{
const Objective *o = CArrayGet(&m->Objectives, objective);
// Pick a random map object out of the available ones
const int i = RAND_INT(0, (int)o->u.MapObjects.size - 1);
const MapObject *mo = *(const MapObject **)CArrayGet(&o->u.MapObjects, i);
return MapTryPlaceOneObject(mb, pos, mo, ObjectiveToThing(objective), false);
return MapTryPlaceOneObject(mb, pos, mo, ObjectiveToThing(objective), strict);
}
void MapPlaceCollectible(

View File

@@ -452,7 +452,7 @@ void MapLoadDynamic(MapBuilder *mb)
AddKeys(mb);
}
}
static bool MapTryPlaceBlowup(MapBuilder *mb, const int objective);
static bool MapTryPlaceBlowup(MapBuilder *mb, const int objective, const bool strict);
static int MapTryPlaceCollectible(MapBuilder *mb, const int objective);
static void AddObjectives(MapBuilder *mb)
{
@@ -476,12 +476,18 @@ static void AddObjectives(MapBuilder *mb)
}
else if (o->Type == OBJECTIVE_DESTROY)
{
// Try using strict rule when placing objective, at least for a bit
int strictCounter = 1000;
for (int i = o->placed; i < o->Count; i++)
{
if (MapTryPlaceBlowup(mb, _ca_index))
if (MapTryPlaceBlowup(mb, _ca_index, strictCounter > 0))
{
o->placed++;
}
if (strictCounter > 0)
{
strictCounter--;
}
}
}
o->Count = o->placed;
@@ -558,23 +564,25 @@ typedef struct
{
const Objective *o;
int objective;
bool strict;
} TryPlaceOneBlowupData;
static bool TryPlaceOneBlowup(
MapBuilder *mb, const struct vec2i tilePos, void *data);
static bool MapTryPlaceBlowup(MapBuilder *mb, const int objective)
static bool MapTryPlaceBlowup(MapBuilder *mb, const int objective, const bool strict)
{
TryPlaceOneBlowupData data;
data.o = CArrayGet(&mb->mission->Objectives, objective);
const PlacementAccessFlags paFlags =
ObjectiveGetPlacementAccessFlags(data.o);
data.objective = objective;
data.strict = strict;
return MapPlaceRandomTile(mb, paFlags, TryPlaceOneBlowup, &data);
}
static bool TryPlaceOneBlowup(
MapBuilder *mb, const struct vec2i tilePos, void *data)
{
const TryPlaceOneBlowupData *pData = data;
return MapTryPlaceDestroyObject(mb, mb->mission, pData->objective, tilePos);
return MapTryPlaceDestroyObject(mb, mb->mission, pData->objective, tilePos, pData->strict);
}
void MapBuilderSetLeaveFree(

View File

@@ -88,7 +88,7 @@ bool MapTryPlaceOneObject(
MapBuilder *mb, const struct vec2i v, const MapObject *mo,
const int extraFlags, const bool isStrictMode);
bool MapTryPlaceDestroyObject(
MapBuilder *mb, const Mission *m, const int objective, const struct vec2i pos);
MapBuilder *mb, const Mission *m, const int objective, const struct vec2i pos, const bool strict);
// TODO: refactor
void MapPlaceCollectible(
const Mission *m, const int objective, const struct vec2 pos);

View File

@@ -195,7 +195,7 @@ static void AddObjective(MapBuilder *mb, const ObjectivePositions *op)
MapPlaceCollectible(mb->mission, op->Index, pos);
break;
case OBJECTIVE_DESTROY:
MapTryPlaceDestroyObject(mb, mb->mission, op->Index, pi->Position);
MapTryPlaceDestroyObject(mb, mb->mission, op->Index, pi->Position, false);
break;
case OBJECTIVE_RESCUE: {
CASSERT(mb->characters != NULL, "cannot add rescue objective");

View File

@@ -221,7 +221,6 @@ void ObjRemove(const NMapObjectRemove mor)
if (strlen(o->Class->Wreck.Bullet) > 0)
{
// A wreck left after the destruction of this object
// TODO: doesn't need to be network event
GameEvent e = GameEventNew(GAME_EVENT_ADD_BULLET);
e.u.AddBullet.UID = MobObjsObjsGetNextUID();
strcpy(e.u.AddBullet.BulletClass, o->Class->Wreck.Bullet);