+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 26

Thread: A simple E2 teleportation extension

  1. #11
    Wire Sofaking Rybec's Avatar
    Join Date
    Apr 2008
    Location
    Denver
    Posts
    648

    Default Re: A simple E2 teleportation extension

    Not to mention it would allow you to make your own stargates/warp holes/portals of any size and shape.

    Wait, no, that'd require rotation support. So it'd work, but only if the gates are facing the same way. ..Unless you add the ability to set the object's rotation on arrival, but that would be a huuuuuge change in your code. Like, total rewrite.


    Also, if you do implement a console command to toggle the ownership protection, you may want to put in a check to insure the entity that's being warped isn't something you shouldn't be moving, like the world, or map entities. Best I can think of is just to insure the object's owner is a player.
    Something like this maybe? I don't have much LUA experience.
    Code:
    if ((!rv1:GetOwner() == self.player && <CONVAR>) || (!rv1:GetOwner():IsPlayer())) then return end

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

    Default Re: A simple E2 teleportation extension

    Quote Originally Posted by Divran View Post
    Please change it to use e2function instead of registerFunction. It's both easier for you to code and nicer on the eyes.

    Also, use "isOwner()" when checking ownership, not GetOwner(). I think GetOwner doesn't work correctly... not sure.

    And remove the print saying that the entity is not valid for two reasons: It's only printed to the server's console, so the user won't even notice it. And the server will get spammed with that error message if the user does something wrong.
    Divran, Thanks for the suggestions. I will take your word for it and make the changes.

  3. #13
    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
    Not to mention it would allow you to make your own stargates/warp holes/portals of any size and shape.

    Wait, no, that'd require rotation support. So it'd work, but only if the gates are facing the same way. ..Unless you add the ability to set the object's rotation on arrival, but that would be a huuuuuge change in your code. Like, total rewrite.


    Also, if you do implement a console command to toggle the ownership protection, you may want to put in a check to insure the entity that's being warped isn't something you shouldn't be moving, like the world, or map entities. Best I can think of is just to insure the object's owner is a player.
    Something like this maybe? I don't have much LUA experience.
    Code:
    if ((!rv1:GetOwner() == self.player && <CONVAR>) || (!rv1:GetOwner():IsPlayer())) then return end
    I considered including rotational support, but your concerns with that type of functionality are valid. I have no idea what will be involved but it's something I will look into.

    Edit: Now that I think about it, the owner will always be a player. Who ever is running the expression will be self.player. Checking to ensure that self.player is equal to the owner of a prop should never result in the world being effected, unless the player owns the world (not sure if thats possible, unless your Scarface). Correct me if I'm wrong.

  4. #14
    Lifetime Supporter Nikita's Avatar
    Join Date
    May 2009
    Posts
    769

    Default Re: A simple E2 teleportation extension

    But what about Hoverdrive controller?

  5. #15
    Wire Sofaking Rybec's Avatar
    Join Date
    Apr 2008
    Location
    Denver
    Posts
    648

    Default Re: A simple E2 teleportation extension

    Well, what I said there only applies if you allow people to turn the owner-only functionality off. My concern there was of the same sort that the "teleport everything" option on the Asguard transporter can, will, and has dislocated planet atmospheres in spacebuild, as well as func_doors, func_buttons, I think a spawnpoint may have got moved once....
    I don't really know how GetOwner works, it might just return nil if it's an entity that's built into the map. If that's the case, just checking that there IS an owner would work.
    But again, only applies if you make the owner-only protection an optional thing.

    EDIT: I just looked it up, rv1:GetOwner():IsValid() will return true if an entity has an owner, which should filter out map props, I think.
    Last edited by Rybec; 01-31-2010 at 12:46 PM.

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

    Default Re: A simple E2 teleportation extension

    Ok, so it now uses e2function. I changed to isOwner because i verified that getOwner is returning Null (don't know why it works when comparing null to self.player should result false). Again i haven't fully tested in multiplayer yet, but plan to later today.

    I tested how the teleportation effects the direction your facing, it doesn't change. If your facing east, after teleport your still facing east. I'm not sure if this is what you meant Rybec. Were you referring to direction or angular velocity. I think it keeps all velocities after port.

    Also added wake to the entities that port. If no physics are applied to them during port, they won't move until woken by a phygun, or a wake function.

    Code:
    e2function void entity:warpStuff(vector DestVec)
    	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)
    	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
    Edit: Changed some stuff, player teleporting wasn't workin, is now.
    Last edited by phreak314; 02-01-2010 at 07:25 PM.

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

    Default Re: A simple E2 teleportation extension

    Examples of usage:

    Port contraptions:

    Code:
    @name PortContrap
    @persist E:entity TeleOK
    
    interval(100)
    runOnChat(1)
    
    if (first()) {E = entity()}
    
    Said = owner():lastSaid():explode(" ")
    
    if (chatClk(owner()) & Said:string(1)  == "/tele")
        {TeleOK = 1}
    elseif (chatClk(owner()) & Said:string(1) == "/notele")
        {TeleOK = 0}
    
    if (TeleOK & E:owner():keyAttack2())
    {
       E:warpStuff(E:owner():aimPos())
    }
    Port player:

    Code:
    @name PortSelf
    @persist Own:entity TeleOK
    
    interval(100)
    runOnChat(1)
    
    if (first()) {Own = entity():owner()}
    
    Said = owner():lastSaid():explode(" ")
    
    if (chatClk(owner()) & Said:string(1)  == "/tele")
        {TeleOK = 1}
    elseif (chatClk(owner()) & Said:string(1) == "/notele")
        {TeleOK = 0}
        
    if (TeleOK & Own:keyAttack2())
    {
       Own:warpStuff(Own:aimPos())
    }

  8. #18
    Wire Sofaking Rybec's Avatar
    Join Date
    Apr 2008
    Location
    Denver
    Posts
    648

    Default Re: A simple E2 teleportation extension

    Quote Originally Posted by phreak314 View Post
    I tested how the teleportation effects the direction your facing, it doesn't change. If your facing east, after teleport your still facing east. I'm not sure if this is what you meant Rybec. Were you referring to direction or angular velocity. I think it keeps all velocities after port.
    I was saying direction, like make a duplicate of the function with an angle argument in addition to the vector position. It repositions the entity to the position, and sets its angles to the new orientation, while moving all constrained ents accordingly.
    But that'd be really really complicated to put together. You have to calculate the new relative positions, orientations, and velocities for all the props. It'd be a wicked awesome thing, but quite frankly how often would it really get used.

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

    Default Re: A simple E2 teleportation extension

    Direction is already covered. It keeps the direction your facing after teleport. Try it out.

  10. #20
    Wire Sofaking Rybec's Avatar
    Join Date
    Apr 2008
    Location
    Denver
    Posts
    648

    Default Re: A simple E2 teleportation extension

    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.

+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast

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