File: DlgPilot.c

package info (click to toggle)
openclonk 8.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 169,656 kB
  • sloc: cpp: 180,484; ansic: 108,988; xml: 31,371; python: 1,223; php: 767; makefile: 148; sh: 101; javascript: 34
file content (148 lines) | stat: -rw-r--r-- 4,243 bytes parent folder | download | duplicates (5)
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
// A pilot which tells about the sky islands.

#appendto Dialogue

public func Dlg_Pilot_Init(object clonk)
{
	AddEffect("IntPilot", clonk, 100, 5, this);
	return true;
}

public func Dlg_Pilot_1(object clonk)
{
	MessageBox(Format("$DlgPilotHello$", dlg_target->GetName()), clonk, dlg_target);
	return true;
}

public func Dlg_Pilot_2(object clonk)
{
	MessageBox("$DlgPilotReply$", clonk, clonk);
	return true;
}

public func Dlg_Pilot_3(object clonk)
{
	MessageBox("$DlgPilotBats$", clonk, dlg_target);
	return true;
}

public func Dlg_Pilot_4(object clonk)
{
	MessageBox("$DlgPilotAgainstBats$", clonk, clonk);
	return true;
}

public func Dlg_Pilot_5(object clonk)
{
	MessageBox("$DlgPilotBowArrow$", clonk, dlg_target);
	return true;
}

public func Dlg_Pilot_6(object clonk)
{
	MessageBox("$DlgPilotHaveBow$", clonk, clonk);
	return true;
}

public func Dlg_Pilot_7(object clonk)
{
	MessageBox("$DlgPilotArmory$", clonk, dlg_target);
	return true;
}

public func Dlg_Pilot_8(object clonk)
{
	MessageBox("$DlgPilotFallOff$", clonk, clonk);
	return true;
}

public func Dlg_Pilot_9(object clonk)
{
	var interact = GetPlayerControlAssignment(clonk->GetOwner(), CON_Interact, true, true);
	MessageBox(Format("$DlgPilotRescue$", interact), clonk, dlg_target);
	StopDialogue();
	SetDialogueProgress(1);
	return true;
}

public func Dlg_Pilot_Closed(object clonk)
{
	GameCall("OnHasTalkedToPilot", clonk);
	return true;
}

public func FxIntPilotStart(object target, proplist effect, int temp)
{
	if (temp)
		return FX_OK;
	// Give the pilot a teleglove.
	effect.glove = target->CreateContents(TeleGlove);
	effect.glove->SetObjectLayer();
	return FX_OK;
}

public func FxIntPilotTimer(object target, proplist effect, int time)
{
	var lorry = target->FindObject(Find_ID(Lorry),  Find_AnyLayer(), Find_Distance(100));
	// Check if a gem comes near and then catch it with the teleglove.
	for (var gem in target->FindObjects(Find_ID(Ruby), Find_Distance(effect.glove->GetTeleGloveReach() - 15), Find_NoContainer(), Find_AnyLayer(), Find_Not(Find_Property("has_been_telegloved")), Sort_Distance()))
	{
		var to_x = lorry->GetX();
		var to_y = lorry->GetY();
		// Only if the gem is not stuck and the path to the lorry is free.
		if (!PathFree(gem->GetX(), gem->GetY(), to_x, to_y) || gem->Stuck())
			continue;
		// Only if the gem is not controlled by another glove.
		if (GetEffect("TeleGloveWeight", gem))		
			continue;
		if (!GetEffect("IntControlGem", target))
			AddEffect("IntControlGem", target, 100, 1, this, nil, gem, effect.glove);
		break;
	}
	return FX_OK;
}

public func FxIntControlGemStart(object target, proplist effect, int temp, object gem, object glove)
{
	if (temp)
		return FX_OK;
	effect.gem = gem;
	effect.glove = glove;
	effect.startx = gem->GetX();
	effect.starty = gem->GetY();
	// Determine time it takes to move the gem.
	var lorry = target->FindObject(Find_ID(Lorry), Find_AnyLayer(), Find_Distance(100));
	effect.move_time = 2 * Distance(effect.startx, effect.starty, lorry->GetX(), lorry->GetY()) / 3;
	// Start using the teleglove.
	effect.glove->ControlUseStart(target, effect.gem->GetX() - target->GetX(), effect.gem->GetY() - target->GetY());
	// Play a confirm sound and show a short message.
	target->PlaySoundConfirm();
	target->Message(Translate(Format("DlgPilotGem%d", Random(3))));
	return FX_OK;
}

public func FxIntControlGemTimer(object target, proplist effect, int time)
{
	var lorry = target->FindObject(Find_ID(Lorry), Find_AnyLayer(), Find_Distance(100));
	if (!lorry || time > effect.move_time)
		return FX_Execute_Kill;
	var ox = effect.startx;
	var oy = effect.starty;
	var tx = lorry->GetX();
	var ty = lorry->GetY() - 12;
	var new_x = ox + time * (tx - ox) / (effect.move_time);
	var new_y = oy + time * (ty - oy) / (effect.move_time);
	effect.glove->ControlUseHolding(target, new_x - target->GetX(), new_y - target->GetY());
	return FX_OK;
}

public func FxIntControlGemStop(object target, proplist effect, int reason, bool temp)
{
	if (temp)
		return FX_OK;
	var lorry = target->FindObject(Find_ID(Lorry), Find_AnyLayer(), Find_Distance(100));
	if (lorry && ObjectDistance(lorry, effect.gem) < 24)
		effect.gem.has_been_telegloved = true;
	effect.glove->ControlUseStop(target);
	return FX_OK;
}