Spawning a trigger between 2 entities...

Discuss programming in the QuakeC language.
Post Reply
Orion
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Spawning a trigger between 2 entities...

Post by Orion »

Hey, I'm coding field generators here, when you build 2 of them side by side and an invisible trigger field is spawned between them, with the proper hitbox width. This trigger will check for players, projectiles etc to damage any player that goes through it. Projectiles will simply 'hit' it.

I'm having trouble on setting the trigger's size, which will go from one field generator to another accordingly.

Here's a simple diagram on how it should be:


Image

Any help will be greatly appreciated!
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

you can't rotate bboxes.

Code: Select all

void(entity point1, entity point2) positionselfaroundbounds =
{
  local vector abs_max, abs_min, sz;
  abs_max = maxv(point1.absmax, point2.absmax);
  abs_min = maxv(point1.absmin, point2.absmin);
  sz = abs_max - abs_min;
  setsize(self, sz * -0.5, sz * 0.5);
  setorigin(self, (abs_max + abs_min) * 0.5;
};
ratbert
Posts: 37
Joined: Thu Nov 19, 2009 3:47 pm

Post by ratbert »

Why not look at custom tf quake source. They have a field generator already in their that works.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

If I was doing that:
1) first, obtain the distance between the two poles (d);
2) do a findradius (pole1.origin, d);
3) for every entity (e) found:
4) do a traceline between pole1 and pole2;
5) if e == trace_ent, block/explode/damage/remove/whatever.

Of course, your force fields won't affect hitscan weapons (shotguns, thunderbolt, etc).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Orion
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Post by Orion »

Yes, the easiest way is doing traceline, but the problem is, It will only work for players or monsters passing through them, because traceline will trace a really narrow line so a rocket will freely pass through the generators...

I can do tracebox, but I want to make it work server-side on any engine, because not all engines have tracebox.

I'm thinking of making findradius() and narrow it down to a narrow cone, which is easy too.

EDIT: But then the field will be somewhat convex...
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

You can set your think frequency a bit higher (instead every 0.1seg, let's say 0.05), but yes, chances are you may miss a really fast projectile.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Orion
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Post by Orion »

Well, I had to take a look at CustomTF source code, that was the only way.
Also, I made the trigger completely solid, so even hitscan weapons will be blocked. :)

The field disengages and becomes non-solid if a teammate passes through it.

But it still have a problem. It only works in one direction. O.o
For example, I build 2 north and south, it works. I build 2 east and west, it doesn't work.
Post Reply