crazy laser (maybe a boxy war add)
- BinarySpike
- Corporal
- Posts: 735
- Joined: Mon Mar 28, 2005 11:58 pm
- Contact:
crazy laser (maybe a boxy war add)
after finding out "make -n" shows the linking commands... I can edit them to include the correct libcurl and dlcompat... I can run plugins and libcurl on my mac
Now anyway, I'm working on a plugin called crazy laser, it works in rabbit hunt, ctf, and ffa...
You define a laser position, time, and several settings
the laser fires from it's position every "time" seconds... so if you set a laser for for 3 seconds
The laser would target players every 3 seconds and fire... (tracking them with laser)
Basically there are some things... Player and Distance and Flag.
Player is the highest player, Distance is the closest player to the "objective", and Flag is a good or bad flag
For example, CTF would be a base... so if a high ranking player was near a base then the claser would be more apt to shoot him...
The claser does NOT target ST's, or CL's
For example you could set Player to any, Distance to any, and Flag to bad, and set the time to 3... now when the laser doesn't have anybody to target it will idle when that happens it has to "load" up and will shoot the moment it has a target and is loaded...
so in this case whenever somebody picked a bad flag up the laser will load for three seconds (if time is 3) and then fire at the player...
Laggy players it won't shoot to well but I hope to have a doppler calculator (which is cake to make)
The targeting and the firing should be easy but the actually setting's setting should be hard... I've only done one other plugin so far... anyway... what do you guys think?
Now anyway, I'm working on a plugin called crazy laser, it works in rabbit hunt, ctf, and ffa...
You define a laser position, time, and several settings
the laser fires from it's position every "time" seconds... so if you set a laser for for 3 seconds
The laser would target players every 3 seconds and fire... (tracking them with laser)
Basically there are some things... Player and Distance and Flag.
Player is the highest player, Distance is the closest player to the "objective", and Flag is a good or bad flag
For example, CTF would be a base... so if a high ranking player was near a base then the claser would be more apt to shoot him...
The claser does NOT target ST's, or CL's
For example you could set Player to any, Distance to any, and Flag to bad, and set the time to 3... now when the laser doesn't have anybody to target it will idle when that happens it has to "load" up and will shoot the moment it has a target and is loaded...
so in this case whenever somebody picked a bad flag up the laser will load for three seconds (if time is 3) and then fire at the player...
Laggy players it won't shoot to well but I hope to have a doppler calculator (which is cake to make)
The targeting and the firing should be easy but the actually setting's setting should be hard... I've only done one other plugin so far... anyway... what do you guys think?
- I_Died_Once
- Special Forces
- Posts: 635
- Joined: Sun Nov 28, 2004 5:27 pm
- Location: The Dark Side
- Contact:
- chandler583
- Private First Class
- Posts: 33
- Joined: Fri Jan 07, 2005 12:01 am
- Location: Brenham
- Contact:
- BinarySpike
- Corporal
- Posts: 735
- Joined: Mon Mar 28, 2005 11:58 pm
- Contact:
requires a server mod
My trig won't work... I've tryed everything I could think of...
(i'm not a math wiz... I do know some trig but this is just to hard)
I could mod the server so that we could use something other than direction and tilt (which is throwing me off)
That "might" be nice but would probably not sit well with the devs if I sent a patch in... if ya'll want to see my code here it is...
(I tried converting to degrees... radians works ONLY if the x isn't negative... and I don't know enough about radians/atan to tell what I'm doing wrong)
It fires correctly if x isn't negative... it misses if it is... also laserpos is the location of the laser... which in this case is 0,0,15 (center, 15 units up)
My trig won't work... I've tryed everything I could think of...
(i'm not a math wiz... I do know some trig but this is just to hard)
I could mod the server so that we could use something other than direction and tilt (which is throwing me off)
That "might" be nice but would probably not sit well with the devs if I sent a patch in... if ya'll want to see my code here it is...
(I tried converting to degrees... radians works ONLY if the x isn't negative... and I don't know enough about radians/atan to tell what I'm doing wrong)
Code: Select all
void claser::process(bz_EventData *eventData)
{
bzAPIIntList targetsList;
//bz_PlayerRecord * targetRec;
bz_PlayerSpawnEventData *targetRec = (bz_PlayerSpawnEventData*)eventData;
//targetRec = bz_getPlayerByIndex(0);
if (targetRec == NULL /*!= NULL && !bz_updatePlayerData (targetRec)*/) // update the target
{
bz_debugMessage(4, "couldn't update target");
}
float reloadTime = (float)bz_getBZDBDouble("_reloadTime") * (float)bz_getBZDBDouble("_laserAdRate");
// calculate direction and tilt...
float x = targetRec->pos[0] - laserpos[0], y = targetRec->pos[1] - laserpos[1], z = targetRec->pos[2] - laserpos[2];
// convert targetDir to a tilt and direction
float tilt = 0, direction;
#define myPI 3.14159265
float tiltX = sqrt(pow(x,2) + pow(y,2));
float dirX = sqrt(pow(x,2) + pow(z,2));
direction = atan2(y,dirX);
tilt = atan2(z, tiltX);
bz_fireWorldWep("L",reloadTime,BZ_SERVER,laserpos,tilt, direction, 0, 0.0f);
bz_debugMessage(0, bz_format("xyz %f %f %f, tilt %f, direction %f", x, y, z, tilt, direction));
}
- BinarySpike
- Corporal
- Posts: 735
- Joined: Mon Mar 28, 2005 11:58 pm
- Contact:
man that would rock! having a bad flag which would make a world weapon fire on you
on thing though, for laser would it be able to sucessfully shoot players with lag? *cough*myself*cough*
better still, have a flag which launches "TAG(Target Aquisition and Guidance)Bullets", and when they hit the player, the world weapon then starts firing upon them, OR have you (or other players) automatically aim and fire at them.
on thing though, for laser would it be able to sucessfully shoot players with lag? *cough*myself*cough*
better still, have a flag which launches "TAG(Target Aquisition and Guidance)Bullets", and when they hit the player, the world weapon then starts firing upon them, OR have you (or other players) automatically aim and fire at them.
Could this tank perhaps go a little bit faster, so it's not being overtaken by stationary objects.
"Words in parentheses can (not) be ignored." -Unknown
"Words in parentheses can (not) be ignored." -Unknown
- MonsterMan++
- Private First Class
- Posts: 189
- Joined: Thu Apr 13, 2006 11:32 am
Hey it looks good! Actually that's pretty awesome. It's a smart laser, so you should make it a little less better.
Fighting for peace is like screwing for virginity.
-George Carlin
If you can't beat them, arrange to have them beaten.
-George Carlin
Nobody goes there anymore. It's too crowded.
-Yogi Berra
Better a broken promise than none at all.
-Mark Twain
-George Carlin
If you can't beat them, arrange to have them beaten.
-George Carlin
Nobody goes there anymore. It's too crowded.
-Yogi Berra
Better a broken promise than none at all.
-Mark Twain
- BinarySpike
- Corporal
- Posts: 735
- Joined: Mon Mar 28, 2005 11:58 pm
- Contact:
That would require a massive client mod, along with a massive server mod... waaay to hard for me... and I can't even get my trig to work fully...Waistless wrote:man that would rock! having a bad flag which would make a world weapon fire on you
on thing though, for laser would it be able to successfully shoot players with lag? *cough*myself*cough*
better still, have a flag which launches "TAG(Target Acquisition and Guidance)Bullets", and when they hit the player, the world weapon then starts firing upon them, OR have you (or other players) automatically aim and fire at them.
About the lag, that's easy... can't remember what JeffM called it but I call it doppler... (yeah totally out of context)
I've tried this exact same thing using a client mod... (where I could shoot a player that was below me or to my side... and hit him)
But lag made me miss... so I had to hit non-moving tanks...
I might just compensate for lag only if the player has a bunch of it... that way the laser wouldn't hit players moving perpendicular to it (like a GM dodge) but stopped/parallel it would hit
- BinarySpike
- Corporal
- Posts: 735
- Joined: Mon Mar 28, 2005 11:58 pm
- Contact:
I haven't read the documentation for all of these functions, but I'm guessing tilt is an angle for up/down and direction is for left/right. If so, I think you should use the normal arctan function instead of atan2 when calculating the tilt. I think your problem is that atan2 returns an angle in the correct quadrant based on the signs of the parameters.BinarySpike wrote:requires a server mod
My trig won't work... I've tryed everything I could think of...
(i'm not a math wiz... I do know some trig but this is just to hard)
I could mod the server so that we could use something other than direction and tilt (which is throwing me off)
That "might" be nice but would probably not sit well with the devs if I sent a patch in... if ya'll want to see my code here it is...
(I tried converting to degrees... radians works ONLY if the x isn't negative... and I don't know enough about radians/atan to tell what I'm doing wrong)
It fires correctly if x isn't negative... it misses if it is... also laserpos is the location of the laser... which in this case is 0,0,15 (center, 15 units up)Code: Select all
void claser::process(bz_EventData *eventData) { bzAPIIntList targetsList; //bz_PlayerRecord * targetRec; bz_PlayerSpawnEventData *targetRec = (bz_PlayerSpawnEventData*)eventData; //targetRec = bz_getPlayerByIndex(0); if (targetRec == NULL /*!= NULL && !bz_updatePlayerData (targetRec)*/) // update the target { bz_debugMessage(4, "couldn't update target"); } float reloadTime = (float)bz_getBZDBDouble("_reloadTime") * (float)bz_getBZDBDouble("_laserAdRate"); // calculate direction and tilt... float x = targetRec->pos[0] - laserpos[0], y = targetRec->pos[1] - laserpos[1], z = targetRec->pos[2] - laserpos[2]; // convert targetDir to a tilt and direction float tilt = 0, direction; #define myPI 3.14159265 float tiltX = sqrt(pow(x,2) + pow(y,2)); float dirX = sqrt(pow(x,2) + pow(z,2)); direction = atan2(y,dirX); tilt = atan2(z, tiltX); bz_fireWorldWep("L",reloadTime,BZ_SERVER,laserpos,tilt, direction, 0, 0.0f); bz_debugMessage(0, bz_format("xyz %f %f %f, tilt %f, direction %f", x, y, z, tilt, direction)); }
EDIT: Just a side note: x*x is faster than pow(x,2).
YET ANOTHER EDIT:
This part of your code doesn't make sense:
Code: Select all
float tiltX = sqrt(pow(x,2) + pow(y,2));
float dirX = sqrt(pow(x,2) + pow(z,2));
direction = atan2(y,dirX);
tilt = atan2(z, tiltX);
Last edited by Enigma on Sun Aug 13, 2006 1:20 am, edited 1 time in total.
- GMMan
- Private First Class
- Posts: 186
- Joined: Sat May 13, 2006 9:32 pm
- Location: On the time-space continuum
This plugin would probably drive me nuts trying to dodge it (if possible!) Though still, this is a great idea. It might work for a map I'm thinking of making.
I haven't touched BZFlag for years, but maybe sometime I'll make a comeback.
I'm on Twitter. And I mess with webOS. This signature is not a blog.
I'm on Twitter. And I mess with webOS. This signature is not a blog.
- BinarySpike
- Corporal
- Posts: 735
- Joined: Mon Mar 28, 2005 11:58 pm
- Contact:
Ok for everyone's information, with inchworm's help I was able to figure the problem out.
As slayer++ said, atan2 only gives me correct information for a specific quadrant (at the time I didn't know what a quadrant is)
Strangly I figured this, not in the exact sense, but I thought how I would do it, but didn't want to sit down and write it all out...
Like I said, there would need to be and update for a timestamp to actually calculate a tanks position, based on his speed and the last update and the current time, you could extropolate a "current" position minus lag, then add a lag fudge.
Also, GMMan, the laser wouldn't be accurate, if you stopped moving it would kill you in an instant, but depending on lag, and how MsgPlayerUpdate works, you would get hit less.
I could also add a "player" target, higher lag players that don't get hit as much could be targeted, or based on how many times the laser has hit a specific tank. That way it wouldn't go after less laggy players more. kidna like handicap
Atm I'm finishing up my iBZEdit, but I might go ahead and do this now with my knowledge of atan2
I'll start a new post if I get anything, thanks
As slayer++ said, atan2 only gives me correct information for a specific quadrant (at the time I didn't know what a quadrant is)
Strangly I figured this, not in the exact sense, but I thought how I would do it, but didn't want to sit down and write it all out...
Like I said, there would need to be and update for a timestamp to actually calculate a tanks position, based on his speed and the last update and the current time, you could extropolate a "current" position minus lag, then add a lag fudge.
Also, GMMan, the laser wouldn't be accurate, if you stopped moving it would kill you in an instant, but depending on lag, and how MsgPlayerUpdate works, you would get hit less.
I could also add a "player" target, higher lag players that don't get hit as much could be targeted, or based on how many times the laser has hit a specific tank. That way it wouldn't go after less laggy players more. kidna like handicap
Atm I'm finishing up my iBZEdit, but I might go ahead and do this now with my knowledge of atan2
I'll start a new post if I get anything, thanks