I am trying to create a sort of aimbot type thing. My success is little to nothing. I examined bot code, but couldn't seem to apply it.
How can I miraculously change the players view via a vector?(No mouse input)
Turn players view toward an entity
-
- Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
- Contact:
-
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
Re: Turn players view toward an entity
For it to be done smoothly this should be done in csqc.Mexicouger wrote:I am trying to create a sort of aimbot type thing. My success is little to nothing. I examined bot code, but couldn't seem to apply it.
How can I miraculously change the players view via a vector?(No mouse input)
You would have to do something similar to ChangeYaw except it changes your view angles.
So you set an ideal view angle to (vector ideal_view) then every frame (or 0.1 sec) you turn from your current angle toward the ideal one by some turn speed.
Take a look at the qc version of changeyaw commented out in ai.qc
The biggest problem your going to face is if your doing this with ssqc your going to have to write the viewangles repeatedly and it wont give you a smooth result.
Yeah, you can't always do it smoothly via ssqc.
Note that a few engines will automatically smooth out angles if you fixangles them in each PlayerPreThink (including both FTE and DP). Also note that such angles are often limited to 256 graduations, even if interpolated.
CSQC gives a way to avoid the graduations. It also means your angles will be correct despite prediction. If you're not using prediction, using an engine with setangles interpolation, and are using an engine with extended WriteAngles protocols (player-angles-only like QW will be just as corse), then csqc for this is overkill.
Note that a few engines will automatically smooth out angles if you fixangles them in each PlayerPreThink (including both FTE and DP). Also note that such angles are often limited to 256 graduations, even if interpolated.
CSQC gives a way to avoid the graduations. It also means your angles will be correct despite prediction. If you're not using prediction, using an engine with setangles interpolation, and are using an engine with extended WriteAngles protocols (player-angles-only like QW will be just as corse), then csqc for this is overkill.
Wazat had some turret code at one point that would turn a stationary turret towards a vector... http://forums.inside3d.com/viewtopic.ph ... ght=turret
you might be able to adapt that to the player pov.
you might be able to adapt that to the player pov.
-
- Posts: 68
- Joined: Mon Oct 04, 2010 9:08 pm
- Location: Lincoln, California
sorry for reviving this thread, but it's never too late to help somebody out
I don't know if you still want something like this, but I was able to get something to happen along the lines of aim assist, it seems a little buggy though, ont to mention it wont run on psp because of some WriteDest: Not a client error, but hey, it's my first (2nd if lightning lines count) time messing with writebytes, which I still have no idea what they do and how they work, all I know is that it works
anyways, here's the code...
enjoy! perhaps haha
ps, I call this function in a zoom function
pps, you may want to edit the function infront() by changing the line from "if ( dot > 0.3)" to "if ( dot > 0.99)", this will make it only auto aim if you are aiming near the goal entity.
like I said before, this is a little bit buggy, and I have no idea why it crashes on the psp.
I don't know if you still want something like this, but I was able to get something to happen along the lines of aim assist, it seems a little buggy though, ont to mention it wont run on psp because of some WriteDest: Not a client error, but hey, it's my first (2nd if lightning lines count) time messing with writebytes, which I still have no idea what they do and how they work, all I know is that it works
anyways, here's the code...
Code: Select all
//this guy basically finds the best monster or thing that is in front of it to aim at
entity() find_infront_zombie =
{
local entity what;
local entity best;
local float bestdist;
bestdist = 1000000;
what = findradius(self.origin, 1000);
while(what)
{
if(what.classname == "monster_knight" || what.classname == "doggy"||what.classname == "RADIO" || what.classname == "teddy")
{
if(infront(what))
{
if(visible(what))
{
if(vlen(what.origin - self.origin) < bestdist)
{
best = what;
bestdist = vlen(what.origin - self.origin);
}
}
}
}
what = what.chain;
}
return best;
};
// this is the actual function that is called to start the aim assist
void() aim_assist =
{
local entity what;
what = find_infront_zombie();
if(what == world)
{
//if there's nothing to aim at
return;
}
// and this is where a whole lotta' luck came into play, basically messing around with different things got it to work.
local vector new_ang;
new_ang = self.v_angle + normalize((what.origin + '0 0 10')- self.origin) * 2;
new_ang = vectoangles(new_ang - self.v_angle);
//using writebytes seemed like the only way to make the angles affect the player
WriteByte (MSG_ONE, 10);
WriteAngle (MSG_ONE,new_ang_x);
WriteAngle (MSG_ONE, new_ang_y);
WriteAngle (MSG_ONE,self.v_angle_z);
};
ps, I call this function in a zoom function
pps, you may want to edit the function infront() by changing the line from "if ( dot > 0.3)" to "if ( dot > 0.99)", this will make it only auto aim if you are aiming near the goal entity.
like I said before, this is a little bit buggy, and I have no idea why it crashes on the psp.
A truly rewarding experience for an AI coder: watching your ai navigate the map... makes all the time invested in the code worth it
-
- Posts: 185
- Joined: Wed Apr 13, 2011 1:34 pm
blubswillrule : There should also be at least something like
to avoid jumping from target to target. I am sorry if You already have it there, I haven't look hard enough to see it.
Code: Select all
if you already have target then
dont do this
else
find new target
Think, touch, movetype, solid, traceline ...
-
- Posts: 68
- Joined: Mon Oct 04, 2010 9:08 pm
- Location: Lincoln, California