Add wounds to RFR

develop
JapaMala 2019-04-18 21:49:18 -05:00
parent 435f92d1bb
commit 6565a3a2ba
2 changed files with 33 additions and 1 deletions

@ -466,6 +466,19 @@ message InventoryItem
optional int32 body_part_id = 3; optional int32 body_part_id = 3;
} }
message WoundPart
{
optional int32 global_layer_idx = 1;
optional int32 body_part_id = 2;
optional int32 layer_idx = 3;
}
message UnitWound
{
repeated WoundPart parts = 1;
optional bool severed_part = 2;
}
message UnitDefinition message UnitDefinition
{ {
required int32 id = 1; required int32 id = 1;
@ -493,6 +506,7 @@ message UnitDefinition
optional float subpos_z = 23; optional float subpos_z = 23;
optional Coord facing = 24; optional Coord facing = 24;
optional int32 age = 25; optional int32 age = 25;
repeated UnitWound wounds = 26;
} }
message UnitList message UnitList

@ -1,5 +1,5 @@
#include "df_version_int.h" #include "df_version_int.h"
#define RFR_VERSION "0.20.0" #define RFR_VERSION "0.20.1"
#include <cstdio> #include <cstdio>
#include <time.h> #include <time.h>
@ -92,6 +92,7 @@
#include "df/ui.h" #include "df/ui.h"
#include "df/unit.h" #include "df/unit.h"
#include "df/unit_inventory_item.h" #include "df/unit_inventory_item.h"
#include "df/unit_wound.h"
#include "df/viewscreen_choose_start_sitest.h" #include "df/viewscreen_choose_start_sitest.h"
#include "df/viewscreen_loadgamest.h" #include "df/viewscreen_loadgamest.h"
#include "df/viewscreen_savegamest.h" #include "df/viewscreen_savegamest.h"
@ -1653,6 +1654,19 @@ float lerp(float a, float b, float f)
return a + f * (b - a); return a + f * (b - a);
} }
void GetWounds(df::unit_wound * wound, UnitWound * send_wound)
{
for (size_t i = 0; i < wound->parts.size(); i++)
{
auto part = wound->parts[i];
auto send_part = send_wound->add_parts();
send_part->set_global_layer_idx(part->global_layer_idx);
send_part->set_body_part_id(part->body_part_id);
send_part->set_layer_idx(part->layer_idx);
}
send_wound->set_severed_part(wound->flags.bits.severed_part);
}
static command_result GetUnitListInside(color_ostream &stream, const BlockRequest *in, UnitList *out) static command_result GetUnitListInside(color_ostream &stream, const BlockRequest *in, UnitList *out)
{ {
auto world = df::global::world; auto world = df::global::world;
@ -1826,6 +1840,10 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques
facing->set_z(unit->path.path.z[0] - unit->pos.z); facing->set_z(unit->path.path.z[0] - unit->pos.z);
} }
} }
for (size_t i = 0; i < unit->body.wounds.size(); i++)
{
GetWounds(unit->body.wounds[i], send_unit->add_wounds());
}
} }
return CR_OK; return CR_OK;
} }