Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 KB | None | 0 0
  1. BulldozerPlayer.spawn = function (self, optional_position, optional_rotation, is_initial_spawn, ammo_melee, ammo_ranged, healthkit, potion, grenade)
  2. local profile_index = self.profile_index
  3. local profile_index_original = self.profile_index
  4. profile_index = 3
  5. local profile = SPProfiles[profile_index]
  6.  
  7. fassert(profile, "[SpawnManager] Trying to spawn with profile %q that doesn't exist in %q.", profile_index, "SPProfiles")
  8.  
  9. local nav_world = Managers.state.entity:system("ai_system"):nav_world()
  10. local difficulty_manager = Managers.state.difficulty
  11. local difficulty_settings = difficulty_manager.get_difficulty_settings(difficulty_manager)
  12. local player_health = difficulty_settings.max_hp
  13. local player_wounds = difficulty_settings.wounds
  14.  
  15. if self.spawn_position then
  16. optional_position = self.spawn_position:unbox()
  17. self.spawn_position = nil
  18. end
  19.  
  20. if self.spawn_rotation then
  21. optional_rotation = self.spawn_rotation:unbox()
  22. self.spawn_rotation = nil
  23. end
  24.  
  25. local character_state_class_list = {
  26. PlayerCharacterStateDead,
  27. PlayerCharacterStateInteracting,
  28. PlayerCharacterStateInspecting,
  29. PlayerCharacterStateJumping,
  30. PlayerCharacterStateClimbingLadder,
  31. PlayerCharacterStateLeavingLadderTop,
  32. PlayerCharacterStateEnterLadderTop,
  33. PlayerCharacterStateFalling,
  34. PlayerCharacterStateKnockedDown,
  35. PlayerCharacterStatePouncedDown,
  36. PlayerCharacterStateStanding,
  37. PlayerCharacterStateWalking,
  38. PlayerCharacterStateDodging,
  39. PlayerCharacterStateLedgeHanging,
  40. PlayerCharacterStateLeaveLedgeHangingPullUp,
  41. PlayerCharacterStateLeaveLedgeHangingFalling,
  42. PlayerCharacterStateCatapulted,
  43. PlayerCharacterStateStunned,
  44. PlayerCharacterStateUsingTransport,
  45. PlayerCharacterStateGrabbedByPackMaster,
  46. PlayerCharacterStateWaitingForAssistedRespawn,
  47. PLayerCharacterStateOverchargeExploding
  48. }
  49. local initial_inventory = self._get_initial_inventory(self, healthkit, potion, grenade)
  50. local extension_init_data = {
  51. input_system = {
  52. player = self
  53. },
  54. character_state_machine_system = {
  55. start_state = "standing",
  56. character_state_class_list = character_state_class_list,
  57. player = self,
  58. nav_world = nav_world
  59. },
  60. health_system = {
  61. health = player_health,
  62. player = self
  63. },
  64. status_system = {
  65. wounds = player_wounds,
  66. profile_id = profile_index_original,
  67. player = self
  68. },
  69. hit_reaction_system = {
  70. is_husk = false,
  71. hit_reaction_template = "player"
  72. },
  73. death_system = {
  74. death_reaction_template = "player",
  75. is_husk = false
  76. },
  77. inventory_system = {
  78. profile = profile,
  79. initial_inventory = initial_inventory,
  80. player = self,
  81. ammo_percent = {
  82. slot_melee = ammo_melee,
  83. slot_ranged = ammo_ranged
  84. }
  85. },
  86. attachment_system = {
  87. profile = profile,
  88. player = self
  89. },
  90. locomotion_system = {
  91. player = self
  92. },
  93. camera_system = {
  94. player = self
  95. },
  96. first_person_system = {
  97. profile = profile
  98. },
  99. dialogue_context_system = {
  100. profile = profile
  101. },
  102. dialogue_system = {
  103. local_player = true,
  104. faction = "player",
  105. wwise_voice_switch_group = "character",
  106. profile = profile,
  107. wwise_voice_switch_value = profile.character_vo
  108. },
  109. whereabouts_system = {
  110. nav_world = nav_world
  111. },
  112. aim_system = {
  113. is_husk = false,
  114. template = "player"
  115. },
  116. buff_system = {
  117. is_husk = false
  118. },
  119. statistics_system = {
  120. template = "player",
  121. statistics_id = self.telemetry_id(self)
  122. },
  123. ai_slot_system = {
  124. profile_index = profile_index
  125. }
  126. }
  127. local unit_template_name = nil
  128. local unit_name = profile.base_units.third_person
  129. local spawn_data = {
  130. unit_template_name = unit_template_name,
  131. unit_name = unit_name,
  132. extension_init_data = extension_init_data
  133. }
  134. local spawn_manager = Managers.state.spawn
  135. local unit = spawn_manager.spawn_unit(spawn_manager, spawn_data, optional_position, optional_rotation)
  136. local player_manager = Managers.player
  137.  
  138. Unit.set_data(unit, "unit_name", profile.unit_name)
  139.  
  140. local world = spawn_manager.world
  141.  
  142. LevelHelper:set_flow_parameter(world, "local_player_profile_name", profile.display_name)
  143. Unit.set_data(unit, "sound_character", profile.sound_character)
  144. Unit.create_actor(unit, "human_collision", false)
  145.  
  146. local is_player_unit = true
  147.  
  148. player_manager.assign_unit_ownership(player_manager, unit, self, is_player_unit)
  149. Managers.state.event:trigger("level_start_local_player_spawned", is_initial_spawn)
  150.  
  151. if GameSettingsDevelopment.use_telemetry then
  152. local peer_type = (self.is_server and "host") or "client"
  153.  
  154. self._add_spawn_telemetry(self, peer_type)
  155. end
  156.  
  157. Managers.state.event:trigger("camera_teleported")
  158.  
  159. return unit
  160. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement