Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local marineModelName = "models/marine/male/male.model"
- local marineSpecialModelName = "models/marine/male/male_special.model"
- local skulkModelName = "models/alien/skulk/skulk.model"
- local lerkModelName = "models/alien/lerk/lerk.model"
- local fadeModelName = "models/alien/fade/fade.model"
- local gorgeModelName = "models/alien/gorge/gorge.model"
- local eggModelName = "models/alien/egg/egg.model"
- //Thanks goes to Feha for this technique: http://www.unknownworlds.com/ns2/forums/index.php?s=&showtopic=114164&view=findpost&p=1860412
- local playerModelAttachmentPoints = {}
- // playerModelAttachmentPoints[modelName] = attachmentPoint, nameOffset, imageOffset
- playerModelAttachmentPoints[marineModelName] = { "JetPack", Vector(-0.02, -0.35, -0.32), Vector(0, 0.20, -0.37) }
- playerModelAttachmentPoints[marineSpecialModelName] = playerModelAttachmentPoints[marineModelName]
- playerModelAttachmentPoints[skulkModelName] = { "Bone_Tongue", Vector(0, -0.30, 0), Vector(0, 0, -0.37) }
- playerModelAttachmentPoints[lerkModelName] = { "Head_Tongue_02", Vector(0, 0.25, 0), Vector(0, 0, -0.37) }
- playerModelAttachmentPoints[fadeModelName] = { "fade_tongue2", Vector(0, 0.46, -0.40), Vector(0, -0.14, -0.37) }
- playerModelAttachmentPoints[gorgeModelName] = { "Head", Vector(0, 0.45, 0), Vector(0, 0.14, 0) }
- playerModelAttachmentPoints[eggModelName] = { "target", Vector(0, 0.55, 0), Vector(0, 0.10, 0) }
- function GUIPlayerBlips:GetModelAttachmentPoints(modelName)
- local value = playerModelAttachmentPoints[modelName]
- if not value then
- //PT("Invalid index:", modelName)
- return
- end
- return unpack(value)
- end
- local playerAngles = Angles()
- function GUIPlayerBlips:GetPlayerNameAndImageAttachmentPoints(playerEntity)
- local nameAttachmentPoint
- local imageAttachmentPoint
- local playerEntityModelName = playerEntity:GetModelName()
- //if playerEntityModelName == "" then
- // PT("entity has no model")
- // return
- //end
- local attachmentPoint, nameOffset, imageOffset = self:GetModelAttachmentPoints(playerEntityModelName)
- local attachPointCoords = playerEntity:GetAttachPointCoords(attachmentPoint)
- // This weird looking if-else structure was necessary to work around the weird rotations of the attachment point axes.
- // Some models use x,y,z attachPointCoords.axes to represant the x-axis, y-axis, and z-axis.
- // Other models used random attachPointCoords.axes to represant the x,y,z directions.
- // If that doesn't make sense then just search this code for all instances of "attachPointCoords.xAxis".
- if playerEntityModelName == marineModelName or playerEntityModelName == marineSpecialModelName or playerEntityModelName == eggModelName then
- nameAttachmentPoint = attachPointCoords.origin + nameOffset.x * attachPointCoords.xAxis +
- nameOffset.y * attachPointCoords.yAxis +
- nameOffset.z * attachPointCoords.zAxis
- imageAttachmentPoint = attachPointCoords.origin + imageOffset.x * attachPointCoords.xAxis +
- imageOffset.y * attachPointCoords.yAxis +
- imageOffset.z * attachPointCoords.zAxis
- elseif playerEntityModelName == skulkModelName then
- //hackish workaround for the problem the skulk attachment-point has when wall walking where it rises high above the skulk.
- //THIS PROBLEM IS FIXED IN NS2 version 181!!!
- playerAngles:BuildFromCoords(playerEntity:GetCoords())
- if math.abs(playerAngles.roll) > 0.01 then //if wallwalking
- local distanceFromAttachPoint = 1
- local startPoint = attachPointCoords.origin - attachPointCoords.xAxis * distanceFromAttachPoint
- local endPoint = attachPointCoords.origin + attachPointCoords.xAxis * distanceFromAttachPoint
- local trace = fTraceRay(startPoint, endPoint, PhysicsMask.Bullets, nil)
- local hitDistance = (startPoint - trace.endPoint):GetLength()
- //that number is the distance i get on the ground
- attachPointCoords.origin = attachPointCoords.origin + (hitDistance - 0.81078) * attachPointCoords.xAxis //it's really a y-axis for the skulk
- end
- nameAttachmentPoint = attachPointCoords.origin + nameOffset.x * attachPointCoords.zAxis +
- nameOffset.y * attachPointCoords.xAxis +
- nameOffset.z * attachPointCoords.yAxis
- imageAttachmentPoint = attachPointCoords.origin + imageOffset.x * attachPointCoords.zAxis +
- imageOffset.y * attachPointCoords.xAxis +
- imageOffset.z * attachPointCoords.yAxis
- elseif playerEntityModelName == lerkModelName or playerEntityModelName == fadeModelName or playerEntityModelName == gorgeModelName then
- nameAttachmentPoint = attachPointCoords.origin + nameOffset.x * attachPointCoords.yAxis +
- nameOffset.y * attachPointCoords.zAxis +
- nameOffset.z * attachPointCoords.xAxis
- imageAttachmentPoint = attachPointCoords.origin + imageOffset.x * attachPointCoords.yAxis +
- imageOffset.y * attachPointCoords.zAxis +
- imageOffset.z * attachPointCoords.xAxis
- //else
- // PT("Unknown model name:", playerEntityModelName)
- end
- return nameAttachmentPoint,imageAttachmentPoint
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement