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

src/action/action_resource.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "player.h"
#include "unit.h"
#include "unittype.h"
#include "animation.h"
#include "actions.h"
#include "pathfinder.h"
#include "interface.h"
#include "sound.h"
#include "map.h"

action_resource.cpp - The generic resource action.

#define SUB_START_RESOURCE   0
#define SUB_MOVE_TO_RESOURCE   5
#define SUB_UNREACHABLE_RESOURCE   31
#define SUB_START_GATHERING   55
#define SUB_GATHER_RESOURCE   60
#define SUB_STOP_GATHERING   65
#define SUB_MOVE_TO_DEPOT   70
#define SUB_UNREACHABLE_DEPOT   100
#define SUB_RETURN_RESOURCE   120
static int MoveToResource (CUnit &unit)
static void UnitGotoGoal (CUnit &unit, CUnit *const goal, int mode)
static int StartGathering (CUnit &unit)
static void AnimateActionHarvest (CUnit &unit)
static void LoseResource (CUnit &unit, const CUnit &source)
static int GatherResource (CUnit &unit)
int GetNumWaitingWorkers (const CUnit &mine)
static int StopGathering (CUnit &unit)
void AiNewDepotRequest (CUnit &worker)
static int MoveToDepot (CUnit &unit)
static int WaitInDepot (CUnit &unit)
void DropResource (CUnit &unit)
void ResourceGiveUp (CUnit &unit)
void HandleActionResource (CUnit &unit)
 Handle command resource.

Define Documentation

#define SUB_GATHER_RESOURCE   60

#define SUB_MOVE_TO_DEPOT   70

#define SUB_MOVE_TO_RESOURCE   5

#define SUB_RETURN_RESOURCE   120

#define SUB_START_GATHERING   55

#define SUB_START_RESOURCE   0

#define SUB_STOP_GATHERING   65

#define SUB_UNREACHABLE_DEPOT   100

#define SUB_UNREACHABLE_RESOURCE   31


Function Documentation

void AiNewDepotRequest ( CUnit worker  ) 

static void AnimateActionHarvest ( CUnit unit  )  [static]

Animate A unit that is harvesting

Parameters:
unit Unit to animate

void DropResource ( CUnit unit  ) 

static int GatherResource ( CUnit unit  )  [static]

Gather the resource

Parameters:
unit Pointer to unit.
Returns:
non-zero if ready, otherwise zero.

int GetNumWaitingWorkers ( const CUnit mine  ) 

void HandleActionResource ( CUnit unit  ) 

Handle command resource.

Control the unit action: getting a resource.

This the generic function for oil, gold, ...

Parameters:
unit Pointer to unit.

static void LoseResource ( CUnit unit,
const CUnit source 
) [static]

Find something else to do when the resource is exhausted. This is called from GatherResorce when the resource is empty.

Parameters:
unit pointer to harvester unit.
source pointer to resource unit.

static int MoveToDepot ( CUnit unit  )  [static]

Move to resource depot

Parameters:
unit Pointer to unit.
Returns:
TRUE if reached, otherwise FALSE.

static int MoveToResource ( CUnit unit  )  [static]

Move unit to resource.

Parameters:
unit Pointer to unit.
Returns:
TRUE if reached, otherwise FALSE.

void ResourceGiveUp ( CUnit unit  ) 

Give up on gathering.

Parameters:
unit Pointer to unit.

static int StartGathering ( CUnit unit  )  [static]

Start harvesting the resource.

Parameters:
unit Pointer to unit.
Returns:
TRUE if ready, otherwise FALSE.

static int StopGathering ( CUnit unit  )  [static]

Stop gathering from the resource, go home.

Parameters:
unit Poiner to unit.
Returns:
TRUE if ready, otherwise FALSE.

static void UnitGotoGoal ( CUnit unit,
CUnit *const   goal,
int  mode 
) [static]

static int WaitInDepot ( CUnit unit  )  [static]

Wait in depot, for the resources stored.

Parameters:
unit Pointer to unit.
Returns:
TRUE if ready, otherwise FALSE.

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