File: gate.cfg

package info (click to toggle)
frogatto-data 1.3.1%2Bdfsg-4
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 254,428 kB
  • sloc: xml: 584; python: 396; perl: 249; sh: 126; ruby: 69; makefile: 21
file content (156 lines) | stat: -rw-r--r-- 4,807 bytes parent folder | download | duplicates (3)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{
id: "gate",
zorder: -4,
has_feet: false,
always_active: true,
solid_dimensions: ["player","common","~thrown"],
collide_dimensions: ["key"],
adjust_feet_on_animation_change: false,
timer_frequency: 5,
properties: {
	locks: "filter(level.chars, 'char', char.type = 'padlock' and abs(distance(context.me, char)) < 100)",
	test_locks: "def(key)	map(locks, 'lock', 
								if(lock.variations = key.variations, 
									[fire_event(lock, 'unlock'), 
										if(level.player.vars.swallowed = key,empty_belly(),remove_object(key))])) where empty_belly = def() [set(level.player.variations, []), set(level.player.vars.swallowed, null)]",
	is_locked: "if(locks and level.cycle > 0, 1, if(level.player.vars.stored_events[vars.event] = 1, 0,1))",
},

# 1 = unlocked in the event.  Also, we check the cycle to avoid contention with a lock that's about to kill itself.
#if we fail to change the animation like we desire, we revert to our
#previous animation, and then schedule another attempt to change the
#animation next cycle.
on_start_level: "[if(is_locked, animation('locked'), animation('unlocked')), spawn('gate.porticullis', img_mid_x, img_mid_y, facing, [set_var('is_locked', is_locked), set_var('desired_y',y-120), set_var('desired_y2',y), set_var('origin_y',y),set(clip_area, [me.x,me.y+18,me.img_w,me.img_h])]), spawn('gate.overlay',img_mid_x,img_mid_y,facing)]",

#on_end_anim="debug(level.player.vars.stored_events[vars.event])"
on_change_animation_failure: "[animation(previous_animation), schedule(1, animation(animation))]",
on_end_locked_anim: "if(is_locked,animation('locked'),[animation('opening'), fire_event( vars.porticullis,'unlock'),sound('gate-open.ogg')])",
on_end_unlocked_anim: "if(is_locked,[animation('closing'),fire_event( vars.porticullis,'lock'),schedule(10,sound('gate-close.ogg'))],animation('unlocked'))",
on_end_closing_anim: "animation('locked')",
on_end_opening_anim: "animation('unlocked')",
on_lock: "if(vars.event, level.player.store_event(vars.event,0))",
on_unlock: "if(vars.event, level.player.store_event(vars.event,1))",
on_button_pressed: "fire_event('unlock')",
on_button_released: "fire_event('lock')",
on_child_spawned: "switch(child.type,
	  'gate.porticullis', set(vars.porticullis, child) )",

#
#
# Key handling:
on_collide_object: "[
		test_locks(collide_with),if(locks,schedule(1,fire_event('check_locks')))]",
on_check_locks: "if(not locks, fire_event('unlock'))",
editor_info: {
	category: "props",
	var: {
		name: "event",

		# use this even if we use a lock; it's necessary for the gate to default to open
		type: "text",
		value: "''",
	},
},
animation: [
	{
		"@base": true,
		image: "props/gate.png",
		pad: 3,
		gate_area: [0,0,39,120,"solid"],
		palettes: "@include data/palettes.cfg:dungeon_palettes",
		frames: 1,
		rect: [2,2,39,120],
	},
	{
		id: "locked",
		solid_area: [8,20,21,85],
		duration: 30,
	},
	{
		id: "opening",
		solid_area: [8,20,21,40],
		duration: 28,
	},
	{
		id: "closing",
		solid_area: [8,20,21,40],
		duration: 24,
		play_backwards: true,
	},
	{
		id: "unlocked",
		solid_area: [8,20,21,30],
		duration: 30,
	},
],
object_type: [
	{
		id: "overlay",
		zorder: 11,
		has_feet: false,
		always_active: true,
		on_end_anim: "animation('normal')",
		animation: {
			image: "props/gate.png",
			pad: 3,
			id: "normal",
			rect: [43,2,80,104],
			frames: 1,
			duration: 1000,
			palettes: "@include data/palettes.cfg:dungeon_palettes",
		},
	},
	{
		id: "porticullis",
		zorder: -3,
		has_feet: false,
		always_active: true,
		adjust_feet_on_animation_change: false,
		timer_frequency: 5,
		properties: {
			set_at_open_pos: "def() [animation('normal'),set(vars.gate_vel,2),set(y,origin_y-120)]",
			set_at_closed_pos: "def() [animation('normal'),set(vars.gate_vel,2),set(y,origin_y)]",
		},
		vars: {
			is_locked: 0,
			desired_y: 9,
			desired_y2: 67,

			# 9 + 67, that is
			gate_vel: 2,
		},
		on_create: "if(is_locked, set_at_closed_pos(),set_at_open_pos())",
		on_lock: "[set(is_locked,1),animation('moving')]",
		on_unlock: "[set(is_locked,0),animation('moving')]",
		on_process_moving: "[
				if(is_locked,
					if(y < vars.desired_y2,
						[set(y, y+(1+gate_vel)),set(vars.gate_vel, vars.gate_vel+1)],
						set_at_closed_pos()  ),
					if(y > vars.desired_y,
						[set(y, y-(1+gate_vel)),set(vars.gate_vel, vars.gate_vel+1)],
						set_at_open_pos() ))]",
		on_end_normal_anim: "animation('normal')",
		animation: [
			{
				image: "props/gate.png",
				pad: 3,
				id: "normal",
				rect: [84,2,121,104],
				frames: 1,
				duration: 200,
				palettes: "@include data/palettes.cfg:dungeon_palettes",
			},
			{
				image: "props/gate.png",
				pad: 3,
				id: "moving",
				rect: [84,2,121,104],
				frames: 1,
				duration: 200,
				palettes: "@include data/palettes.cfg:dungeon_palettes",
			},
		],
	},
],
}