Guest User

Untitled

a guest
Jan 15th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. --careerservice hochschule battlebots
  2. local fullHealth=Spring.GetUnitHealth(unitID)
  3. local MeatRange=420
  4.  
  5.  
  6. function cleanseTable(tableName)
  7. table.remove(unitID)
  8. local spGetUnitDefID=Spring.GetUnitDefID
  9. for i=1,table.getn(tableName),1 do
  10. areyouDeafID=spGetUnitDefID(tableName[i])
  11. if not (areyouDeafID== UnitDefNames["gjbigbiowaste"].id or areyouDeafID== UnitDefNames["gjmedbiowaste"].idf) then
  12. table.remove(tableName,i)
  13. end
  14.  
  15. end
  16. return tableName
  17. end
  18.  
  19. --infunction
  20. --HiveHoundTable[1]=unitID
  21. --HiveHoundTable[2]=unitDefIf
  22.  
  23.  
  24. local spGetUnitHealth=Spring.GetUnitHealth
  25.  
  26. if spGetUnitHealth(unitID) < fullHealth then
  27. IsItMeat={}
  28. IsItMeat=spGetUnitsInCylinder(teamID,ux,uz,MeatRange)
  29. IsItMeat=cleanseTable(IsItMeat)
  30. local spGetUPosition=Spring.GetUnitPosition
  31. local spIsUnitIDValid=Spring.ValidUnitID
  32.  
  33. if IsItMeat~=nil and table.getn(IsItMeat)~=0 then
  34. dice= math.random(1,table.getn(IsItMeat)
  35. mx,mz,my=Spring.GetUnitPosition(IsItMeat[dice])
  36. --TODO Activate every Unit in HiveHoundTable
  37. --spawn every active HiveHound
  38. --Iterate through all active HiveHounds
  39. for i=1,table.getn(HiveHoundTable),1 do
  40. if spIsUnitIDValid(HiveHoundTable[i][1])==false then
  41. --unit is dead, spawn a new HiveHound
  42. HiveHoundTable[i][1]=Spring.CreateUnit("jHiveHound",homex,homey,homez, 0, teamID)
  43. HiveHoundTable[i][2]=UnitDefNames["jHiveHound"].id
  44.  
  45. end
  46. Spring.SetUnitMoveGoal(HiveHoundTable[i][1],mx,my,mz)
  47.  
  48. end
  49. -- Send them towards meat
  50.  
  51. for i=1,table.getn(HiveHoundTable),1 do
  52. if spIsUnitIDValid(HiveHoundTable[i][1])==true and isHiveHoundInMeatRange(HiveHoundTable[i][1],mx,my,mz)==true then
  53. -- if Hivehounds are in MeatRange... respawn as MeatHoldingHiveHound at that to the table
  54. ax,ay,az=Spring.GetUnitPosition(HiveHoundTable[i][1])
  55. Spring.DestroyUnit(HiveHoundTable[i][1],false,false)
  56. StartThread(tearingOffSomeFlash,IsItMeat[dice])
  57. HiveHoundTable[i][1]=Spring.CreateUnit("jMeatHiveHound",ax,ay,az, 0, teamID)
  58. HiveHoundTable[i][2]=UnitDefNames["jMeatHiveHound"].id
  59. -- send MeatHivehound home
  60.  
  61. Spring.SetUnitMoveGoal(HiveHoundTable[i][1],homex,homey,homez) --TODO replace home with the updated move coordinates
  62. end
  63.  
  64. end
  65.  
  66.  
  67.  
  68. --check For MeatHive
  69. checkForHiveHoundsToDissolve()
  70. end
  71.  
  72. end
  73.  
  74. local arbitraryMeatMagicValue=45
  75. function isHiveHoundInMeatRange(id,mx,mz,my)
  76. hx,hy,hz=Spring.GetUnitPosition(id)
  77. distance=math.sqrt((hx-mx)^2+(hy-my)^2 +(hz-mz)^2)
  78. if distance < arbitraryMeatMagicValue then return true else return false end
  79. end
  80. --sfx for the hungrys
  81. function tearingOffSomeFlash(meatId)
  82. Spring.AddUnitDamage(meatID,235)
  83. EmitSfx(1024,deathpivot)
  84. end
  85.  
  86. function findHoundInHiveHOundTable(houndID)
  87. for i=1,table.getn(HiveHoundTable),1 do
  88. if HiveHoundTable[i][1]== houndID then return true end
  89. end
  90. return false end
  91.  
  92. function checkForHiveHoundsToDissolve()
  93. tableToCheck={}
  94. x,y,z=Spring.GetUnitPosition(unitID)
  95. local spGetUnitDefID=Spring.GetUnitDefId
  96. tableToCheck=Spring.GetUnitsInCylinder(teamID,x,z)
  97. local ffHH=findHoundInHiveHOundTable
  98.  
  99. table.remove(tableToCheck,unitID)
  100. if tableToCheck~=nil and table.getn(tableToCheck)~= 0 then
  101. for i=1,#tableToCheck,1 do
  102. boolCheckson= (spGetUnitDefID(tableToCheck[i])== UnitDefNames["jMeatHiveHound"].id)
  103. if ffHH([tableToCheck[i])== true or spGetUnitDefID(tableToCheck[i])== UnitDefNames["jMeatHiveHound"].id then
  104. if then
  105. Spring.AddUnitDamage(unitID,256)
  106. end
  107. Spring.DestroyUnit(tableToCheck[i],false,true)
  108. end
  109. end
  110. end
  111.  
  112. end
Add Comment
Please, Sign In to add comment