So on Unsmarts there were a few people making turrets with ungodly amounts of clip planes and they were off center regardless. This gave me an idea, allowing you to play animations (sequences) that props have built in. After about an hour I've got it working well. The video below is Divrans upgrading sentry, recorded by danking.
To get this to work you must first overwrite the file in wire/lua/entities/gmod_wire_hologram/ called shared.lua with:
Code:
ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.PrintName = "Wire Hologram"
ENT.Author = "McLovin, edited for animations by dlb"
ENT.Spawnable = false
ENT.AdminSpawnable = false
ENT.AutomaticFrameAdvance = true
--Taken from base_gmodentity--
function ENT:SetPlayer( ply )
self:SetVar( "Founder", ply )
self:SetVar( "FounderIndex", ply:UniqueID() )
self:SetNetworkedString( "FounderName", ply:Nick() )
end
function ENT:GetPlayer()
return self:GetVar( "Founder", NULL )
end
function ENT:Think()
self:NextThink(CurTime())
return true
end
and then in wire/lua/entities/gmod_wire_expression2/core/custom create a file called holoAnim with the following code:
Code:
local CheckIndex = wire_holograms.CheckIndex
local function SetHoloAnim( Holo, Animation, Frame, Rate )
Holo.ent:ResetSequence(Animation)
Holo.ent:SetCycle(Frame)
Holo.ent:SetPlaybackRate(Rate)
end
e2function void holoAnim(index, string animation)
local Holo = CheckIndex(self, index)
if not Holo then return end
local Sequence = Holo.ent:LookupSequence(animation)
if not Sequence then return end
SetHoloAnim(Holo, Sequence, 0, 1)
end
e2function void holoAnim(index, string animation, frame)
local Holo = CheckIndex(self, index)
if not Holo then return end
local Sequence = Holo.ent:LookupSequence(animation)
if not Sequence then return end
SetHoloAnim(Holo, Sequence, frame, 1)
end
e2function void holoAnim(index, string animation, frame, rate)
local Holo = CheckIndex(self, index)
if not Holo then return end
local Sequence = Holo.ent:LookupSequence(animation)
if not Sequence then return end
SetHoloAnim(Holo, Sequence, frame, rate)
end
e2function void holoAnim(index, animation)
local Holo = CheckIndex(self, index)
if not Holo then return end
SetHoloAnim(Holo, animation, 0, 1)
end
e2function void holoAnim(index, animation, frame)
local Holo = CheckIndex(self, index)
if not Holo then return end
SetHoloAnim(Holo, animation, frame, 1)
end
e2function void holoAnim(index, animation, frame, rate)
local Holo = CheckIndex(self, index)
if not Holo then return end
SetHoloAnim(Holo, animation, frame, rate)
end
e2function number holoAnimLength(index)
local Holo = CheckIndex(self, index)
if not Holo then return 0 end
return Holo.ent:SequenceDuration()
end
e2function number holoAnimNum(index, string animation)
local Holo = CheckIndex(self, index)
if not Holo then return 0 end
local Sequence = Holo.ent:LookupSequence(animation)
if not Sequence then return 0 end
return Sequence
end
e2function void holoSetPose(index, string pose, value)
local Holo = CheckIndex(self, index)
if not Holo then return end
Holo.ent:SetPoseParameter( pose, value )
end
e2function number holoGetPose(index, string pose)
local Holo = CheckIndex(self, index)
if not Holo then return end
return Holo.ent:GetPoseParameter( pose )
end
Then restart the server or your client(if you play singleplayer) and it should work. You need UWSVNs holoModel allowing any model so you can actually have models with animations.
You should now have the following functions:
Code:
holoAnim(index, string animation) - sets the animation of the holo to that of the string
holoAnim(index, string animation, frame) - as above with start frame
holoAnim(index, string animation, frame, rate) - as above with playback rate (1 is normal)
holoAnim(index, string animation) - sets the animation of the holo to that of the number
holoAnim(index, string animation, frame) - as above with start frame
holoAnim(index, string animation, frame, rate) - as above with playback rate (1 is normal)
holoAnimLength(index) - returns the length of the animation thats playing for the specified index
holoAnimNum(index, string animation) - returns the number for that animation with the model of the holo specified
holoSetPose(index, string pose, value) - sets the pose variable to that of value, for example you can set aim_yaw for a tf2 sentries rotation
holoGetPose(index, string pose) - returns the value for the specified pose variable, for example aim_yaw on a tf2 sentry
This e2 will cycle through the models animations, playing each one in full, you can wire a screen to the I output to get the anim numbers:
Code:
@name HoloAnim Tester
@outputs I
if(first()){
holoCreate(1)
holoModel(1,"models/dog.mdl")
holoAnim(1,0)
I++
timer("changeanim",holoAnimLength(1)*1000)
}
if(clk("changeanim")){
holoAnim(1,I)
I++
timer("changeanim",holoAnimLength(1)*1000)
} Comments, critisism and advice below, thanks
If you have a server that has this, leave a comment and I'll add it to the list.
Credit to Cody for the idea, Flieboy for help finding the functions, Divran for testing and Danking for recording the video.
Servers that have this addon:
Unsmart's Wiremod Build Server - 89.238.160.112:27017
Bookmarks