Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Is there a way to forcefully damage sails with scripts?

A topic by Qwerry, St. created Aug 26, 2021 Views: 210 Replies: 1
Viewing posts 1 to 2

Found in some scripts attempts to forcefully damage the sails of the ship in order to pretend that it was battered by some events.
But they all don't work.
=
For the basis, I took the way in which damage is done in storms
function MakeSailDmg (chr_idx, dmg)
But nothing came of it, there are no errors in the log and there is no result.
Apparently, this feature only works in BattleInterface.
=
So, Is there a way to forcefully damage sails with scripts?

(1 edit)

The MakeSailDmg (chr_idx, dmg) function does not require BattleInterface to be present on the screen because the BattleInterface.c script is a core include file.  But, it does require that the ship be loaded to sea, in the current scene to work.  If you want to emulate that, without the ship currently loaded at sea, it functions like the following:

MakeSailDmg calls message SendMessage(&objSail,"lslf", MSG_SAIL_SCRIPT_PROCESSING,"RandomSailsDmg", chrIdx,dmg);

The objSail ("sail" class from engine) will execute RandomSailsDmg routine.
RandomSailsDmg iterates all the ship's sails to determine where to add holes for new damage.
RandomSailsDmg then calls event "evntRandomSailDmg" which is processed by script function ProcessRandomSailDmg().

So if you send "evntRandomSailDmg" directly, you can probably achieve what you want:

Event("evntRandomSailDmg", "lslfflll", chrIdx, nodeName, groupNum, fDmg, fSPow, newHoleCount, maxHole, hdat_new);

hdat_new is a bit mask of the hole count for the sail.  Here is the c++ function:  { DWORD v = 0, t = 1; for (int i = 0; i < 12; i++, t <<= 1)if (ss.hole[i])v |= t; return v; }