Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- |
2 | -- Hirable |
3 | -- Specialization for hirable vehicles (eg bots) |
4 | -- |
5 | -- @author Stefan Geiger |
6 | -- @date 10/01/09 |
7 | -- |
8 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
9 | |
10 | Hirable = {}; |
11 | |
12 | Hirable.numHirablesHired = 0; |
13 | |
14 | function Hirable.prerequisitesPresent(specializations) |
15 | return true; |
16 | end; |
17 | |
18 | function Hirable:load(xmlFile) |
19 | |
20 | self.hire = SpecializationUtil.callSpecializationsFunction("hire"); |
21 | self.dismiss = SpecializationUtil.callSpecializationsFunction("dismiss"); |
22 | |
23 | self.pricePerMS = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.pricePerHour"), 2000)/60/60/1000; |
24 | self.isHired = false; |
25 | self.isHirableBlocked = false; |
26 | end; |
27 | |
28 | function Hirable:delete() |
29 | self:dismiss(); |
30 | end; |
31 | |
32 | function Hirable:mouseEvent(posX, posY, isDown, isUp, button) |
33 | end; |
34 | |
35 | function Hirable:keyEvent(unicode, sym, modifier, isDown) |
36 | end; |
37 | |
38 | function Hirable:update(dt) |
39 | if self.isHired then |
40 | self.forceIsActive = true; |
41 | self.stopMotorOnLeave = false; |
42 | self.steeringEnabled = false; |
43 | self.deactivateOnLeave = false; |
44 | end; |
45 | end; |
46 | |
47 | function Hirable:updateTick(dt) |
48 | if self.isHired and self.isServer and not self.isHirableBlocked then |
49 | local difficultyMultiplier = Utils.lerp(0.6, 1, (g_currentMission.missionStats.difficulty-1)/2) -- range from 0.6 (easy) to 1 (hard) |
50 | g_currentMission:addSharedMoney(-dt*difficultyMultiplier*self.pricePerMS, "wagePayment"); |
51 | end; |
52 | end; |
53 | |
54 | function Hirable:draw() |
55 | end; |
56 | |
57 | function Hirable:hire() |
58 | if not self.isHired then |
59 | Hirable.numHirablesHired = Hirable.numHirablesHired + 1; |
60 | end; |
61 | self.isHired = true; |
62 | self.isHirableBlocked = false; |
63 | |
64 | self.forceIsActive = true; |
65 | self.stopMotorOnLeave = false; |
66 | self.steeringEnabled = false; |
67 | self.deactivateOnLeave = false; |
68 | self.disableCharacterOnLeave = false; |
69 | |
70 | end; |
71 | |
72 | function Hirable:dismiss() |
73 | if self.isHired then |
74 | Hirable.numHirablesHired = math.max(Hirable.numHirablesHired - 1, 0); |
75 | end; |
76 | |
77 | self.isHired = false; |
78 | |
79 | self.forceIsActive = false; |
80 | self.stopMotorOnLeave = true; |
81 | self.steeringEnabled = true; |
82 | self.deactivateOnLeave = true; |
83 | |
84 | self.disableCharacterOnLeave = true; |
85 | |
86 | if not self.isEntered and not self.isControlled then |
87 | self:setCharacterVisibility(false); |
88 | end; |
89 | end; |
90 | |
91 | function Hirable:getXMLStatsAttributes() |
92 | if self.isHired then |
93 | return 'isHired="true"'; |
94 | end |
95 | return nil; |
96 | end
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de