-
Notifications
You must be signed in to change notification settings - Fork 12
/
qb.py
1784 lines (1615 loc) · 94.2 KB
/
qb.py
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import bpy
import os
import struct
from bpy.props import *
import bgl
from pprint import pprint
from . import autorail, helpers
from . constants import *
from . autorail import *
from . helpers import *
from . import script_template
from mathutils import Vector
# PROPERTIES
#############################################
checksumLookupTable = {0x00000000: ''}
# METHODS
#############################################
def script_exists(name):
return "script_" + name in bpy.data.texts
def blub_int(integer):
return "%i({},{:08})".format(integer, integer)
#----------------------------------------------------------------------------------
def blub_float(value):
return "%f({})".format(value)
#----------------------------------------------------------------------------------
def blub_str(string):
return "%s({},\"{}\")".format(len(string), string)
#----------------------------------------------------------------------------------
def _generate_script(_ob):
script_props = _ob.thug_triggerscript_props
tmpl = script_template.get_template(script_props.template_name_txt)
script_name, script_code = script_template.generate_template_script(_ob, tmpl, 'Blub')
return script_name, script_code
#----------------------------------------------------------------------------------
def get_custom_node_props():
node_props_text = bpy.data.texts.get("THUG_NODES", None)
if not node_props_text: return {}
node_props = {}
current_node_name = None
for line in node_props_text.as_string().split('\n'):
if line.startswith("#="):
current_node_name = line[2:]
else:
node_props[current_node_name] = node_props.get(current_node_name, "") + line + '\n'
return node_props
#----------------------------------------------------------------------------------
def get_custom_func_code():
funcs_text = bpy.data.texts.get("THUG_FUNCS", None)
if not funcs_text: return {}
funcs_code = {}
current_node_name = None
for line in funcs_text.as_string().split('\n'):
if line.startswith("#="):
current_node_name = line[2:].lower()
else:
funcs_code[current_node_name] = funcs_code.get(current_node_name, "") + line + '\n'
return funcs_code
#----------------------------------------------------------------------------------
#- Exports the node array to a .qb file!
#----------------------------------------------------------------------------------
def export_qb(filename, directory, target_game, operator=None):
checksums = {}
def v3(v):
return "%vec3({:6f},{:6f},{:6f})".format(*v)
def c(s):
if s not in checksums:
if is_hex_string(s):
checksums[s] = int(s, 0)
else:
checksums[s] = crc_from_string(bytes(s, 'ascii'))
return "$" + s + "$"
i = blub_int
f = blub_float
_string = blub_str
# List of scripts which are generated during export
premade_scripts = [
"TRG_CTF_BlueScript"
,"TRG_CTF_RedScript"
,"TRG_CTF_YellowScript"
,"TRG_CTF_GreenScript"
,"TRG_CTF_Blue_BaseScript"
,"TRG_CTF_Red_BaseScript"
,"TRG_CTF_Yellow_BaseScript"
,"TRG_CTF_Green_BaseScript"
,"TRG_Flag_BlueScript"
,"TRG_Flag_RedScript"
,"TRG_Flag_YellowScript"
,"TRG_Flag_GreenScript"
,"TRG_Flag_Blue_BaseScript"
,"TRG_Flag_Red_BaseScript"
,"TRG_Flag_Yellow_BaseScript"
,"TRG_Flag_Green_BaseScript"
]
# Step 0: go through all objects and ensure that any TriggerScripts referenced actually exist
# (this can happen with imported scenes)
for ob in bpy.data.objects:
# If a custom script is referenced on the whole object, create it if it doesn't actually exist
if hasattr(ob, 'thug_triggerscript_props') and ob.thug_triggerscript_props.template_name_txt == "Custom" and ob.thug_triggerscript_props.custom_name != "":
# Don't bother creating an empty script if it's going to be generated during export
if ob.thug_triggerscript_props.custom_name not in premade_scripts:
get_triggerscript(ob.thug_triggerscript_props.custom_name)
# Handle individual point script references on paths
if ob.type == "CURVE" and ob.thug_path_type in ("Rail", "Ladder", "Waypoint"):
for spline in ob.data.splines:
points = spline.points
p_num = -1
for point in points:
p_num += 1
if len(ob.data.thug_pathnode_triggers) > p_num:
if ob.data.thug_pathnode_triggers[p_num].script_name != "":
get_triggerscript(ob.data.thug_pathnode_triggers[p_num].script_name)
if ob.data.thug_pathnode_triggers[p_num].spawnobjscript != "":
get_triggerscript(ob.data.thug_pathnode_triggers[p_num].spawnobjscript)
generated_scripts = {}
custom_triggerscript_names = []
custom_node_props = get_custom_node_props()
custom_func_code = get_custom_func_code()
str_node_pos = "Pos" if target_game in [ "THUG1", "THUG2" ] else "Position"
func_thug_coords = to_thug_coords if target_game in [ "THUG1", "THUG2" ] else to_thug_coords_scalar
with open(os.path.join(directory, filename + ".txt"), "w") as outp:
from io import StringIO
string_output = StringIO()
p = lambda *args, **kwargs: print(*args, **kwargs, file=string_output)
p("%include \"qb_table.qbi\"")
# Dump all TriggerScript text blocks here!
all_triggerscripts = [s for s in bpy.data.texts if s.name.startswith("script_")]
for ts in all_triggerscripts:
p(":i function $" + ts.name[7:] + "$")
if target_game != "THUG2":
# Make sure we don't export the THUG2 if/else conditions!
p(ts.as_string().replace(":i if", ":i doIf").replace(":i else", ":i doElse"))
else:
p(ts.as_string())
p(":i endfunction")
p("")
p("")
p("#/ custom script code end")
p("")
# Start listing the actual NodeArray...
if target_game == "THUG2":
p("$" + filename + "_NodeArray$ =")
else:
p("$NodeArray$ =")
p(":i :a{")
print("Exporting level QB...")
rail_custom_triggerscript_names, rail_generated_scripts, rail_node_offsets = autorail._export_rails(p, c, target_game, operator)
custom_triggerscript_names += rail_custom_triggerscript_names
generated_scripts.update(rail_generated_scripts)
# Used further down to determine if we need to auto-generate nodes of certain types
has_restart_p1 = False
has_restart_p2 = False
has_restart_multi = False
has_restart_gen = False
has_restart_ctf = False
has_restart_team = False
has_restart_horse = False
has_koth = False
has_ctf_base_red = False
has_ctf_base_yellow = False
has_ctf_base_green = False
has_ctf_base_blue = False
has_ctf_red = False
has_ctf_yellow = False
has_ctf_green = False
has_ctf_blue = False
has_team_red = False
has_team_yellow = False
has_team_green = False
has_team_blue = False
has_team_red_base = False
has_team_yellow_base = False
has_team_green_base = False
has_team_blue_base = False
# Export 'primary' restarts first so they will be used first
# (e.g., the primary Player1 restart will be used over any others)
primary_restarts = [o for o in bpy.data.objects if hasattr(o, 'thug_empty_props') and o.thug_empty_props.empty_type == "Restart" and hasattr(o.thug_restart_props, 'primary_restart') and o.thug_restart_props.primary_restart == True]
for ob in primary_restarts:
if not ob.thug_export_scene:
continue
p("\t:i :s{")
p("\t\t:i {} = {}".format(c(str_node_pos), v3(func_thug_coords(ob.location))))
p("\t\t:i {} = {}".format(c("Angles"), v3(to_thug_coords_ns(ob.rotation_euler))))
p("\t\t:i {} = {}".format(c("Name"), c(get_clean_name(ob))))
p("\t\t:i {} = {}".format(c("Class"), c("Restart")))
p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_restart_props.restart_type)))
auto_restart_name = ""
str_all_types = ":a{"
if ob.thug_restart_props.restart_p1:
has_restart_p1 = True
str_all_types += c("Player1")
if auto_restart_name == "": auto_restart_name = "P1: Restart"
if ob.thug_restart_props.restart_p2:
has_restart_p2 = True
str_all_types += c("Player2")
if auto_restart_name == "": auto_restart_name = "P2: Restart"
if ob.thug_restart_props.restart_gen:
has_restart_gen = True
str_all_types += c("Generic")
if auto_restart_name == "": auto_restart_name = "Gen: Restart"
if ob.thug_restart_props.restart_multi:
has_restart_multi = True
str_all_types += c("Multiplayer")
if auto_restart_name == "": auto_restart_name = "Multi: Restart"
if ob.thug_restart_props.restart_team:
has_restart_team = True
str_all_types += c("Team")
if auto_restart_name == "": auto_restart_name = "Team: Restart"
if ob.thug_restart_props.restart_horse:
has_restart_horse = True
str_all_types += c("Horse")
if auto_restart_name == "": auto_restart_name = "Horse: Restart"
if ob.thug_restart_props.restart_ctf:
has_restart_ctf = True
str_all_types += c("CTF")
if auto_restart_name == "": auto_restart_name = "CTF: Restart"
if auto_restart_name == "":
# If none of the type boxes were checked off, use the primary type!
#raise Exception("Restart node {} has no restart type(s).".format(ob.name))
if ob.thug_restart_props.restart_type == "Player1":
str_all_types += c("Player1")
auto_restart_name = "P1: Restart"
has_restart_p1 = True
elif ob.thug_restart_props.restart_type == "Player2":
str_all_types += c("Player2")
auto_restart_name = "P2: Restart"
has_restart_p2 = True
if ob.thug_restart_props.restart_type == "Generic":
str_all_types += c("Generic")
auto_restart_name = "Gen: Restart"
has_restart_gen = True
if ob.thug_restart_props.restart_type == "Multiplayer":
str_all_types += c("Multiplayer")
auto_restart_name = "Multi: Restart"
has_restart_multi = True
if ob.thug_restart_props.restart_type == "Team":
str_all_types += c("Team")
auto_restart_name = "Team: Restart"
has_restart_team = True
if ob.thug_restart_props.restart_type == "Horse":
str_all_types += c("Horse")
auto_restart_name = "Ho: Restart"
has_restart_horse = True
if ob.thug_restart_props.restart_type == "CTF":
str_all_types += c("CTF")
auto_restart_name = "CTF: Restart"
has_restart_ctf = True
str_all_types += ":a}"
p("\t\t:i {} = {}".format(c("restart_types"), str_all_types))
actual_restart_name = ob.thug_restart_props.restart_name
if ob.thug_restart_props.restart_name == "":
actual_restart_name = auto_restart_name
p("\t\t:i {} = {}".format(c("RestartName"), blub_str(actual_restart_name)))
p("\t:i :s}")
# Yes, this is duplicated again below for the other restarts, will clean it up later!
for ob in bpy.data.objects:
# -----------------------------------------------------------------------------------------------------------
# - Export node definitions for mesh-based objects (level geometry, level object)
# -----------------------------------------------------------------------------------------------------------
if ob.type == "MESH" and not ob.get("thug_autosplit_object_no_export_hack"):
if ob.name.endswith("_SCN") and bpy.data.objects.get(ob.name[:-4]):
#print("Skipping scene mesh " + ob.name + ". It has a collision mesh we will work from")
continue
if ob.name.endswith("_COL"):
print("Special collision mesh: " + ob.name + ". It is not meant to be exported to the QB. Skipping...")
continue
col_ob = ob # Collision object may have different properties than the scene object (Triggers, etc)
if bpy.data.objects.get(ob.name + "_SCN"):
#print("Mesh " + ob.name + " also has a scene mesh. Using its properties instead!")
ob = bpy.data.objects.get(ob.name + "_SCN")
is_levelobject = col_ob.thug_object_class == "LevelObject"
clean_name = get_clean_name(ob)
if not ob.thug_always_export_to_nodearray and \
not operator.is_park_editor and \
not is_levelobject and \
col_ob.thug_created_at_start and \
not custom_node_props.get(clean_name) and \
col_ob.thug_occluder == False and \
ob.thug_lightgroup == "None" and \
ob.thug_tod_controlled == False and \
ob.thug_lighting_mesh == False and \
not ob.name.lower().startswith("NightOn") and \
not ob.name.lower().startswith("NightOff") :
if (not getattr(ob, "thug_is_trickobject", False) and
(col_ob.thug_triggerscript_props.template_name_txt == "None" or \
col_ob.thug_triggerscript_props.template_name_txt == "")) or not \
(getattr(ob, "thug_export_collision", True) or
getattr(ob, "thug_export_scene", True)):
continue
print("Exporting node definition for " + ob.name + " (" + clean_name + ")...")
if is_hex_string(clean_name):
print("Error: Object name must not be a checksum when exporting to the level QB.")
raise Exception("Object {} does not have a proper name. Please assign one before exporting to a level QB.".format(clean_name))
p("\t:i :s{")
if ob.parent:
p("\t\t:i {} = {}".format(c(str_node_pos), v3(func_thug_coords(ob.parent.location + ob.location)))) # v3(get_sphere(ob))))
else:
p("\t\t:i {} = {}".format(c(str_node_pos), v3(func_thug_coords(ob.location)))) # v3(get_sphere(ob))))
if is_levelobject:
p("\t\t:i {} = {}".format(c("Angles"), v3(to_thug_coords_ns(ob.rotation_euler))))
else:
p("\t\t:i {} = {}".format(c("Angles"), v3((0, 0, 0))))
p("\t\t:i {} = {}".format(c("Name"), c(clean_name)))
p("\t\t:i {} = {}".format(c("Class"), c("LevelGeometry") if not is_levelobject else c("LevelObject")))
# Exporting LevelObject specific properties below
if is_levelobject:
if col_ob.thug_levelobj_props.obj_type != '':
p("\t\t:i {} = {}".format(c("Type"), c(col_ob.thug_levelobj_props.obj_type)))
else:
p("\t\t:i {} = {}".format(c("Type"), c("Normal")))
if col_ob.thug_levelobj_props.obj_bouncy:
# Bouncy Object properties go here!
p("\t\t:i {}".format(c("Bouncy")))
#p("\t\t:i {} = :a{{ ".format(c("contacts")))
_ctnum = 0
_prop = "\t\t:i {} = :a{{ "
# Imported scenes will have contacts defined directly in custom props
if len(col_ob.thug_levelobj_props.contacts) > 0:
for _contact in col_ob.thug_levelobj_props.contacts:
_ctnum += 1
if _ctnum > 1:
_prop += ";"
firstc = False
_prop += v3(_contact.contact)
# For other scenes, we need to get the verts from the object data
else:
for _contact in get_vertices_thug(col_ob):
_ctnum += 1
if _ctnum > 1:
_prop += ";"
firstc = False
_prop += v3(_contact)
_prop += ":a}}"
p(_prop.format(c("contacts")))
#p(":a}}")
p("\t\t:i {} = {}".format(c("center_of_mass"), v3(col_ob.thug_levelobj_props.center_of_mass)))
p("\t\t:i {} = {}".format(c("coeff_restitution"), f(col_ob.thug_levelobj_props.coeff_restitution)))
p("\t\t:i {} = {}".format(c("coeff_friction"), f(col_ob.thug_levelobj_props.coeff_friction)))
p("\t\t:i {} = {}".format(c("skater_collision_impulse_factor"), f(col_ob.thug_levelobj_props.skater_collision_impulse_factor)))
p("\t\t:i {} = {}".format(c("skater_collision_rotation_factor"), f(col_ob.thug_levelobj_props.skater_collision_rotation_factor)))
p("\t\t:i {} = {}".format(c("skater_collision_assent"), i(col_ob.thug_levelobj_props.skater_collision_assent)))
p("\t\t:i {} = {}".format(c("skater_collision_radius"), i(col_ob.thug_levelobj_props.skater_collision_radius)))
if col_ob.thug_levelobj_props.mass_over_moment >= 0:
p("\t\t:i {} = {}".format(c("mass_over_moment"), f(col_ob.thug_levelobj_props.mass_over_moment)))
if col_ob.thug_levelobj_props.stuckscript != "":
p("\t\t:i {} = {}".format(c("stuckscript"), c(col_ob.thug_levelobj_props.stuckscript)))
if col_ob.thug_levelobj_props.SoundType != "":
p("\t\t:i {} = {}".format(c("SoundType"), c(col_ob.thug_levelobj_props.SoundType)))
# Only export Links on LevelObjects
if col_ob.thug_rail_connects_to:
if col_ob.thug_rail_connects_to not in bpy.data.objects:
operator.report({"ERROR"}, "Object {} connects to nonexistent path {}".format(col_ob.name, col_ob.thug_rail_connects_to))
else:
connected_to = bpy.data.objects[col_ob.thug_rail_connects_to]
if connected_to.name in rail_node_offsets:
p("\t\t:i {} = :a{{{}:a}}".format(
c("Links"),
i(rail_node_offsets[connected_to.name])))
if col_ob.thug_occluder:
p("\t\t:i {}".format(c("Occluder")))
if col_ob.thug_created_at_start:
p("\t\t:i {}".format(c("CreatedAtStart")))
if col_ob.thug_network_option != "Default":
p("\t\t:i {}".format(c(col_ob.thug_network_option)))
if col_ob.thug_network_option == "NetEnabled":
p("\t\t:i {}".format(c("Permanent")))
if ob.thug_lightgroup != "None" and ob.thug_export_scene:
p("\t\t:i {} = {}".format(c("LightGroup"), c(ob.thug_lightgroup)))
if ob.thug_tod_controlled == True and ob.thug_export_scene:
p("\t\t:i {}".format(c("TODControlled")))
p("\t\t:i {} = {}".format(c("TOD_On"), f(ob.thug_tod_values[0])))
p("\t\t:i {} = {}".format(c("TOD_Off"), f(ob.thug_tod_values[1])))
if ob.thug_lighting_mesh == True and ob.thug_export_scene:
p("\t\t:i {}".format(c("LightingObject")))
if getattr(col_ob, "thug_is_trickobject", False):
p("\t\t:i call {} arguments".format(c("TrickObject")))
p("\t\t\t{} = {}".format(c("Cluster"),
c(col_ob.thug_cluster_name if col_ob.thug_cluster_name else clean_name)))
# Fallback in case someone is setting TrickObject props on the scene mesh instead of the collision
elif getattr(ob, "thug_is_trickobject", False):
p("\t\t:i call {} arguments".format(c("TrickObject")))
p("\t\t\t{} = {}".format(c("Cluster"),
c(ob.thug_cluster_name if ob.thug_cluster_name else clean_name)))
p("\t\t:i {} = {}".format(c("CollisionMode"), c("Geometry")))
if col_ob.thug_triggerscript_props.template_name_txt != "" and col_ob.thug_triggerscript_props.template_name_txt != "None":
if col_ob.thug_triggerscript_props.template_name_txt == "Custom":
script_name = col_ob.thug_triggerscript_props.custom_name
custom_triggerscript_names.append(script_name)
elif col_ob.thug_triggerscript_props.template_name_txt == "Template":
script_name, script_code = script_template.generate_custom_template_script(col_ob, 'Blub')
generated_scripts.setdefault(script_name, script_code)
else:
script_name, script_code = _generate_script(col_ob)
generated_scripts.setdefault(script_name, script_code)
if script_name != "":
p("\t\t:i {} = {}".format(c("TriggerScript"), c(script_name)))
else:
operator.report({'WARNING'}, "Unable to determine a TriggerScript for object {}.".format(col_ob.name))
if col_ob.thug_node_expansion:
p("\t\t:i {}".format(c(col_ob.thug_node_expansion)))
# -----------------------------------------------------------------------------------------------------------
# - Export node definitions for lamps (LevelLights)!
# -----------------------------------------------------------------------------------------------------------
elif ob.type == "LAMP" and ob.data.type == "POINT":
if not ob.thug_export_scene:
continue
clean_name = get_clean_name(ob)
p("\t:i :s{")
p("\t\t:i {} = {}".format(c(str_node_pos), v3(func_thug_coords(ob.location))))
p("\t\t:i {} = {}".format(c("Angles"), v3(to_thug_coords_ns(ob.rotation_euler))))
p("\t\t:i {} = {}".format(c("Name"), c(clean_name)))
p("\t\t:i {} = {}".format(c("Class"), c("LevelLight")))
if ob.thug_created_at_start:
p("\t\t:i {}".format(c("CreatedAtStart")))
if ob.thug_network_option != "Default":
p("\t\t:i {}".format(c(ob.thug_network_option)))
if ob.thug_network_option == "NetEnabled":
p("\t\t:i {}".format(c("Permanent")))
p("\t\t:i {} = {}".format(c("Brightness"), i(int(ob.data.energy))))
p("\t\t:i {} = {}".format(c("InnerRadius"), i(int(ob.data.thug_light_props.light_radius[0]))))
p("\t\t:i {} = {}".format(c("OuterRadius"), i(int(ob.data.thug_light_props.light_radius[1]))))
if ob.data.thug_light_props.light_excludeskater:
p("\t\t:i {}".format(c("ExcludeSkater")))
if ob.data.thug_light_props.light_excludelevel:
p("\t\t:i {}".format(c("ExcludeLevel")))
light_color = [ int((ob.data.color[0] * 255) / 1),
int((ob.data.color[1] * 255) / 1) ,
int((ob.data.color[2] * 255) / 1)]
p("\t\t:i {} = :a{{ {};{};{} :a}}".format(c("Color"),
i(light_color[0]), i(light_color[1]),i(light_color[2])))
p("\t\t:i {} = {}".format(c("TOD_On"), f(ob.thug_tod_values[0])))
p("\t\t:i {} = {}".format(c("TOD_Off"), f(ob.thug_tod_values[1])))
if ob.thug_node_expansion:
p("\t\t:i {}".format(c(ob.thug_node_expansion)))
#p("\t:i :s}")
# -----------------------------------------------------------------------------------------------------------
# - Export node definitions for empties
# -----------------------------------------------------------------------------------------------------------
elif ob.type == "EMPTY" and ob.thug_empty_props.empty_type != "" and ob.thug_empty_props.empty_type != "None":
if ob.thug_empty_props.empty_type == "BouncyObject":
continue
if not ob.thug_export_scene:
continue
clean_name = get_clean_name(ob)
if ob.thug_empty_props.empty_type == "GameObject":
# Need special logic for exporting CTF nodes, as they use a specific naming convention that
# must be followed for everything to work correctly - we should also check for duplicate flags
# and alert in the case we find any, as that can cause unexpected behavior
if ob.thug_go_props.go_type == "Flag_Blue":
if has_ctf_blue:
print("Duplicate CTF Flag_Blue found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_CTF_Blue"
has_ctf_blue = True
elif ob.thug_go_props.go_type == "Flag_Blue_Base":
if has_ctf_base_blue:
print("Duplicate CTF Flag_Blue_Base found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_CTF_Blue_Base"
has_ctf_base_blue = True
elif ob.thug_go_props.go_type == "Team_Blue":
if has_team_blue:
print("Duplicate CTF Team_Blue found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_Flag_Blue"
has_team_blue = True
elif ob.thug_go_props.go_type == "Team_Blue_Base":
if has_team_blue_base:
print("Duplicate CTF Team_Blue_Base found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_Flag_Blue_Base"
has_team_blue_base = True
elif ob.thug_go_props.go_type == "Flag_Red":
if has_ctf_red:
print("Duplicate CTF Flag_Red found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_CTF_Red"
has_ctf_red = True
elif ob.thug_go_props.go_type == "Flag_Red_Base":
if has_ctf_base_red:
print("Duplicate CTF Flag_Red_Base found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_CTF_Red_Base"
has_ctf_base_red = True
elif ob.thug_go_props.go_type == "Team_Red":
if has_team_red:
print("Duplicate CTF Team_Red found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_Flag_Red"
has_team_red = True
elif ob.thug_go_props.go_type == "Team_Red_Base":
if has_team_red_base:
print("Duplicate CTF Team_Red_Base found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_Flag_Red_Base"
has_team_red_base = True
elif ob.thug_go_props.go_type == "Flag_Green":
if has_ctf_green:
print("Duplicate CTF Flag_Green found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_CTF_Green"
has_ctf_green = True
elif ob.thug_go_props.go_type == "Flag_Green_Base":
if has_ctf_base_green:
print("Duplicate CTF Flag_Green_Base found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_CTF_Green_Base"
has_ctf_base_green = True
elif ob.thug_go_props.go_type == "Team_Green":
if has_team_green:
print("Duplicate CTF Team_Green found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_Flag_Green"
has_team_green = True
elif ob.thug_go_props.go_type == "Team_Green_Base":
if has_team_green_base:
print("Duplicate CTF Team_Green_Base found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_Flag_Green_Base"
has_team_green_base = True
elif ob.thug_go_props.go_type == "Flag_Yellow":
if has_ctf_yellow:
print("Duplicate CTF Flag_Yellow found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_CTF_Yellow"
has_ctf_yellow = True
elif ob.thug_go_props.go_type == "Flag_Yellow_Base":
if has_ctf_base_yellow:
print("Duplicate CTF Flag_Yellow_Base found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_CTF_Yellow_Base"
has_ctf_base_yellow = True
elif ob.thug_go_props.go_type == "Team_Yellow":
if has_team_yellow:
print("Duplicate CTF Team_Yellow found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_Flag_Yellow"
has_team_yellow = True
elif ob.thug_go_props.go_type == "Team_Yellow_Base":
if has_team_yellow_base:
print("Duplicate CTF Team_Yellow_Base found. Skipping {}...".format(ob.name))
continue
clean_name = "TRG_Flag_Yellow_Base"
has_team_yellow_base = True
p("\t:i :s{")
p("\t\t:i {} = {}".format(c(str_node_pos), v3(func_thug_coords(ob.location))))
p("\t\t:i {} = {}".format(c("Angles"), v3(to_thug_coords_ns(ob.rotation_euler))))
p("\t\t:i {} = {}".format(c("Name"), c(clean_name)))
# RESTART NODE
if ob.thug_empty_props.empty_type == "Restart" and ( not hasattr(ob.thug_restart_props, 'primary_restart') or ob.thug_restart_props.primary_restart == False ):
p("\t\t:i {} = {}".format(c("Class"), c("Restart")))
p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_restart_props.restart_type)))
auto_restart_name = ""
str_all_types = ":a{"
if ob.thug_restart_props.restart_p1:
has_restart_p1 = True
str_all_types += c("Player1")
if auto_restart_name == "": auto_restart_name = "P1: Restart"
if ob.thug_restart_props.restart_p2:
has_restart_p2 = True
str_all_types += c("Player2")
if auto_restart_name == "": auto_restart_name = "P2: Restart"
if ob.thug_restart_props.restart_gen:
has_restart_gen = True
str_all_types += c("Generic")
if auto_restart_name == "": auto_restart_name = "Gen: Restart"
if ob.thug_restart_props.restart_multi:
has_restart_multi = True
str_all_types += c("Multiplayer")
if auto_restart_name == "": auto_restart_name = "Multi: Restart"
if ob.thug_restart_props.restart_team:
has_restart_team = True
str_all_types += c("Team")
if auto_restart_name == "": auto_restart_name = "Team: Restart"
if ob.thug_restart_props.restart_horse:
has_restart_horse = True
str_all_types += c("Horse")
if auto_restart_name == "": auto_restart_name = "Horse: Restart"
if ob.thug_restart_props.restart_ctf:
has_restart_ctf = True
str_all_types += c("CTF")
if auto_restart_name == "": auto_restart_name = "CTF: Restart"
if auto_restart_name == "":
# If none of the type boxes were checked off, use the primary type!
#raise Exception("Restart node {} has no restart type(s).".format(ob.name))
if ob.thug_restart_props.restart_type == "Player1":
str_all_types += c("Player1")
auto_restart_name = "P1: Restart"
has_restart_p1 = True
elif ob.thug_restart_props.restart_type == "Player2":
str_all_types += c("Player2")
auto_restart_name = "P2: Restart"
has_restart_p2 = True
if ob.thug_restart_props.restart_type == "Generic":
str_all_types += c("Generic")
auto_restart_name = "Gen: Restart"
has_restart_gen = True
if ob.thug_restart_props.restart_type == "Multiplayer":
str_all_types += c("Multiplayer")
auto_restart_name = "Multi: Restart"
has_restart_multi = True
if ob.thug_restart_props.restart_type == "Team":
str_all_types += c("Team")
auto_restart_name = "Team: Restart"
has_restart_team = True
if ob.thug_restart_props.restart_type == "Horse":
str_all_types += c("Horse")
auto_restart_name = "Ho: Restart"
has_restart_horse = True
if ob.thug_restart_props.restart_type == "CTF":
str_all_types += c("CTF")
auto_restart_name = "CTF: Restart"
has_restart_ctf = True
str_all_types += ":a}"
p("\t\t:i {} = {}".format(c("restart_types"), str_all_types))
actual_restart_name = ob.thug_restart_props.restart_name
if ob.thug_restart_props.restart_name == "":
actual_restart_name = auto_restart_name
p("\t\t:i {} = {}".format(c("RestartName"), blub_str(actual_restart_name)))
# PROXIMITY NODE
elif ob.thug_empty_props.empty_type == "ProximNode":
p("\t\t:i {} = {}".format(c("Class"), c("ProximNode")))
p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_proxim_props.proxim_type)))
if ob.thug_proxim_props.proxim_object == True:
p("\t\t:i {}".format(c("ProximObject")))
if ob.thug_proxim_props.proxim_rendertoviewport == True:
p("\t\t:i {}".format(c("RenderToViewport")))
if ob.thug_proxim_props.proxim_selectrenderonly == True:
p("\t\t:i {}".format(c("SelectRenderOnly")))
p("\t\t:i {} = {}".format(c("Shape"), c(ob.thug_proxim_props.proxim_shape)))
p("\t\t:i {} = {}".format(c("Radius"), i(ob.thug_proxim_props.proxim_radius)))
# EMITTER OBJECT NODE
elif ob.thug_empty_props.empty_type == "EmitterObject":
p("\t\t:i {} = {}".format(c("Class"), c("EmitterObject")))
p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_emitter_props.emit_type)))
if ob.thug_emitter_props.emit_radius > 0:
p("\t\t:i {} = {}".format(c("radius"), f(ob.thug_emitter_props.emit_radius)))
# PARTICLE OBJECT NODE
elif ob.thug_empty_props.empty_type == "ParticleObject":
p("\t\t:i {} = {}".format(c("Class"), c("ParticleObject")))
#p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_particle_props.particle_profile)))
p("\t\t:i {} = {}".format(c("SuspendDistance"), i(ob.thug_particle_props.particle_suspend)))
p("\t\t:i {} = {}".format(c("lod_dist1"), i(1024)))
p("\t\t:i {} = {}".format(c("lod_dist2"), i(2048)))
p("\t\t:i {} = {}".format(c("BoxDimsStart"), v3(to_thug_coords_scalar(ob.thug_particle_props.particle_boxdimsstart))))
p("\t\t:i {} = {}".format(c("BoxDimsMid"), v3(to_thug_coords_scalar(ob.thug_particle_props.particle_boxdimsmid))))
p("\t\t:i {} = {}".format(c("BoxDimsEnd"), v3(to_thug_coords_scalar(ob.thug_particle_props.particle_boxdimsend))))
# Always use local space!
p("\t\t:i {}".format(c("LocalSpace")))
#if ob.thug_particle_props.particle_usestartpos == True:
p("\t\t:i {}".format(c("UseStartPosition")))
p("\t\t:i {} = {}".format(c("StartPosition"), v3(to_thug_coords_scalar(ob.thug_particle_props.particle_startposition))))
p("\t\t:i {} = {}".format(c("MidPosition"), v3(to_thug_coords_scalar(ob.thug_particle_props.particle_midposition))))
p("\t\t:i {} = {}".format(c("EndPosition"), v3(to_thug_coords_scalar(ob.thug_particle_props.particle_endposition))))
p("\t\t:i {} = {}".format(c("Texture"), c(ob.thug_particle_props.particle_texture)))
if ob.thug_particle_props.particle_usemidpoint == True:
p("\t\t:i {}".format(c("UseMidPoint")))
if ob.thug_particle_props.particle_midpointpct >= 0:
p("\t\t:i {} = {}".format(c("MidPointPCT"), i(ob.thug_particle_props.particle_midpointpct)))
p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_particle_props.particle_type)))
p("\t\t:i {} = {}".format(c("BlendMode"), c(ob.thug_particle_props.particle_blendmode)))
p("\t\t:i {} = {}".format(c("FixedAlpha"), i(ob.thug_particle_props.particle_fixedalpha)))
if ob.thug_particle_props.particle_alphacutoff >= 0:
p("\t\t:i {} = {}".format(c("AlphaCutoff"), i(ob.thug_particle_props.particle_alphacutoff)))
p("\t\t:i {} = {}".format(c("MaxStreams"), i(ob.thug_particle_props.particle_maxstreams)))
p("\t\t:i {} = {}".format(c("EmitRate"), f(ob.thug_particle_props.particle_emitrate)))
if ob.thug_particle_props.particle_radius[0] >= 0:
p("\t\t:i {} = {}".format(c("StartRadius"), f(ob.thug_particle_props.particle_radius[0])))
if ob.thug_particle_props.particle_radius[1] >= 0:
p("\t\t:i {} = {}".format(c("MidRadius"), f(ob.thug_particle_props.particle_radius[1])))
if ob.thug_particle_props.particle_radius[2] >= 0:
p("\t\t:i {} = {}".format(c("EndRadius"), f(ob.thug_particle_props.particle_radius[2])))
if ob.thug_particle_props.particle_radiusspread[0] >= 0:
p("\t\t:i {} = {}".format(c("StartRadiusSpread"), f(ob.thug_particle_props.particle_radiusspread[0])))
if ob.thug_particle_props.particle_radiusspread[1] >= 0:
p("\t\t:i {} = {}".format(c("MidRadiusSpread"), f(ob.thug_particle_props.particle_radiusspread[1])))
if ob.thug_particle_props.particle_radiusspread[2] >= 0:
p("\t\t:i {} = {}".format(c("EndRadiusSpread"), f(ob.thug_particle_props.particle_radiusspread[2])))
if ob.thug_particle_props.EmitScript != "":
p("\t\t:i " + c("EmitScript") + " = :a{ " + c(ob.thug_particle_props.EmitScript) + " :a}")
if ob.thug_particle_props.Force[0] >= 0:
p("\t\t:i {} = {}".format(c("Force_X"), f(ob.thug_particle_props.Force[0])))
p("\t\t:i {} = {}".format(c("Force_Y"), f(ob.thug_particle_props.Force[1])))
p("\t\t:i {} = {}".format(c("Force_Z"), f(ob.thug_particle_props.Force[2])))
if ob.thug_particle_props.Speed[0] >= 0:
p("\t\t:i {} = {}".format(c("SpeedMin"), f(ob.thug_particle_props.Speed[0])))
p("\t\t:i {} = {}".format(c("SpeedMax"), f(ob.thug_particle_props.Speed[1])))
if ob.thug_particle_props.Size[0] >= 0:
p("\t\t:i {} = {}".format(c("EmitWidth"), f(ob.thug_particle_props.Size[0])))
p("\t\t:i {} = {}".format(c("EmitHeight"), f(ob.thug_particle_props.Size[1])))
if ob.thug_particle_props.Width[0] >= 0:
p("\t\t:i {} = {}".format(c("StartWidth"), f(ob.thug_particle_props.Width[0])))
p("\t\t:i {} = {}".format(c("EndWidth"), f(ob.thug_particle_props.Width[1])))
if ob.thug_particle_props.AngleSpread >= 0:
p("\t\t:i {} = {}".format(c("AngleSpread"), f(ob.thug_particle_props.AngleSpread)))
if ob.thug_particle_props.UsePulseEmit:
p("\t\t:i {} = {}".format(c("UsePulseEmit"), c("TRUE")))
else:
p("\t\t:i {} = {}".format(c("UsePulseEmit"), c("FALSE")))
if ob.thug_particle_props.RandomEmitRate:
p("\t\t:i {} = {}".format(c("RandomEmitRate"), c("TRUE")))
else:
p("\t\t:i {} = {}".format(c("RandomEmitRate"), c("FALSE")))
if ob.thug_particle_props.RandomEmitDelay:
p("\t\t:i {} = {}".format(c("RandomEmitDelay"), c("TRUE")))
else:
p("\t\t:i {} = {}".format(c("RandomEmitDelay"), c("FALSE")))
if ob.thug_particle_props.UseMidTime:
p("\t\t:i {} = {}".format(c("UseMidTime"), c("TRUE")))
else:
p("\t\t:i {} = {}".format(c("UseMidTime"), c("FALSE")))
if ob.thug_particle_props.MidTime >= 0:
p("\t\t:i {} = {}".format(c("MidTime"), i(ob.thug_particle_props.MidTime)))
if ob.thug_particle_props.EmitTarget[0] >= 0:
p("\t\t:i {} = {}".format(c("EmitTarget_X"), f(ob.thug_particle_props.EmitTarget[0])))
p("\t\t:i {} = {}".format(c("EmitTarget_Y"), f(ob.thug_particle_props.EmitTarget[1])))
p("\t\t:i {} = {}".format(c("EmitTarget_Z"), f(ob.thug_particle_props.EmitTarget[2])))
if ob.thug_particle_props.EmitRate1[0] > 0:
p("\t\t:i {} = {}".format(c("EmitRate1"), f(ob.thug_particle_props.EmitRate1[0])))
p("\t\t:i {} = {} ; {}".format(c("EmitRate1Rnd"), i(int(ob.thug_particle_props.EmitRate1[1])), i(int(ob.thug_particle_props.EmitRate1[2]))))
if ob.thug_particle_props.EmitRate1Delay[0] > 0:
p("\t\t:i {} = {}".format(c("EmitRate1Delay"), f(ob.thug_particle_props.EmitRate1Delay[0])))
p("\t\t:i {} = {} ; {}".format(c("EmitRate1DelayRnd"), i(int(ob.thug_particle_props.EmitRate1Delay[1])), i(int(ob.thug_particle_props.EmitRate1Delay[2]))))
if ob.thug_particle_props.EmitRate2[0] > 0:
p("\t\t:i {} = {}".format(c("EmitRate2"), f(ob.thug_particle_props.EmitRate2[0])))
p("\t\t:i {} = {} ; {}".format(c("EmitRate2Rnd"), i(int(ob.thug_particle_props.EmitRate2[1])), i(int(ob.thug_particle_props.EmitRate2[2]))))
if ob.thug_particle_props.EmitRate2Delay[0] > 0:
p("\t\t:i {} = {}".format(c("EmitRate2Delay"), f(ob.thug_particle_props.EmitRate2Delay[0])))
p("\t\t:i {} = {} ; {}".format(c("EmitRate2DelayRnd"), i(int(ob.thug_particle_props.EmitRate2Delay[1])), i(int(ob.thug_particle_props.EmitRate2Delay[2]))))
start_color = [ int(ob.thug_particle_props.particle_startcolor[0] * 255),
int(ob.thug_particle_props.particle_startcolor[1] * 255) ,
int(ob.thug_particle_props.particle_startcolor[2] * 255) ,
int(ob.thug_particle_props.particle_startcolor[3] * 255) ]
mid_color = [ int(ob.thug_particle_props.particle_midcolor[0] * 255),
int(ob.thug_particle_props.particle_midcolor[1] * 255) ,
int(ob.thug_particle_props.particle_midcolor[2] * 255) ,
int(ob.thug_particle_props.particle_midcolor[3] * 255) ]
end_color = [ int(ob.thug_particle_props.particle_endcolor[0] * 255),
int(ob.thug_particle_props.particle_endcolor[1] * 255) ,
int(ob.thug_particle_props.particle_endcolor[2] * 255) ,
int(ob.thug_particle_props.particle_endcolor[3] * 255) ]
p("\t\t:i {} = :a{{ {};{};{} :a}}".format(c("StartRGB"),
i(start_color[0]), i(start_color[1]),i(start_color[2])))
p("\t\t:i {} = {}".format(c("StartAlpha"), i(start_color[3])))
p("\t\t:i {} = :a{{ {};{};{} :a}}".format(c("EndRGB"),
i(end_color[0]), i(end_color[1]),i(end_color[2])))
p("\t\t:i {} = {}".format(c("EndAlpha"), i(end_color[3])))
if ob.thug_particle_props.particle_usecolormidtime == True:
p("\t\t:i {}".format(c("UseColorMidTime")))
p("\t\t:i {} = {}".format(c("ColorMidTime"), f(ob.thug_particle_props.particle_colormidtime)))
p("\t\t:i {} = :a{{ {};{};{} :a}}".format(c("MidRGB"),
i(mid_color[0]), i(mid_color[1]),i(mid_color[2])))
p("\t\t:i {} = {}".format(c("MidAlpha"), i(mid_color[3])))
# GAME OBJECT NODE
elif ob.thug_empty_props.empty_type == "GameObject":
p("\t\t:i {} = {}".format(c("Class"), c("GameObject")))
if ob.thug_go_props.go_type == "Custom":
p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_go_props.go_type_other)))
else:
gameobj_type = ob.thug_go_props.go_type
if gameobj_type.startswith("Team_"):
gameobj_type = gameobj_type.replace("Team_", "Flag_")
p("\t\t:i {} = {}".format(c("Type"), c(gameobj_type)))
# Override the TriggerScript settings for CTF nodes
# We want to use an auto-generated script which sets the appropriate game logic
if ob.thug_go_props.go_type.startswith("Flag_") or ob.thug_go_props.go_type.startswith("Team_"):
if ob.thug_triggerscript_props.template_name_txt == "" or ob.thug_triggerscript_props.template_name_txt == "None" or ob.thug_triggerscript_props.custom_name == "":
ob.thug_triggerscript_props.template_name_txt = "Custom"
ob.thug_triggerscript_props.custom_name = clean_name + "Script"
# Removing temporarily to make imported levels easier to work with!
#if ob.thug_go_props.go_model != "":
# p("\t\t:i {} = {}".format(c("Model"), c(ob.thug_go_props.go_type)))
if ob.thug_go_props.go_type in THUG_DefaultGameObjects:
p("\t\t:i {} = {}".format(c("Model"), blub_str(THUG_DefaultGameObjects[ob.thug_go_props.go_type])))
elif ob.thug_go_props.go_type == "Custom":
if ob.thug_go_props.go_model == "":
raise Exception("Game object " + clean_name + " has no model specified.")
else:
p("\t\t:i {} = {}".format(c("Model"), blub_str(ob.thug_go_props.go_model)))
p("\t\t:i {} = {}".format(c("SuspendDistance"), i(ob.thug_go_props.go_suspend)))
p("\t\t:i {} = {}".format(c("lod_dist1"), i(1024)))
p("\t\t:i {} = {}".format(c("lod_dist2"), i(2048)))
# PEDESTRIAN NODE
elif ob.thug_empty_props.empty_type == "Pedestrian":
p("\t\t:i {} = {}".format(c("Class"), c("Pedestrian")))
p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_ped_props.ped_type)))
if ob.thug_ped_props.ped_source == "Profile":
p("\t\t:i {} = {}".format(c("profile"), c(ob.thug_ped_props.ped_profile)))
else:
p("\t\t:i {} = {}".format(c("model"), blub_str(ob.thug_ped_props.ped_model)))
if ob.thug_ped_props.ped_nologic:
p("\t\t:i {}".format(c("NoPedLogic")))
p("\t\t:i {} = {}".format(c("SkeletonName"), c(ob.thug_ped_props.ped_skeleton)))
p("\t\t:i {} = {}".format(c("AnimName"), c(ob.thug_ped_props.ped_animset)))
if ob.thug_ped_props.ped_extra_anims != "":
p("\t\t:i {} = {}".format(c("Extra_Anims"), c(ob.thug_ped_props.ped_extra_anims)))
p("\t\t:i {} = {}".format(c("SuspendDistance"), i(ob.thug_ped_props.ped_suspend)))
p("\t\t:i {} = {}".format(c("lod_dist1"), i(1024)))
p("\t\t:i {} = {}".format(c("lod_dist2"), i(2048)))
# VEHICLE NODE
elif ob.thug_empty_props.empty_type == "Vehicle":
p("\t\t:i {} = {}".format(c("Class"), c("Vehicle")))
p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_veh_props.veh_type)))
p("\t\t:i {} = {}".format(c("model"), blub_str(ob.thug_veh_props.veh_model)))
if ob.thug_veh_props.veh_skeleton != "":
p("\t\t:i {} = {}".format(c("SkeletonName"), c(ob.thug_veh_props.veh_skeleton)))
p("\t\t:i {} = {}".format(c("SuspendDistance"), i(ob.thug_veh_props.veh_suspend)))
if ob.thug_veh_props.veh_norail == True:
p("\t\t:i {}".format(c("NoRail")))
if ob.thug_veh_props.veh_noskitch == True:
p("\t\t:i {}".format(c("NoSkitch")))
if ob.thug_veh_props.veh_usemodellights == True:
p("\t\t:i {}".format(c("UseModelLights")))
if ob.thug_veh_props.veh_allowreplacetex == True:
p("\t\t:i {}".format(c("AllowReplaceTex")))
p("\t\t:i {} = {}".format(c("lod_dist1"), i(1024)))
p("\t\t:i {} = {}".format(c("lod_dist2"), i(2048)))
# GENERIC NODE
elif ob.thug_empty_props.empty_type == "GenericNode":
p("\t\t:i {} = {}".format(c("Class"), c("GenericNode")))
p("\t\t:i {} = {}".format(c("Type"), c(ob.thug_generic_props.generic_type)))
if ob.thug_generic_props.generic_type == 'Crown':
has_koth = True
elif ob.thug_empty_props.empty_type == 'CubemapProbe':
p("\t\t:i {} = {}".format(c("Class"), c("ReflectionProbe")))
bbox, bbox_min, bbox_max, bbox_mid = get_bbox_from_node(ob)
p("\t\t:i {} = {}".format(c("BoxMin"), v3(bbox_min)))
p("\t\t:i {} = {}".format(c("BoxMax"), v3(bbox_max)))
elif ob.thug_empty_props.empty_type == 'LightProbe':
p("\t\t:i {} = {}".format(c("Class"), c("LightProbe")))
# COMMON PROPERTIES
if ob.thug_created_at_start:
p("\t\t:i {}".format(c("CreatedAtStart")))
if ob.thug_network_option != "Default":
p("\t\t:i {}".format(c(ob.thug_network_option)))
if ob.thug_network_option == "NetEnabled":
p("\t\t:i {}".format(c("Permanent")))
if ob.thug_triggerscript_props.template_name_txt != "" and ob.thug_triggerscript_props.template_name_txt != "None":
if ob.thug_triggerscript_props.template_name_txt == "Custom":
script_name = ob.thug_triggerscript_props.custom_name
custom_triggerscript_names.append(script_name)
elif col_ob.thug_triggerscript_props.template_name_txt == "Template":
script_name, script_code = script_template.generate_custom_template_script(col_ob, 'Blub')
generated_scripts.setdefault(script_name, script_code)
else:
script_name, script_code = _generate_script(ob)
generated_scripts.setdefault(script_name, script_code)
if script_name != "":
p("\t\t:i {} = {}".format(c("TriggerScript"), c(script_name)))
else:
operator.report({'WARNING'}, "Unable to determine a TriggerScript for object {}.".format(ob.name))
if ob.thug_rail_connects_to:
if ob.thug_rail_connects_to not in bpy.data.objects:
operator.report({"ERROR"}, "Object {} connects to nonexistent path {}".format(ob.name, ob.thug_rail_connects_to))
else:
connected_to = bpy.data.objects[ob.thug_rail_connects_to]
if connected_to.name in rail_node_offsets:
p("\t\t:i {} = :a{{{}:a}}".format(
c("Links"),
i(rail_node_offsets[connected_to.name])))
if ob.thug_node_expansion:
p("\t\t:i {}".format(c(ob.thug_node_expansion)))
else:
continue
if custom_node_props.get(clean_name):
p("#/ custom props")
p(custom_node_props.get(clean_name).strip('\n'))
p("#/ end custom props")
p("\t:i :s}")
# -----------------------------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------------------------
single_restarts = []
multi_restarts = []
team_restarts = []
generic_restarts = []
koth_nodes = []
ctf_nodes = []
team_nodes = []
if not has_restart_p1:
single_restarts = [("TRG_Playerone_0", (0.0, 0.0, 0.0), (0.0, 0.0, 0.0))]
print("Level has no Player 1 restarts. Generating one...")
if not has_restart_multi:
single_restarts = [("TRG_Multiplayer_0", (0.0, 0.0, 0.0), (0.0, 0.0, 0.0))]
print("Level has no Multiplayer restarts. Generating one...")
if not has_restart_team:
single_restarts = [("TRG_Team_Restart", (0.0, 0.0, 0.0), (0.0, 0.0, 0.0))]
print("Level has no Team restarts. Generating one...")
if not has_koth:
koth_nodes = [("TRG_KOTH", (0.0, 108.0, 0.0), (0.0, 0.0, 0.0))]
print("Level has no KOTH crown. Generating one...")
# Generate CTF components if any are missing, then alert with a warning for future reference
if not has_ctf_blue:
ctf_nodes.append(("TRG_CTF_Blue", "Flag_Blue", (0.0, 0.0, 0.0), (0.0, 0.0, 0.0)))
print("Level has no CTF Blue Flag. Generating one...")
if not has_ctf_base_blue:
ctf_nodes.append(("TRG_CTF_Blue_Base", "Flag_Blue_Base", (0.0, 0.0, 0.0), (0.0, 0.0, 0.0)))
print("Level has no CTF Blue Base. Generating one...")
if not has_ctf_red:
ctf_nodes.append(("TRG_CTF_Red", "Flag_Red", (500.0, 0.0, 0.0), (0.0, 0.0, 0.0)))
print("Level has no CTF Red Flag. Generating one...")
if not has_ctf_base_red:
ctf_nodes.append(("TRG_CTF_Red_Base", "Flag_Red_Base", (500.0, 0.0, 0.0), (0.0, 0.0, 0.0)))
print("Level has no CTF Red Base. Generating one...")
if not has_ctf_green:
ctf_nodes.append(("TRG_CTF_Green", "Flag_Green", (0.0, 0.0, 500.0), (0.0, 0.0, 0.0)))
print("Level has no CTF Green Flag. Generating one...")
if not has_ctf_base_green:
ctf_nodes.append(("TRG_CTF_Green_Base", "Flag_Green_Base", (0.0, 0.0, 500.0), (0.0, 0.0, 0.0)))
print("Level has no CTF Green Base. Generating one...")
if not has_ctf_yellow:
ctf_nodes.append(("TRG_CTF_Yellow", "Flag_Yellow", (-500.0, 0.0, 0.0), (0.0, 0.0, 0.0)))
print("Level has no CTF Yellow Flag. Generating one...")
if not has_ctf_base_yellow:
ctf_nodes.append(("TRG_CTF_Yellow_Base", "Flag_Yellow_Base", (-500.0, 0.0, 0.0), (0.0, 0.0, 0.0)))
if not has_team_blue:
ctf_nodes.append(("TRG_Flag_Blue", "Flag_Blue", (1000.0, 0.0, 1000.0), (0.0, 0.0, 0.0)))
print("Level has no Blue Team Flag. Generating one...")
if not has_team_red:
ctf_nodes.append(("TRG_Flag_Red", "Flag_Red", (700.0, 0.0, 1000.0), (0.0, 0.0, 0.0)))
print("Level has no Red Team Flag. Generating one...")
if not has_team_green:
ctf_nodes.append(("TRG_Flag_Green", "Flag_Green", (400.0, 0.0, 1000.0), (0.0, 0.0, 0.0)))
print("Level has no Green Team Flag. Generating one...")
if not has_team_yellow: