Advertisement
Guest User

Untitled

a guest
Oct 12th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.18 KB | None | 0 0
  1. function widget:GetInfo()
  2.   return {
  3.     name      = "JigokuShoujo",
  4.     desc      = "Go to HELL",
  5.     author    = "banana_Ai",
  6.     date      = "31 Aug 2013",
  7.     license   = "GNU GPL v2",
  8.     layer     = 0,
  9.     enabled   = true,  --  loaded by default?
  10.   }
  11. end
  12.  
  13. local localTeamID=Spring.GetLocalTeamID()
  14. local localAlly=Spring.GetLocalAllyTeamID()
  15. --------------------------------------------------
  16. -- options
  17. local lighnessK=1.8     -- than big this number than lighter will be map when u select units
  18. local silence=false     -- no auto-chat stuff?
  19.  
  20. ---------------------------------------------------
  21. -- quotes
  22.  
  23. -- to remove any quote just remove it from the list
  24. local quotesList={
  25.         -- enemie's comm got killed by your units
  26.         ["enComKilled"]={"Perhaps, it is time to die..."},  -- {"Oh, pitiful shadow lost in the darkness, bringing torment and pain to others,",
  27.                                                             -- "Oh, damned soul wallowing in your sin, Perhaps, it is time to die..."}
  28.         -- you nuke someone
  29.         ["nukeLaunch"]={"SHINY"}
  30.     }
  31.  
  32. -- send quote to chat
  33. local function DisplayMessage(teamID,quoteName)
  34.     if silence then return end
  35.    
  36.     local playerName=""
  37.     if teamID then
  38.         local _,playerID=Spring.GetTeamInfo(teamID)
  39.         playerName=Spring.GetPlayerInfo(playerID)
  40.         playerName=playerName..": "
  41.     end
  42.     local quote=quotesList[quoteName]
  43.     if quote then
  44.         for i=1,#quote,1 do
  45.             Spring.SendCommands("say "..playerName..quote[i])
  46.         end
  47.     end
  48. end
  49.  
  50. -------------------------------------------------------
  51. -- SHINY!
  52. local nukeDefID=UnitDefNames["corsilo"].id
  53. local lastNuke=0
  54. function widget:StockpileChanged(unitID, unitDefID, unitTeam, weaponNum, oldCount, newCount)
  55.     if unitTeam==localTeamID and unitDefID==nukeDefID and newCount<oldCount then
  56.         local now=Spring.GetGameSeconds()
  57.         if now-lastNuke>2 then
  58.             DisplayMessage(nil,"nukeLaunch")
  59.         end
  60.         lastNuke=now
  61.     end
  62. end
  63.  
  64. ----------------------------------------------------------
  65. -- unitName -> true
  66. local NamesAADefense={
  67.         { "armcir" , true },        --chainsaw
  68.         { "corrl" , true },     --defender
  69.  
  70.         { "corrazor" , true },      --razorkiss
  71.         { "corflak" , true },       --flak
  72.         { "screamer" , true },      --screamer
  73.         { "missiletower" , true },  --hacksaw
  74.        
  75.         --mobile AA
  76.         { "amphaa", true },
  77.         { "armaak", true},
  78.         { "armjeth", true},
  79.         { "corarch", true},
  80.         { "corcrash", true},
  81.         { "corsent", true},
  82.         { "gunshipaa", true},
  83.         { "hoveraa", true},
  84.         { "spideraa", true},
  85.         { "vehaa", true},
  86.     }
  87.  
  88. -- convert array form unitName -> true to unitDefID -> true
  89. local function convertUnitsArray(array)
  90.     local endAr={}
  91.     for i=1,#array,1 do
  92.         local p=array[i]
  93.         local ud=UnitDefNames[ p[1] ]
  94.         if ud then
  95.             endAr[ud.id]=p[2]
  96.             --Spring.Echo(p[1].." to "..ud.id)
  97.         end
  98.     end
  99.     return endAr
  100. end
  101.  
  102. local function GetAAWeaponData(ud)
  103.     local dps=0
  104.     local maxrange=0
  105.    
  106.     local weapData=ud.weapons
  107.     for i=1,#weapData,1 do
  108.         local weaponDef = WeaponDefs[weapData[i].weaponDef]
  109.         if not weaponDef.isShield then
  110.             local maxdmg=0
  111.            
  112.             local burst=weaponDef.salvoSize or 1
  113.             local projectiles= weaponDef.projectiles or 1
  114.             local reload = weaponDef.reload or 1
  115.            
  116.             local range=weaponDef.range or 0
  117.            
  118.             maxrange=math.max(maxrange,range)
  119.            
  120.             for key, val in pairs(weaponDef.damages) do
  121.                 maxdmg=math.max(maxdmg,val)
  122.             end
  123.             dps=dps+maxdmg*burst*projectiles/reload
  124.         end
  125.     end
  126.     return dps,maxrange
  127. end
  128.  
  129. AADefense=convertUnitsArray(NamesAADefense) -- defID -> true
  130.  
  131. -- defID -> {dps,range,mobile}
  132. local maxDPS=0
  133. for defID,_ in pairs(AADefense) do
  134.     local dps,maxrange=GetAAWeaponData(UnitDefs[defID])
  135.     local canMove=UnitDefs[defID].canMove
  136.     maxDPS=math.max(maxDPS,dps)
  137.     AADefense[defID]={dps=dps,range=maxrange,mobile=canMove}
  138. end
  139.  
  140. local defenseList={} -- unitID -> {defID,ally,pos}
  141.  
  142. -- based on code from gui_defenseRange.lua
  143. -- add unit into defenseList
  144. local function AddAA(unitID)
  145.     local unitDefID=Spring.GetUnitDefID(unitID)
  146.     if not unitDefID or not AADefense[unitDefID] or defenseList[unitID] then return end
  147.    
  148.     local data={}
  149.    
  150.     data.defID=unitDefID
  151.    
  152.     if Spring.GetUnitAllyTeam(unitID)==localAlly then
  153.         data.ally=true
  154.     end
  155.    
  156.     local x,y,z=Spring.GetUnitPosition(unitID)
  157.     data.pos={x,y,z}
  158.    
  159.     -- I do not know what is going on here
  160.     local _,_,_,_,build=Spring.GetUnitHealth(unitID)
  161.     data.complited=(build or 0)==1
  162.     defenseList[unitID]=data
  163. end
  164.  
  165. -----------------------------------------------------
  166.  
  167. local mode=Game.gameShortName or Game.modShortName
  168. local dotaComDefID
  169. if mode=="zkdota" then
  170.     dotaComDefID=UnitDefNames["custom_com_amp"].id
  171. end
  172.  
  173. local enComsInfo={}
  174.  
  175. function widget:UnitEnteredLos(unitID, teamID)
  176.     if Spring.AreTeamsAllied(teamID,Spring.GetMyTeamID()) then return end
  177.    
  178.     local unitDefID=Spring.GetUnitDefID(unitID)
  179.     if unitDefID then
  180.         -- add AA
  181.         AddAA(unitID)
  182.        
  183.         -- Add commander
  184.         if mode=="zkdota" and unitDefID==dotaComDefID then
  185.             enComsInfo[unitID]={defID=unitDefID,yoffset=UnitDefs[unitDefID].height+14}
  186.         elseif mode=="ZK" and UnitDefs[unitDefID].customParams.commtype then
  187.             local data={defID=unitDefID,yoffset=UnitDefs[unitDefID].height+14}
  188.            
  189.             local commModules = WG.GetCommModules and WG.GetCommModules(unitDefID)
  190.            
  191.             data.modules={}
  192.             if commModules then
  193.                 for i=1, #commModules,1 do
  194.                     local cmod=commModules[i]
  195.                     if cmod=="Personal Cloak" then
  196.                         data.modules.pcloak=true
  197.                     elseif cmod=="Lazarus Device" then
  198.                         data.modules.lazarus=true
  199.                     end
  200.                 end
  201.             end
  202.             data.weapons={}
  203.             data.dps=0
  204.             data.wdps=0
  205.             data.maxrange=0
  206.             data.range=999999
  207.             data.dmg=0
  208.             data.wdmg=0
  209.            
  210.             local weapData=UnitDefs[unitDefID].weapons
  211.             for i=1,#weapData,1 do
  212.                 local weaponDef = WeaponDefs[weapData[i].weaponDef]
  213.                 if not weaponDef.isShield then
  214.                     if weaponDef.description=="Disintegrator" then
  215.                         data.weapons.disintegrator=true
  216.                     elseif weaponDef.description=="Shock Rifle" then
  217.                         data.weapons.srifle=(data.weapons.srifle and data.weapons.srifle+1) or 1
  218.                     end
  219.                    
  220.                     local maxdmg=0
  221.                    
  222.                     local burst=weaponDef.salvoSize or 1
  223.                     local projectiles= weaponDef.projectiles or 1
  224.                     local reload = weaponDef.reload or 1
  225.                     local extraDmg= weaponDef.customParams.extra_damage or 0
  226.                    
  227.                     local range=weaponDef.range or 0
  228.                    
  229.                     data.maxrange=math.max(data.maxrange,range)
  230.                     if range>0 then
  231.                         data.range=math.min(data.range,range)
  232.                     end
  233.                    
  234.                     for key, val in pairs(weaponDef.damages) do
  235.                         maxdmg=math.max(maxdmg,val)
  236.                     end
  237.                    
  238.                    
  239.                     if weaponDef.paralyzer then
  240.                         data.wdmg=data.wdmg+maxdmg*burst*projectiles*3
  241.                         data.dmg=data.dmg+extraDmg*burst*projectiles
  242.                        
  243.                         data.wdps=data.wdps+maxdmg*burst*projectiles*3/reload
  244.                         data.dps=data.dps+extraDmg*burst*projectiles/reload
  245.                     else
  246.                         data.dmg=data.dmg+maxdmg*burst*projectiles
  247.                         data.dmg=data.dmg+extraDmg*burst*projectiles
  248.                        
  249.                         data.dps=data.dps+maxdmg*burst*projectiles/reload
  250.                         data.dps=data.dps+extraDmg*burst*projectiles/reload
  251.                     end
  252.                 end
  253.             end
  254.             enComsInfo[unitID]=data
  255.         end
  256.     end
  257. end
  258.  
  259. function widget:UnitLeftRadar(unitID, unitTeam)
  260.     if defenseList[unitID] then
  261.         local defData=AADefense[defenseList[unitID].defID]
  262.         if defData.mobile==true then
  263.             local x,y,z=Spring.GetUnitPosition(unitID)
  264.             if x and y and z then
  265.                 local inLosOrRadar=Spring.GetPositionLosState(x,y,z)
  266.                 if not inLosOrRadar then
  267.                     defenseList[unitID]=nil
  268.                 end
  269.             else
  270.                 defenseList[unitID]=nil
  271.             end
  272.         end
  273.     end
  274. end
  275.  
  276. function widget:UnitLeftLos(unitID, unitDefID, teamID)
  277.     enComsInfo[unitID]=nil
  278.    
  279.     if defenseList[unitID] then
  280.         local defData=AADefense[defenseList[unitID].defID]
  281.         if defData.mobile==true then
  282.             local x,y,z=Spring.GetUnitPosition(unitID)
  283.             if x and y and z then
  284.                 local inLosOrRadar=Spring.GetPositionLosState(x,y,z)
  285.                 if not inLosOrRadar then
  286.                     defenseList[unitID]=nil
  287.                 end
  288.             else
  289.                 defenseList[unitID]=nil
  290.             end
  291.         end
  292.     end
  293. end
  294.  
  295. function widget:TeamDied(teamID)
  296.     if not Spring.AreTeamsAllied(teamID,Spring.GetMyTeamID()) and teamID~=Spring.GetGaiaTeamID() then
  297.         local _,playerID,dead,_,_,ally=Spring.GetTeamInfo(teamID)
  298.         local teams=Spring.GetTeamList(ally)
  299.         for i=1,#teams,1 do
  300.             local t=teams[i]
  301.             if t~=teamID then
  302.                 local _,_,isDead,_,_,_=Spring.GetTeamInfo(t)
  303.                 if isDead==false then
  304.                     return
  305.                 end
  306.             end
  307.         end
  308.         -- AllyTeam is dead
  309.         -- Do whatever u want
  310.     end
  311.    
  312. end
  313.  
  314. function widget:GameFrame(frame)
  315.     for unitID, data in pairs(enComsInfo) do
  316.         local hp=Spring.GetUnitHealth(unitID)
  317.         if hp then
  318.             if hp<=0 then
  319.                 -- Com is DEAD!
  320.                 enComsInfo[unitID]=nil
  321.                
  322.                 local attackerID=Spring.GetUnitLastAttacker(unitID)
  323.                 if attackerID then
  324.                     if Spring.GetUnitTeam(attackerID)==localTeamID then
  325.                         DisplayMessage(Spring.GetUnitTeam(unitID),"enComKilled") -- Perhaps, it is time to die...
  326.                     end
  327.                 end
  328.             end
  329.         end
  330.     end
  331.    
  332.     if frame%10 then
  333.         -- code based on code from gui_defenseRange.lua
  334.         for unitID,data in pairs(defenseList) do
  335.             local defData=AADefense[data.defID]
  336.             if defData.mobile~=true then
  337.                 local x,y,z=data.pos[1],data.pos[2],data.pos[3]
  338.                 local inLosOrRadar, inLos, inRadar = Spring.GetPositionLosState(x, y, z)
  339.                 if inLos==true then
  340.                     if not Spring.GetUnitDefID(unitID) then
  341.                         defenseList[unitID]=nil --killed
  342.                     elseif not data.complited then
  343.                         local _,_,_,_,build=Spring.GetUnitHealth(unitID)
  344.                         data.complited=(build or 0)==1
  345.                     end
  346.                 end
  347.             else
  348.                 if not data.complited then
  349.                     local _,_,_,_,build=Spring.GetUnitHealth(unitID)
  350.                     data.complited=(build or 0)==1
  351.                 end
  352.             end
  353.         end
  354.     end
  355. end
  356.  
  357. function widget:UnitCreated(unitID, unitDefID, teamID, builderID)
  358.     AddAA(unitID)
  359. end
  360.  
  361. function widget:UnitDestroyed(unitID)
  362.     defenseList[unitID]=nil
  363. end
  364.  
  365. function widget:TextCommand(command)
  366.     local args={}
  367.     for arg in command:gmatch("%w+") do
  368.         args[#args+1]=arg
  369.     end
  370.    
  371.     if args[1]=="note" then
  372.         local selectedUnits=Spring.GetSelectedUnits()
  373.         if #selectedUnits>0 then
  374.             local unitID=selectedUnits[1]
  375.         end
  376.     end
  377. end
  378.  
  379. -- draw tip for coms
  380. local function DrawTip(unitID,data)
  381.     gl.Translate(0, data.yoffset,0)
  382.     gl.Billboard()
  383.     gl.Translate(0, 5 ,0)
  384.    
  385.     if mode=="zkdota" then
  386.         -- not ready yet
  387.         --local ud=UnitDefs[data.defID]
  388.     elseif mode=="ZK" then
  389.         local str=""
  390.         if data.dmg>0 then
  391.             str=str.." DMG"..data.dmg..":DPS"..data.dps
  392.         end
  393.        
  394.         if data.wdmg>0 then
  395.             str=str.." DMG"..data.wdmg..":DPS"..data.wdps.."P"
  396.         end
  397.        
  398.         str=str.." RNG"..data.maxrange..">"..data.range
  399.        
  400.         if data.modules.pcloak then
  401.             str=str.." PersCloak"
  402.         end
  403.        
  404.         if data.modules.lazarus then
  405.             str=str.." LazDev"
  406.         end
  407.        
  408.         if data.weapons.disintegrator then
  409.             str=str.." DG"
  410.         end
  411.        
  412.         if data.weapons.srifle then
  413.             if data.weapons.srifle==2 then
  414.                 str=str.." 2ShockR"
  415.             end
  416.         end
  417.        
  418.         gl.Text(str, 0, 0, 8, "co")
  419.     end
  420. end
  421.  
  422. local function DrawDecloackRange(r,yoffset)
  423.     gl.Translate(0, data.yoffset,0)
  424.     gl.DrawGroundCircle(0,0,0,r,15)
  425. end
  426.  
  427. local function DrawGroundLine(x1,z1,x2,z2,w)
  428.     local vec={x2-x1,z2-z1}
  429.     local len=math.sqrt(vec[1]*vec[1]+vec[2]*vec[2])
  430.    
  431.     local a=math.atan2(vec[1],vec[2])
  432.     gl.Utilities.DrawGroundLine(x1+w/2,z1+w/2,w,len,a)
  433. end
  434.  
  435. -- code from gfx_night.lua
  436. local function DrawNight()
  437.   gl.Blending(GL.ZERO, GL.SRC_COLOR)
  438.  
  439.   gl.MatrixMode(GL.PROJECTION)
  440.   gl.PushMatrix()
  441.   gl.LoadIdentity()
  442.   gl.MatrixMode(GL.MODELVIEW)
  443.   gl.PushMatrix()
  444.   gl.LoadIdentity()
  445.  
  446.   gl.Color(0.2*lighnessK, 0.25*lighnessK, 0.3*lighnessK)
  447.   gl.Rect(-1,1,1,-1)
  448.  
  449.   gl.MatrixMode(GL.PROJECTION)
  450.   gl.PopMatrix()
  451.   gl.MatrixMode(GL.MODELVIEW)
  452.   gl.PopMatrix()
  453.  
  454.   gl.Color(1, 1, 1, 1)
  455.   gl.Blending(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA)
  456. end
  457. -----
  458. local function Range2(x1,z1,x2,z2)
  459.     return (x1-x2)*(x1-x2)+(z1-z2)*(z1-z2)
  460. end
  461.  
  462. local function DrawRange(x1,z1,r1,x2,z2,r2,diam)
  463.     local unitDist=math.sqrt(Range2(x1,z1,x2,z2))-r1-r2;
  464.     if unitDist<=diam then
  465.         gl.Color(1,0,0,0.2)
  466.         DrawGroundLine(x1,z1,x2,z2,2)
  467.     elseif unitDist>diam and unitDist<diam*1.3 then
  468.         gl.Color(1,1,0,0.2)
  469.         DrawGroundLine(x1,z1,x2,z2,2)
  470.     elseif unitDist>=diam*1.3 and unitDist<=diam*2 then
  471.         gl.Color(0,1,0,0.2)
  472.         DrawGroundLine(x1,z1,x2,z2,2)
  473.     end
  474. end
  475.  
  476. local function UnitsRangeBetwen(uid,range,units)
  477.     local diam=range*2
  478.     for i=1,#units,1 do
  479.         local ally = Spring.GetUnitAllyTeam(units[i])
  480.         local x1,_,z1 = Spring.GetUnitPosition(units[i])
  481.         local r1 = Spring.GetUnitRadius(units[i])
  482.         if units[i]~=uid and ally~=localAlly and x1 and z1 and r1 then
  483.             for j=1,#units,1 do
  484.                 local ally2=Spring.GetUnitAllyTeam(units[j])
  485.                 if i~=j and units[j]~=uid and ally2~=localAlly then
  486.                     local x2,_,z2=Spring.GetUnitPosition(units[j])
  487.                     local r2 = Spring.GetUnitRadius(units[j])
  488.                     if x2 and z2 and r2 then
  489.                         DrawRange(x1,z1,r1,x2,z2,r2,diam)
  490.                     end
  491.                 end
  492.             end
  493.         end
  494.     end
  495. end
  496.  
  497. local function DrawCloakRanges(selectedUnits)
  498.     DrawNight()
  499.     local alreadyDrawed={}
  500.     for i=1,#selectedUnits,1 do
  501.         local unitID=selectedUnits[i]
  502.         local unitDefID=Spring.GetUnitDefID(unitID)
  503.         local cloaked=Spring.GetUnitIsCloaked(unitID)
  504.         if cloaked then
  505.             local r=UnitDefs[unitDefID].decloakDistance
  506.             local x,_,z=Spring.GetUnitPosition(unitID)
  507.            
  508.             gl.Color(0,1,0,0.2)
  509.             gl.Utilities.DrawGroundCircle(x,z,r)
  510.            
  511.             local enemyID=Spring.GetUnitNearestEnemy(unitID,r*3)
  512.             if enemyID then
  513.                 local ex,_,ez=Spring.GetUnitPosition(enemyID)
  514.                 if ex and ez then
  515.                     local rangeTo=math.sqrt((x-ex)*(x-ex)+(z-ez)*(z-ez))
  516.                     if rangeTo>r then
  517.                         gl.Color(1,0,0,0.2)
  518.                         DrawGroundLine(x,z,ex,ez,5)
  519.                     end
  520.                 end
  521.             end
  522.            
  523.             local enUnitsList=Spring.GetUnitsInCylinder(x,z,r*3)
  524.             UnitsRangeBetwen(unitID,r,enUnitsList)
  525.             if enUnitsList then
  526.                 for i=1,#enUnitsList,1 do
  527.                     local uid=enUnitsList[i]
  528.                     if not alreadyDrawed[uid] then
  529.                         local ux,_,uz=Spring.GetUnitPosition(uid)
  530.                         local ally=Spring.GetUnitAllyTeam(uid)
  531.                         local mradious=Spring.GetUnitRadius(uid)
  532.                         if mradious and ux and uz and ally~=localAlly then
  533.                             gl.Color(0,0,1,0.2)
  534.                             gl.Utilities.DrawGroundCircle(ux,uz,mradious)
  535.                             alreadyDrawed[uid]=true
  536.                         end
  537.                     end
  538.                 end
  539.             end
  540.         end
  541.     end
  542. end
  543.  
  544. local AAalphaMin=0.03
  545. local AAalphaMax=0.5
  546. local dpsK=(AAalphaMax-AAalphaMin)/maxDPS
  547.  
  548. local function DrawAAMap()
  549.     DrawNight()
  550.     for unitID,data in pairs(defenseList) do
  551.         if data.complited then
  552.             local defData=AADefense[data.defID]
  553.             local alpha=AAalphaMin + dpsK*defData.dps
  554.             if data.ally then
  555.                 gl.Color(0,1.0,0,alpha)
  556.             else
  557.                 gl.Color(1,0,0,alpha)
  558.             end
  559.            
  560.             local x,z
  561.             if defData.mobile then
  562.                 x,_,z = Spring.GetUnitPosition(unitID)
  563.             else
  564.                 x,z=data.pos[1],data.pos[3]
  565.             end
  566.             if x and z then
  567.                 gl.Utilities.DrawGroundCircle(x,z,defData.range)
  568.             end
  569.         end
  570.     end
  571. end
  572.  
  573. function widget:DrawWorldPreUnit()
  574.     local selectedUnits=Spring.GetSelectedUnits()
  575.     for i=1,#selectedUnits,1 do
  576.         local unitID=selectedUnits[i]
  577.         local unitDefID=Spring.GetUnitDefID(unitID)
  578.         if unitDefID then
  579.             if Spring.GetUnitIsCloaked(unitID) then
  580.                 DrawCloakRanges(selectedUnits)
  581.                 break
  582.             elseif UnitDefs[unitDefID].canFly==true or AADefense[unitDefID] then
  583.                 DrawAAMap()
  584.                 break
  585.             end
  586.         end
  587.     end
  588. end
  589.  
  590. function widget:DrawWorld()
  591.     if Spring.IsGUIHidden() then return end
  592.     gl.DepthTest(true)
  593.  
  594.     gl.Color(1, 1, 1)
  595.     --fontHandler.UseDefaultFont()
  596.  
  597.     for unitID, data in pairs(enComsInfo) do
  598.         gl.DrawFuncAtUnit(unitID, false, DrawTip, unitID,data)
  599.     end
  600.  
  601.     gl.DepthTest(false)
  602. end
  603.  
  604. -- redefine some gl.Utilities functions
  605. if (not gl) then
  606.     return
  607. end
  608. --------------------------------------------------------------------------------
  609. --------------------------------------------------------------------------------
  610. -- Exported Functions:
  611. --  gl.Utilities.DrawMyBox(minX,minY,minZ, maxX,maxY,maxZ)
  612. --  gl.Utilities.DrawMyCylinder(x,y,z, height,radius,divs)
  613. --  gl.Utilities.DrawMyHollowCylinder(x,y,z, height,radius,innerRadius,divs)
  614. --  gl.Utilities.DrawGroundLine(x,z,w,h,a) -- new one
  615. --  gl.Utilities.DrawGroundCircle(x,z,radius)
  616. --  gl.Utilities.DrawGroundHollowCircle(x,z,radius,innerRadius)
  617. --  gl.Utilities.DrawVolume(vol_dlist)
  618.  
  619. --------------------------------------------------------------------------------
  620. --------------------------------------------------------------------------------
  621.  
  622. VFS.Include("LuaRules/Utilities/glVolumes.lua")
  623. do
  624. gl.Utilities = gl.Utilities or {}
  625.  
  626. --------------------------------------------------------------------------------
  627. --------------------------------------------------------------------------------
  628.  
  629. local glVertex = gl.Vertex
  630.  
  631. local box = gl.CreateList(gl.Utilities.DrawMyBox,0,-0.5,0,1,0.5,1)
  632.  
  633. local heightMargin = 2000
  634. local minheight, maxheight = Spring.GetGroundExtremes()
  635. local averageGroundHeight = (minheight + maxheight) / 2
  636. local shapeHeight = heightMargin + (maxheight - minheight) + heightMargin
  637.  
  638. function gl.Utilities.DrawGroundLine(x,z,w,h,a)
  639.   gl.PushMatrix()
  640.   gl.Translate(x, averageGroundHeight, z)
  641.   gl.Rotate(180*a/math.pi,0,1,0)
  642.   gl.Scale(w, shapeHeight, h)
  643.  
  644.   gl.Utilities.DrawVolume(box)
  645.   gl.PopMatrix()
  646. end
  647.  
  648. --------------------------------------------------------------------------------
  649. --------------------------------------------------------------------------------
  650. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement