ArenMook

Server-wide pirate invasion

Dec 28th, 2015
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. if (TNManager.isHosting)
  2. {
  3.     List<GameTown> towns = new List<GameTown>();
  4.  
  5.     for (int i = 0; i < GameTown.list.size; ++i)
  6.     {
  7.         GameTown t = GameTown.list[i];
  8.         if (!t || t.isPlayerClose) continue;
  9.         towns.Add(t);
  10.     }
  11.  
  12.     if (towns.size == 0) return;
  13.  
  14.     float farthestDist = 0f;
  15.     GameTown farthest = null;
  16.     Vector3 pos = (MyPlayer.ship != null) ? MyPlayer.ship.position : Vector3.zero;
  17.  
  18.     for (int i = 0; i < towns.size; ++i)
  19.     {
  20.         float dist = Vector3.SqrMagnitude(pos - towns[i].dockPos);
  21.  
  22.         if (dist > farthestDist)
  23.         {
  24.             farthestDist = dist;
  25.             farthest = towns[i];
  26.         }
  27.     }
  28.  
  29.     if (!farthest) return;
  30.  
  31.     farthest.ChangeFaction(0);
  32.  
  33.     for (int i = 0; i < farthest.sightRangeList.size; ++i)
  34.     {
  35.         GameUnit unit = farthest.sightRangeList[i];
  36.         if (unit && unit.isActive && unit.player == null)
  37.             unit.ChangeFaction(0);
  38.     }
  39.    
  40.     GameZone.UpdateChannelInfo(false);
  41. }
  42.  
  43. UIGameChat.AddCurrent("The pirates are invading!", Color.yellow);
Advertisement
Add Comment
Please, Sign In to add comment