1/*
2 *
3 *  Copyright (C) 2006  Alun Bestor/The Exult Team
4 *
5 *  This program is free software; you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation; either version 2 of the License, or
8 *  (at your option) any later version.
9 *
10 *  This program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with this program; if not, write to the Free Software
17 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 *	Author: Marzo Junior (reorganizing/updating code by Alun Bestor)
20 *	Last Modified: 2006-03-19
21 */
22
23void Bellows shape#(0x1AF) ()
24{
25	//Go to the bellows to operate it
26	if (event == DOUBLECLICK)
27		gotoObject(item, 1, 0, -1, Bellows, item, SCRIPTED);
28	else if (event == SCRIPTED)
29	{
30		var item_frame = get_item_frame();
31		var starting_frame;
32		//Forge of Virtue bellows
33		if (item_frame >= 3 && item_frame <= 5)
34			starting_frame = 3;
35		//Regular bellows
36		else
37			starting_frame = 0;
38
39		halt_scheduled();	//Stop whatever animation the bellows were doing
40		AVATAR->halt_scheduled();	//And stop what the Avatar was doing too
41
42		//Animate the bellows pumping
43		script item
44		{
45			sfx SOUND_BELLOWS;
46			continue;	//I actually have no idea what continue does, since it seems to animate regardless
47
48			frame starting_frame;
49			repeat (NUM_BELLOWS_PUMPS - 1)
50			{
51				next frame; wait 1;
52				next frame; wait 1;
53				previous frame; wait 1;
54				previous frame; wait 1;
55			};
56		}
57
58		//Animate the Avatar pumping them
59		script AVATAR
60		{
61			face directionFromAvatar(item);
62			repeat (NUM_BELLOWS_PUMPS - 1)
63			{
64				actor frame standing;
65				actor frame bowing;
66				wait 3;
67				actor frame standing;
68			};
69		}
70
71		var nearby_firepits = find_nearby(SHAPE_FIREPIT, 4, MASK_ALL_UNSEEN);
72		//The firepit animation behaviour is now moved off to its own function,
73		//as it *really* does not belong here
74		for (firepit in nearby_firepits)
75			script firepit { call Firepit; }
76	}
77}
78