AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Teleport and entity (https://forums.alliedmods.net/showthread.php?t=254728)

Shiina.Mashiro 01-05-2015 10:47

[Help] Teleport and entity
 
Hi guys, I'm trying to make a plugin which can teleport victim to the attacker's back
For example, player A shoot player B => player B will teleport to the back of player A
But I have a few trouble:

- I don't know how to teleport the victim to the back of the attacker (I tried the attacker's origin but it would be stuck)
- I want to create an entity with custom player models, when the victim has been teleported, the entity will appear at the old position of the victim and do the dead animation

Any ideas will be much appreciated :D
Thanks :D

akcaliberg 01-05-2015 11:42

Re: [Help] Teleport and entity
 
PHP Code:

get_target_behind(idFloat:fOrigin[3],units) {
    
    new 
Float:fAngles[3];
    new 
Float:fForward[3];
    
    
pev(id,pev_origin,fOrigin);
    
pev(id,pev_v_angle,fAngles);
    
    new 
Float:temp fOrigin[2];
    
    
angle_vector(fAngles,ANGLEVECTOR_FORWARD,fForward)
    
    
xs_vec_mul_scalar(fForward,(-1.0*units),fForward);
    
xs_vec_add(fForward,fOrigin,fOrigin);
    
    
fOrigin[2] = temp;


units is how far will be the origin from the enemy. 100-150 is ideal

RateX 01-05-2015 11:48

Re: [Help] Teleport and entity
 
1.you can use velocity by aim:
PHP Code:

new Float:Vel[3]
velocitybyaim(playerb_id20.0Vel[3]) 

then negate Vel[0] to Vel[2] and add them to player B's origin. The outcome will be player B's back. You can modify 20.0 to any number you want till you're satisfy.
2.You can take a look at some dias's npc plugins.
I'm typing from my phone so there's might be some typos:)

Shiina.Mashiro 01-06-2015 01:31

Re: [Help] Teleport and entity
 
@akcaliberg
Tried your code but it teleport me to somewhere, just like i have noclip :D

@RateX
1. Negate Vel[0] to Vel[2] you mean Vel[0] = Vel[2] or Vel[2] = Vel[0] ?
2. Ya I checked at dias's oberon boss and it works fine :D but how to remove the entity at newround ?

akcaliberg 01-06-2015 02:39

Re: [Help] Teleport and entity
 
Quote:

Originally Posted by Shiina.Mashiro (Post 2245369)
@akcaliberg
Tried your code but it teleport me to somewhere, just like i have noclip :D

@RateX
1. Negate Vel[0] to Vel[2] you mean Vel[0] = Vel[2] or Vel[2] = Vel[0] ?
2. Ya I checked at dias's oberon boss and it works fine :D but how to remove the entity at newround ?

maybe the enemies behind is wall or something. It works fine for me.

Shiina.Mashiro 01-06-2015 03:07

Re: [Help] Teleport and entity
 
Quote:

Originally Posted by akcaliberg (Post 2245379)
maybe the enemies behind is wall or something. It works fine for me.


I'm not at home so I will send you the image later :D
So do you have anything to avoid this ?

RateX 01-06-2015 04:05

Re: [Help] Teleport and entity
 
Quote:

1. Negate Vel[0] to Vel[2] you mean Vel[0] = Vel[2] or Vel[2] = Vel[0] ?
Oh, by that I meant:
PHP Code:

Vel[0] = Vel[0]*-1.0
Vel
[1] = Vel[1]*-1.0
Vel
[2] = Vel[2]*-1.0 

Quote:

2. Ya I checked at dias's oberon boss and it works fine but how to remove the entity at newround ?
PHP Code:

remove_entity(iIndex)
remove_entity_name(const eName[]) 


akcaliberg 01-06-2015 08:11

Re: [Help] Teleport and entity
 
Quote:

Originally Posted by Shiina.Mashiro (Post 2245384)
I'm not at home so I will send you the image later :D
So do you have anything to avoid this ?

Avoid what? If you mean the wall, you can simply check if there is a wall at that origin by creating an entity. If the entity touches anything that means there is another entity at the target origin and you can stuck if you teleport there. You can use that information however you want :wink: You can abort teleportation or you can teleport targets near. It is up to you.

HamletEagle 01-06-2015 09:37

Re: [Help] Teleport and entity
 
Quote:

Originally Posted by akcaliberg (Post 2245441)
Avoid what? If you mean the wall, you can simply check if there is a wall at that origin by creating an entity. If the entity touches anything that means there is another entity at the target origin and you can stuck if you teleport there. You can use that information however you want :wink: You can abort teleportation or you can teleport targets near. It is up to you.

Lol, use a trace.

Shiina.Mashiro 01-06-2015 10:03

Re: [Help] Teleport and entity
 
@RateX
Thanks :D

@akcaliberg
how to check an entity touches anything? I'm new in these stuff :D


All times are GMT -4. The time now is 15:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.