Sprache Deutsch Language English

Script Dokumentation LS 2015 - Hirable (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/specializations/Hirable.lua

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
10Hirable = {};
11
12Hirable.numHirablesHired = 0;
13
14function Hirable.prerequisitesPresent(specializations)
15 return true;
16end;
17
18function 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;
26end;
27
28function Hirable:delete()
29 self:dismiss();
30end;
31
32function Hirable:mouseEvent(posX, posY, isDown, isUp, button)
33end;
34
35function Hirable:keyEvent(unicode, sym, modifier, isDown)
36end;
37
38function 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;
45end;
46
47function 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;
52end;
53
54function Hirable:draw()
55end;
56
57function 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
70end;
71
72function 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;
89end;
90
91function Hirable:getXMLStatsAttributes()
92 if self.isHired then
93 return 'isHired="true"';
94 end
95 return nil;
96end
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
Script Dokumentation Übersicht