PDA

View Full Version : Partial Fix: Nuke Siren



Higor
07-01-2012, 11:49 PM
Nuke siren will spam log warnings on the server machine (or standalone) in presence of spectators or generous nuke givers.


function CheckForNukers()
{
local PlayerPawn p;

SirenRange = 2048*(1+Grade);
TurnOffRange = SirenRange + 1024;

if (!bAlreadySounding)
{
foreach RadiusActors(Class'PlayerPawn', p, SirenRange)
if (p.PlayerReplicationInfo.Team != Team && sgNukeLauncher(p.FindInventoryType(class'sgNukeLau ncher')).AmmoType.AmmoAmount > 0)
{
SoundTheAlarm();
}
}
else
{
foreach RadiusActors(Class'PlayerPawn', p, TurnOffRange)
if (p.PlayerReplicationInfo.Team != Team && sgNukeLauncher(p.FindInventoryType(class'sgNukeLau ncher')).AmmoType.AmmoAmount > 0)
{
return;
}
else
{
TurnOffAlarm();
}
}
}
Code assumes all PlayerPawns in radius must have a sgNukeLauncher weapon.
Code attempts to search again for nukers even if one has been found.
Alarm message spamming will be multiplied by the amount of nukers, anyone with half a brain would realize the amount of nukers due to this bug.
Also, alarm is turned off betwen 0-10 times per check even with a nuker in radius.
Alarm will disable itself after 0.5 second and reenable itself after another 0.5 second.

New code:

var Pawn aNuker;

Store the detected nuker to avoid iterations



simulated function FinishBuilding()
{
Super.FinishBuilding();
SetTimer(1.0, True);
}
Run every 1 second instead of 0.5, same functionality, less iterations.



function CheckForNukers()
{
local PlayerPawn p;
local sgNukeLauncher aNuke;

SirenRange = 2048*(1+Grade);
TurnOffRange = SirenRange + 1024;

if (!bAlreadySounding)
{
foreach RadiusActors(Class'PlayerPawn', p, SirenRange)
if ( p.PlayerReplicationInfo.Team != Team )
{
aNuke = sgNukeLauncher(p.FindInventoryType(class'sgNukeLau ncher'));
if ( (aNuke != none) && (aNuke.AmmoType.AmmoAmount > 0) )
{
SoundTheAlarm();
aNuker = p;
return;
}
}
}
else
{
if ( (aNuker != none) && !aNuker.bDeleteMe )
{
if ( VSize(aNuker.Location - Location) < TurnOffRange + aNuker.CollisionRadius)
aNuke = sgNukeLauncher(aNuker.FindInventoryType(class'sgNu keLauncher'));
if ( (aNuke != none) && (aNuke.AmmoType.AmmoAmount > 0) )
{
SoundTheAlarm();
return;
}
aNuker = none;
}
else
aNuker = none;

foreach RadiusActors(Class'PlayerPawn', p, TurnOffRange)
if ( p.PlayerReplicationInfo.Team != Team )
{
aNuke = sgNukeLauncher(p.FindInventoryType(class'sgNukeLau ncher'));
if ( (aNuke != none) && (aNuke.AmmoType.AmmoAmount > 0) )
{
SoundTheAlarm();
aNuker = p;
return;
}
}
TurnOffAlarm();
}
}
Check if players actually have a Nuke launcher.
If nuker is found, store it and shut down the iterator.
If previously found nuker is still within radius and still has the nuke, sound alarm again without iterating.
In contrary case, start searching for another nuker before turning off the alarm.
If another nuker is found, alarm is sound and iterator is shut down.
If all conditions fail, turn off the alarm.

EDIT, if mods want unaltered code, enter Edit Mode and copy it from there.

.seVered.][
07-02-2012, 12:09 AM
that might explain the lag. perhaps when more than one person has a nuke or multiple nuke's in hand....