/
engines_wrap_python.cpp
1182 lines (986 loc) · 35.5 KB
/
engines_wrap_python.cpp
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
/**
* =============================================================================
* Source Python
* Copyright (C) 2014 Source Python Development Team. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, the Source Python Team gives you permission
* to link the code of this program (as well as its derivative works) to
* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, the Source.Python
* Development Team grants this exception to all derivative works.
*/
//---------------------------------------------------------------------------------
// Includes.
//---------------------------------------------------------------------------------
// Required to fix compilation errors after including cdll_int.h
#if defined( _WIN32 )
#include <Windows.h>
#endif
#include "export_main.h"
#include "utilities/conversions.h"
#include "dt_send.h"
#include "irecipientfilter.h"
#include "server_class.h"
#include "iscratchpad3d.h"
#include "cdll_int.h"
#include "con_nprint.h"
#include "iachievementmgr.h"
#include "client_textmessage.h"
#include "steam/steamclientpublic.h"
#include "inetchannelinfo.h"
#include "eiface.h"
#include "engine/IEngineSound.h"
#include "engine/IEngineTrace.h"
#include "engine/iserverplugin.h"
#include "public/worldsize.h"
#include "engines_wrap.h"
#include ENGINE_INCLUDE_PATH(engines_wrap_python.h)
//---------------------------------------------------------------------------------
// External variables.
//---------------------------------------------------------------------------------
extern IVEngineServer* engine;
extern IEngineSound* enginesound;
extern IEngineTrace* enginetrace;
extern CGlobalVars* gpGlobals;
extern IServerGameDLL* servergamedll;
extern IServerPluginHelpers *helpers;
//---------------------------------------------------------------------------------
// Forward declarations.
//---------------------------------------------------------------------------------
void export_engine_server(scope);
void export_query_cvar_status(scope);
void export_engine_sound(scope);
void export_engine_trace(scope);
void export_server_game_dll(scope);
void export_worldsize(scope);
//---------------------------------------------------------------------------------
// Declare the _engines module.
//---------------------------------------------------------------------------------
DECLARE_SP_MODULE(_engines)
{
export_engine_server(_engines);
export_query_cvar_status(_engines);
export_engine_sound(_engines);
export_engine_trace(_engines);
export_server_game_dll(_engines);
export_worldsize(_engines);
}
//---------------------------------------------------------------------------------
// Exports IVEngineServer.
//---------------------------------------------------------------------------------
void export_engine_server(scope _engines)
{
// Call engine specific implementation function
IVEngineServer_Visitor(
class_<IVEngineServer, boost::noncopyable>("_EngineServer", no_init)
.def("change_level",
&IVEngineServer::ChangeLevel,
"Tells the engine to change the level. If s2 is None, the engine will execute a \
changelevel command. If s2 is a valid map, the engine will execute a changelevel2 \
command",
args("s1", "s2")
)
.def("is_map_valid",
&IVEngineServer::IsMapValid,
"Returns true if filename refers to a valid map.",
args("filename")
)
.def("is_dedicated_server",
&IVEngineServer::IsDedicatedServer,
"Returns true if the engine is running in dedicated mode."
)
.def("is_in_edit_mode",
&IVEngineServer::IsInEditMode,
"Returns false if the engine is not in hammer editing mode."
)
.def("precache_model",
&IVEngineServer::PrecacheModel,
"Precaches a model and returns an integer containing its index.",
("s", arg("preload")=false)
)
.def("precache_decal",
&IVEngineServer::PrecacheDecal,
"Precaches a decal file and returns an integer containing its index.",
("s", arg("preload")=false)
)
.def("precache_generic",
&IVEngineServer::PrecacheGeneric,
"Precaches a generic asset file and returns an integer containing its index.",
("s", arg("preload")=false)
)
.def("is_model_precached",
&IVEngineServer::IsModelPrecached,
"Returns true if the given model is precached.",
args("s")
)
.def("is_decal_precached",
&IVEngineServer::IsDecalPrecached,
"Returns true if the given decal is precached.",
args("s")
)
.def("is_generic_precached",
&IVEngineServer::IsGenericPrecached,
"Returns true if the given generic asset is precached.",
args("s")
)
.def("get_cluster_for_origin",
&IVEngineServer::GetClusterForOrigin,
"Returns the cluster number for the specified position.",
args("origin")
)
.def("get_pvs_for_cluster",
&IVEngineServer::GetPVSForCluster,
"Gets the PVS bits for a specified cluster and copies the bits into outputpvs.",
args("cluster", "outputpvslength", "outputpvs")
)
.def("check_origin_in_pvs",
&IVEngineServer::CheckOriginInPVS,
"Check whether the specified origin is inside the PVS",
args("org", "checkpvs", "checkpvssize")
)
.def("check_box_in_pvs",
&IVEngineServer::CheckBoxInPVS,
"Checks whether the specified worldspace bounding box is inside the specified PVS",
args("mins", "maxs", "checkpvs", "checkpvssize")
)
.def("get_entity_count",
&IVEngineServer::GetEntityCount,
"Returns the number of used edict slots."
)
.def("get_player_net_info",
&IVEngineServer::GetPlayerNetInfo,
"Returns stats info interface for a client netchannel.",
args("player_index"),
reference_existing_object_policy()
)
.def("create_edict",
&IVEngineServer::CreateEdict,
"Creates an edict. If <force_edict_index> is not -1, then it return the edict with that index.",
args("force_edict_index"),
reference_existing_object_policy()
)
.def("remove_edict",
&IVEngineServer::RemoveEdict,
"Remove the specified edict and place back into the free edict list.",
args("edict_instance")
)
.def("emit_ambient_sound",
&IVEngineServer::EmitAmbientSound,
"Emits an ambient sound associated with the specified entity",
args("entindex", "pos", "samp", "vol", "soundlevel", "flags", "pitch", "delay")
)
.def("fade_client_volume",
&IVEngineServer::FadeClientVolume,
"Fade out the client's volume level toward silence (or fadePercent)",
args("edict", "fade_percent", "fade_out_seconds", "hold_time", "fade_in_seconds")
)
.def("sentence_group_pick",
&IVEngineServer::SentenceGroupPick,
args("group_index", "name", "name_buf_len")
)
.def("sentence_group_pick_sequential",
&IVEngineServer::SentenceGroupPickSequential,
args("group_index", "name", "name_buf_len", "sentence_index", "reset")
)
.def("sentence_index_from_name",
&IVEngineServer::SentenceIndexFromName,
args("sentence_name")
)
.def("sentence_name_from_index",
&IVEngineServer::SentenceNameFromIndex,
args("sentence_index")
)
.def("sentence_group_index_from_name",
&IVEngineServer::SentenceGroupIndexFromName,
args("group_name")
)
.def("sentence_group_name_from_index",
&IVEngineServer::SentenceGroupNameFromIndex,
args("group_index")
)
.def("sentence_length",
&IVEngineServer::SentenceLength,
args("sentence_index")
)
.def("server_command",
&IVEngineServer::ServerCommand,
"Issues a command to the command parser as if it was typed at the server console.",
args("command")
)
.def("server_execute",
&IVEngineServer::ServerExecute,
"Executes any commands currently in the command parser immediately (instead of once per frame)."
)
.def("client_command",
&IVEngineServerExt::ClientCommand,
"Runs a command on the client.",
("edict", "command", arg("server_side")=false)
)
.def("light_style",
&IVEngineServer::LightStyle,
"Set the lightstyle to the specified value and network the change to any connected clients.",
args("style", "val")
)
.def("static_decal",
&IVEngineServer::StaticDecal,
"Project a static decal onto the specified entity / model (for level placed decals in the .bsp)",
args("origin_in_entity_space", "decal_index", "entity_index", "model_index", "low_priority")
)
.def("message_determine_multicast_recipients",
&IVEngineServer::Message_DetermineMulticastRecipients,
"Given the current PVS (or PAS), determine which players should hear/recieve the message.",
args("use_pas", "origin", "player_bits")
)
.def("client_printf",
&IVEngineServer::ClientPrintf,
"Prints szMsg to the client's console.",
args("edict", "message")
)
.def("con_nprintf",
&IVEngineServerExt::Con_NPrintf,
"LISTEN SERVER ONLY: Prints a string to the notification area of the screen.",
args("pos", "string")
)
.def("con_nxprintf",
&IVEngineServerExt::Con_NXPrintf,
"LISTEN SERVER ONLY: Same as con_nprintf but allows you to specify additional information.",
args("info", "string")
)
.def("set_view",
&IVEngineServer::SetView,
"Change a specified player's \"view entity\"",
args("client", "view_entity")
)
.def("crosshair_angle",
&IVEngineServer::CrosshairAngle,
"Sets the player's crosshair angle",
args("client", "pitch", "yaw")
)
.def("lock_network_string_tables",
&IVEngineServer::LockNetworkStringTables,
"Locks/unlocks the network string tables.",
args("lock")
)
.def("create_fake_client",
&IVEngineServer::CreateFakeClient,
"Creates a bot with the given name. Returns NULL if this call fails.",
args("netname"),
reference_existing_object_policy()
)
.def("get_client_convar_value",
&IVEngineServer::GetClientConVarValue,
"Get a convar keyvalue for specified client.",
args("client_index", "name")
)
.def("reset_pvs",
&IVEngineServer::ResetPVS,
"Resets the potentially visible set. pvssize is the size in bytes of the buffer pointed to by pvs.",
args("pvs", "pvssize")
)
.def("add_origin_to_pvs",
&IVEngineServer::AddOriginToPVS,
"Merge the pvs bits into the current accumulated pvs based on the specified origin.",
args("origin")
)
.def("set_area_portal_state",
&IVEngineServer::SetAreaPortalState,
"Marks a specified area portal as open or closed.",
args("portal_number", "is_open")
)
.def("playback_temp_entity",
&IVEngineServer::PlaybackTempEntity,
"Queue a temp entity for transmission",
args("filter", "delay", "sender", "st", "class_id")
)
.def("check_head_node_visible",
&IVEngineServer::CheckHeadnodeVisible,
"Given a node number and the specified PVS, return with the node is in the PVS.",
args("nodenum", "pvs", "vissize")
)
.def("check_areas_connected",
&IVEngineServer::CheckAreasConnected,
"Using area bits, check whether area 1 flows into area 2 and vice versa (depends on portal state)",
args("area1", "area2")
)
.def("get_area",
&IVEngineServer::GetArea,
"Given an origin, determine which area index the origin is within.",
args("origin")
)
.def("get_area_bits",
&IVEngineServer::GetAreaBits,
"Get area portal bit set.",
args("area", "bits", "buflen")
)
.def("get_area_portal_plane",
&IVEngineServer::GetAreaPortalPlane,
"Given a view origin and a portal key, fill in the plane that leads out of this area.",
args("view_origin", "portal_key", "plane")
)
.def("load_game_state",
&IVEngineServer::LoadGameState,
"Save/Restore wrapper - FIXME: At some point we should move this to its own interface.",
args("mapname", "create_players")
)
.def("load_adjacent_ents",
&IVEngineServer::LoadAdjacentEnts,
args("old_level", "landmark_name")
)
.def("get_map_entities_string",
&IVEngineServer::GetMapEntitiesString,
"Get the pristine map entity lump string."
)
.def("text_message_get",
&IVEngineServer::TextMessageGet,
"Text message system -- lookup the text message of the specified name",
args("name"),
reference_existing_object_policy()
)
.def("log_print",
&IVEngineServer::LogPrint,
"Print a message to the server log file.",
args("msg")
)
.def("build_entity_cluster_list",
&IVEngineServer::BuildEntityClusterList,
"Builds PVS information for an entity.",
args("edict", "pvs_info")
)
.def("solid_moved",
&IVEngineServer::SolidMoved,
"A solid entity moved, update spatial partition.",
args("solid_ent", "solid_collide", "prev_abs_origin", "test_surrounding_bounds_only")
)
.def("trigger_moved",
&IVEngineServer::TriggerMoved,
"A trigger entity moved, update the spatial partition",
args("trigger_ent", "test_surrounding_bounds_only")
)
.def("create_spatial_partition",
&IVEngineServer::CreateSpatialPartition,
"Create a custom spatial partition",
args("worldmin", "worldmax"),
reference_existing_object_policy()
)
.def("destroy_spatial_partition",
&IVEngineServer::DestroySpatialPartition,
"Destroy a custom spatial partition",
args("partition")
)
.def("draw_map_to_scratch_pad",
&IVEngineServer::DrawMapToScratchPad,
"Draw the brush geometry in the map into the scratch pad.",
args("pad", "flags")
)
.def("get_entity_transmit_bits_for_client",
&IVEngineServer::GetEntityTransmitBitsForClient,
"This returns which entities, to the server's knowledge the client currently knows about.",
args("client_index"),
reference_existing_object_policy()
)
.def("is_paused",
&IVEngineServer::IsPaused,
"Returns true if the game is paused"
)
.def("force_exact_file",
&IVEngineServer::ForceExactFile,
"Marks the filename for consistency checking. this should be called after precaching the file.",
args("file")
)
.def("force_model_bounds",
&IVEngineServer::ForceModelBounds,
"Marks a precached model as having a maximum bounding size on the client.",
args("s", "mins", "maxs")
)
.def("clear_save_dir_after_client_load",
&IVEngineServer::ClearSaveDirAfterClientLoad
)
.def("set_fake_client_convar_value",
&IVEngineServer::SetFakeClientConVarValue,
"Sets a USERINFO client ConVar for a fakeclient.",
args("entity", "cvar", "value")
)
.def("force_simple_material",
&IVEngineServer::ForceSimpleMaterial,
"Marks the material (vmt file) for consistency checking.",
args("s")
)
.def("set_area_portal_states",
&IVEngineServer::SetAreaPortalStates,
"Mark some area portals as open/closed.",
args("portal_numbers", "is_open", "portals")
)
.def("notify_edict_flags_change",
&IVEngineServer::NotifyEdictFlagsChange,
"Called when relevant edict state flags change.",
args("edict")
)
.def("get_prev_check_transmit_info",
&IVEngineServer::GetPrevCheckTransmitInfo,
args("pPlayerEdict"),
reference_existing_object_policy()
)
.def("get_shared_edict_change_info",
&IVEngineServer::GetSharedEdictChangeInfo,
reference_existing_object_policy()
)
.def("allow_immediate_edict_reuse",
&IVEngineServer::AllowImmediateEdictReuse,
"Tells the engine we can immediately re-use all the edict indices."
)
.def("is_internal_build",
&IVEngineServer::IsInternalBuild,
"Returns true if the engine is an internal build."
)
.def("get_change_accessor",
&IVEngineServer::GetChangeAccessor,
args("edict"),
reference_existing_object_policy()
)
.def("clean_up_entity_cluster_list",
&IVEngineServer::CleanUpEntityClusterList,
"Cleans up the cluster list.",
args("pvs_info")
)
.def("set_achievement_mgr",
&IVEngineServer::SetAchievementMgr,
"Sets the achievement manager."
)
.def("get_achievement_mgr",
&IVEngineServer::GetAchievementMgr,
"Returns the current achievement manager.",
reference_existing_object_policy()
)
.def("get_app_id",
&IVEngineServer::GetAppID,
"Returns the game's appid."
)
.def("is_low_violence",
&IVEngineServer::IsLowViolence,
"Returns true if the game is in low-violence mode."
)
.def("start_query_cvar_value",
&IVEngineServerExt::StartQueryCvarValue,
"Returns the value of a cvar on the client.",
args("edict", "cvar_name")
)
.def("insert_server_command",
&IVEngineServer::InsertServerCommand,
"Inserts a command into the server's command buffer.",
args("command_string")
)
.def("get_player_info",
&IVEngineServer::GetPlayerInfo,
"Fill in the player info structure for the specified player.",
args("ent_num", "pinfo")
)
.def("is_client_fully_authenticated",
&IVEngineServer::IsClientFullyAuthenticated,
"Returns true if this client has been fully authenticated by Steam.",
args("edict")
)
.def("set_dedicated_server_benchmark_mode",
&IVEngineServer::SetDedicatedServerBenchmarkMode,
"Makes the host run 1 tick per frame.",
args("benchmark_mode")
)
.def("is_split_screen_player",
&IVEngineServer::SetDedicatedServerBenchmarkMode,
args("ent_num")
)
.def("get_cluster_count",
&IVEngineServer::GetClusterCount,
"Returns total number of clusters."
)
/*
TODO: Create a wrapper that requires a list or tuple with bbox_t elements
.def("get_all_cluster_bounds",
&IVEngineServer::GetAllClusterBounds,
"Gets a list of all clusters and bounds.",
args("bbox_list", "max_bbox")
)
TODO: Patch SDK, so we can access CGameStatsData
.def("set_gamestats_data",
&IVEngineServer::SetGamestatsData,
"Sets the gamestats data container.",
args("gamestats_data")
)
.def("get_gamestats_data",
&IVEngineServer::GetGamestatsData,
"Returns the gamestats data container.",
reference_existing_object_policy()
)
*/
.def("get_client_steamid",
&IVEngineServer::GetClientSteamID,
"Returns the SteamID of the specified player. Returns NULL if the player isn't authenticated.",
args("client"),
reference_existing_object_policy()
)
.def("get_game_server_steamid",
&IVEngineServer::GetGameServerSteamID,
"Returns the SteamID of the game server.",
reference_existing_object_policy()
)
.def("client_command_key_values",
&IVEngineServer::ClientCommandKeyValues,
"Sends a client command keyvalues which are deleted inside this function.",
args("edict", "key_values")
)
.def("get_server_version",
&IVEngineServer::GetServerVersion,
"Returns the version of the server."
)
// OB specific methods
.NOT_IMPLEMENTED("get_time")
.NOT_IMPLEMENTED("multiplayer_end_game")
.NOT_IMPLEMENTED("create_fake_client_ex")
.NOT_IMPLEMENTED("get_replay")
// CS:GO specific methods
.NOT_IMPLEMENTED("get_launch_options")
.NOT_IMPLEMENTED("is_userid_in_use")
.NOT_IMPLEMENTED("get_loading_process_for_userid")
.NOT_IMPLEMENTED("is_log_enabled")
.NOT_IMPLEMENTED("get_timescale")
.NOT_IMPLEMENTED("is_level_main_menu_background")
.NOT_IMPLEMENTED("is_any_client_low_violence")
.NOT_IMPLEMENTED("is_split_screen_player")
.NOT_IMPLEMENTED("get_split_screen_player_for_edict")
.NOT_IMPLEMENTED("is_override_load_game_ents_on")
.NOT_IMPLEMENTED("force_flush_entity")
.NOT_IMPLEMENTED("get_single_player_shared_memory_space")
.NOT_IMPLEMENTED("alloc_level_static_data")
.NOT_IMPLEMENTED("is_creating_reslist")
.NOT_IMPLEMENTED("get_replayis_creating_xbox_reslist")
.NOT_IMPLEMENTED("is_dedicated_server_for_xbox")
.NOT_IMPLEMENTED("is_dedicated_server_for_ps3")
.NOT_IMPLEMENTED("pause")
.NOT_IMPLEMENTED("set_timescale")
.NOT_IMPLEMENTED("host_validated_session")
.NOT_IMPLEMENTED("refresh_screen_if_necessary")
.NOT_IMPLEMENTED("has_paint_map")
.NOT_IMPLEMENTED("sphere_paint_surface")
.NOT_IMPLEMENTED("sphere_trace_paint_surface")
.NOT_IMPLEMENTED("remove_all_paint")
.NOT_IMPLEMENTED("paint_all_surfaces")
.NOT_IMPLEMENTED("get_client_xuid")
.NOT_IMPLEMENTED("is_active_app")
.NOT_IMPLEMENTED("set_noclip_enabled")
.NOT_IMPLEMENTED("get_paint_map_data_rle")
.NOT_IMPLEMENTED("load_paint_map_data_rle")
.NOT_IMPLEMENTED("send_paint_map_data_to_client")
.NOT_IMPLEMENTED("get_latency_for_choreo_sounds")
.NOT_IMPLEMENTED("get_client_cross_play_platform")
.NOT_IMPLEMENTED("ensure_instance_baseline")
.NOT_IMPLEMENTED("reserve_server_for_queued_game")
.NOT_IMPLEMENTED("get_engine_hltv_info")
) ADD_MEM_TOOLS(IVEngineServer); // IVEngineServer_Visitor
_engines.attr("engine_server") = object(ptr(engine));
}
//---------------------------------------------------------------------------------
// Exports EQueryCvarValueStatus.
//---------------------------------------------------------------------------------
void export_query_cvar_status(scope _engines)
{
enum_<EQueryCvarValueStatus> QueryCvarStatus("QueryCvarStatus");
// Values...
QueryCvarStatus.value("SUCCESS", eQueryCvarValueStatus_ValueIntact);
QueryCvarStatus.value("NOT_FOUND", eQueryCvarValueStatus_CvarNotFound);
QueryCvarStatus.value("INVALID", eQueryCvarValueStatus_NotACvar);
QueryCvarStatus.value("PROTECTED", eQueryCvarValueStatus_CvarProtected);
}
//---------------------------------------------------------------------------------
// Exports IEngineSound.
//---------------------------------------------------------------------------------
void export_engine_sound(scope _engines)
{
// Call engine specific implementation function
IEngineSound_Visitor(
class_<IEngineSound, boost::noncopyable>("_EngineSound", no_init)
.def("precache_sound",
&IEngineSound::PrecacheSound,
("sample", arg("preload")=false, arg("is_ui_sound")=false),
"Precaches a particular sample."
)
.def("is_sound_precached",
&IEngineSound::IsSoundPrecached,
args("sample"),
"Returns True if the given sound is precached."
)
.def("prefetch_sound",
&IEngineSound::PrefetchSound,
args("sample"),
"Prefetches a sample."
)
.def("get_sound_duration",
&IEngineSound::GetSoundDuration,
args("sample"),
"Returns the sound duration."
)
.def("emit_sound",
&IEngineSoundExt::EmitSound,
("filter", "entity_index", "channel", "sample",
"volume", "attenuation",
arg("flags")=0, arg("pitch")=PITCH_NORM, arg("origin")=object(), arg("direction")=object(),
arg("origins")=tuple(), arg("update_positions")=true, arg("sound_time")=0.0f, arg("speaker_entity")=INVALID_ENTITY_INDEX),
"Emits a sound from an entity."
)
// TODO: Can we use IVEngineServer::SentenceNameFromIndex() and then call IEngineSound::EmitSound()?
.NOT_IMPLEMENTED("emit_sentence_by_index")
.def("stop_sound",
&IEngineSoundExt::StopSound,
args("entity_index", "channel", "sample"),
"Stops a sound from being emitted from an entity."
)
// TODO: StopAllSounds, SetRoomType, SetPlayerDSP. Are they really just client only?
.def("get_dist_gain_from_sound_level",
&IEngineSound::GetDistGainFromSoundLevel,
args("sound_level", "distance"),
"Returns the distance gain value from a sound level"
)
// Only available for CS:GO
.NOT_IMPLEMENTED("is_looping_sound")
) ADD_MEM_TOOLS(IEngineSound); // IEngineSound_Visitor
_engines.attr("engine_sound") = object(ptr(enginesound));
// Channels
enum_<int>("Channels")
.value("REPLACE", CHAN_REPLACE)
.value("AUTO", CHAN_AUTO)
.value("WEAPON", CHAN_WEAPON)
.value("VOICE", CHAN_VOICE)
.value("ITEM", CHAN_ITEM)
.value("BODY", CHAN_BODY)
.value("STREAM", CHAN_STREAM)
.value("STATIC", CHAN_STATIC)
.value("VOICE_BASE", CHAN_VOICE_BASE)
.value("USER_BASE", CHAN_USER_BASE)
;
// Common volume values
_engines.attr("VOL_NORM") = VOL_NORM;
// Common attenuation values
_engines.attr("ATTN_NONE") = ATTN_NONE;
_engines.attr("ATTN_NORM") = ATTN_NORM;
_engines.attr("ATTN_IDLE") = ATTN_IDLE;
_engines.attr("ATTN_STATIC") = ATTN_STATIC;
_engines.attr("ATTN_RICOCHET") = ATTN_RICOCHET;
_engines.attr("ATTN_GUNFIRE") = ATTN_GUNFIRE;
_engines.attr("MAX_ATTENUATION") = MAX_ATTENUATION;
// Flags for iFlags fields
enum_<SoundFlags_t>("SoundFlags")
.value("NOFLAGS", SND_NOFLAGS)
.value("CHANGE_VOL", SND_CHANGE_VOL)
.value("CHANGE_PITCH", SND_CHANGE_PITCH)
.value("STOP", SND_STOP)
.value("SPAWNING", SND_SPAWNING)
.value("DELAY", SND_DELAY)
.value("STOP_LOOPING", SND_STOP_LOOPING)
.value("SPEAKER", SND_SPEAKER)
.value("SHOULDPAUSE", SND_SHOULDPAUSE)
.value("IGNORE_PHONEMES", SND_IGNORE_PHONEMES)
.value("IGNORE_NAME", SND_IGNORE_NAME)
;
// Common pitch values
_engines.attr("PITCH_NORM") = PITCH_NORM;
_engines.attr("PITCH_LOW") = PITCH_LOW;
_engines.attr("PITCH_HIGH") = PITCH_HIGH;
_engines.attr("SOUND_FROM_LOCAL_PLAYER") = SOUND_FROM_LOCAL_PLAYER;
_engines.attr("SOUND_FROM_WORLD") = SOUND_FROM_WORLD;
}
//---------------------------------------------------------------------------------
// Exports IEngineTrace.
//---------------------------------------------------------------------------------
void export_engine_trace(scope _engines)
{
// Since Ray_t has members of the type AlignedVector that uses ALIGN16, we have
// to declare this class as noncopyable.
class_<Ray_t, boost::noncopyable>("Ray", no_init)
.def("__init__", make_constructor(&Ray_tExt::CreateRay1))
.def("__init__", make_constructor(&Ray_tExt::CreateRay2))
ADD_MEM_TOOLS(Ray_t)
;
class_<IEngineTrace, boost::noncopyable>("_EngineTrace", no_init)
.def("get_point_contents",
&IEngineTraceExt::GetPointContents,
"Returns the contents mask and the entities at the given position.",
args("position")
)
.def("get_point_contents_of_collidable",
&IEngineTrace::GetPointContents_Collideable,
"Returns the content mask, but only tests the given entity.",
args("entity", "position")
)
.def("clip_ray_to_entity",
&IEngineTrace::ClipRayToEntity,
"Traces a ray against a particular entity.",
args("ray", "mask", "entity", "trace")
)
.def("clip_ray_to_collidable",
&IEngineTrace::ClipRayToCollideable,
"Traces a ray against a particular entity.",
args("ray", "mask", "entity", "trace")
)
.def("trace_ray",
&IEngineTrace::TraceRay,
"A version that simply accepts a ray (can work as a traceline or tracehull).",
args("ray", "mask", "filter", "trace")
)
.def("enumerate_entities",
GET_METHOD(void, IEngineTrace, EnumerateEntities, const Ray_t&, bool, IEntityEnumerator*),
"Enumerates over all entities along a ray.",
args("ray", "triggers", "enumerator")
)
.def("enumerate_entities_in_box",
GET_METHOD(void, IEngineTrace, EnumerateEntities, const Vector&, const Vector&, IEntityEnumerator*),
"Enumerates over all entities within a box.",
args("mins", "maxs", "enumerator")
)
.def("get_collideable",
&IEngineTrace::GetCollideable,
"Convert a handle entity to a collideable.",
args("entity"),
reference_existing_object_policy()
)
.def("is_point_outside_of_world",
&IEngineTrace::PointOutsideWorld,
"Tests a point to see if it's outside any playable area.",
args("position")
)
.def("sweep_collideable",
&IEngineTrace::SweepCollideable,
"Sweeps a collideable through the world.",
args("collideable", "start", "end", "angles", "mask", "filter", "trace")
)
/*
//finds brushes in an AABB, prone to some false positives
virtual void GetBrushesInAABB( const Vector &vMins, const Vector &vMaxs, CUtlVector<int> *pOutput, int iContentsMask = 0xFFFFFFFF ) = 0;
//retrieve brush planes and contents, returns true if data is being returned in the output pointers, false if the brush doesn't exist
virtual bool GetBrushInfo( int iBrush, CUtlVector<Vector4D> *pPlanesOut, int *pContentsOut ) = 0;
*/
ADD_MEM_TOOLS(IEngineTrace)
;
_engines.attr("engine_trace") = object(ptr(enginetrace));
class_<CBaseTrace, boost::noncopyable>("BaseTrace")
.def_readwrite("start_position",
&CBaseTrace::startpos
)
.def_readwrite("end_position",
&CBaseTrace::endpos
)
.def_readwrite("plane",
&CBaseTrace::plane
)
.def_readwrite("fraction",
&CBaseTrace::fraction
)
.def_readwrite("contents",
&CBaseTrace::contents
)
.def_readwrite("displacement_flags",
&CBaseTrace::dispFlags
)
.def_readwrite("all_solid",
&CBaseTrace::allsolid
)
.def_readwrite("start_solid",
&CBaseTrace::startsolid
)
ADD_MEM_TOOLS(CBaseTrace)
;
_engines.attr("DISPSURF_FLAG_SURFACE") = DISPSURF_FLAG_SURFACE;
_engines.attr("DISPSURF_FLAG_WALKABLE") = DISPSURF_FLAG_WALKABLE;
_engines.attr("DISPSURF_FLAG_BUILDABLE") = DISPSURF_FLAG_BUILDABLE;
_engines.attr("DISPSURF_FLAG_SURFPROP1") = DISPSURF_FLAG_SURFPROP1;
_engines.attr("DISPSURF_FLAG_SURFPROP2") = DISPSURF_FLAG_SURFPROP2;
class_<CGameTrace, bases<CBaseTrace>, boost::noncopyable>("GameTrace")
.def("did_hit_world",
&CGameTrace::DidHitWorld,
"Returns True if the ray hit the world entity."
)
.def("did_hit",
&CGameTrace::DidHit,
"Returns true if there was any kind of impact at all"
)
.def("get_entity_index",
&CGameTrace::GetEntityIndex,
"Returns the index of the entity that was hit."
)
.def("get_entity",
&CGameTraceExt::GetEntity,
"Returns the entity instance that was hit.",
reference_existing_object_policy()
)
.def_readwrite("fraction_left_solid",
&CGameTrace::fractionleftsolid
)
.def_readwrite("surface",
&CGameTrace::surface
)
.def_readwrite("hitgroup",