____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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"
#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} |
Definition in file action_resource.cpp.
| #define SUB_GATHER_RESOURCE 60 |
| #define SUB_MOVE_TO_RESOURCE 5 |
| #define SUB_START_GATHERING 55 |
| #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 |
| static void AnimateActionHarvest | ( | CUnit * | unit | ) | [static] |
Animate a unit that is harvesting
| 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.
| 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] |
Gather the resource
| unit | Harvester unit |
Definition at line 174 of file action_resource.cpp.
References _C_, AlliedUnitRecyclingEfficiency, CUnit::Anim, AnimateActionHarvest(), CalculateRequestedAmount(), CUnit::ClearAction(), CUnit::_order_data_::_order_harvest_::CurrentProduction, CUnit::Data, DebugPrint, EnemyUnitRecyclingEfficiency, FindNewResource(), CUnit::_order_data_::Harvest, HP_INDEX, CUnit::IsAliveOnMap(), CPlayer::IsAllied(), CPlayer::IsEnemy(), LetUnitDie(), CVariable::Max, MaxCosts, NoUnitP, CUnit::OrderCount, CUnit::Orders, CUnit::Player, CUnitType::ProductionCosts, CPlayer::ProductionRate, CUnit::ResourcesHeld, CUnit::Slot, CUnit::Type, CUnit::_unit_anim_::Unbreakable, UnitHoldsResources(), CVariable::Value, and CUnit::Variable.
Referenced by HandleActionResource().
| void HandleActionResource | ( | CUnit * | unit | ) |
Handle command die.
Control the unit action: getting a resource.
This is the generic function for harvesting resources
| 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.
| unit | Pointer to unit. |
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.
| 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] |
Start harvesting the resource.
| unit | Pointer to unit. |
Definition at line 97 of file action_resource.cpp.
References Assert, CUnit::ClearAction(), CUnit::IsVisibleAsGoal(), CUnit::IX, CUnit::IY, MapDistanceBetweenUnits(), NoUnitP, CUnit::Orders, CUnit::Player, CUnit::RefsDecrease(), CUnit::RefsIncrease(), SUB_START_RESOURCE, CUnit::SubAction, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitFindResource(), UnitHeadingFromDeltaXY(), CUnit::X, and CUnit::Y.
Referenced by HandleActionResource().
| int AlliedUnitRecyclingEfficiency[MaxCosts] = {0, 50} |
Definition at line 59 of file action_resource.cpp.
Referenced by GatherResource(), tolua_get_stratagus_AlliedUnitRecyclingEfficiency(), and tolua_set_stratagus_AlliedUnitRecyclingEfficiency().
| int EnemyUnitRecyclingEfficiency[MaxCosts] = {0, 40} |
Definition at line 60 of file action_resource.cpp.
Referenced by GatherResource(), tolua_get_stratagus_EnemyUnitRecyclingEfficiency(), and tolua_set_stratagus_EnemyUnitRecyclingEfficiency().
1.5.6