Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --careerservice hochschule battlebots
- local fullHealth=Spring.GetUnitHealth(unitID)
- local MeatRange=420
- function cleanseTable(tableName)
- table.remove(unitID)
- local spGetUnitDefID=Spring.GetUnitDefID
- for i=1,table.getn(tableName),1 do
- areyouDeafID=spGetUnitDefID(tableName[i])
- if not (areyouDeafID== UnitDefNames["gjbigbiowaste"].id or areyouDeafID== UnitDefNames["gjmedbiowaste"].idf) then
- table.remove(tableName,i)
- end
- end
- return tableName
- end
- --infunction
- --HiveHoundTable[1]=unitID
- --HiveHoundTable[2]=unitDefIf
- local spGetUnitHealth=Spring.GetUnitHealth
- if spGetUnitHealth(unitID) < fullHealth then
- IsItMeat={}
- IsItMeat=spGetUnitsInCylinder(teamID,ux,uz,MeatRange)
- IsItMeat=cleanseTable(IsItMeat)
- local spGetUPosition=Spring.GetUnitPosition
- local spIsUnitIDValid=Spring.ValidUnitID
- if IsItMeat~=nil and table.getn(IsItMeat)~=0 then
- dice= math.random(1,table.getn(IsItMeat)
- mx,mz,my=Spring.GetUnitPosition(IsItMeat[dice])
- --TODO Activate every Unit in HiveHoundTable
- --spawn every active HiveHound
- --Iterate through all active HiveHounds
- for i=1,table.getn(HiveHoundTable),1 do
- if spIsUnitIDValid(HiveHoundTable[i][1])==false then
- --unit is dead, spawn a new HiveHound
- HiveHoundTable[i][1]=Spring.CreateUnit("jHiveHound",homex,homey,homez, 0, teamID)
- HiveHoundTable[i][2]=UnitDefNames["jHiveHound"].id
- end
- Spring.SetUnitMoveGoal(HiveHoundTable[i][1],mx,my,mz)
- end
- -- Send them towards meat
- for i=1,table.getn(HiveHoundTable),1 do
- if spIsUnitIDValid(HiveHoundTable[i][1])==true and isHiveHoundInMeatRange(HiveHoundTable[i][1],mx,my,mz)==true then
- -- if Hivehounds are in MeatRange... respawn as MeatHoldingHiveHound at that to the table
- ax,ay,az=Spring.GetUnitPosition(HiveHoundTable[i][1])
- Spring.DestroyUnit(HiveHoundTable[i][1],false,false)
- StartThread(tearingOffSomeFlash,IsItMeat[dice])
- HiveHoundTable[i][1]=Spring.CreateUnit("jMeatHiveHound",ax,ay,az, 0, teamID)
- HiveHoundTable[i][2]=UnitDefNames["jMeatHiveHound"].id
- -- send MeatHivehound home
- Spring.SetUnitMoveGoal(HiveHoundTable[i][1],homex,homey,homez) --TODO replace home with the updated move coordinates
- end
- end
- --check For MeatHive
- checkForHiveHoundsToDissolve()
- end
- end
- local arbitraryMeatMagicValue=45
- function isHiveHoundInMeatRange(id,mx,mz,my)
- hx,hy,hz=Spring.GetUnitPosition(id)
- distance=math.sqrt((hx-mx)^2+(hy-my)^2 +(hz-mz)^2)
- if distance < arbitraryMeatMagicValue then return true else return false end
- end
- --sfx for the hungrys
- function tearingOffSomeFlash(meatId)
- Spring.AddUnitDamage(meatID,235)
- EmitSfx(1024,deathpivot)
- end
- function findHoundInHiveHOundTable(houndID)
- for i=1,table.getn(HiveHoundTable),1 do
- if HiveHoundTable[i][1]== houndID then return true end
- end
- return false end
- function checkForHiveHoundsToDissolve()
- tableToCheck={}
- x,y,z=Spring.GetUnitPosition(unitID)
- local spGetUnitDefID=Spring.GetUnitDefId
- tableToCheck=Spring.GetUnitsInCylinder(teamID,x,z)
- local ffHH=findHoundInHiveHOundTable
- table.remove(tableToCheck,unitID)
- if tableToCheck~=nil and table.getn(tableToCheck)~= 0 then
- for i=1,#tableToCheck,1 do
- boolCheckson= (spGetUnitDefID(tableToCheck[i])== UnitDefNames["jMeatHiveHound"].id)
- if ffHH([tableToCheck[i])== true or spGetUnitDefID(tableToCheck[i])== UnitDefNames["jMeatHiveHound"].id then
- if then
- Spring.AddUnitDamage(unitID,256)
- end
- Spring.DestroyUnit(tableToCheck[i],false,true)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment