_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

action_unload.cpp File Reference
#include "stratagus.h"
#include "action/action_unload.h"
#include "animation.h"
#include "iolib.h"
#include "map.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
#include "video.h"

action_unload.cpp - The unload action.

constexpr int MAX_SEARCH_RANGE = 20
 
constexpr int MAX_RETRIES = 20
 
constexpr int FIND_DROPZONE_STATE = 0
 
constexpr int MOVE_TO_DROPZONE_STATE = 1
 
constexpr int UNLOAD_STATE = 2
 
static bool FindUnloadPosition (const CUnit &transporter, const CUnit &unit, const Vec2i startPos, int maxRange, Vec2i *res)
 
static int UnloadUnit (CUnit &transporter, CUnit &unit)
 
static bool IsDropZonePossible (const CUnit &transporter, const Vec2i &pos)
 
static bool ClosestFreeDropZone_internal (const CUnit &transporter, const Vec2i &startPos, int maxRange, Vec2i *resPos)
 
static int ClosestFreeDropZone (CUnit &transporter, const Vec2i &startPos, int maxRange, Vec2i *resPos)
 

Function Documentation

◆ ClosestFreeDropZone()

static int ClosestFreeDropZone ( CUnit transporter,
const Vec2i startPos,
int  maxRange,
Vec2i resPos 
)
static

Find the closest available drop zone for a transporter. Fail if transporter don't transport any unit..

Parameters
transporterthe transporter
startPosstart location for the search
maxRangeThe maximum distance from initial position to search...
resPosdrop zone position
Returns
1 if a location was found, 0 otherwise

◆ ClosestFreeDropZone_internal()

static bool ClosestFreeDropZone_internal ( const CUnit transporter,
const Vec2i startPos,
int  maxRange,
Vec2i resPos 
)
static

Find the closest available drop zone for a transporter. Fail if transporter don't transport any unit..

Parameters
transporterthe transporter
startPosstart location for the search
maxRangeThe maximum distance from initial position to search...
resPosdrop zone position
Returns
true if a location was found, false otherwise
Note
to be called only from ClosestFreeDropZone.

◆ FindUnloadPosition()

static bool FindUnloadPosition ( const CUnit transporter,
const CUnit unit,
const Vec2i  startPos,
int  maxRange,
Vec2i res 
)
static

Find a free position close to startPos

Parameters
transporter
unitUnit to unload.
startPosOriginal search position
maxrangemaximum range to unload.
resUnload position.
Returns
True if a position was found, False otherwise.
Note
res is undefined if a position is not found.
Bug:
FIXME: Place unit only on fields reachable from the transporter

◆ IsDropZonePossible()

static bool IsDropZonePossible ( const CUnit transporter,
const Vec2i pos 
)
static

Return true if position is a correct place to drop out units.

Parameters
transporterTransporter unit.
posposition to drop out units.

◆ UnloadUnit()

static int UnloadUnit ( CUnit transporter,
CUnit unit 
)
static

Reappear unit on map.

Parameters
unitUnit to drop out.
Returns
True if unit is unloaded.
Bug:
FIXME: Place unit only on fields reachable from the transporter

Variable Documentation

◆ FIND_DROPZONE_STATE

constexpr int FIND_DROPZONE_STATE = 0
constexpr

◆ MAX_RETRIES

constexpr int MAX_RETRIES = 20
constexpr

◆ MAX_SEARCH_RANGE

constexpr int MAX_SEARCH_RANGE = 20
constexpr

◆ MOVE_TO_DROPZONE_STATE

constexpr int MOVE_TO_DROPZONE_STATE = 1
constexpr

◆ UNLOAD_STATE

constexpr int UNLOAD_STATE = 2
constexpr
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.