File: action_returngoods.c

package info (click to toggle)
ale-clone 1.15pre16.3-1
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 2,432 kB
  • ctags: 3,217
  • sloc: ansic: 37,483; sh: 1,105; makefile: 343
file content (117 lines) | stat: -rw-r--r-- 2,783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
**	A clone of a famous game.
*/
/**@name action_returngoods.c -	The return goods action. */
/*
**	(c) Copyright 1998 by Lutz Sammer
**
**	$Id: action_returngoods.c,v 1.8 1999/06/20 02:09:22 root Exp $
*/

//@{

#include <stdio.h>
#include <stdlib.h>

#include "clone.h"
#include "video.h"
#include "sound_id.h"
#include "unitsound.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "actions.h"

/**
**	Return goods to gold/wood deposit.
**
**	@param unit	pointer to unit.
*/
global void HandleActionReturnGoods(Unit* unit)
{
    int type;
    Unit* destu;

    //
    //	Select target to return goods.
    //
    type=unit->Type->Type;
    if( type==UnitPeonWithGold || type==UnitPeasantWithGold ) {
	if( !(destu=FindGoldDeposit(unit->Player,unit->X,unit->Y)) ) {
	    unit->Command.Action=UnitActionStill;
	    return;
	}
	unit->Command.Data.Move.Fast=1;
	unit->Command.Data.Move.Goal=destu;
	unit->Command.Data.Move.Range=1;
#if 1
	NearestOfUnit(destu,unit->X,unit->Y
	    ,&unit->Command.Data.Move.DX
	    ,&unit->Command.Data.Move.DY);
#else
	unit->Command.Data.Move.DX=destu->X;
	unit->Command.Data.Move.DY=destu->Y;
#endif
	unit->Command.Action=UnitActionMineGold;
	unit->SubAction=65;
	DebugLevel3("Wait: %d\n",unit->Wait);
	unit->Wait=1;
	return;
    }

    if( type==UnitPeonWithWood || type==UnitPeasantWithWood ) {
	if( !(destu=FindWoodDeposit(unit->Player,unit->X,unit->Y)) ) {
	    unit->Command.Action=UnitActionStill;
	    return;
	}
	unit->Command.Data.Move.Fast=1;
	unit->Command.Data.Move.Goal=destu;
	unit->Command.Data.Move.Range=1;
#if 1
	NearestOfUnit(destu,unit->X,unit->Y
		,&unit->Command.Data.Move.DX
		,&unit->Command.Data.Move.DY);
#else
	unit->Command.Data.Move.DX=destu->X;
	unit->Command.Data.Move.DY=destu->Y;
#endif
	DebugLevel3("Return to %Zd=%d,%d\n"
	    ,destu-UnitsPool
	    ,unit->Command.Data.Move.DX
	    ,unit->Command.Data.Move.DY);
	unit->Command.Action=UnitActionHarvest;
	unit->SubAction=2;
	DebugLevel3("Wait: %d\n",unit->Wait);
	unit->Wait=1;
	return;
    }

    if( type==UnitTankerHumanFull || type==UnitTankerOrcFull ) {
	if( !(destu=FindOilDeposit(unit->Player,unit->X,unit->Y)) ) {
	    unit->Command.Action=UnitActionStill;
	    return;
	}
	unit->Command.Data.Move.Fast=1;
	unit->Command.Data.Move.Goal=destu;
	unit->Command.Data.Move.Range=1;
#if 1
	NearestOfUnit(destu,unit->X,unit->Y
		,&unit->Command.Data.Move.DX
		,&unit->Command.Data.Move.DY);
#else
	unit->Command.Data.Move.DX=destu->X;
	unit->Command.Data.Move.DY=destu->Y;
#endif
	DebugLevel3("Return to %Zd=%d,%d\n"
	    ,destu-UnitsPool
	    ,unit->Command.Data.Move.DX
	    ,unit->Command.Data.Move.DY);
	unit->Command.Action=UnitActionHaulOil;
	unit->SubAction=2;
	DebugLevel3("Wait: %d\n",unit->Wait);
	unit->Wait=1;
	return;
    }
}

//@}