using teleportentity without having to press the alt key

11 replies [Last post]
Posts: 147

Hi all,

I was kinda wondering where I can find the code that I need to change to make a player teleport intstantly by just walking over the teleportentity (topdown view) instead of needing to press the alt (or any other key) at all.

Thanks in advance

Posts: 147

Sorry to bumb this one but is there no one who has an idea?? I have been looking for two days now.

Posts: 263

*checks SVO code*

Open NetGore.sln

Goto

DemoGame.Server > World > Map > Entities > Character > User.cs
Find:

readonly UserStats _userStatsMod;

After, add
bool justWarped;

Find:
		 protected override void UpdatePreCollision(IMap map, int deltaTime)
		 {
			 // Update velocity
			 UpdateVelocity(map,deltaTime);)
                  }

Inside the procedure, after UpdateVelocity, Add:

OnMove();

Now, outside the procedure, Add:

		 protected void OnMove()
		 {
 
			 foreach (TeleportEntity warp in Map.DynamicEntities.OfType<TeleportEntity>())
			 {
				   // If we're standing on a warp
				 if (warp.Intersects(this))
				 {
					 // And we weren't already on one...
					 if (!justWarped)
					 {
						 // Warp, and check if we're on one!
						 warp.Use(this);
						 if (Map.DynamicEntities.OfType<TeleportEntity>().Any(newwarp => newwarp.IntersectsTD(this)))
						 {
							 justWarped = true;
							 return;
						 }
						 justWarped = false;
						 return; 
					 }
					 return;
				  }
			 }
 
			 //We looped through every warp without finding one we're standing on!
			 justWarped = false;
		 }

Posts: 40

well I guess I was looking in the way wrong area I figured it would be client side since u hit a key and it should call an event o.o but then again the server maintains the characters position...

Posts: 147

@ Shinsetsu I had the same idea. I have been looking at the client side for the key input and the as well. No wonder I couldn't find it

@ darkfrost thanks for your reaction, I will give it a go tonight

Posts: 147

Hi darkfrost (or Skye) I tried the code you provided but I couldn't find

		 protected override void UpdatePreCollision(IMap map, int deltaTime)
		 {
			 // Update velocity
			 UpdateVelocity(map,deltaTime);)
                  }

anywhere in the code. Therefore I added the piece of code to the class and added the rest of the code you provided. This however resulted in the following error :

Error 1 'DemoGame.Server.TeleportEntity' does not contain a definition for 'IntersectsTD' and no extension method 'IntersectsTD' accepting a first argument of type 'DemoGame.Server.TeleportEntity' could be found (are you missing a using directive or an assembly reference?)

Can it be that you forget to mention some code that needs to be changed/added aswell in addition to the code you provided??

Thanks again Dark for helping out

Posts: 1691

Check the overloads available for a DynamicEntity. I believe there is an OnCollideWith overload, or something like that.

Posts: 40

That subs in there however its not in there as Protected Override void, I believe its in there as protected private void, then when u continue to work with it you being to get other errors.

Posts: 1691

Shinsetsu wrote:
I believe its in there as protected private void

I hope not. Otherwise, the code wouldn't compile. Tongue

I wouldn't be surprised if its protected virtual... that just means it can be overridden.

Posts: 40

your right its virtual void

        protected virtual void UpdatePreCollision(IMap map, int deltaTime)
        {
            // Update velocity
            UpdateVelocity(map, deltaTime);
        }

PART 1.
u can safely change that to override cant you without much issue the probelm i get when I try to do this is

    foreach (TeleportEntity warp in Map.DynamicEntities.OfType<TeleportEntity>())

2 errors

Map does not exist in this context

The type or namespace 'TeleportEntity' could not be found "Missing assembly reference?"

            //We looped through every warp without finding one we're standing on!
            justWarped = false;

the name just warped does not exist in this context

now here is the interesting thing I only get the justwarped error on the last one but not the other 3... as for the second error It disappears if I change it to just Map.Entities.TeleportEntity()

however I havent used this long so Idk if that is the same thing... =/ guess i should spend less time watching shows in my freetime and actually try and crack netgore open =P

PART 2.
So i also tried changing it from virtual to override it got rid of all the error except I got a new one now its on where I changed it to override new error is no suitable method found to override o.o

JasDonor
Posts: 111

Has anyone gotten this working without errors yet? How about a wiki how-to?

Posts: 263

Well, I have Tongue

Not sure if I missesd anything, only other thing is
if (warp.IntersectsTD(this))

should be
if (warp.Intersects(this))