New Movement Code

Discussion in 'Deathrun' started by thomasfn, Sep 16, 2009.

Thread Status:
Not open for further replies.
  1. thomasfn

    thomasfn New Member

    Joined:
    Sep 16, 2009
    Messages:
    1
    Likes Received:
    0
    (Note - this is directed at the devs)
    Can't remember where this originally came from, I don't think I made it, but then again, I got so much crap lying around it's hard to tell what came from what. Basically, stick this in a file and make it all shared - remove any existing movement code hooks or you'll get weird things happening. Should be 100% lagless - no sticky feet or whatever causes the current movement script to lag.

    Code:
    function GM:UpdateAnimation( pl )
    	
    end
    
    function GM:SetupMove( pl, move )
    	
    end
    
    function GM:Move( ply, movedata )
    	
    	if !ply:Alive() or ply:WaterLevel() > 0 then return end
    	if ply:IsOnGround() then
    		
    		local vel = movedata:GetVelocity()
    		
    		if ply:KeyDown( IN_SPEED ) then
    			vel = vel * 0.95
    		end
    		
    		movedata:SetVelocity(vel)
    		
    	else
    	
    		local aim = movedata:GetMoveAngles()
    		local forward, right = aim:Forward(), aim:Right()
    		local fmove = movedata:GetForwardSpeed()
    		local smove = movedata:GetSideSpeed()
    		
    		forward.z, right.z = 0,0
    		forward:Normalize()
    		right:Normalize()
    		
    		local wishvel = forward * fmove + right * smove
    		wishvel.z = 0
    		
    		local wishspeed = wishvel:Length()
    		
    		//print(wishvel)
    		//print(wishspeed)
    		
    		if(wishspeed > movedata:GetMaxSpeed()) then
    			wishvel = wishvel * (movedata:GetMaxSpeed()/wishspeed)
    			wishspeed = movedata:GetMaxSpeed()
    		end
    		
    		local wishspd = wishspeed
    		wishspd = math.Clamp(wishspd, 0, 30)
    		
    		local wishdir = wishvel:GetNormal()
    		local current = movedata:GetVelocity():Dot(wishdir)
    		//print("current: " .. tostring(current))
    		
    		local addspeed = wishspd - current
    		//print(addspeed)
    		
    		if(addspeed <= 0) then return end
    		
    		local accelspeed = (100) * wishspeed * FrameTime()
    		//print(accelspeed)
    		
    		if(accelspeed > addspeed) then
    			accelspeed = addspeed
    		end
    		
    		local vel = movedata:GetVelocity()
    		vel = vel + (wishdir * accelspeed)
    		
    		movedata:SetVelocity(vel)
    		
    		return false
    		
    	end
    	
    end
     
  2. Teddi

    Teddi Well-Known Member Bear

    Joined:
    Jul 21, 2007
    Messages:
    9,636
    Likes Received:
    1,118
    I'll take a look at this soon, however the problem at the moment is due to CSS collisions. But brb testing this.

    ---------- Post added at 12:01 AM ---------- Previous post was Yesterday at 11:58 PM ----------

    Edit: Yep, just tested and the same problems still occur. All that can really be done is minimizing the effect of how often it occurs. The alternative method is to rebuild the maps under the ep2 engine.
     
  3. Dan

    Dan Active Member

    Joined:
    Feb 21, 2008
    Messages:
    1,689
    Likes Received:
    0
    So why don't we do that? Underlying problems which no1 wants to deal with because they have better things to do :)P) ?
     
  4. Whitefang

    Whitefang ( ͡° ͜ʖ ͡°)

    Joined:
    Jul 12, 2008
    Messages:
    4,009
    Likes Received:
    43
    Because EP2 doesn't have much CSS materials, so most of the CSS specific materials have to be pakratted in.
     
  5. Teddi

    Teddi Well-Known Member Bear

    Joined:
    Jul 21, 2007
    Messages:
    9,636
    Likes Received:
    1,118
    What Whitefang said, and we can't really decompile via vmex, as that's not it's purpose. Any map recompiled after decompilation will be fucked up.
     
  6. Blue

    Blue ANTAGONIST

    Joined:
    Sep 25, 2009
    Messages:
    24
    Likes Received:
    1
    Cool
     
  7. giantzfan53

    giantzfan53 Member

    Joined:
    Jul 7, 2008
    Messages:
    502
    Likes Received:
    1
    Blue for future references, check the last post before you. 1 week ago. Also, try not to post just for your post count, that's pretty uncool. I officially declare this thread BUMPED. And probably closed, soon.
     
Thread Status:
Not open for further replies.