Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (Quad, AndrewAMD), 1,007 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Teleport help [SOLVED] #444590
08/14/14 17:47
08/14/14 17:47
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Hello Community laugh

I have been struggling with what sounds like an easy idea.
I am trying to have my player approach a teleporter(MDL) and teleport to another teleporter.

Now the obvious point is that when the player teleports from one to the other, He should not keep teleporting back and forth, thus keeping him in a continuous loop.

I am trying to do this with one single action.

Now, my current solution appears as though it should work correctly. But it doesn't.

Code:
action telehole_act(){
	
	set(me,PASSABLE | ENABLE_SCAN);
	reset(me, INVISIBLE);//Glitch? ???
	
	my.material = mtl_basic_shader;
	
	while(player_active == 0){wait(1);}
	
	VECTOR telepos;
	vec_set(telepos.x, my.skill1);
		
	my.skill10 = 0;
	
	while(1){wait(1);
		
		if(vec_dist(my.x,player.x)<35 && my.skill10 == 0){
			vec_set(player.x,telepos.x);
			result = c_scan(player.x,player.pan,vector(360,0,50), SCAN_ENTS | SCAN_LIMIT);
			if(result > 5){
				if(you!=NULL){					
					you.skill10 = 1;
					beep();
				}
			}
		}
	}	
	
}



What I've done is set the teleport to passable, (so IGNORE_PASSABLE is not an option) and ENABLE SCAN to have only this entity scanned - which comes later.

Then in WED, I set the partnered teleports parnters x,y,z position into their skills 1,2,3 and store them into a temp vector.

by default, each teleport is active (skill10 = 0) and able to accept the player in the comming while loop, and checked with a vec_dist.

if the player is close enough it will teleport the player to the temppos.

[At this point, with no further code, the player would be stuck in a loop where he is sent back and forth, and unable to move. which would and does make sense]

Now, to make it so that when the player finishes his teleport, he doesnt teleport back, I've set a scan from the player. The scan should check for entities with enable scan, and if one has been found then set its skill10 = 1. Thus disabling the teleporter until I code more code to renable it.

However this is not the case.

When the player teleports, he becomes stuck on the first created in WED teleport. and no Beep sound is played informing me that the result did not find anything.

I've tried saying that if(you!= NULL && you!= player) then continue with the code. But setting it so that it recognizes if the entity it has scanned's skill99 == 1 is a good idea too. But that does not work.

So I thought it had to do with the fact that the player is teleported, and the following code happens before the player reached this tele-point. So I set a wait inside. That just made it so he fluently teleported back and forth, and didn't get stuck at the first created teleporter.

So. Why is this? Anyone know whats up? Im stumped.

Last edited by DLively; 08/14/14 18:24.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: Teleport help [SOLVED] [Re: DLively] #444591
08/14/14 18:25
08/14/14 18:25
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
I solved it.

Although I didn't want to take this route, I placed the scan in the players code, and triggered it with another temp var.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: Teleport help [SOLVED] [Re: DLively] #444607
08/15/14 01:17
08/15/14 01:17
Joined: Jul 2008
Posts: 2,101
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,101
Germany
Guess the problem here is that c_scan returns only the first and nearest entity. Something like this could solve such probs:
Code:
// ------------------------------------------------------------------------
function find_nearest (ENTITY* ent){
   if (!ent) return;      // entity doesnt exist? stop!  
   you       = NULL;      // or lowercase, "null" ... not sure right now ^^
   var _dist = 1000;      // range
   var _ndist;
   var you_handle;
   // ---=[ repeat for all entities ]=-------------------------------------
   for (you = ent_next (NULL); you; you = ent_next (you)){
      _ndist = vec_dist (ent.x, you.x);
      if (_ndist < _dist) { _dist = _ndist; you_handle = handle (you); }
   }
   you = ptr_for_handle (you_handle);             // "you" to nearest found
}
// ---=[ example call ]=---------------------------------------------------
.
..
...
#define skill100   whatisit
#define amonstaaa  1234
...
..
.
//while (!player) wait (1);
//you = NULL;
  find_nearest (player);                 // set you 2 next / closest entity
  if (you) if (you.whatisit == amonstaaa){
     ...
     ..                           // omg next "you" 2 "ent" was amonstaaa ! 
     .
  }
...
..
.
// ------------------------------------------------------------------------


more here
http://www.opserver.de/ubb7/ubbthreads.p...true#Post405495

peace


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Teleport help [SOLVED] [Re: rayp] #444609
08/15/14 02:53
08/15/14 02:53
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
I was able to do this with less code laugh

The problem was exactly that. It was detecting WORLD, and there were ents around it that needed c_ignore applied to them too.

I was reading in another post you were bored - I knew it was only a matter of time before you posted here ^_^

Thanks Rayp!


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: Teleport help [SOLVED] [Re: DLively] #444614
08/15/14 07:54
08/15/14 07:54
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
I would encourage you to use the events. I wrote the very basiscs using the impact event in order to show you one of the multiple ways. I can imagine the same system with the shoot event called from the players up down c_trace and some teleporting planes over the ground. Or the scan event inclusive, but I would avoid more 'c_' intruction calls than necessary.

Code:
function evnTeleporter ()
{
	if ( event_type == EVENT_IMPACT )
	{
		if ( you == player )
		{
			ENTITY *entDestiny = ptr_for_handle ( my.skill1 ); // Retrieve the destiny entity
			entDestiny.emask &= ~ENABLE_IMPACT; // Disable its impact event
			vec_set ( player.x, entDestiny.x ); // Move the player to the destiny
			while ( abs ( player.x - entDestiny.x ) + abs ( player.y - entDestiny.y ) < 64 ) // Wait until the player is far enough
				wait(1);
			entDestiny.emask |= ENABLE_IMPACT; // Enable the previously disabled event impact
		}
	}
}

action actTeleporter ()
{
	ENTITY *entDestiny = ent_for_name ( my.string1 ); // Name of the destiny teleporter in WED saved into string1
	my.skill1 = handle ( entDestiny );
	my.emask |= ENABLE_IMPACT;
	my.event = evnTeleporter;
}



Salud!

Re: Teleport help [SOLVED] [Re: txesmi] #444617
08/15/14 08:30
08/15/14 08:30
Joined: Jun 2010
Posts: 71
L
LawnmowerMan Offline
Junior Member
LawnmowerMan  Offline
Junior Member
L

Joined: Jun 2010
Posts: 71
I made some simple teleport code and works fine
Code:
void teleport_position(var teleport_id)
{
	if(teleport_id == 1)
	{
		player.x = 454; player.y = 878; player.z = 0;
	}
	if(teleport_id == 2)
	{
		player.x = 454; player.y = 878; player.z = 0;
	}
	// .....	
}

var teleport_activated;

action teleporter()
{
	while(!player){wait(1);}
	while(1)
	{
		if (vec_dist(my.x,player.x) < 400)
		{
			if (vec_dist(my.x,player.x) < 300)
			{
				if (vec_dist(my.x,player.x) < 200 && teleport_activated == 0)
				{ 
					teleport_activated = 1;
					teleport_position(my.skill1);
				}
			} 
			else 
			{
				// turn on again teleport effect
				teleport_activated = 0;	
			}
		}
		wait(1);
	}	
}


Re: Teleport help [SOLVED] [Re: LawnmowerMan] #444638
08/16/14 04:33
08/16/14 04:33
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Thanks Guys laugh

Quote:

I would encourage you to use the events. I wrote the very basiscs using the impact event in order to show you one of the multiple ways. I can imagine the same system with the shoot event called from the players up down c_trace and some teleporting planes over the ground. Or the scan event inclusive, but I would avoid more 'c_' intruction calls than necessary.


What If I am only using the scan in one frame? It doesn't loop. Its triggered only when a variable is set to one. Once the scan is complete, the variable is reset to 0.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: Teleport help [SOLVED] [Re: DLively] #444641
08/16/14 07:57
08/16/14 07:57
Joined: May 2009
Posts: 5,365
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,365
Caucasus
I would recommend you to use push event, so as soon as player touches the teleport (which will be passable for players movement) he will be teleported to another teleport with the same ID, and player will be able to teleport back only if he moves away for a specific distance from teleport (vec_dist check) or if you need to teleport by pressing a key, I would recommend to create a simple 'cooldown' timer, which won't allow you to reteleport back for lets say 1 second after last teleportation. I could make a simple demo for you if you need, just give me more details of what you need.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Teleport help [SOLVED] [Re: 3run] #444643
08/16/14 08:09
08/16/14 08:09
Joined: Jul 2008
Posts: 2,101
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,101
Germany
Mhhh...why not a interaction key. Simply tracing infront when a key was pressed? I always use such kind of master interaction function ( one 4 all ents ). Then a simple if - block looks what was hit, calling a function ( you.id == id_teleporter pipapo(); ).

edit: if its a fps script, of course.


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Teleport help [SOLVED] [Re: rayp] #444654
08/16/14 11:03
08/16/14 11:03
Joined: May 2009
Posts: 5,365
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,365
Caucasus
Take a look here...
Teleport Example Countribution

Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1