Automatic ejection of weapons when conditions do not match Automatic ejection of weapons when conditions do not match A mutator for throwing weapons away if the player does not meet certain criteria. For example, throwing away someone else's perk weapon or throwing away speci...
#1
Posted:
Automatic ejection of weapons when conditions do not match
A mutator for throwing weapons away if the player does not meet certain criteria. For example, throwing away someone else’s perk weapon or throwing away special guns, for which you need to have a certain level and/or perk. The weapon is thrown in front of the player at a certain distance.
Settings in the ini file:
WeaponInfoList=(Perk="SRVetBerserker",Level=4,Weapon="KFMod.Katana") - элемент основного массива
Weapon - код пушки (полный - пакет.оружие)
Perk - перк обладателю которого позволено владеть данной пушкой (если написать Perk="", то важен только уровень - перк любой)
Level - уровень начиная с которого можно владеть оружием
То есть если мы хотим, чтобы катана у всех перков кроме берсеркера 4+ уровня выпадала - пишем то, что написано выше
Если мы хотим чтобы все перки до 6 выкидывали катану - пишем
WeaponInfoList=(Perk="",Level=6,Weapon="KFMod.Katana")
Если же мы хотим, чтобы катаной могли владеть берс начиная с 4 уровня и медик начиная с 8 уровня, то создаём ещё один элемента массива:
WeaponInfoList=(Perk="SRVetFieldMedic",Level=8,Weapon="KFMod.Katana")
При такой настройке катана будет у 4+ берса и 8+ медика, у остальных она будет выпадать
Ну вроде самое сложное отписал. Если что непонятно - спрашивайте в комментариях.
Остальные настройки:
ExceptionList=76561198044444444 - массив игроков на которых мутатор не действует
bAdminInExceptionList=false - принадлежат ли админы к исключениям? если true, то на всех кто сейчас находится под админкой мутатор не действует
TimerPeriod=2.000000 - период таймера в секундах, который осуществляет проверку легитимности)
bDestroy=True - некоторые пушки нельзя выкинуть, если значение этого параметра true - значит такие пушки просто будут уничтожаться
ThrowDistance=100 - расстояние на которое выбрасываются пушки впереди игрока
bSendInfoMessage=True - пишем ли мы сообщение игроку о выбрасывании пушки
MSG_Drop=Your perk and/or level is not good enough to possess - само сообщение. в конце данного сообщения автоматически добавляется название пушки (Weapon.ItemName)
Mutator
class DropWeaponsMut extends Mutator config(DropWeaponsMut);
// Drops weapons listed in ini when perk/level rules fail.
struct WeaponInfoStruct
{
var() globalconfig string Perk;
var() globalconfig int Level;
var() globalconfig string Weapon;
};
var() globalconfig array<WeaponInfoStruct> WeaponInfoList;
var() globalconfig array<string> ExceptionList;
var() globalconfig bool bAdminInExceptionList;
var() globalconfig float TimerPeriod;
var() globalconfig bool bDestroy;
var() globalconfig int ThrowDistance;
var() globalconfig bool bSendInfoMessage;
var() globalconfig string MSG_Drop;
function PostBeginPlay()
{
SaveConfig();
SetTimer(TimerPeriod, true);
}
function Timer()
{
local Controller C;
for (C = Level.ControllerList; C != None; C = C.NextController)
{
if (C.IsA('PlayerController') && C.Pawn != None)
ModifyPawn(C.Pawn);
}
}
// Client: switch to best weapon after a forced drop.
simulated function Tick(float Delta)
{
local PlayerController PC;
PC = Level.GetLocalPlayerController();
if (PC != None && PC.Pawn != None && PC.Pawn.Weapon == None)
PC.SwitchToBestWeapon();
}
function ModifyPawn(Pawn Other)
{
local Inventory Inv;
if (Other == None || Other.Inventory == None)
return;
for (Inv = Other.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (InDropList(Inv, Other) && !InExceptionList(Other.Controller))
DropOrDestroy(Inv, Other);
}
}
function bool InDropList(Inventory Inv, Pawn Other)
{
local int i;
local int cLevel;
local string Veterancy;
local int InList, ReturnTrue;
local KFPlayerReplicationInfo KFPRI;
KFPRI = KFPlayerReplicationInfo(Other.PlayerReplicationInfo);
if (KFPRI != None)
{
cLevel = KFPRI.ClientVeteranSkillLevel;
Veterancy = string(KFPRI.ClientVeteranSkill.Name);
}
for (i = 0; i < WeaponInfoList.Length; i++)
{
if (string(Inv.Class) ~= WeaponInfoList[i].Weapon)
{
InList++;
if (
(WeaponInfoList[i].Perk != "" && Veterancy != WeaponInfoList[i].Perk)
|| cLevel < WeaponInfoList[i].Level)
{
ReturnTrue++;
}
}
}
if (InList > 0 && ReturnTrue == InList)
return true;
return false;
}
function DropOrDestroy(Inventory Inv, Pawn Other)
{
if (KFWeapon(Inv) == None)
return;
if (!KFWeapon(Inv).bKFNeverThrow)
{
if (PlayerController(Other.Controller) != None && bSendInfoMessage)
PlayerController(Other.Controller).ClientMessage(MSG_Drop @ Inv.ItemName);
Inv.DropFrom(Other.Location + vector(Other.Rotation) * ThrowDistance);
}
else if (bDestroy)
{
if (PlayerController(Other.Controller) != None && bSendInfoMessage)
PlayerController(Other.Controller).ClientMessage(MSG_Drop @ Inv.ItemName);
Inv.Destroy();
}
}
function bool InExceptionList(Controller C)
{
local PlayerController PC;
local int i;
local string Hash;
PC = PlayerController(C);
if (PC == None)
return true;
if (bAdminInExceptionList && C.PlayerReplicationInfo.bAdmin)
return true;
Hash = PC.GetPlayerIDHash();
for (i = 0; i < ExceptionList.Length; i++)
{
if (ExceptionList[i] ~= Hash)
return true;
}
return false;
}
defaultproperties
{
ExceptionList(0)="76561198044444444"
WeaponInfoList(0)=(Weapon="KFMod.Katana",Perk="SRVetBerserker",Level=4)
WeaponInfoList(1)=(Weapon="KFMod.Deagle",Perk="SRVetSharpshooter",Level=4)
WeaponInfoList(2)=(Weapon="KFMod.Katana",Perk="SRVetFieldMedic",Level=8)
bSendInfoMessage=true
MSG_Drop="Your perk and/or level is not good enough to possess"
bDestroy=true
bAdminInExceptionList=false
TimerPeriod=2.0
ThrowDistance=100
bAddToServerPackages=True
GroupName="KF-DropWeapons"
FriendlyName="DropWeapons"
Description="DropWeapons"
bAlwaysRelevant=True
RemoteRole=ROLE_SimulatedProxy
}
Path to the mutator:
DropWeaponsMut.DropWeaponsMut
Compiled version: https://yadi.sk/d/PdqXk-b_dpfCo
I wrote this mutator and thought But the one who asked me probably just needed a mutator that throws out the guns of someone else’s perk He will hesitate to drive all the guns into the inishnik) And he made a stripped-down version of the same mutator without any lists. Stupidly checking the perk index and gun index
So, the mutator throws out guns belonging to someone else’s perk
Settings in the ini file:
ExceptionList=76561198044444444 - массив игроков на которых мутатор не действует
bAdminInExceptionList=false - принадлежат ли админы к исключениям? если true, то на всех кто сейчас находится под админкой мутатор не действует
TimerPeriod=1.000000 - период таймера в секундах, который осуществляет проверку легитимности)
bDestroy=True - некоторые пушки нельзя выкинуть, если значение этого параметра true - значит такие пушки просто будут уничтожаться
ThrowDistance=100 - расстояние на которое выбрасываются пушки впереди игрока
bSendInfoMessage=True - пишем ли мы сообщение игроку о выбрасывании пушки
MSG_Drop=You have wrong perk to possess - само сообщение. в конце данного сообщения автоматически добавляется название пушки (Weapon.ItemName)
Mutator
class DropNonPerkWeaponsMut extends Mutator config(DropNonPerkWeaponsMut);
// Simpler mutator: drop weapons that do not match the player perk index.
var() globalconfig array<string> ExceptionList;
var() globalconfig bool bAdminInExceptionList;
var() globalconfig float TimerPeriod;
var() globalconfig bool bDestroy;
var() globalconfig int ThrowDistance;
var() globalconfig bool bSendInfoMessage;
var() globalconfig string MSG_Drop;
function PostBeginPlay()
{
SaveConfig();
SetTimer(TimerPeriod, true);
}
function Timer()
{
local Controller C;
for (C = Level.ControllerList; C != None; C = C.NextController)
{
if (C.IsA('PlayerController') && C.Pawn != None)
ModifyPawn(C.Pawn);
}
}
simulated function Tick(float Delta)
{
local PlayerController PC;
PC = Level.GetLocalPlayerController();
if (PC != None && PC.Pawn != None && PC.Pawn.Weapon == None)
PC.SwitchToBestWeapon();
}
function ModifyPawn(Pawn Other)
{
local Inventory Inv;
if (Other == None || Other.Inventory == None)
return;
for (Inv = Other.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (InDropList(Inv, Other) && !InExceptionList(Other.Controller))
DropOrDestroy(Inv, Other);
}
}
function bool InDropList(Inventory Inv, Pawn Other)
{
local int cLevel;
local string Veterancy;
local KFPlayerReplicationInfo KFPRI;
local int PerkIndex;
if (KFWeapon(Inv) == None)
return false;
KFPRI = KFPlayerReplicationInfo(Other.PlayerReplicationInfo);
if (KFPRI != None)
{
cLevel = KFPRI.ClientVeteranSkillLevel;
Veterancy = string(KFPRI.ClientVeteranSkill.Name);
PerkIndex = KFPRI.ClientVeteranSkill.default.PerkIndex;
}
if (PerkIndex != class<KFWeaponPickup>(KFWeapon(Inv).PickupClass).default.CorrespondingPerkIndex)
return true;
return false;
}
function DropOrDestroy(Inventory Inv, Pawn Other)
{
if (KFWeapon(Inv) == None)
return;
if (!KFWeapon(Inv).bKFNeverThrow)
{
if (PlayerController(Other.Controller) != None && bSendInfoMessage)
PlayerController(Other.Controller).ClientMessage(MSG_Drop @ Inv.ItemName);
Inv.DropFrom(Other.Location + vector(Other.Rotation) * ThrowDistance);
}
else if (bDestroy)
{
if (PlayerController(Other.Controller) != None && bSendInfoMessage)
PlayerController(Other.Controller).ClientMessage(MSG_Drop @ Inv.ItemName);
Inv.Destroy();
}
}
function bool InExceptionList(Controller C)
{
local PlayerController PC;
local int i;
local string Hash;
PC = PlayerController(C);
if (PC == None)
return true;
if (bAdminInExceptionList && C.PlayerReplicationInfo.bAdmin)
return true;
Hash = PC.GetPlayerIDHash();
for (i = 0; i < ExceptionList.Length; i++)
{
if (ExceptionList[i] ~= Hash)
return true;
}
return false;
}
defaultproperties
{
ExceptionList(0)="76561198044444444"
bSendInfoMessage=true
MSG_Drop="You have wrong perk to possess"
bDestroy=false
bAdminInExceptionList=false
TimerPeriod=1.0
ThrowDistance=150
bAddToServerPackages=True
GroupName="KF-DropNonPerkWeapons"
FriendlyName="DropNonPerkWeaponsMut"
Description="DropNonPerkWeaponsMut"
bAlwaysRelevant=True
RemoteRole=ROLE_SimulatedProxy
}
Path to the mutator:
DropNonPerkWeaponsMut.DropNonPerkWeaponsMut
Compiled version: https://yadi.sk/d/FzmWo6KNdpfUH
P.S. Both mutators spam the log a bit when throwing out guns. I’ll fix it later.
Warning: DropWeaponsMut KF-Meow-NewYearFix.DropWeaponsMut (Function DropWeaponsMut.DropWeaponsMut.ModifyPawn:008A) Accessed None 'Inv'
Author: Flame