Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

How to check an area

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Sat Jul 03, 2010 12:56 am Post subject: How to check an area |

I don't know how to question this, But I will explain. A teammate of mine asked if There was a way to make it so the player Can't transform from Morph ball to player if he is in an enclosed place. I don't know Much about tracelines, And I don't even know if this is possible. But ALL help would be appreciated. Even your help Downsider
This is actually essential, And I have 0% knowledge on doing this. I don't even know where to start.
And on an offtrack note, Why did they use self.weaponmodel, rather than setmodel?

Code:
void() W_SetCurrentAmmo = { if (self.mballtoggle == 1) return; {
player_run (); // get out of any weapon firing states
self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
if (self.weapon == IT_AXE)
{
self.currentammo = 0;
self.weaponmodel = "progs/v_axe.mdl";
self.weaponframe = 0;
}

Thanks

Back to top |

Arkage Joined: 19 Nov 2009 Posts: 27 |

Posted: Sat Jul 03, 2010 1:13 am Post subject: |

self.weaponmodel (also called the view model) sets just that the weapon model where as setmodel set the entity's real model. Since it for the psp you wont have the tracebox option so trace lines it is. Just trace five lines, forward, back, left, right and up.
Then check how far each traveled and if all have traveled more than half the width (or half of the dir your checking, eg half the height) of the player bounding box its safe-ish to swap back.

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Sat Jul 03, 2010 3:20 am Post subject: |

Well how would this Code do? I have never used a traceline before, So how about this?

Code:
if (traceline (self.origin , (self.origin+(v_forward * 5)+(v_forward*-5)+(v_right*5)+v_right*-5)+(v_up*5)+v_up*-5 , FALSE , self)) return else self.mballtoggle = 0; //Able to transform back to human

First of all, Can someone define all the parts of a traceline and tell me what they do? I really appreciate it!
EDIT: I am totally off.... Traceline shouldn't be an if statement...

Back to top |

Arkage Joined: 19 Nov 2009 Posts: 27 |

Posted: Sat Jul 03, 2010 3:35 am Post subject: |

Trace line is documented in plenty of places, have a look at Quakes qc, or even the flash light tutorial, it sends out a trace line in front of the player so it should be easy pickings. Also try the qc refrance on the front page of the site.

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Sat Jul 03, 2010 3:52 am Post subject: |

I actually used the Flash light code as a reference. But I will go see the qc reference And Try my luck. EDIT: So I figured out that I need to use my Traceline code, but not as an if statement. I should use traceline, and Then what? Tracefraction?

Back to top |

r00k Joined: 13 Nov 2004 Posts: 483 |

Posted: Sat Jul 03, 2010 4:47 am Post subject: |

im not sober enough to think but the only thought i can think of is find radius? this will search for an ent witin a given range but if your checked ent isnt there it doesnt matther if the original ent is enclosed? btw if i remmember correctly .weaponmodel is just for sbar??
wow i need to sober up!

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Sat Jul 03, 2010 5:05 am Post subject: |

Come back when You have a coding mind

Back to top |

gnounc Joined: 06 Apr 2009 Posts: 120 |

Posted: Sat Jul 03, 2010 5:19 am Post subject: |

you could do a traceline then check to see if tracefraction is smaller than 1 (meaning it hit something). and if so dont morph. the traceline obviously should be as long (or tall) as the amount of space you want in that direction.

Back to top |

gnounc Joined: 06 Apr 2009 Posts: 120 |

Posted: Sat Jul 03, 2010 5:24 am Post subject: |

Also split that into 4 seperate tracelines set them all up as variables so traceline (self.origin , (self.origin+(v_forward * 5); x = trace_fraction;
(traceline (self.origin , (self.origin+(v_forward * -5);
y = trace_fraction;
etc
then check that tracefraction for all of those is less than 1
if (x >= 1)
return; //meaning dont morph, so it should be in your morph code
thats the basic idea anyways

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Sat Jul 03, 2010 5:52 am Post subject: |

I forget, how are you doing the morph ball? Is the player's bbox/hull size actually shrinking in morph ball mode somehow? (The so-called "crouching hull") If you are, then in the absence of tracebox you should use "walkmove". You setsize to the larger bbox size, check walkmove, and if it fails (meaning you are now intersecting solid geometry), go back to the small one, cancelling the "uncrouch".
But before I go further into this I want to know if the morphball actually has a smaller bbox than the regular player. If not, then this "can't transform from ball to player if in an enclosed place" idea will end up being a big and confusing (to the player) hack.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Sat Jul 03, 2010 11:57 pm Post subject: |

Heres the Morphball code(It is subject to change)

Code:
void () CCam; void () CCamChasePlayer = { makevectors (self.v_angle); traceline ((self.origin + self.view_ofs),((((self.origin + self.view_ofs)
+ (v_forward * self.camview_z)) + (v_up * self.camview_x)) + (v_right * self.camview_y)),FALSE,self);
setorigin (self.trigger_field,trace_endpos);
WriteByte (MSG_ONE,5);
WriteEntity (MSG_ONE,self.trigger_field);
self.weaponmodel = "";
};
void () CCam =
{
local entity camera;
local entity spot;
if (self.aflag == FALSE)
{
self.aflag = TRUE;
camera = spawn ();
spot = spawn ();
self.trigger_field = camera;
camera.classname = "camera";
camera.movetype = MOVETYPE_FLY;
camera.solid = SOLID_NOT;
setmodel (camera,"progs/eyes.mdl");
setsize (camera,'0 0 0','0 0 0');
makevectors (self.v_angle);
traceline ((self.origin + self.view_ofs),(((self.origin + self.view_ofs)
+ (v_forward * -64.000))),FALSE,self);
self.camview = '0 0 -64'; // added
setorigin (camera,trace_endpos);
camera.angles = self.angles;
self.weaponmodel = "";
msg_entity = self;
WriteByte (MSG_ONE,5);
WriteEntity (MSG_ONE,camera);
WriteByte (MSG_ONE,10.000);
WriteAngle (MSG_ONE,camera.angles_x);
WriteAngle (MSG_ONE,camera.angles_y);
WriteAngle (MSG_ONE,camera.angles_z);
sprint (self,"Chase Cam On\n");
self.mballtoggle = self.mballtoggle = 1;
self.view_ofs = '0 -10 8';
stuffcmd(self,"cl_forwardspeed 800 \n");
stuffcmd(self,"cl_backspeed 800 \n");
stuffcmd(self,"cl_sidespeed 800 \n");
setsize (self, '-0 -0 -24', '0 0 0');
}
else
{
if (traceline (self.origin , (self.origin+(v_forward * 500)) , FALSE , self))
return;
else
{
self.aflag = FALSE;
msg_entity = self;
WriteByte (MSG_ONE,5);
WriteEntity (MSG_ONE,self);
WriteByte (MSG_ONE,10);
WriteAngle (MSG_ONE,self.angles_x);
WriteAngle (MSG_ONE,self.angles_y);
WriteAngle (MSG_ONE,self.angles_z);
remove (self.trigger_field);
sprint (self,"Chase Cam Off\n");
W_SetCurrentAmmo ();
self.mballtoggle = self.mballtoggle = 0;
self.view_ofs = '0 0 22';
setsize (self, '-16 -16 -24', '16 16 32');
W_SetCurrentAmmo ();
}
}
}

I know That I should clean the code up a bit, and For now, I am using the 0 hull until I get in the engine and Change the shambler HULL. So for now, It's 0

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Sun Jul 04, 2010 12:48 am Post subject: |

neworigin = self.origin; neworigin_z = neworigin_z - newmins_z + self.mins_z; tracebox(neworigin, newmins, newmaxs, neworigin, false, self); if (trace_startsolid) {
traceissolid_canttransform();
}
else
{
traceisokay_theboxisempty();
self.mins = newmins;
self.maxs = newmaxs;
setorigin(self, neworigin);
setmodelorframeorwhateverelseyouneedhere();
}
I may have gotten the + and - on the second line wrong.
But yeah, if you're modifying the engine already, tracebox is a really easy addition, and does exactly what you need.
This is assuming you actually use a custom hull.
If you want to use points, you'll probably need to use at least 4 traces instead of the tracebox and reject the change if any fail.
_________________
What's a signature?

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Sun Jul 04, 2010 1:02 am Post subject: |

Alright thanks. I will test the code. an d There actually isn't really a transform code. It is just self.mballtoggle = 0;//Transform back to human But thanks. And I suck terribly an engine coding, a matter of fact, I don't have to touch the engine. The bad thing about prime, is that It is gonna be the kurok engine, Nothing more, nothing less... sigh...

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group