Added replace_with_snipers

This commit is contained in:
Resxt 2022-05-27 10:36:16 +02:00
parent e76bc74443
commit 4be042e009
2 changed files with 87 additions and 0 deletions

View File

@ -4,8 +4,16 @@ This can easily be modified to always give a certain weapon or only give it when
This is useful to add ported weapons like the Intervention to your default classes until Plutonium adds the possibility to do it directly in dsr files.
## replace_rsass_with_intervention.gsc
Replace the RSASS with an Intervention (ACOG sight)
Replace the RSASS silencer with an Intervention (ACOG sight + silencer)
Gives a throwing knife and a tactical insertion in both cases
## replace_with_snipers.gsc
Replace any weapon with a bolt action sniper with the extended mags attachment.
Can be configured to only work for bots, players or both by changing `level.rws_applies_to`.
As of now this removes secondary weapons and grenades but the script can easily be modified to add additional checks for these and replace/remove them only if needed.
An example that shows how to only apply the replacement if the primary isn't valid can be found in `DoWeaponCheck()`.

View File

@ -0,0 +1,79 @@
#include common_scripts\utility;
Init()
{
level.rws_available_weapons = [];
level.rws_available_weapons[level.rws_available_weapons.size] = "iw5_l96a1_mp_l96a1scope_xmags";
level.rws_available_weapons[level.rws_available_weapons.size] = "iw5_msr_mp_msrscope_xmags";
level.rws_available_weapons[level.rws_available_weapons.size] = "iw5_cheytac_mp_cheytacscope_xmags";
level.rws_applies_to = 0; // 0 = bots only, 1 = players only, 2 = everyone
level thread OnPlayerConnect();
}
OnPlayerConnect()
{
for(;;)
{
level waittill("connected", player);
if (isDefined(player.pers["isBot"]))
{
if (player.pers["isBot"])
{
if (level.rws_applies_to == 1) {
continue; // if level.rws_applies_to is set to players only and we are a bot, skip
}
}
else {
if (level.rws_applies_to == 0) {
continue; // if level.rws_applies_to is set to bots only and we are a player, skip
}
}
}
else {
if (level.rws_applies_to == 0) {
continue; // if level.rws_applies_to is set to bots only and we are a player, skip
}
}
player thread OnPlayerSpawned();
}
}
OnPlayerSpawned()
{
self endon("disconnect");
for(;;)
{
self waittill("changed_kit");
current_weapon = self GetCurrentWeapon();
self thread DoWeaponCheck(current_weapon);
}
}
DoWeaponCheck(current_weapon)
{
// Uncomment this block and put all the code below (in this function) in the if condition if you don't want to change classes that already have the correct primary
// Additional checks are required to check for secondary weapon lethal/tactical grenades
// Thanks to TakeAllWeapons() in ReplaceWeapon() the secondary weapon and lethal/tactical grenades are removed so no check is needed
/*weapon_tokens = strTok(current_weapon, "_");
if (weapon_tokens[1] != "l96a1" && weapon_tokens[1] != "msr" && weapon_tokens[1] != "cheytac") {
}*/
ReplaceWeapon(random(level.rws_available_weapons));
}
ReplaceWeapon(new_weapon)
{
self TakeAllWeapons();
self GiveWeapon(new_weapon);
self SetSpawnWeapon(new_weapon); // This gives the weapon without playing the animation
}