Game Modding | Call of Duty: Black Ops 3 | Scripting
ModmeBot:
Thread By: TrueGamerCalls
I'm working on a PUBG like looting system and was wondering how I can turn this script into a script that can be used several times.
I'm looking to being able to place as many trigger_use named "loot_spawned" as I want with each trigger_use having different weapons.
Note: This isn't the final script, its just something I made in 20min, judge me many.
ModmeBot:
Reply By: mathfag
How high were you when you did this
anyway...
I made a little something. It may work, it may not, I didn't really try to make something good. Basically every 60 seconds a gun spawns on a random struct and then what you wanted to do happens. You should probably look into how to not make 2 guns spawn on the same struct.
wait(60) in the first function
ModmeBot:
Reply By: Harry Bo21
you could edit the post you know...
also this doesnt check for last stand and other 'is_valid' stuff, and will allow guns to spawn on the same spot repeatedly potentially - and is missing some code to allow trigger_radius_use to actually display the hintstrings
ModmeBot:
Reply By: ihmiskeho
Did this pretty quickly. Seemed to work when I did a quick test, however.
Should not spawn multiple weapons on the same struct.
Just place as many script_structs (targetname = loot_spawn) around the map. Can also edit the respawn time
Let me know if there is any issues with this
ModmeBot:
Reply By: Harry Bo21
that actually looks pretty good
ModmeBot:
Reply By: TrueGamerCalls
ihmiskeho
Did this pretty quickly. Seemed to work when I did a quick test, however. Should not spawn multiple weapons on the same struct. function loot_logic() { level endon("end_game"); n_loot_respawn = 60; //Time until new loot respawns a_loot_spawn = struct::get_array( "loot_spawn", "targetname" ); if(!isdefined(a_loot_spawn) || a_loot_spawn.size <= 0) //Tells if you didn't place any structs or mispelled kvps { IPrintLnBold("No loot structs found"); return; } while(1) { selected_loot = array::random(a_loot_spawn); if(IS_TRUE(selected_loot.loot_active)) { WAIT_SERVER_FRAME; continue; } else { selected_loot thread LootSpawnWeapon(); wait(n_loot_respawn); } } } function LootSpawnWeapon() { self.loot_active = true; //Added so that multiple weapons can't spawn on one struct a_weapons = array( "ar_standard", "lmg_light", "ray_gun", "ar_damage" ); selected_weapon = GetWeapon( array::random(a_weapons) ); e_gun = Spawn("script_model", self.origin); e_gun SetModel(GetWeaponWorldModel( selected_weapon) ); //trigger stuff t_loot = Spawn("trigger_radius", e_gun.origin, 0, 32, 32); t_loot SetHintString( "Hold ^3&&1 ^7To Take Weapon" ); t_loot SetCursorHint( "HINT_NOICON" ); while(1) { t_loot waittill("trigger", user); if(IsPlayer(user) && user UseButtonPressed()) { if( user HasWeapon(GetWeapon("minigun") ) || user laststand::player_is_in_laststand() ) { continue; } if( user HasWeapon( selected_weapon )) { user SwitchToWeapon( selected_weapon ); user GiveMaxAmmo( selected_weapon ); break; } else { user zm_weapons::weapon_give(selected_weapon); //_zm_weapons.gsc, line 2603 function weapon_give( weapon, is_upgrade = false, magic_box = false, nosound = false, b_switch_weapon = true ) break; } } } e_gun Delete(); t_loot Delete(); self.loot_active = false; } Just place as many script_structs (targetname = loot_spawn) around the map. Can also edit the respawn time Let me know if there is any issues with this
ModmeBot:
Reply By: ihmiskeho
TrueGamerCalls
ihmiskeho Did this pretty quickly. Seemed to work when I did a quick test, however. Should not spawn multiple weapons on the same struct. function loot_logic() { level endon("end_game"); n_loot_respawn = 60; //Time until new loot respawns a_loot_spawn = struct::get_array( "loot_spawn", "targetname" ); if(!isdefined(a_loot_spawn) || a_loot_spawn.size <= 0) //Tells if you didn't place any structs or mispelled kvps { IPrintLnBold("No loot structs found"); return; } while(1) { selected_loot = array::random(a_loot_spawn); if(IS_TRUE(selected_loot.loot_active)) { WAIT_SERVER_FRAME; continue; } else { selected_loot thread LootSpawnWeapon(); wait(n_loot_respawn); } } } function LootSpawnWeapon() { self.loot_active = true; //Added so that multiple weapons can't spawn on one struct a_weapons = array( "ar_standard", "lmg_light", "ray_gun", "ar_damage" ); selected_weapon = GetWeapon( array::random(a_weapons) ); e_gun = Spawn("script_model", self.origin); e_gun SetModel(GetWeaponWorldModel( selected_weapon) ); //trigger stuff t_loot = Spawn("trigger_radius", e_gun.origin, 0, 32, 32); t_loot SetHintString( "Hold ^3&&1 ^7To Take Weapon" ); t_loot SetCursorHint( "HINT_NOICON" ); while(1) { t_loot waittill("trigger", user); if(IsPlayer(user) && user UseButtonPressed()) { if( user HasWeapon(GetWeapon("minigun") ) || user laststand::player_is_in_laststand() ) { continue; } if( user HasWeapon( selected_weapon )) { user SwitchToWeapon( selected_weapon ); user GiveMaxAmmo( selected_weapon ); break; } else { user zm_weapons::weapon_give(selected_weapon); //_zm_weapons.gsc, line 2603 function weapon_give( weapon, is_upgrade = false, magic_box = false, nosound = false, b_switch_weapon = true ) break; } } } e_gun Delete(); t_loot Delete(); self.loot_active = false; } Just place as many script_structs (targetname = loot_spawn) around the map. Can also edit the respawn time Let me know if there is any issues with this This works amazingly, but I have one problem. How do I change this to only spawn a weapon once at a location?
ModmeBot:
Reply By: TrueGamerCalls
ihmiskeho
TrueGamerCalls ihmiskeho Did this pretty quickly. Seemed to work when I did a quick test, however. Should not spawn multiple weapons on the same struct. function loot_logic() { level endon("end_game"); n_loot_respawn = 60; //Time until new loot respawns a_loot_spawn = struct::get_array( "loot_spawn", "targetname" ); if(!isdefined(a_loot_spawn) || a_loot_spawn.size <= 0) //Tells if you didn't place any structs or mispelled kvps { IPrintLnBold("No loot structs found"); return; } while(1) { selected_loot = array::random(a_loot_spawn); if(IS_TRUE(selected_loot.loot_active)) { WAIT_SERVER_FRAME; continue; } else { selected_loot thread LootSpawnWeapon(); wait(n_loot_respawn); } } } function LootSpawnWeapon() { self.loot_active = true; //Added so that multiple weapons can't spawn on one struct a_weapons = array( "ar_standard", "lmg_light", "ray_gun", "ar_damage" ); selected_weapon = GetWeapon( array::random(a_weapons) ); e_gun = Spawn("script_model", self.origin); e_gun SetModel(GetWeaponWorldModel( selected_weapon) ); //trigger stuff t_loot = Spawn("trigger_radius", e_gun.origin, 0, 32, 32); t_loot SetHintString( "Hold ^3&&1 ^7To Take Weapon" ); t_loot SetCursorHint( "HINT_NOICON" ); while(1) { t_loot waittill("trigger", user); if(IsPlayer(user) && user UseButtonPressed()) { if( user HasWeapon(GetWeapon("minigun") ) || user laststand::player_is_in_laststand() ) { continue; } if( user HasWeapon( selected_weapon )) { user SwitchToWeapon( selected_weapon ); user GiveMaxAmmo( selected_weapon ); break; } else { user zm_weapons::weapon_give(selected_weapon); //_zm_weapons.gsc, line 2603 function weapon_give( weapon, is_upgrade = false, magic_box = false, nosound = false, b_switch_weapon = true ) break; } } } e_gun Delete(); t_loot Delete(); self.loot_active = false; } Just place as many script_structs (targetname = loot_spawn) around the map. Can also edit the respawn time Let me know if there is any issues with this This works amazingly, but I have one problem. How do I change this to only spawn a weapon once at a location? Sorry, I misread what you wanted. If you only want them to spawn once you could simply do this: function loot_logic() { a_loot_spawn = struct::get_array( "loot_spawn", "targetname" ); if(!isdefined(a_loot_spawn) || a_loot_spawn.size <= 0) //Tells if you didn't place any structs or mispelled kvps { IPrintLnBold("No loot structs found"); return; } foreach(struct in a_loot_spawn) { struct thread LootSpawnWeapon(); } } function LootSpawnWeapon() { a_weapons = array( "ar_standard", "lmg_light", "ray_gun", "ar_damage" ); selected_weapon = GetWeapon( array::random(a_weapons) ); e_gun = Spawn("script_model", self.origin); e_gun SetModel(GetWeaponWorldModel( selected_weapon) ); //trigger stuff t_loot = Spawn("trigger_radius", e_gun.origin, 0, 32, 32); t_loot SetHintString( "Hold ^3&&1 ^7To Take Weapon" ); t_loot SetCursorHint( "HINT_NOICON" ); while(1) { t_loot waittill("trigger", user); if(IsPlayer(user) && user UseButtonPressed()) { if( user HasWeapon(GetWeapon("minigun") ) || user laststand::player_is_in_laststand() ) { continue; } if( user HasWeapon( selected_weapon )) { user SwitchToWeapon( selected_weapon ); user GiveMaxAmmo( selected_weapon ); break; } else { user zm_weapons::weapon_give(selected_weapon); //_zm_weapons.gsc, line 2603 function weapon_give( weapon, is_upgrade = false, magic_box = false, nosound = false, b_switch_weapon = true ) break; } } } e_gun Delete(); t_loot Delete(); } This will spawn all weapons instantly and they wont respawn. If you want to have a delay between the spawns, you can add a wait in the foreach loop