Advertisement
FocusedWolf

AttachmentPoints

Jul 13th, 2011
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.37 KB | None | 0 0
  1. local marineModelName = "models/marine/male/male.model"
  2. local marineSpecialModelName = "models/marine/male/male_special.model"
  3. local skulkModelName = "models/alien/skulk/skulk.model"
  4. local fadeModelName = "models/alien/fade/fade.model"
  5. local lerkModelName = "models/alien/lerk/lerk.model"
  6. local gorgeModelName = "models/alien/gorge/gorge.model"
  7. local eggModelname = "models/alien/egg/egg.model"
  8.  
  9. local readyRoomPlayerClassName = "ReadyRoomPlayer"
  10. local marineClassName = "Marine"
  11. local skulkClassName = "Skulk"
  12. local fadeClassName = "Fade"
  13. local lerkClassName = "Lerk"
  14. local gorgeClassName = "Gorge"
  15. local eggClassName = "Embryo"
  16.  
  17. function PlayerHasMarineModel(playerEntity)
  18.     if playerEntity:isa(marineClassName) then
  19.         return true
  20.  
  21. //i think this is faster then going straight to the GetModelName() string compare.
  22.     elseif playerEntity:isa(readyRoomPlayerClassName) then
  23.         local modelName = playerEntity:GetModelName()
  24.         return modelName == marineModelName or modelName == marineSpecialModelName
  25.     end
  26.  
  27.     return false
  28. end
  29.  
  30. function PlayerHasSkulkModel(playerEntity)
  31.     if playerEntity:isa(skulkClassName) then
  32.         return true
  33.  
  34.     elseif playerEntity:isa(readyRoomPlayerClassName) then
  35.         return playerEntity:GetModelName() == skulkModelName
  36.     end
  37.  
  38.     return false
  39. end
  40.  
  41. function PlayerHasLerkModel(playerEntity)
  42.     if playerEntity:isa(lerkClassName) then
  43.         return true
  44.  
  45.     elseif playerEntity:isa(readyRoomPlayerClassName) then
  46.         return playerEntity:GetModelName() == lerkModelName
  47.     end
  48.  
  49.     return false
  50. end
  51.  
  52. function PlayerHasFadeModel(playerEntity)
  53.     if playerEntity:isa(fadeClassName) then
  54.         return true
  55.  
  56.     elseif playerEntity:isa(readyRoomPlayerClassName) then
  57.         return playerEntity:GetModelName() == fadeModelName
  58.     end
  59.  
  60.     return false
  61. end
  62.  
  63. function PlayerHasGorgeModel(playerEntity)
  64.     if playerEntity:isa(gorgeClassName) then
  65.         return true
  66.  
  67.     elseif playerEntity:isa(readyRoomPlayerClassName) then
  68.         return playerEntity:GetModelName() == gorgeModelName
  69.     end
  70.  
  71.     return false
  72. end
  73.  
  74. function PlayerHasEggModel(playerEntity)
  75.     if playerEntity:isa(eggClassName) then
  76.         return true
  77.  
  78.     elseif playerEntity:isa(readyRoomPlayerClassName) then
  79.         return playerEntity:GetModelName() == eggModelName
  80.     end
  81.  
  82.     return false
  83. end
  84.  
  85. //this (incomplete at the moment) function is specific to my application of figuring out where to put the name and icon for a player, but how it works could be useful for someone.
  86. function GetPlayerNameAndImageAttachmentPoints(playerEntity)
  87.  
  88. //I'm gonna upload a more optimized version of all this code as soon as i can.
  89. //For now note that calling playerEntity:GetAttachPointOrigin("JetPack") is unnecessary because attachPointCoords.origin is the same vector.
  90.  
  91.     local nameAttachmentPoint = nil
  92.     local imageAttachmentPoint = nil
  93.  
  94.     if self:PlayerHasMarineModel(playerEntity) then
  95.         local attachPointOrigin,success = playerEntity:GetAttachPointOrigin("JetPack")
  96.         if success then
  97.            
  98.             local attachPointCoords = playerEntity:GetAttachPointCoords("JetPack")
  99.            
  100.            
  101.             nameAttachmentPoint = attachPointOrigin + 0.00 * attachPointCoords.xAxis +
  102.                                                      -0.35 * attachPointCoords.yAxis +
  103.                                                      -0.37 * attachPointCoords.zAxis
  104.                                        
  105.             imageAttachmentPoint = attachPointOrigin + 0.00 * attachPointCoords.xAxis +
  106.                                                        0.20 * attachPointCoords.yAxis +
  107.                                                       -0.37 * attachPointCoords.zAxis            
  108.         end
  109.  
  110.     elseif self:PlayerHasSkulkModel(playerEntity) then
  111.         local attachPointOrigin,success = playerEntity:GetAttachPointOrigin("Bone_Tongue")
  112.         if success then
  113.            
  114.         end
  115.  
  116.     elseif self:PlayerHasLerkModel(playerEntity) then
  117.         local attachPointOrigin,success = playerEntity:GetAttachPointOrigin("Head_Tongue_02")
  118.         if success then
  119.            
  120.         end
  121.  
  122.     elseif self:PlayerHasFadeModel(playerEntity) then
  123.         local attachPointOrigin,success = playerEntity:GetAttachPointOrigin("fade_tongue2")
  124.         if success then
  125.            
  126.         end
  127.  
  128.     elseif self:PlayerHasGorgeModel(playerEntity) then
  129.         local attachPointOrigin,success = playerEntity:GetAttachPointOrigin("Head")
  130.         if success then
  131.            
  132.         end
  133.  
  134.     elseif self:PlayerHasEggModel(playerEntity) then
  135.         local attachPointOrigin,success = playerEntity:GetAttachPointOrigin("target")
  136.         if success then
  137.            
  138.         end    
  139.     end
  140.  
  141.     //anyone serious about messing with attachment points can maintain their sanity with this
  142.     //vector debug stuff. The code for these is here: http://pastebin.com/8jjwcCeH
  143.     DrawVectorPointBig(nameAttachmentPoint, white)
  144.     DrawVectorPointOnGround(nameAttachmentPoint,playerEntity:GetOrigin().y, white)
  145.    
  146.     DrawVectorPointBig(imageAttachmentPoint, orange)
  147.     DrawVectorPointOnGround(imageAttachmentPoint,playerEntity:GetOrigin().y, orange)
  148.    
  149.     //DrawVectorPointHuge(playerEntity:GetOrigin())
  150.     //DrawVectorPointHuge(playerEntity:GetEyePos())
  151.  
  152.     return nameAttachmentPoint,imageAttachmentPoint
  153. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement