____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

action_resource.cpp File Reference

The generic resource action. More...

#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"

Go to the source code of this file.

Defines

#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

Functions

static int MoveToResource (CUnit *unit)
static bool StartGathering (CUnit *unit)
static void AnimateActionHarvest (CUnit *unit)
static void FindNewResource (CUnit *unit)
static void GatherResource (CUnit *unit)
static void ResourceGiveUp (CUnit *unit)
void HandleActionResource (CUnit *unit)
 Handle command die.

Variables

int AlliedUnitRecyclingEfficiency [MaxCosts] = {0, 50}
int EnemyUnitRecyclingEfficiency [MaxCosts] = {0, 40}


Detailed Description

The generic resource action.

Definition in file action_resource.cpp.


Define Documentation

#define SUB_GATHER_RESOURCE   60

Definition at line 57 of file action_resource.cpp.

Referenced by HandleActionResource().

#define SUB_MOVE_TO_RESOURCE   5

Definition at line 54 of file action_resource.cpp.

Referenced by HandleActionResource().

#define SUB_START_GATHERING   55

Definition at line 56 of file action_resource.cpp.

Referenced by HandleActionResource().

#define SUB_START_RESOURCE   0

Definition at line 53 of file action_resource.cpp.

Referenced by FindNewResource(), HandleActionResource(), and StartGathering().

#define SUB_UNREACHABLE_RESOURCE   31

Definition at line 55 of file action_resource.cpp.

Referenced by HandleActionResource().


Function Documentation

static void AnimateActionHarvest ( CUnit unit  )  [static]

Animate a unit that is harvesting

Parameters:
unit Unit to animate

Definition at line 139 of file action_resource.cpp.

References CUnitType::Animations, Assert, CAnimations::Harvest, CUnit::Type, and UnitShowAnimation().

Referenced by GatherResource().

static void FindNewResource ( CUnit unit  )  [static]

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

Parameters:
unit Harvester unit

Definition at line 151 of file action_resource.cpp.

References _C_, CUnit::ClearAction(), DebugPrint, NoUnitP, CUnit::Orders, CUnit::Slot, CUnit::State, SUB_START_RESOURCE, CUnit::SubAction, UnitFindResource(), CUnit::X, and CUnit::Y.

Referenced by GatherResource().

static void GatherResource ( CUnit unit  )  [static]

void HandleActionResource ( CUnit unit  ) 

Handle command die.

Control the unit action: getting a resource.

This is the generic function for harvesting resources

Parameters:
unit Pointer to unit.

Definition at line 282 of file action_resource.cpp.

References CUnit::_order_data_::_order_harvest_::CurrentProduction, CUnit::Data, GatherResource(), CUnit::_order_data_::Harvest, MoveToResource(), NewResetPath, CUnit::Orders, ResourceGiveUp(), StartGathering(), SUB_GATHER_RESOURCE, SUB_MOVE_TO_RESOURCE, SUB_START_GATHERING, SUB_START_RESOURCE, SUB_UNREACHABLE_RESOURCE, CUnit::SubAction, and CUnit::Wait.

static int MoveToResource ( CUnit unit  )  [static]

Move unit to resource.

Parameters:
unit Pointer to unit.
Returns:
-1 if unreachable, 0 if moving, 1 if reached.

Definition at line 73 of file action_resource.cpp.

References CUnit::Anim, DoActionMove(), CUnit::Orders, PF_REACHED, PF_UNREACHABLE, CUnit::Player, and CUnit::_unit_anim_::Unbreakable.

Referenced by HandleActionResource().

static void ResourceGiveUp ( CUnit unit  )  [static]

Give up on gathering.

Parameters:
unit Pointer to unit.

Definition at line 265 of file action_resource.cpp.

References _C_, CUnit::ClearAction(), DebugPrint, CUnit::Orders, and CUnit::Slot.

Referenced by HandleActionResource().

static bool StartGathering ( CUnit unit  )  [static]


Variable Documentation

int AlliedUnitRecyclingEfficiency[MaxCosts] = {0, 50}

int EnemyUnitRecyclingEfficiency[MaxCosts] = {0, 40}


Generated on Sat Feb 21 00:28:15 2009 for Bos Wars by  doxygen 1.5.6