Jump to content

Home

A few How Too questions?


Jman3ooo

Recommended Posts

I need to know the following things Thanks in advance:

 

  • How can I adjust the player speed without adjusting the server command g_speed
  • How can I turn down the percentage of deflecting guns with a saber.
  • Can I tell if there is an opponent nearby, and if so how?

 

Once again thanks alot

Link to comment
Share on other sites

	if (mod_cheatProtection.integer)
{
	for ( count = 0 ; count < MAX_GENTITIES ; count++ ) 
	{
		if (g_entities[count].client && g_entities[count].client->ps.clientNum != ent->client->ps.clientNum)
		{
			if ( ((ent->client->ps.origin[0]-g_entities[count].client->ps.origin[0]) * (ent->client->ps.origin[0]-g_entities[count].client->ps.origin[0])) +
				((ent->client->ps.origin[1]-g_entities[count].client->ps.origin[1])*(ent->client->ps.origin[1]-g_entities[count].client->ps.origin[1])) + 
				((ent->client->ps.origin[2]-g_entities[count].client->ps.origin[2])*(ent->client->ps.origin[2]-g_entities[count].client->ps.origin[2]))
				< mod_cheatProtection.integer*mod_cheatProtection.integer)
			{
//					G_Printf("ent in radius\n");//debug
				canSizeChange=qfalse;
			}
		}
	}
}

 

Thats how I checked to see if an opponent was near by. It's just the distance equation that loops through all the players. If your checking if an opponent is near by fairly often (about once per frame per person) then you should probably optimize it some.

Link to comment
Share on other sites

there's a far better method (I used it in my mod to check if the player was at certain distance from the rocket projectile):

VectorSubtract(entity1->r.currentOrigin, entity2->r.currentOrigin, a);
			distcheck = VectorLength(a);

 

distcheck now contains the distance.

 

The VectorSubstract is a define that was in the code and works exactly like Dest's code, but again, it saves typing

Link to comment
Share on other sites

Originally posted by Jman3ooo

Ok but say i want this to be checked every frame, where would I put this code and what is the distance measured in?

 

Can you please answer this question.

And can you also tell me how to run a timer?

Thanks a lot!

Imagine connecting 2 theese board thru a cell phone!!!

Thats nad so please let me limit my visits so i dony have 2 w8 fot the banner 2 download

Link to comment
Share on other sites

I'm not sure if this is a probability, but could the G_RadiusList function in g_utils.c be used? The function returns all the entities that are within a certain radius from an origin - you could easily code a function based on G_RadiusList that tells you whether there is a person in a certain radius.....

 

BTW, has anybody been able to find where the death messages are located? They're obviously not in the source code...

Link to comment
Share on other sites

Originally posted by Jman3ooo

Ok but say i want this to be checked every frame, where would I put this code and what is the distance measured in?

 

Depends on what you want to do with the inforations.

 

but there are several functions called everey server frame.

I think the server end frame function could be the one you are search

Link to comment
Share on other sites

Here is another question how would I turn down the reflecting abilities of the lightsabe so more shots get through?

 

I think i have found the line of code in g_weapon.c but it didnt seem to work.

 

Here is what I think is the reflecting code:

 

missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;

 

This is what the code for the rocket is:

 

//rww - We don't want rockets to be deflected, do we?
missile->clipmask = MASK_SHOT;// | CONTENTS_LIGHTSABER;

 

This is what I tried to do with the code, which is probaly completly incorrect.

 

if 	(((rand() % 5) + 1)  > 1)
{
missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;
}
else
{
missile->clipmask = MASK_SHOT;// | CONTENTS_LIGHTSABER;
}

Link to comment
Share on other sites

Ok, there are a lot of ways to make a "timer". If I were you, I'd just use the attribute set aside for forceHealTime:

 

self->client->ps.fd.forceHealTime

 

That attribute of the client was origianlly created in order to make force heal work the way it does in SP, but I don't think it's actually used in the MP code at all.

 

What you would do is:

 

(pseudocode)

When the player picks up a powerup and you want that powerup to last for say 30 seconds

 

self->client->ps.fd.forceHealTime = level.time + 30000;

 

Then you just make a quick check on it every frame refresh like so:

 

if ((player has a powerup active) && self->client->ps.fd.forceHealTime <= level.time){

deactivate powerup;

}
Link to comment
Share on other sites

jman what r u trying to make it sound like a perfect dark mod? with smart slow motion and all it seems alot like perfect dark, and using that heal timer instead of making you own does seem like a good idea, also i dont think rockets are actually deflected by the lightsaber i think they blow up on impact, the thing that happens in SP and with bots with rockets is that they are force pushed away so it may seem like they r being deflected but i am pretty shure they aren't so i dont see what u were doing with the code back there heh.

Link to comment
Share on other sites

Yeah I am trying to make it so less of the shots from a gun are deflected.

 

The mod I am working on is a type of enchanced dueling/ffa were everything will slow down when people get closer, this creating this cool matrix style fight. My friend and I have duked it out and he concluded that it was much funner then the normal mode. I still need answers to my questions cause i am still a n00b coder.

 

I have also suggested this Co-op stealth mod but it hasnt been to popular.

Link to comment
Share on other sites

Have you tested this across the internet? on a server with multiple clients? I believe I read somewhere that force speed was changed in MP because when multiple clients were running at different time scales servers started freaking out. too hard to keep track of who is in which time frame. It sounds really cool but I'm afraid it may end up being a LAN party only sort of mod.

Link to comment
Share on other sites

But it doesnt alter Time scales :)

 

It only slows down movement speed, firing velocitity and such :)

 

It creates this "mock" slow motion. Some animations look a little bad but it doesnt lag. RIght now it always goes in slow motion though because I dont know how to implement the "smart" slow motion.

 

That was the purpose of this thread.

Link to comment
Share on other sites

Add your checking code to G_RunFrame with some sort of time condition if statement, so you can make your checking every so many seconds.

 

E.G.

 

gentity_t *ent;

 

for (i = 0; i < level.maxclients; i++)

{

ent = level.gentities;

if (ent->slomochecktime <= level.time)

{

//do your checking here

ent->slomochecktime = level.time + 1000 //1 second

}

}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...