-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeightModule.py
More file actions
169 lines (152 loc) · 6.55 KB
/
Copy pathHeightModule.py
File metadata and controls
169 lines (152 loc) · 6.55 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Python bytecode 3.3 (3230)
# Embedded file name: HeightModule.py
# Compiled at: 2016-02-17 11:41:31
# Size of source mod 2**32: 6798 bytes
import AddSimSlider, services, injector, traits.trait_tracker, random, sims.sim_info, sims4.commands
from server_commands.argument_helpers import get_optional_target, OptionalTargetParam, OptionalSimInfoParam
from sims.sim_info_types import Age
from sims4.resources import Types
from sims.sim_info import SimInfo
import zone, alarms, clock, date_and_time
def randomizeHeightIfDefault(sim_info):
trait = services.trait_manager().get(15258887174838921384L)
hastrait = sim_info.trait_tracker.has_trait(trait)
if hastrait is False:
if trait is None:
return
sim_info.add_trait(trait)
howTall = random.randrange(0, 13)
if howTall <= 5:
HEIGHT = 'AVERAGE'
if howTall > 5 and howTall < 8:
HEIGHT = 'TALL'
if howTall >= 8 and howTall < 11:
HEIGHT = 'SHORT'
if howTall == 11:
HEIGHT = 'VERYSHORT'
if howTall == 12:
HEIGHT = 'VERYTALL'
manager = services.get_instance_manager(Types.STATISTIC)
stat_file = manager.get(18157023230166068511L)
stat_commodity = sim_info.get_statistic(stat_file)
if HEIGHT == 'AVERAGE':
randHeight = random.randrange(-35, 35)
else:
if HEIGHT == 'SHORT':
randHeight = random.randrange(-60, -35)
else:
if HEIGHT == 'TALL':
randHeight = random.randrange(35, 60)
else:
if HEIGHT == 'VERYTALL':
randHeight = random.randrange(60, 100)
else:
if HEIGHT == 'VERYSHORT':
randHeight = random.randrange(-100, -60)
stat_commodity.set_value(randHeight, add=True)
AddSimSlider.setModifierWithSimInfo('height', randHeight, sim_info)
return
@sims4.commands.Command('sa', command_type=sims4.commands.CommandType.Live)
def randomize_facial_attributes(amount: None, opt_sim: OptionalSimInfoParam=None, _connection=None):
sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection)
sim_info._age_progress.set_value(amount + sim_info.age_progress)
sim_info.send_age_progress()
@sims4.commands.Command('rhall', command_type=sims4.commands.CommandType.Live)
def SimGrowthCommand():
trait = services.trait_manager().get(15258887174838921384L)
if trait != None:
SimGrowth(None)
return
@sims4.commands.Command('rhone', command_type=sims4.commands.CommandType.Live)
def SimGrowthCommand(opt_sim: OptionalSimInfoParam=None, _connection=None):
sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection)
trait = services.trait_manager().get(15258887174838921384L)
if trait != None:
SimGrowthOneSim(sim_info)
return
def SimGrowth(_):
ageSpeed = services.get_age_service().aging_speed
pop = 0
if not services.get_age_service()._unplayed_aging_enabled:
ageSpeed = None
for sim_info in services.sim_info_manager().get_all():
pop = pop + 1
sim_age = sim_info._days_until_ready_to_age()
SimAge = sim_info.age
randomizeHeightIfDefault(sim_info)
manager = services.get_instance_manager(Types.STATISTIC)
stat_file = manager.get(18157023230166068511L)
stat_commodity = sim_info.get_statistic(stat_file)
simHeightStat = stat_commodity.get_value()
if SimAge == Age.CHILD:
childHeightSlider = 15.36 * sim_age + simHeightStat - 100
teenHeightSlider = 0
height = None
else:
if SimAge == Age.TEEN:
teenHeightSlider = 7.68 * sim_age
childHeightSlider = 0
height = None
else:
if SimAge == Age.YOUNGADULT or SimAge == Age.ADULT or SimAge == Age.ELDER:
height = None
teenHeightSlider = 0
childHeightSlider = 0
if height is not None:
AddSimSlider.setModifierWithSimInfo('height', height, sim_info)
if childHeightSlider is not None:
AddSimSlider.setModifierWithSimInfo('chs', childHeightSlider, sim_info)
if teenHeightSlider is not None:
AddSimSlider.setModifierWithSimInfo('ths', teenHeightSlider, sim_info)
continue
return
def SimGrowthOneSim(sim_info=None):
ageSpeed = services.get_age_service().aging_speed
pop = 0
if not services.get_age_service()._unplayed_aging_enabled:
ageSpeed = None
if sim_info is not None:
pop = pop + 1
ScumLog.log('1')
sim_age = sim_info._days_until_ready_to_age()
SimAge = sim_info.age
randomizeHeightIfDefault(sim_info)
manager = services.get_instance_manager(Types.STATISTIC)
stat_file = manager.get(18157023230166068511L)
stat_commodity = sim_info.get_statistic(stat_file)
simHeightStat = stat_commodity.get_value()
if SimAge == Age.CHILD:
childHeightSlider = 15.36 * sim_age + simHeightStat - 100
teenHeightSlider = 0
else:
if SimAge == Age.TEEN:
teenHeightSlider = 7.68 * sim_age
childHeightSlider = 0
else:
if SimAge == Age.YOUNGADULT or SimAge == Age.ADULT or SimAge == Age.ELDER:
teenHeightSlider = 0
childHeightSlider = 0
if childHeightSlider is not None:
AddSimSlider.setModifierWithSimInfo('chs', childHeightSlider, sim_info)
if teenHeightSlider is not None:
AddSimSlider.setModifierWithSimInfo('ths', teenHeightSlider, sim_info)
return
height_alarm = None
def height_alarm_set():
global height_alarm
if height_alarm is not None:
alarms.cancel_alarm(height_alarm)
height_alarm = None
time_service = services.time_service()
time = date_and_time.create_date_and_time(hours=1)
span2 = time_service.sim_now.time_till_next_day_time(time)
span = clock.interval_in_sim_days(1)
height_alarm = alarms.add_alarm(height_alarm_set, span2, SimGrowth, repeating=True, repeating_time_span=span, use_sleep_time=True)
return
@injector.inject_to(zone.Zone, 'on_hit_their_marks')
def height_on_their_marks(original, self):
original(self)
trait = services.trait_manager().get(15258887174838921384L)
if trait != None:
height_alarm_set()
return