Arqade Asked by Michael Parrish on December 4, 2020
Before the silk road updates, i could spawn and pick up sentries via a command in the text chat a mod (as long as I had sentries equipped going into the heist I could pick them up, but if I didn’t the game crashed) and I had no problem leaving them behind at the end of the heist, regardless of if I had them equipped. Now the game crashes when I try to pick up the spawned sentries, as well as if I leave any lying around when the heist ends in success.
here is my mod code that used to work
if peer and peer:unit() then
ammo_multiplier = managers.player:upgrade_value( "sentry_gun", "extra_ammo_multiplier", 1 )
armor_multiplier = managers.player:upgrade_value( "sentry_gun", "armor_multiplier", 1 )
damage_multiplier = managers.player:upgrade_value( "sentry_gun", "damage_multiplier", 1 )
unit = managers.player:player_unit()
pos = managers.player:player_unit():position()
rot = managers.player:player_unit():rotation()
selected_index = nil
if Network:is_client() then
managers.network:session():send_to_host( "place_sentry_gun", pos, rot, ammo_multiplier, armor_multiplier, damage_multiplier, selected_index, unit )
PlayerEquipment.sentrygun_placement_requested = true
else
local shield = managers.player:has_category_upgrade( "sentry_gun", "shield" )
local sentry_gun_unit = SentryGunBase.spawn( unit, pos, rot, ammo_multiplier, armor_multiplier, damage_multiplier )
if sentry_gun_unit then
managers.network:session():send_to_peers_synched( "from_server_sentry_gun_place_result", managers.network:session():local_peer():id(), selected_index, sentry_gun_unit, sentry_gun_unit:movement()._rot_speed_mul, sentry_gun_unit:weapon()._setup.spread_mul, shield )
else
end
end
end
also, if you happen to know the enemytype for the bank cops in san martin, as well as the federales in Border Crossing, that would be nice, I have a command to kill enemies, but the non-infinitely-spawned new enemies have a new type, and I cant find it.
I fixed it.
So I prodded around the luajit files, and thanks to pierredjays on unknowncheats, who pointed me to the crash data txt (which I initially mistook for him wanting me to view the minidump files)
a change I made last night, which probably didn't actually fix anything, but did not make the issue worse either, but was derived from sentrygunbase.lua code, is the line I used to call the sentry up, with an extra variable being passed to it, I altered it to match my existing code (I use "sentry_gun_unit" in place of "unit".)
I also copied the send_to_peers_synched:equipment setup, which may not be necessary to avoid crash.
But with the crash data, I found the holy grail. The movement, brain, and, most importantly: the post_setup, which is a new function to handle the new feature of placing down sentries in the firemode of your choice, so you dont waste ammo on non AP shots in the heat of battle.
It works. I can spawn more than is possible to hold, pick them up, the outline is still not present when spawned, but I can leave them and end the heist without crashing the game. here is the final code.
I left the client code commented because I am afraid to open that can of worms. for now...
if peer and peer:unit() then
ammo_multiplier = managers.player:upgrade_value( "sentry_gun", "extra_ammo_multiplier", 1 )
armor_multiplier = managers.player:upgrade_value( "sentry_gun", "armor_multiplier", 1 )
damage_multiplier = managers.player:upgrade_value( "sentry_gun", "damage_multiplier", 1 )
unit = managers.player:player_unit()
pos = managers.player:player_unit():position()
rot = managers.player:player_unit():rotation()
--selected_index = nil
managers.player:clear_equipment()
managers.player._equipment.selections = {}
managers.player:add_equipment({equipment = "sentry_gun"})
if Network:is_client() then
--managers.network:session():send_to_host( "place_sentry_gun", pos, rot, ammo_multiplier, armor_multiplier, damage_multiplier, selected_index, unit )
--PlayerEquipment.sentrygun_placement_requested = true
else
local sentry_gun_unit = SentryGunBase.spawn( unit, pos, rot, ammo_multiplier, armor_multiplier, damage_multiplier )
if sentry_gun_unit then
managers.network:session():send_to_peers_synched("sync_equipment_setup", sentry_gun_unit, 0, 0)
managers.network:session():send_to_peers_synched( "from_server_sentry_gun_place_result", managers.network:session():local_peer():id(), 0, sentry_gun_unit, 2, 2, true, 2, 1 )
local team = managers.groupai:state():team_data(tweak_data.levels:get_default_team_ID("player"))
sentry_gun_unit:movement():set_team(team)
sentry_gun_unit:brain():set_active(true)
sentry_gun_unit:base():post_setup(1)
else
end
end
end
Answered by Michael Parrish on December 4, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP