multitasker fix

This commit is contained in:
Shtoyan 2022-07-19 19:26:56 +04:00
parent 288aa99416
commit 605d020251
3 changed files with 60 additions and 57 deletions

View File

@ -13,6 +13,16 @@ var float InventoryBoxWidth;
var float InventoryBoxHeight;
var float BorderSize;
// weapons list for `MultiTasker` skill
struct WeaponProgressDisplay
{
var class<NiceWeapon> weapClass;
var float progress;
var bool bShowCounter;
var int counter;
};
var array<WeaponProgressDisplay> niceWeapProgressSet;
event NotifyLevelChange()
{
Master.RemoveInteraction(self);
@ -53,6 +63,30 @@ final private function bool bIsBleeding(ScrnHumanPawn pwn)
return false;
}
final private function UpdateNiceWeapProgressSet(NiceHumanPawn pwn)
{
local Inventory I;
local NiceWeapon niceWeap;
local WeaponProgressDisplay newProgress;
if (pwn != none && pwn.Inventory != none)
{
for (I = pwn.Inventory; I != none; I = I.Inventory)
{
niceWeap = NiceWeapon(I);
if (niceWeap != none && niceWeap != pwn.weapon && !niceWeap.IsMagazineFull())
{
newProgress.weapClass = niceWeap.class;
newProgress.progress = niceWeap.holsteredCompletition;
newProgress.bShowCounter = true;
newProgress.counter = niceWeap.GetMagazineAmmo();
niceWeapProgressSet[niceWeapProgressSet.Length] = newProgress;
}
}
}
}
function PostRender(Canvas C)
{
local int i;
@ -171,22 +205,27 @@ function PostRender(Canvas C)
}
}
nicePawn = NiceHumanPawn(nicePlayer.pawn);
//// Draw weapons progress bars
if (class'NiceVeterancyTypes'.static.hasSkill(nicePlayer, class'NiceSkillEnforcerMultitasker')
&& nicePlayer.bFlagDisplayWeaponProgress && niceMutator.niceWeapProgressSet.length > 0)
// at first update weapon info
niceWeapProgressSet.Length = 0;
UpdateNiceWeapProgressSet(nicePawn);
if (nicePawn != none && class'NiceVeterancyTypes'.static.hasSkill(nicePlayer, class'NiceSkillEnforcerMultitasker')
&& nicePlayer.bFlagDisplayWeaponProgress && niceWeapProgressSet.length > 0)
{
x = C.ClipX - InventoryBoxWidth * C.ClipX - 5;
y = C.ClipY * 0.5 - 0.5 * (InventoryBoxHeight * C.ClipX + 4) * niceMutator.niceWeapProgressSet.Length;
for (i = 0;i < niceMutator.niceWeapProgressSet.Length;i ++)
y = C.ClipY * 0.5 - 0.5 * (InventoryBoxHeight * C.ClipX + 4) * niceWeapProgressSet.Length;
for (i = 0; i < niceWeapProgressSet.Length; i++)
{
DrawWeaponProgress(C, niceMutator.niceWeapProgressSet[i], x, y,
C.ViewPort.Actor.Pawn.PlayerReplicationInfo.Team);
DrawWeaponProgress(C, niceWeapProgressSet[i], x, y, nicePawn.PlayerReplicationInfo.Team);
y += (InventoryBoxHeight * C.ClipX + 4);
}
}
//// Draw invincibility bar
nicePawn = NiceHumanPawn(nicePlayer.pawn);
if(nicePawn != none && nicePawn.invincibilityTimer != 0.0)
{
C.SetDrawColor(255, 255, 255);
@ -360,9 +399,9 @@ function DrawCalibrationStars(Canvas C){
}
}
function DrawWeaponProgress(Canvas C, NicePack.WeaponProgressDisplay weapProgress, int x, int y, TeamInfo team)
function DrawWeaponProgress(Canvas C, WeaponProgressDisplay weapProgress, int x, int y, TeamInfo team)
{
local float textWidth, textHeight;
local float textWidth, textHeight;
local string textToDraw;
local float TempWidth, TempHeight, TempBorder;

View File

@ -221,16 +221,20 @@ function ServerCooldownAbility(string abilityID){
if(index >= 0)
nicePlayer.abilityManager.SetAbilityState(index, ASTATE_COOLDOWN);
}
simulated function Tick(float deltaTime){
simulated function Tick(float deltaTime)
{
local int index;
local Inventory Item;
local NiceWeapon niceWeap;
local WeaponTimePair newPair;
local array<WeaponTimePair> newWTPList;
local NicePack niceMutator;
local NicePlayerController nicePlayer;
nicePlayer = NicePlayerController(Controller);
if(Role == Role_AUTHORITY){
if (Role == Role_AUTHORITY)
{
// Brutal carnage
if (brutalCranageTimer > 0)
{
@ -329,33 +333,10 @@ simulated function Tick(float deltaTime){
forcedZedTimeCountDown -= deltaTime;
else
forcedZedTimeCountDown = 0.0;
niceMutator = class'NicePack'.static.Myself(Level);
if(niceMutator != none)
niceMutator.ClearWeapProgress();
if(!class'NiceVeterancyTypes'.static.hasSkill(NicePlayerController(Controller), class'NiceSkillEnforcerMultitasker'))
return;
if ( Role < ROLE_Authority && nicePlayer != none
&& nicePlayer.bFlagDisplayWeaponProgress)
{
// Update weapon progress for this skill
if(niceMutator == none) {
Log("Failed to update holstered progress, because no mut! :(");
return;
}
for(Item = Inventory; Item != none; Item = Item.Inventory){
niceWeap = NiceWeapon(Item);
if(niceWeap != none && niceWeap != weapon && !niceWeap.IsMagazineFull()){
niceMutator.AddWeapProgress(niceWeap.class, niceWeap.holsteredCompletition,
true, niceWeap.GetMagazineAmmo());
}
}
return;
}
else if (Role < ROLE_Authority)
{
Log( "Failed to update holstered progress, checked variables:"
@ nicePlayer @ nicePlayer.bFlagDisplayWeaponProgress);
}
// Auto-reload holstered weapons
holsteredReloadCountDown -= deltaTime;
if(holsteredReloadCountDown <= 0.0){

View File

@ -95,13 +95,7 @@ struct CounterDisplay{
var class<NiceSkill> ownerSkill;
};
var array<CounterDisplay> niceCounterSet;
struct WeaponProgressDisplay{
var class<NiceWeapon> weapClass;
var float progress;
var bool bShowCounter;
var int counter;
};
var array<WeaponProgressDisplay> niceWeapProgressSet;
// Replication of config between player and server
var int SrvFlags;
var array<NicePlayerController> playersList;
@ -502,18 +496,7 @@ simulated function int GetVisibleCountersAmount(){
simulated function int UpdateCounterValue(string cName){
return 0;
}
simulated function AddWeapProgress(class<NiceWeapon> weapClass, float progress,
optional bool bShowCounter, optional int counter){
local WeaponProgressDisplay newProgress;
newProgress.weapClass = weapClass;
newProgress.progress = progress;
newProgress.bShowCounter = bShowCounter;
newProgress.counter = counter;
niceWeapProgressSet[niceWeapProgressSet.Length] = newProgress;
}
simulated function ClearWeapProgress(){
niceWeapProgressSet.Length = 0;
}
// Returns cash per wave based on current difficulty
// Returns cash per wave based on current difficulty
function int GetWaveCash(int lastCashWave, int nextWave){