Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
sailors: add customizable sailors models
Browse files Browse the repository at this point in the history
  • Loading branch information
Artess999 committed Jun 7, 2022
1 parent 306e975 commit 09aac3a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
49 changes: 26 additions & 23 deletions src/libs/sailors/src/sailors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,27 +722,8 @@ void ShipWalk::CreateNewMan(SailorsPoints &sailorsPoints)

shipMan[current].modelID = core.CreateEntity("MODELR");

switch (rand() % 6) // 6 different character types
{
case 0:
core.Send_Message(shipMan[current].modelID, "ls", MSG_MODEL_LOAD_GEO, "Lowcharacters\\Lo_Man_1");
break;
case 1:
core.Send_Message(shipMan[current].modelID, "ls", MSG_MODEL_LOAD_GEO, "Lowcharacters\\Lo_Man_2");
break;
case 2:
core.Send_Message(shipMan[current].modelID, "ls", MSG_MODEL_LOAD_GEO, "Lowcharacters\\Lo_Man_3");
break;
case 3:
core.Send_Message(shipMan[current].modelID, "ls", MSG_MODEL_LOAD_GEO, "Lowcharacters\\Lo_Man_Kamzol_1");
break;
case 4:
core.Send_Message(shipMan[current].modelID, "ls", MSG_MODEL_LOAD_GEO, "Lowcharacters\\Lo_Man_Kamzol_2");
break;
case 5:
core.Send_Message(shipMan[current].modelID, "ls", MSG_MODEL_LOAD_GEO, "Lowcharacters\\Lo_Man_Kamzol_3");
break;
}
int modelIdx = rand() % std::size(shipManModels_);
core.Send_Message(shipMan[current].modelID, "ls", MSG_MODEL_LOAD_GEO, shipManModels_[modelIdx].c_str());

core.Send_Message(shipMan[current].modelID, "ls", MSG_MODEL_LOAD_ANI, "Lo_Man");

Expand Down Expand Up @@ -779,7 +760,7 @@ void ShipWalk::DeleteMan(int Index)
// UN//GUARD_SAILORS
};
//------------------------------------------------------------------------------------
bool ShipWalk::Init(entid_t _shipID, int editorMode, const char *shipType)
bool ShipWalk::Init(entid_t _shipID, int editorMode, const char *shipType, std::vector<std::string> &shipManModels)
{
crewCount = 0;
bHide = false;
Expand Down Expand Up @@ -825,6 +806,11 @@ bool ShipWalk::Init(entid_t _shipID, int editorMode, const char *shipType)
SetMastBroken(((iNumMasts - 1) - i) + 1); // ??? The masts are opposite ???
}

if (std::size(shipManModels) > 0)
{
shipManModels_ = std::move(shipManModels);
}

// people count
// ATTRIBUTES *att = ship->GetACharacter();
auto *paShip = ship->GetAShip();
Expand Down Expand Up @@ -1170,9 +1156,26 @@ uint64_t Sailors::ProcessMessage(MESSAGE &message)

shipID = message.EntityID();
const std::string &c = message.String();
std::vector<std::string> shipManModels;

if (message.GetFormat() == "lise")
{
auto *pvd = message.ScriptVariablePointer();

if (pvd != nullptr)
{
const int nq = pvd->GetElementsNum();
const char *pstr;
for (auto i = 0; i < nq; i++)
{
pvd->Get(pstr, i);
shipManModels.push_back(pstr);
}
}
}

shipWalk.emplace_back();
if (shipWalk[shipsCount].Init(shipID, editorMode, c.c_str()))
if (shipWalk[shipsCount].Init(shipID, editorMode, c.c_str(), shipManModels))
{
shipsCount++;

Expand Down
5 changes: 4 additions & 1 deletion src/libs/sailors/src/sailors.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,13 @@ class ShipWalk
ShipState shipState; // Ship state

std::vector<ShipMan> shipMan;
std::vector<std::string> shipManModels_ = {"Lowcharacters\\Lo_Man_1", "Lowcharacters\\Lo_Man_2",
"Lowcharacters\\Lo_Man_3", "Lowcharacters\\Lo_Man_Kamzol_1",
"Lowcharacters\\Lo_Man_Kamzol_2", "Lowcharacters\\Lo_Man_Kamzol_3"};
void CreateNewMan(SailorsPoints &sailorsPoints);
void DeleteMan(int Index);

bool Init(entid_t _shipID, int editorMode, const char *shipType);
bool Init(entid_t _shipID, int editorMode, const char *shipType, std::vector<std::string> &shipManModels);
void CheckPosition(uint32_t &dltTime);
void SetMastBroken(int iMastIndex);
void OnHullHit(const CVECTOR &v);
Expand Down

0 comments on commit 09aac3a

Please sign in to comment.