-
Notifications
You must be signed in to change notification settings - Fork 0
/
Familiar.as
executable file
·85 lines (63 loc) · 2.07 KB
/
Familiar.as
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
/* the player's familiar is a movieclip that follows him
around, but is not scaled. */
class Familiar extends Depthable {
var spoken : String;
var speakframesleft : Number;
public function onLoad() {
/* position all sayboxes appropriately */
var xx = this["saybox"]._x;
var yy = this["saybox"]._y;
this["sayboxl"]._x = xx - 2;
this["sayboxr"]._x = xx + 2;
this["sayboxl"]._y = yy;
this["sayboxr"]._y = yy;
this["sayboxul"]._x = xx - 2;
this["sayboxur"]._x = xx + 2;
this["sayboxul"]._y = yy - 2;
this["sayboxur"]._y = yy - 2;
this["sayboxu"]._y = yy - 2;
this["sayboxd"]._y = yy + 2;
this["sayboxu"]._x = xx;
this["sayboxd"]._x = xx;
this["sayboxdl"]._y = yy + 2;
this["sayboxdr"]._y = yy + 2;
this["sayboxdl"]._x = xx - 2;
this["sayboxdr"]._x = xx + 2;
}
public function relocate() {
/* XXX need to..
- place appropriately so it doesn't seem to change
distance from player when walking up/down
- stretch saybox appropritely for short/long text
- treat right side of screen too
- not use baked-in constants
*/
/* start centered */
var xx = _root["player"]._x - (this["saybox"]._width / 2);
/* getting near left edge? then snap to left edge. */
if (_root["player"]._x < (this["saybox"]._width / 2))
xx = 8;
/* XXX determine this programatically...
_root._width is way too huge; huh??
*/
var rootwidth = 550;
/* right edge? */
if ((xx + this["saybox"]._width) > rootwidth)
xx = rootwidth - this["saybox"]._width;
this._x = xx;
/* the y coordinate is always based on the player's location */
this._y = _root["player"]._y - (_root["player"].sizebox._height * _root["player"]._yscale / 125);
if (this._y < 18) this._y = 18;
}
/* count down frames until the saybox
is erased. */
public function onEnterFrame() {
if (speakframesleft > 0) {
speakframesleft --;
if (speakframesleft == 0) {
/* PERF make invisible too? */
spoken = "";
}
}
}
}