Compare commits
4 Commits
c8613dc519
...
67f3dd11ed
Author | SHA1 | Date | |
---|---|---|---|
67f3dd11ed | |||
0d65944d4f | |||
62ece8d8dd | |||
28dba1571d |
@ -1,8 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* Mutator that replicates and diplayes on clients information about how many
|
* Mutator that replicates and diplayes on clients information about how many
|
||||||
* zeds are spawned and with what recent spawn rate.
|
* zeds are spawned and with what recent spawn rate.
|
||||||
|
*
|
||||||
|
* Author: dkanus
|
||||||
|
* Home repo: https://insultplayers.ru/git/dkanus/KFZedsReport
|
||||||
*/
|
*/
|
||||||
class KFZedsReportMut extends Mutator;
|
class KFZedsReportMut extends Mutator
|
||||||
|
config(KFZedsReport);
|
||||||
|
|
||||||
// How often should we update our information?
|
// How often should we update our information?
|
||||||
var config float updateInterval;
|
var config float updateInterval;
|
||||||
@ -16,14 +20,12 @@ var array<float> zedSpawnTimes;
|
|||||||
var int repCurrentTotalZeds, repGameInfo_MaxMonsters;
|
var int repCurrentTotalZeds, repGameInfo_MaxMonsters;
|
||||||
var float repCurrentSpawnRate;
|
var float repCurrentSpawnRate;
|
||||||
|
|
||||||
replication
|
replication {
|
||||||
{
|
reliable if (role == ROLE_Authority)
|
||||||
reliable if(Role == ROLE_Authority)
|
|
||||||
repCurrentTotalZeds, repGameInfo_MaxMonsters, repCurrentSpawnRate;
|
repCurrentTotalZeds, repGameInfo_MaxMonsters, repCurrentSpawnRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
function PostBeginPlay()
|
function PostBeginPlay() {
|
||||||
{
|
|
||||||
if (updateInterval <= 0) {
|
if (updateInterval <= 0) {
|
||||||
updateInterval = 0.25;
|
updateInterval = 0.25;
|
||||||
}
|
}
|
||||||
@ -33,44 +35,40 @@ function PostBeginPlay()
|
|||||||
SetTimer(updateInterval, true);
|
SetTimer(updateInterval, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bool CheckReplacement(Actor other, out byte bSuperRelevant)
|
function bool CheckReplacement(Actor other, out byte bSuperRelevant) {
|
||||||
{
|
|
||||||
if (Monster(other) != none) {
|
if (Monster(other) != none) {
|
||||||
zedSpawnTimes[zedSpawnTimes.length] = level.timeSeconds;
|
zedSpawnTimes[zedSpawnTimes.length] = level.timeSeconds;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
simulated function Tick(float delta)
|
simulated function Tick(float delta) {
|
||||||
{
|
|
||||||
local ReportInteraction myInteraction;
|
local ReportInteraction myInteraction;
|
||||||
local Player localPlayer;
|
local Player localPlayer;
|
||||||
|
|
||||||
if (role == Role_AUTHORITY) return;
|
if (role == Role_AUTHORITY) return;
|
||||||
if (interactionAdded) return;
|
if (interactionAdded) return;
|
||||||
localPlayer = level.GetLocalPlayerController().player;
|
localPlayer = level.GetLocalPlayerController().player;
|
||||||
if (localPlayer == none) return;
|
if (localPlayer == none) return;
|
||||||
|
|
||||||
myInteraction = ReportInteraction(localPlayer.interactionMaster
|
myInteraction = ReportInteraction(localPlayer.interactionMaster
|
||||||
.AddInteraction("KFZedsReport.ReportInteraction", localPlayer));
|
.AddInteraction(string(class'ReportInteraction'), localPlayer));
|
||||||
if (myInteraction != none)
|
if (myInteraction != none) {
|
||||||
{
|
|
||||||
myInteraction.reportMutator = self;
|
myInteraction.reportMutator = self;
|
||||||
interactionAdded = true;
|
interactionAdded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Timer()
|
function Timer() {
|
||||||
{
|
|
||||||
local int i;
|
local int i;
|
||||||
local float cutOffTime;
|
local float cutOffTime;
|
||||||
local Monster nextMonster;
|
local Monster nextMonster;
|
||||||
|
|
||||||
cutOffTime = level.timeSeconds - smoothingInterval;
|
cutOffTime = level.timeSeconds - smoothingInterval;
|
||||||
while (i < zedSpawnTimes.length)
|
while (i < zedSpawnTimes.length) {
|
||||||
{
|
|
||||||
if (zedSpawnTimes[i] < cutOffTime) {
|
if (zedSpawnTimes[i] < cutOffTime) {
|
||||||
zedSpawnTimes.Remove(i, 1);
|
zedSpawnTimes.Remove(i, 1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,16 +76,14 @@ function Timer()
|
|||||||
repGameInfo_MaxMonsters = KFGameType(level.game).maxMonsters;
|
repGameInfo_MaxMonsters = KFGameType(level.game).maxMonsters;
|
||||||
repCurrentSpawnRate = zedSpawnTimes.length / smoothingInterval;
|
repCurrentSpawnRate = zedSpawnTimes.length / smoothingInterval;
|
||||||
repCurrentTotalZeds = 0;
|
repCurrentTotalZeds = 0;
|
||||||
foreach level.DynamicActors(class'Monster', nextMonster)
|
foreach level.DynamicActors(class'Monster', nextMonster) {
|
||||||
{
|
|
||||||
if (nextMonster.health > 0) {
|
if (nextMonster.health > 0) {
|
||||||
repCurrentTotalZeds += 1;
|
repCurrentTotalZeds += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultproperties
|
defaultproperties {
|
||||||
{
|
|
||||||
// Mutator description
|
// Mutator description
|
||||||
GroupName = "Test mutatros"
|
GroupName = "Test mutatros"
|
||||||
FriendlyName = "Zed report mutator"
|
FriendlyName = "Zed report mutator"
|
@ -1,19 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Author: dkanus
|
||||||
|
* Home repo: https://insultplayers.ru/git/dkanus/KFZedsReport
|
||||||
|
*/
|
||||||
class ReportInteraction extends Interaction;
|
class ReportInteraction extends Interaction;
|
||||||
|
|
||||||
var KFZedsReportMut reportMutator;
|
var KFZedsReportMut reportMutator;
|
||||||
|
|
||||||
event NotifyLevelChange()
|
event NotifyLevelChange() {
|
||||||
{
|
|
||||||
if (master != none) {
|
if (master != none) {
|
||||||
master.RemoveInteraction(self);
|
master.RemoveInteraction(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function PostRender(Canvas canvas)
|
function PostRender(Canvas canvas) {
|
||||||
{
|
|
||||||
local float textWidth, textHeight;
|
local float textWidth, textHeight;
|
||||||
local string maxZedsReport, spawnRateReport;
|
local string maxZedsReport, spawnRateReport;
|
||||||
local string tagWhite, tagGreen;
|
local string tagWhite, tagGreen;
|
||||||
|
|
||||||
if (canvas == none) return;
|
if (canvas == none) return;
|
||||||
if (reportMutator == none) return;
|
if (reportMutator == none) return;
|
||||||
|
|
||||||
@ -32,7 +35,6 @@ function PostRender(Canvas canvas)
|
|||||||
canvas.DrawText(spawnRateReport);
|
canvas.DrawText(spawnRateReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultproperties
|
defaultproperties {
|
||||||
{
|
|
||||||
bVisible = true
|
bVisible = true
|
||||||
}
|
}
|
6
Configs/KFZedsReport.ini
Normal file
6
Configs/KFZedsReport.ini
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[KFZedsReport.KFZedsReportMut]
|
||||||
|
;= Home repo: https://insultplayers.ru/git/dkanus/KFZedsReport
|
||||||
|
;= How often should we update our information?
|
||||||
|
updateInterval=0.25
|
||||||
|
;= Over what interval do we count average spawn rate?
|
||||||
|
smoothingInterval=10.0
|
Loading…
Reference in New Issue
Block a user