+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: [E2]HoloAnim Extension

  1. #1
    Wirererer ben1066's Avatar
    Join Date
    Aug 2009
    Posts
    151

    Default [E2]HoloAnim Extension

    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
    Last edited by ben1066; 08-10-2010 at 09:07 AM. Reason: Updated for holoSetPose() and holoGetPose()

  2. #2
    No u Divran's Avatar
    Join Date
    Jul 2008
    Location
    Sweden
    Posts
    4,582

    Default Re: [E2]HoloAnim Extension

    Here's the upgrading sentry code. Change HOLONUM in if first if you want more sentries next to eachother
    Code:
    @name 
    @inputs 
    @outputs 
    @persist HOLONUM
    @trigger 
    #exit()
    if (first()) {
        HOLONUM = 50
        holoCreate(1)
        holoModel(1,"models/buildables/sentry1_heavy.mdl")
        holoAnim(1,"build")
        timer("1",holoAnimLength(1)*1000)
        if (HOLONUM) {
            for(I=2,HOLONUM) {
                holoCreate(I)
                holoModel(I,"models/buildables/sentry1_heavy.mdl")
                holoAnim(I,"build")
                holoPos(I,entity():pos()+vec(0,60*(I-1),0))
            }
        }
    } elseif (clk("1")) {
        holoModel(1,"models/buildables/sentry1.mdl")
        timer("2",1000)
        if (HOLONUM) {
            for(I=2,HOLONUM) {
                holoModel(I,"models/buildables/sentry1.mdl")
            }
        }
    } elseif (clk("2")) {
        holoModel(1,"models/buildables/sentry2_heavy.mdl")
        holoAnim(1,"upgrade")
        timer("3",holoAnimLength(1)*1000)
        if (HOLONUM) {
            for(I=2,HOLONUM) {
                holoModel(I,"models/buildables/sentry2_heavy.mdl")
                holoAnim(I,"upgrade")
            }
        }
    } elseif (clk("3")) {
        holoModel(1,"models/buildables/sentry2.mdl")
        timer("4",1000)
        if (HOLONUM) {
            for(I=2,HOLONUM) {
                holoModel(I,"models/buildables/sentry2.mdl")
            }
        }
    } elseif (clk("4")) {
        holoModel(1,"models/buildables/sentry3_heavy.mdl")
        holoAnim(1,"upgrade")
        if (HOLONUM) {
            for(I=2,HOLONUM) {
                holoModel(I,"models/buildables/sentry3_heavy.mdl")
                holoAnim(I,"upgrade")
            }
        }
        timer("5",holoAnimLength(1)*1000)
    } elseif (clk("5")) {
        holoModel(1,"models/buildables/sentry3.mdl")
        if (HOLONUM) {
            for(I=2,HOLONUM) {
                holoModel(I,"models/buildables/sentry3.mdl")
            }
        }
    }
    SVN Tutorial
    My SVN:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    Get dropbox and get 250 MB extra space: Dropbox

  3. #3
    Wirererer ben1066's Avatar
    Join Date
    Aug 2009
    Posts
    151

    Default Re: [E2]HoloAnim Extension

    Oh also, to get anim names use model viewer in source SDK.

  4. #4
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,680
    Blog Entries
    5

    Default Re: [E2]HoloAnim Extension

    I tried doing this awhile back, but it didn't work...

  5. #5
    Ursus maritimus Drunkie's Avatar
    Join Date
    Feb 2009
    Location
    Canada
    Posts
    5,657
    Blog Entries
    1

    Default Re: [E2]HoloAnim Extension

    Looks nice, good job.

  6. #6
    Wire Amateur Teh Reborn Devil's Avatar
    Join Date
    Jun 2010
    Location
    Norway, Larvik
    Posts
    99

    Default Re: [E2]HoloAnim Extension

    This should definitely be added to the UWSVN
    E2 is awesome <3

  7. #7
    Wire Noob Rynoxx's Avatar
    Join Date
    Oct 2009
    Location
    RetardXX-Land(aka Sweden)
    Posts
    7

    Default Re: [E2]HoloAnim Extension

    *agrees with the reborn devil* we better get this to UWSVN


    -----♥♥♥-----
    ----♥♥♥♥♥ ---Put This
    ---♥♥---♥♥---In Your
    ---♥♥---♥♥---Sig If
    ---♥♥---♥♥---You Know
    ----♥♥-♥♥----Someone
    -----♥♥♥-----Who Died Or Is Suffering
    ----♥♥-♥♥----from
    ---♥♥---♥♥---Retardness

  8. #8
    Wirererer ben1066's Avatar
    Join Date
    Aug 2009
    Posts
    151

    Default Re: [E2]HoloAnim Extension

    UPDATE: Cleaned up the code a bit and added holoSetPose() and holoGetPose().

  9. #9
    Wire Amateur rouing3's Avatar
    Join Date
    May 2010
    Posts
    35

    Default Re: [E2]HoloAnim Extension

    lol it was me fuckign around with a holo cliped tf2 turret i used the real prop and clipped it to turn so yea i think ill post it even though it isnt as good

  10. #10
    Alopex Lagopus DanKing's Avatar
    Join Date
    Aug 2009
    Location
    Bergen, Norway
    Posts
    632

    Default Re: [E2]HoloAnim Extension

    It works on ragdolls too:

+ Reply to Thread
Page 1 of 3 123 LastLast

LinkBacks (?)

  1. 10-31-2010, 05:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots