Advertisement
Guest User

Sayis Destruction System

a guest
Apr 10th, 2020
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.98 KB | None | 0 0
  1. -- Sayis Destruction System
  2. behaviour("SayisTheJew")
  3. local PLAYER_TEAM = Team.Blue
  4. local ENEMY_TEAM = Team.Red
  5. local MIN_SPAWN_DISTANCE = 5
  6. local MAX_SPAWN_DISTANCE = 10
  7. -- local variables are launched using the awake function in the ravenscript api
  8. function SayisTheJew:Awake()
  9.         -- A `CapturePoint` where the player will start.
  10.         self.playerSpawn = nil -- CapturePoint
  11.         local Nodes = Ravenlua.new("Behaviour_Options")
  12.              for i,v in pairs(get(nodes) ) ;
  13.         print(Nodes)
  14.         -- Overlay Text
  15.        Overlay.ShowMessage("Detected" + Nodes)
  16.         self.enemySpawn = {} -- array<PathfindingNode>  
  17.         self.enemyBase = nil -- SpawnPoint
  18.         self.numAliveEnemies = 0
  19.         -- A number that represents the game's difficulty setting. Not used.
  20.         self.difficulty = 0.4
  21. end
  22. -- function is called to modify gamerule in ravenscript api
  23. function MyGameMode:OnModifyRules(rules)
  24.         print("Gamerule 1 detected, modifying.")
  25.         rules.noVehicles = true
  26.         rules.noTurrets = true
  27.         rules.playerTeam = PLAYER_TEAM
  28.         rules.nightMode = true
  29.         rules.balance = 1
  30.         self.difficulty = rules.difficulty
  31.         rules.spawnDeadPlayers = true
  32. end
  33. -- core scripts
  34. function SayisTheJew:OnStartGame()
  35.         local crates = GameObject.FindObjectsOfType(ResupplyCrate)
  36.         for i,c in ipairs(crates) do
  37.                 GameObject.Destroy(c)
  38.         end
  39.         print("Removed " .. tostring(#crates) .. " crates")  
  40.         for i,sp in ipairs(ActorManager.spawnPoints) do
  41.                 sp.gameObject:SetActive(false)
  42.         end
  43.         for i,sp in ipairs(ActorManager.spawnPoints) do
  44.                 if sp.isCapturePoint and sp.defaultOwner == PLAYER_TEAM then
  45.                         self.playerSpawn = sp
  46.                         print("Found player spawn point")
  47.                         break
  48.                 end
  49.         end
  50.         for i,sp in ipairs(ActorManager.spawnPoints) do
  51.                 if sp ~= self.playerSpawn then              
  52.                         local nodes = self:FindNodesCloseToSpawnPoint(sp)
  53.                         table.add_range(self.enemySpawn, nodes)
  54.                        -- Defend from the sayis jews
  55.                         if sp.defaultOwner == ENEMY_TEAM then
  56.                                 self.enemyBase = sp
  57.                         end
  58.                 end
  59.         end
  60.         print("Found ".. tostring(#self.enemySpawn) .." enemy spawn points")
  61. end
  62. function SayisTheJew:OnLoadoutAccepted(e)
  63.         if e.firstTime then
  64.                 print("Player is ready!")
  65.                 self:SpawnDeadActorsOfTeam(PLAYER_TEAM)
  66.                 self:SpawnDeadActorsOfTeam(ENEMY_TEAM)
  67.                 Overlay.ShowMessage("Make sure that you don't see any whores nearby")
  68.         end
  69.         return true
  70. end
  71. function SayisTheJew:FindNodesCloseToSpawnPoint(spawnPoint)
  72.         local close = {} -- array<PathfindingNode>
  73.         local center = spawnPoint.transform.position
  74.         local radius = MAX_SPAWN_DISTANCE
  75.         local nodes = Pathfinding.FindNodes(center, radius)
  76.         for i,node in ipairs(nodes) do
  77.                 local distance = Vector3.Distance(node.position, center)
  78.                 if distance > MIN_SPAWN_DISTANCE and distance < MAX_SPAWN_DISTANCE then
  79.                         table.insert(close, node)
  80.                 end
  81.         end
  82.         return close
  83. end
  84. function SayisTheJew:GetRandomEnemySpawn()
  85.         local i = Random.Range(1, #self.enemySpawn)
  86.         local node = self.enemySpawn[i]  
  87.         return node:RandomPointOnSurface()
  88. end
  89. function SayisTheJew:OnSpawnActors(e)
  90.         if e.team == PLAYER_TEAM then
  91.                 -- From the player's team we are only interested in spawning the
  92.                 -- player. All others are left for dead.
  93.                 for i,actor in ipairs(e.actorsToSpawn) do
  94.                         if actor.isPlayer then
  95.                                 actor.SpawnAt(self.playerSpawn.spawnPosition,
  96.                                         Quaternion.identity)
  97.                         end
  98.                 end
  99.         else              
  100.                 self.numAliveEnemies = self.numAliveEnemies + #e.actorsToSpawn          
  101.                 for i,actor in ipairs(e.actorsToSpawn) do
  102.                         actor.SpawnAt(self:GetRandomEnemySpawn(), Quaternion.identity)
  103.                 end            
  104.                 Order.PatrolBase(e.actorsToSpawn, self.enemyBase)
  105.         end      
  106.         return true
  107. end
  108. ]
  109. function SayisTheJew:OnActorDied(e)
  110.         if e.actor.isPlayer then
  111.                 -- The player is dead! Game over!
  112.                print("rip lmao its ok though sayis usually dies after like 1 battle in rp")
  113.                Overlay.ShowMessage("Vaccinate yourself Sayis")
  114.                 self:GameLost()
  115.         end
  116.         if e.actor.team == ENEMY_TEAM then
  117.                 -- A bot was killed. Keep track of number of living bots.
  118.                 self.numAliveEnemies = self.numAliveEnemies - 1
  119.                 print("Enemies alive: " .. tostring(self.numAliveEnemies))
  120.                 if self.numAliveEnemies <= 0 then
  121.                         -- All bots dead! Game over!
  122.                         self:GameWon()
  123.                 end
  124.         end
  125.         return true -- Override default behavior
  126. end
  127. function SayisTheJew:GameLost()
  128.         print("i mean its not game lost since sayis still dies")
  129.         self.script.StartCoroutine("FadeInGameOver")    
  130. end
  131. function SayisTheJew:FadeInGameOver()
  132.         self.targets.canvas.SetActive(true)      
  133.   `   local blackout = self.targets.blackout.GetComponent(UiImage)
  134.         local color = Color(0, 0, 0, 0)
  135.         local steps = 100
  136.         for i = 1, steps do            
  137.                 color.a = (1 / steps) * i
  138.                 blackout.color = color
  139.                 coroutine.yield(WaitForSeconds(0.02))
  140.         end
  141.  
  142. end
  143. function SayisTheJew:GameWon()
  144.         print("gottem")
  145.         Overlay.ShowMessage("Sayis Didn't Think Of This NOOOO HE DIED OMG")
  146. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement