ignoring creator entity in multiplayer

Posted By: Denn15

ignoring creator entity in multiplayer - 04/11/15 20:33

I am working on a small multiplayer game where currently every palyer joining is a block model and can shoot projectiles after the other players, however when you shoot the projectile often hits the player that shoots it instead of continuing.

The player that creates the projectile sets the "you" pointer to be the created projectile and both the projectile and player has the IGNORE_YOU flag in their movement commands, however for some reason they dont ignore each other.

I assume there is another way to do this but i just cant figure out how to do it.
Posted By: Anonymous

Re: ignoring creator entity in multipålayer - 04/11/15 21:02

Try group and c_ignore, looking at.

Bullet()
my.group = 2;

c_ignore(1);
c_move(...)

PLAYER()
my.group= 1;
Posted By: Denn15

Re: ignoring creator entity in multipålayer - 04/11/15 21:10

the problem is that all the players are given the same action so that they will also have the same group.
therefore the projectiles will ignore all the players and you are soppused to ba able to hit each other.
Posted By: txesmi

Re: ignoring creator entity in multipålayer - 04/11/15 22:40

I have used in the past the IGNORE_PUSH c_move modifier adding a higher push to arrows and checking the arrow parent inside the player event.
Posted By: Ch40zzC0d3r

Re: ignoring creator entity in multipålayer - 04/11/15 22:44

wow wtf
Im glad Im using ANet and not the native 3DGS multiplayer system.
Try to check for a group value. If its your own client-ID set it to a different group but dont change it globally for all players.
Easy as that, idk if its easy to code with the actual 3DGS multiplayer system.
Posted By: Denn15

Re: ignoring creator entity in multipålayer - 04/11/15 22:59

well about the push stuff, they would still affect each other. i supposed you could make them ignore everything and then check collision with vec_dist in a for loop and check for client id in some way.

@chaos that sounds like it could be an option too. ill try it out tomorrow
Posted By: txesmi

Re: ignoring creator entity in multipålayer - 04/11/15 23:13

Originally Posted By: Denn15
they would still affect each other.


They affect just on the event call. The arrow does not collide playes but calls the event and makes hurt when (you->parent != me). It works.
Posted By: Denn15

Re: ignoring creator entity in multipålayer - 04/11/15 23:22

i havent really read into how parent works so i dont know much about that method but my guess is that it makes the projectile ignore the player but not make the player ignore the projectile? and the players movement should not be hindered by its own projectiles
Posted By: txesmi

Re: ignoring creator entity in multipålayer - 04/11/15 23:34

Any player should not collide with any arrow. Ignore the arrows group on player move or so.
Posted By: Denn15

Re: ignoring creator entity in multipålayer - 04/12/15 11:36

@txesmi i have tried to do the following:

Code:
function gethit()
{
	if(your->parent != me)
	{
		your.health = 0;
	}
}

action playeraction()
{
	my.emask = ENABLE_ENTITY;
	my.event = gethit;
        ...
        while(1)
        {
                c_move(me, NULL, vector(my.velx * time_step, my.vely * time_step, my.velz * time_step), GLIDE | IGNORE_YOU);
	        c_rotate(me, vector(my.campan - my.pan, 0, 0), GLIDE | IGNORE_YOU);
        }
}

action shotaction()
{
	my.push = 3;
        ...
        while(1)
        {
	        c_move(me, vector((90 - my.shotpower * 30) * time_step, 0, 0), NULL, IGNORE_PUSH);
        }
}



however now the projectiles dont react at all when hitting any players and when you fire you often get pushed around by your own projectile. is the above code like you meant it or should i do something different?
Posted By: Reconnoiter

Re: ignoring creator entity in multipålayer - 04/12/15 13:00

It sounds that your problem is that the 'you' pointer is different for the server and each client. So IGNORE_YOU does not do the same on each computer. I don't know for sure though. But its easy to check if that's the problem:

When the server player fires, does his projectile also sometimes hit himself?

Whatever the case, I think the easiest problem to solve this is just to remove the IGNORE_YOU line and create the projectile a bit futher away from player/block.

Or perhaps send a handle of the firing player on the server to the clients, though the problem here is a small delay before the clients get the handle from the server.

Or or: let almost all of the code run only on the server and only small visual effects like movement and particles effects etc. run on the client. And than only create entities on the server (not on the clients) and remove the projectiles only on the server (let the server send the STATE of the projectile to the clients). This way only the server needs to know the 'you' pointer wink.
Posted By: Denn15

Re: ignoring creator entity in multipålayer - 04/12/15 13:45

The projectiles event does not seem to trigger with the server player, however the player still gets pushed all over the place because of the projectile.

I have thought about just creating the projectile away from the player, but i would rather want the two to completely ignore esch other just to be sure that there is not gonna happen some jerks in the gameplay or the projectiles spawning inside other players and stuff like that.

I have thought about the handle thing but i just dont know how to make a c_move instruction ignore an entity with a specific handle. my first thought was to use c_ignore with the handle but entity groups only ranges from 0 - 30 and the handle is something 3000 number so that would not work. is there another way to use it?

About running it all on the server, that is also an option but it then there would be small delays on players movement and such and it would feel less smooth.

Posted By: Reconnoiter

Re: ignoring creator entity in multipålayer - 04/12/15 14:19

Originally Posted By: Denn15
About running it all on the server, that is also an option but it then there would be small delays on players movement and such and it would feel less smooth.
, you will get a small delay on the clients, however this delay is technically than only a visual one since the server does the real work and the clients just move projectiles for smooth movement. To 'hide' these small delays, most mp games use things like interpolation. I don't know how experienced you are with mp, but these things can get pretty difficult and head scratching (I have experienced it myself the hard way grin ).

Is your game fps/3rd person or topdown? For topdown it is a bit easier to get things right since the camera is more far away so you could get away with a simple/not perfect interpolation function or no interpolation at all perhaps.
Posted By: Denn15

Re: ignoring creator entity in multipålayer - 04/12/15 15:07

the game is a firstperson shooter. this is my first ever try at a multiplayer game so im not experienced at all tongue but im guessing that interpolation is some sort of prediction og players positioing and such?
Posted By: EpsiloN

Re: ignoring creator entity in multipålayer - 04/12/15 15:46

You cant send handles over the internet. Well, you could, but it will most probably fail at some point...

The solution to your problem is the IGNORE_YOU method you originally tried to use laugh

The problem is that the you pointer is probably reset and you havent saved it anywhere, or on the wrong machine.

Here's what I mean:
Create the bullet on the client and attach a custom local function for it.
On the server it runs the function given in the ent_create statement on the client.
With the local function you attached and on the server's function for that bullet, search for the player entity that has the same client_id as the desired client.
When you find it, set 'you' to that player both in the server function and in the local custom function, and use IGNORE_YOU on both machines.

The other method, (I'm currently building it) is to have local bullets only.
ent_createlocal...
Its executed on the client and on the server when a client hits the mouse button. And the same process goes, search for a player entity with the same client_id, set 'you' to that player entity and IGNORE_YOU.

PS.: If you get stuck, PM me. I think I'll have my code working soon...
Posted By: rayp

Re: ignoring creator entity in multipålayer - 04/13/15 15:17

Just wrote c_ignore - example ... then i saw the 2nd post grin but ive another idea ( no glue if this will work, guess it will )...

Like "EpsiloN" above said u could compare bullet ent handle with creator handle.
Guess it could work like that in the creator - ent:
Code:
...
ENTITY* entbullet = ent_create (bullet...);
if (entbullet) entbullet.skill100 = handle (me);
...


and in the bullet add something like:
Code:
...
ENTITY* entshooter;
if (my.skill100){
   entshooter = ptr_for_handle (my.skill100);
   if (entshooter) if (me != entshooter){
      ...bullet hit entity, but NOT the creator ( different entity - handles )...
      ...bullet removement here and so on...
   }
}

Guess this could work, give it try, doesnt hurt grin

Peace
Posted By: Denn15

Re: ignoring creator entity in multipålayer - 04/13/15 20:35

i just found the problem. since you suggested that it was the you pointer that didnt point to the correct entity i decided to make the player do something visible to the players you entity and the projectile do something visible to its you entity and it seemed like the pointer was valid. because i dint know what to do about the problem i decided to try out testing the you pointers again but this time the players you entity was not the projectile and i found out why.

the player action calls a shooting function that created the projectiles with you=ent_create and thus the you pointer would not be set to that entity in the players action and the c_move instructions was in the players action and the you=ent_create was in the shooting function so i now create the projectiles in the player action and now it works laugh

in short the c_move instruction was not in the same function as the you pointer and then IGNORE_YOU didnt do anything.

anyways thanks for your time and help everyone grin
© 2019 lite-C Forums