User Tag List

Results 1 to 2 of 2
  1. #1
    Whicked Sick Higor's Avatar
    Join Date
    Apr 2012
    Location
    Full sail ahead!
    Posts
    3,676
    Country:

    Partial Fix: Nuke Siren

    Nuke siren will spam log warnings on the server machine (or standalone) in presence of spectators or generous nuke givers.

    Code:
    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'sgNukeLauncher')).AmmoType.AmmoAmount > 0)
    					{
    						SoundTheAlarm();
    					}
    		}
    	else
    		{
    			foreach RadiusActors(Class'PlayerPawn', p, TurnOffRange)
    				if (p.PlayerReplicationInfo.Team != Team && sgNukeLauncher(p.FindInventoryType(class'sgNukeLauncher')).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:
    Code:
    var Pawn aNuker;
    Store the detected nuker to avoid iterations


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


    Code:
    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'sgNukeLauncher'));
    				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'sgNukeLauncher'));
    			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'sgNukeLauncher'));
    				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.
    Last edited by Higor; 07-01-2012 at 11:52 PM.

  2. #2
    Moderator .seVered.]['s Avatar
    Join Date
    Jun 2011
    Location
    Near a River and Under a Bridge
    Posts
    2,125
    Country:
    that might explain the lag. perhaps when more than one person has a nuke or multiple nuke's in hand....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Nuke Siren poll
    By Higor in forum Code Reviews
    Replies: 32
    Last Post: 03-15-2013, 07:34 PM
  2. Nuke Siren
    By ][X][~FLuKE~][X][ in forum Code Reviews
    Replies: 23
    Last Post: 01-14-2013, 07:47 AM
  3. Better than a nuke siren:
    By Higor in forum Code Reviews
    Replies: 38
    Last Post: 01-13-2013, 12:23 AM
  4. NUKE SIREN!
    By |uK|kenneth in forum Code Reviews
    Replies: 16
    Last Post: 07-12-2012, 07:36 PM
  5. Reduce the Area of the Nuke Siren
    By SilverWing in forum zp| * * * -=[SIEGE]=- |uK| One Night Stand -=[SIEGE]=- Server * * *
    Replies: 17
    Last Post: 02-28-2012, 08:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •