-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHirable2.lua
89 lines (67 loc) · 2.02 KB
/
Hirable2.lua
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
--
-- Hirable2
-- Specialization for Hirable2 vehicles (eg bots)
--
-- @author Stefan Geiger
-- @date 10/01/09
--
-- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
Hirable2 = {};
Hirable2.numHirablesHired = 0;
function Hirable2.prerequisitesPresent(specializations)
return true;
end;
function Hirable2:load(xmlFile)
self.hire = SpecializationUtil.callSpecializationsFunction("hire");
self.dismiss = SpecializationUtil.callSpecializationsFunction("dismiss");
self.pricePerMS = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.pricePerHour"), 2000)/60/60/1000;
self.isHired = false;
end;
function Hirable2:delete()
self:dismiss();
end;
function Hirable2:mouseEvent(posX, posY, isDown, isUp, button)
end;
function Hirable2:keyEvent(unicode, sym, modifier, isDown)
end;
function Hirable2:update(dt)
if self.isHired then
self.forceIsActive = true;
self.stopMotorOnLeave = false;
self.steeringEnabled = false;
self.deactivateOnLeave = false;
if self.isServer then
local difficultyMultiplier = Utils.lerp(0.6, 1, (g_currentMission.missionStats.difficulty-1)/2) -- range from 0.6 (easy) to 1 (hard)
g_currentMission:addSharedMoney(-dt*difficultyMultiplier*self.pricePerMS, "wagePayment");
end;
end;
end;
function Hirable2:draw()
end;
function Hirable2:hire()
if not self.isHired then
Hirable2.numHirablesHired = Hirable2.numHirablesHired + 1;
end;
self.isHired = true;
self.forceIsActive = true;
self.stopMotorOnLeave = false;
self.steeringEnabled = false;
self.deactivateOnLeave = false;
self.disableCharacterOnLeave = false;
end;
function Hirable2:dismiss()
if self.isHired then
Hirable2.numHirablesHired = math.max(Hirable2.numHirablesHired - 1, 0);
end;
self.isHired = false;
self.forceIsActive = false;
self.stopMotorOnLeave = true;
self.steeringEnabled = true;
self.deactivateOnLeave = true;
self.disableCharacterOnLeave = true;
if not self.isEntered and not self.isControlled then
if self.characterNode ~= nil then
setVisibility(self.characterNode, false);
end;
end;
end;