Archived copy of war3source.com, the War3Source forum (2009–2020), rebuilt from the Internet Archive by wc3mods.net. This page was captured on 2012-10-24 (original capture). Forum · All archived topics · Wiki · Bug tracker · Blog
Chat

War3:Source
October 24, 2012, 03:27:05 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Download: http://war3source.com/index.php?board=9.0
What is War3Source?: http://war3source.com/index.php?topic=200.0
Sample Stats: http://war3source.com/war3stats
Steam Community Group: http://steamcommunity.com/groups/war3source
War3Source SVN Checkout: http://ownageclan.com/svn/war3source/
War3Source servers: http://www.game-monitor.com/search.php?vars=war3_version=
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Teleport to aim point  (Read 318 times)
M.A.C.A.B.R.A
Newbie
*
Posts: 20



View Profile WWW
« on: July 28, 2011, 11:48:15 AM »

Hi,
I am trying to code a function that teleports enemy to the point which client are looking at. I wrote smth like that, but it doesn't work good.
Code:
new Float:tppos[3];
War3_GetAimEndPoint( client, tppos );
TeleportEntity(enemy, tppos, NULL_VECTOR, NULL_VECTOR);
This part of a code teleports player and stucks him into the wall or chest.
Is there any function that teleports player to the end of the vector which length is defined by programmer ?

And what do mean individual indexes in my tppos?
[ 0] - right/left    [1] - up/down  [2] - into/from the screen ?
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2045



View Profile WWW Email
« Reply #1 on: July 28, 2011, 11:49:42 AM »

no, if you want to make him not stuck, you will have to do complicated tracing, which is what race human does
Logged

DarkEnergy
M.A.C.A.B.R.A
Newbie
*
Posts: 20



View Profile WWW
« Reply #2 on: July 28, 2011, 11:59:36 AM »

Oh you're really fast.
Thanks for reply but I would prefer not to copy someone's code. Is there any other way to do this? Maybe checking whether the point is empty or smth? And is there a full documentation for all of War3Source functions? I mean smth like THIS
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2045



View Profile WWW Email
« Reply #3 on: July 28, 2011, 12:08:13 PM »

there really is no other way. tracing is the only method of checking for empty space. war3source functions can be found in war3source_interface.inc under W3SIncs in the download
Logged

DarkEnergy
Glider⠠⠵
Global Moderator
Sr. Member
*****
Posts: 413


⠠⠵


View Profile
« Reply #4 on: July 28, 2011, 02:42:14 PM »

I would prefer not to copy someone's code.

Why re-invent the wheel? The time you save not having to figure this out on your own can be used for much better things like coming up with new stuff or improving something else. I've ported over 1000+ lines standalone plugins for race skills before and use the Sourcemod forums as a big inspiriation on my part. Helps me be much more productive Smiley

There's no shame in using what already exists, that's kind of the point behind open source.
Logged

M.A.C.A.B.R.A
Newbie
*
Posts: 20



View Profile WWW
« Reply #5 on: July 29, 2011, 02:53:40 AM »

Maybe you're right. When i looked to the human's code I realised how complicated would it be to invent. I decided to use it but I wanted to teleport an enemy, not a client. I made some modifications and it works, but not as good as in human race and with no cooldown.

Here is the code after some changes:
Code:
/* *************************************** OnUltimateCommand *************************************** */
new bool:inteleportcheck[MAXPLAYERS];
public OnUltimateCommand(client,race,bool:pressed)
{
if(race==thisRaceID && pressed && ValidPlayer(client,true))
{
new skill_ult = War3_GetSkillLevel(client,thisRaceID,ULT_TELEPORT);
if(skill_ult > 0)
{
if(!Silenced(client) && War3_SkillNotInCooldown(client,thisRaceID,ULT_TELEPORT,true ))
{
new enemy = GetRandomPlayer(client);
if( enemy > 0 && !W3HasImmunity(enemy,Immunity_Ultimates))
{
new enemysTeamPlayers;
new enemyTeam = GetClientTeam(enemy);
for(new i = 1; i <= MaxClients; i++)
{
if(i != enemy && ValidPlayer(i,true) && GetClientTeam(i) == enemyTeam)
{
enemysTeamPlayers++;
}
}

if(enemysTeamPlayers > 0)
{
if(!inteleportcheck[enemy]) //not in the 0.2 second delay when we check stuck via moving
{
AttackerID = client; // here I'm saving client's ID
TeleportPlayerView(enemy,TeleportDistance[skill_ult]); // cause I want to teleport another player
}
}
else
{
PrintHintText( client, "Target is last enemy alive, cannot be teleported" );
}
}
else
{
PrintHintText( client, "No Target Found" );
}
}
}
else
{
PrintHintText(client, "Level your Teleport first");
}
}
}
/* *************************************** Teleport Stuff *************************************** */
// Teleport Stuff
// By: stinkyfax
// Much thanks, this would be a nightmare without him.
new ClientTracer;
new Float:emptypos[3];
new Float:oldpos[MAXPLAYERS][3];
new Float:teleportpos[MAXPLAYERS][3];

bool:TeleportPlayerView(client,Float:distance)
{
if(client>0)
{
if(IsPlayerAlive(client))
{

new Float:angle[3];
GetClientEyeAngles(AttackerID,angle); // replaced client to AttackerID
new Float:endpos[3];
new Float:startpos[3];
GetClientEyePosition(AttackerID,startpos); // replaced client to AttackerID
new Float:dir[3];
GetAngleVectors(angle, dir, NULL_VECTOR, NULL_VECTOR);

ScaleVector(dir, distance);
//PrintToChatAll("DIR %f %f %f",dir[0],dir[1],dir[2]);

AddVectors(startpos, dir, endpos);

GetClientAbsOrigin(client,oldpos[client]);


//PrintToChatAll("1");

ClientTracer=client;
TR_TraceRayFilter(startpos,endpos,MASK_ALL,RayType_EndPoint,AimTargetFilter);
TR_GetEndPosition(endpos);


//new Float:normal[3];
//TR_GetPlaneNormal(INVALID_HANDLE,normal);

//ScaleVector(normal, 20.0);


if(enemyImmunityInRange(client,endpos)){
W3MsgEnemyHasImmunity(client);
return false;
}

//PrintToChatAll("1endpos %f %f %f",endpos[0],endpos[1],endpos[2]);
distance=GetVectorDistance(startpos,endpos);
GetAngleVectors(angle, dir, NULL_VECTOR, NULL_VECTOR);///get dir again
ScaleVector(dir, distance-33.0);

AddVectors(startpos,dir,endpos);
//PrintToChatAll("DIR %f %f %f",dir[0],dir[1],dir[2]);

//PrintToChatAll("2endpos %f %f %f",endpos[0],endpos[1],endpos[2]);

//endpos[1]=(startpos[1]+(distance*Sine(DegToRad(angle[1]))));
//endpos[0]=(startpos[0]+(distance*Cosine(DegToRad(angle[1]))));
//if(!CheckPlayerBox(endpos,startpos,client))
// return false;
emptypos[0]=0.0;
emptypos[1]=0.0;
emptypos[2]=0.0;

endpos[2]-=30.0;
getEmptyLocationHull(client,endpos);

//PrintToChatAll("emptypos %f %f %f",emptypos[0],emptypos[1],emptypos[2]);
if(GetVectorLength(emptypos)<1.0){
new String:buffer[100];
Format(buffer, sizeof(buffer), "%T", "NoEmptyLocation", client);
PrintHintText(AttackerID,buffer); // replaced client to AttackerID
return false; //it returned 0 0 0
}


TeleportEntity(client,emptypos,NULL_VECTOR,NULL_VECTOR);
EmitSoundToAll(teleportSound,client);
EmitSoundToAll(teleportSound,AttackerID); // replaced client to AttackerID



teleportpos[client][0]=emptypos[0];
teleportpos[client][1]=emptypos[1];
teleportpos[client][2]=emptypos[2];

inteleportcheck[client]=true;
CreateTimer(0.14,checkTeleport,client);






return true;
}
}
return false;
}
public Action:checkTeleport(Handle:h,any:client){
inteleportcheck[client]=false;
new Float:pos[3];

GetClientAbsOrigin(client,pos);

// new Float:velocity[3];

//GetEntDataVector(client,m_vecVelocity,velocity);
//PrintToChatAll("%f/%f %f/%f %f/%f",teleportpos[client][0],pos[0],teleportpos[client][1],pos[1],teleportpos[client][2],pos[2]);

if(GetVectorDistance(teleportpos[client],pos)<0.001)//he didnt move in this 0.1 second
{
TeleportEntity(client,oldpos[client],NULL_VECTOR,NULL_VECTOR);
PrintHintText(AttackerID,"%T","CantTeleportHere",client);
}
else{


PrintHintText(AttackerID,"%T","Teleported",client); // replaced client to AttackerID

new Float:cooldown=GetConVarFloat(ultCooldownCvar);
War3_CooldownMGR(AttackerID,cooldown,thisRaceID,ULT_TELEPORT,_,_); // replaced client to AttackerID
}
}
public bool:AimTargetFilter(entity,mask)
{
return !(entity==ClientTracer);
}

There is no changes in other parts of this code.  I just replaced word "client" to "AttackerID" in some lines. Maybe I overlooked smth or do something wrong.
Sometimes it doesn't work good.  Enemy appears behind me when I use it aiming on the floor.  I've never done anything with a tracing and I don't know how to fix this bug.
And there is no cooldown for it despite the declarations of averything for that. I called variable for colldown the same as it is in Human Race to not overlook anything but it still doesn't work. Maybe this is due to previous changes, but I'm still checking it.
Logged

qwerty
Jr. Member
**
Posts: 87


View Profile
« Reply #6 on: July 29, 2011, 11:09:23 AM »

what do you mean they appear behind you when you aim at the floor?

the race's ability makes sure that when they arrive they're not stuck.  so it makes sense that they'd not appear directly inside of you, but instead get moved so as to not get them stuck.

try it with noblock set to 1
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!