+ Reply to Thread
Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: A simple E2 teleportation extension

  1. #21
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: A simple E2 teleportation extension

    Quote Originally Posted by Rybec View Post
    I mean CHANGE the direction when it teleports. Like, prior to teleporting it's angles are (10,15,0), but you use E:warpStuff(Pos,ang(30,50,0)) and that becomes the new angles after it teleports, with all velocities and orientations etc. changed to match.

    As though it went through a portal.

    As I've said though, it's another project entirely.
    Ooohhhh, k. ya. that sounds hard...

  2. #22
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: A simple E2 teleportation extension

    I've started implementing a teleport ability that works like portal, keeps your velocity but changes your direction. This is currently only for players. I've tested it, it works.

    Based on the function documentation, SetEyeAngle is one of the few that will work on players. I would like to implement a way for it handle angle difference so instead of changing to a set angle, it changes to an angle relative to how the player entered the portal.

    For contraptions, i can see this working much more like I want.

    This can be added to the same file as the other, just specify an angle and it will use this:

    Code:
    e2function void entity:warpStuff(vector DestVec, angle DestAng)
    	DestAng = Angle(DestAng[1],DestAng[2],DestAng[3])
    	DestVec = Vector(DestVec[1], DestVec[2], DestVec[3])
    	if(!validEntity(this)) then return end
    	if (!util.IsInWorld(DestVec)) then
    		while (!util.IsInWorld(DestVec)) do
    			DestVec = DestVec/1.05
    		end
    	end
    	if (this:IsPlayer()) then
    		if (!self.player == this) then return end
    		this:SetPos(DestVec)
    		this:SetLocalVelocity(DestAng:Forward() * (this:GetVelocity():Length()*2))
    		this:SetEyeAngles( DestAng )
    	else
    		if (!isOwner(self, this)) then return end
    		ConstrainedEnts = constraint.GetAllConstrainedEntities(this)
    		for _, v in pairs(ConstrainedEnts) do
    			EntPhy = v:GetPhysicsObject()
    			EntPhy:SetPos(DestVec + (EntPhy:GetPos() - v:GetPos()))
    			EntPhy:Wake()
    		end
    	end
    end

  3. #23
    Wire Sofaking SystemsLock's Avatar
    Join Date
    Mar 2009
    Posts
    474

    Default Re: A simple E2 teleportation extension

    Looks great, but "warpStuff" is a pretty lame function name, how about just "teleport" (it sounds more professional that way). After all we don't call "applyForce" "moveShit".
    Make a Small Loan, Make a Big Difference - Check out Kiva.org to Learn How!

  4. #24
    Wire Sofaking feha's Avatar
    Join Date
    Sep 2009
    Location
    Here
    Posts
    1,156

    Default Re: A simple E2 teleportation extension

    +1 vote for renaming applyforce to moveStuff()!

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

    Default Re: A simple E2 teleportation extension

    Quote Originally Posted by feha View Post
    +1 vote for renaming applyforce to moveStuff()!
    No, moveShit!

    Code:
    e2function void entity:moveShit(vector force)
    	if not validPhysics(this) then return nil end
    	if not isOwner(self, this) then return nil end
    	local phys = this:GetPhysicsObject()
    	phys:ApplyForceCenter(Vector(force[1],force[2],force[3]))
    end
    SVN Tutorial
    My SVN:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    Get dropbox and get 250 MB extra space: Dropbox

  6. #26
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: A simple E2 teleportation extension

    Haha, i wasn't intending on it being the final name. Since it is just source code, people can change it to whatever they want currently. I'll have to consider other name possibilities.

+ Reply to Thread
Page 3 of 3 FirstFirst 123

Tags for this Thread

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