File: fish1_timer.txt

package info (click to toggle)
nikwi 0.0.20120213-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 8,628 kB
  • ctags: 1,246
  • sloc: cpp: 7,111; ansic: 880; objc: 247; makefile: 142; sh: 48
file content (39 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (6)
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
#
# Timer script for fish
#

Object	obj = getThisObject();
int	tick = getObjectVar(obj, 0);
int	wantedTick = getObjectVar(obj, 1);

if (tick >= wantedTick)
{
	int	x = getObjectXPosition(obj) + 16;
	int	y = getObjectYPosition(obj);
	
	createParticleObject(makeCode("par4"), x, y, 270.0, 0.4+rand()/2.0, randi(40, 60));
	createParticleObject(makeCode("par4"), x + 3, y - 5, 270.0, 0.4+rand()/2.0, randi(30, 60));
	createParticleObject(makeCode("par4"), x - 2, y - 9, 270.0, 0.4+rand()/2.0, randi(50, 70));
	setObjectVar(obj, 1, randi(110, 200));
	tick = 0;
}

if (canObjectSeeObject(obj, getHero()))
{
	setObjectVar(obj, 2, true);
	if (getObjectOrientation(obj) == ORIENTATION_LEFT)
		setObjectMovement(obj, 0.0-2.5, 0.0);
	else
		setObjectMovement(obj, 2.5, 0.0);
}
else if (getObjectVar(obj, 2))
{
	setObjectVar(obj, 2, false);
	if (getObjectOrientation(obj) == ORIENTATION_LEFT)
		setObjectMovement(obj, 0.0-1.0, 0.0);
	else
		setObjectMovement(obj, 1.0, 0.0);
}

setObjectVar(obj, 0, tick + 1);