Author Topic: How would this work?  (Read 5609 times)

0 Members and 2 Guests are viewing this topic.

Offline Gryphus_One

  • Banned
  • *
  • Posts: 1079
  • Personal Text
    • My Youtube account ;)
    • Awards
How would this work?
« on: March 21, 2011, 03:24:04 PM »
You know that currently Samp can't detect if a Rustler destroys another plane the same way it can detect if a player kills another. However, maybe some of you remember that some time ago, Hazard talked about a script to prevent Rustlers from attacking racers:

Was thinking more along the lines of...

Code: [Select]
OnFireKeyPressed:
  LoopRacers {
    If RacerIsStreamedForRustlerPilot() && RustlerPilotIsLookingInRacerDirection()
        SlowDownRustler(); // Decrease relative X and Y velocity so they fall back from the racer.
    OR
        MakeRustlerFlyUpwards(); // Set Z velocity upwards..thus making the rustler not aim at the players on the ground AND not crash as a side effect.
}

Hopefully that's readable.

Well, this inspired me to think of a modified version of that script to detect if a Rustler destroys another plane, which might be useful for aircombats. For example, imagine that I'm flying a plane and Qwerbeet comes with a Rustler and starts shooting me: if Hazard's script detects that he is shooting to my plane AND if my plane takes damage, then a timer starts counting X seconds (maybe 10, 15 or 20 to say a figure). If within that time my plane gets destroyed OR if I jump out of it, then the script would detect that Qwerbeet has destroyed my plane, even if I have survived to the attack.
But of course it can happen that Qwerbeet needs to do several fly-by's to destroy my plane (for example if I'm flying slowly). In this case, the mentioned timer would be restarted with each new flyby in which my plane takes damage, so those X seconds would be always counted from the last flyby in which my plane has been damaged.
If there are several Rustlers shooting to me, then my downing would be scored by the last one in shooting me, like when fighting on foot.

If this worked well, it would be useful for aircombat stats: how many times you have destroyed other planes, how many times your own plane has been destroyed and an aircombat ratio.

Do you think this would work without being too heavy and without creating much lag?

NOTE: this is NOT a suggestion for the server, I just want to know the opinion of the scripters about how this would work.
.
« Last Edit: March 21, 2011, 03:33:53 PM by [kicked]Gryphus_One »

Offline BikeDriver

  • Fisher
  • ******
  • Posts: 1765
  • I can do anything
    • Awards
Re: How would this work?
« Reply #1 on: March 21, 2011, 03:53:25 PM »
wow it took your inspired super brain only 8 month to make this up? ;D

you seem to not quite understand anything.

this thing detects if you are looking towards a racer while you fly a rustler and shoot the rustlers weapon.

if so it will slow down your rustler or change its direction.

it does not detect if you destroyed or attacked a plane. it only detects if you are looking towards a specific player while you press a button. its hardly enough to punish somebody for shooting a racer. its impossible to script proper air combat stats with this.
BikeDriv:))))

Haha blwelrwelrt, I registered here earlier :P

Offline EnzoMortelli

Re: How would this work?
« Reply #2 on: March 21, 2011, 07:18:22 PM »
At least it could be used like that, but its like using simple integer arrays to build up a stackmemory (but as pawno hasnt much alternatives :/)

anyways it would be an idea, so if the rustler heads the target rustler, and fires his guns, and the targetrustler takes damage, then start a timer. If the rustler gets destroyed within that time, u'll get the kill. Thats how i understood what u wrote.

That could work, but there are quite some things that could be seen as bugs and lead to fails, for example a 'scary kill', how i would name it, wich means u shoot the target rustler, but u didnt take him down by now, but then he crashes, within the time, into something else, and u would get the kill then. that means u somehow 'scared him to death'. Equal to a normal death match scenario, the player doing /kill would count to ur stats then ???

And what should be in the stats, when does a fight end? either when the plane is down, or when the pilot is dead? I assume from what u wrote that it should count to the stats when the plane is down. im not quite sure if it can be registrated if a player leaves a car, but if it would, that would be doable in the means of programming aswell.

But as all that informations: plane heading, health, guns, crashes, leaving have to be processed in real time and constantly, and in average case not only of one single player, but of multiple players at the same time, u can almost be sure this would create lag on some players systems, maybe also on the server himself.

I'd say the best would be to script it by urself, test it on ur own pc, i guess it would be scriptable, but as i do not know pawno very well i cant say exactly, and look if it works.

And dont bullshit anyone gryphus, i knew by the third line that if it would work u would instantly suggest this for LWs ;D

Offline [eVo]PvtBenny

  • SA-MP Donator
  • *
  • Posts: 690
    • Awards
Re: How would this work?
« Reply #3 on: March 21, 2011, 08:27:23 PM »
It sure does smell like a suggestion.... eventhough its not....

Offline Simon

  • SA-MP Retirees
  • *
  • *
  • *
  • Posts: 1236
  • Retired
    • Awards
  • SA-MP: [CP]Simon
Re: How would this work?
« Reply #4 on: March 27, 2011, 06:03:54 AM »
You'll have some inaccuracies, which I'm sure you've thought about. It would be workable and it may cause some "WTF"-that was my kill moments. You'd have to test it to really know if it's suitable.

Instead of a timer you'd want to have player variables that stores the time  (GetTickCount() or tickcount()) a player was last shot. When a player dies you'd then use that time to check who was the last person to shoot them and whether or not that is within your 20 seconds.

That code I post was just psuedo-code. Although I still personally think it will work, it has never been tested. It's based on a theory that you can rotate the players velocity vector then project that to test if it hits a streamed in player (this assumes that velocity is almost always in the direction the plane is going)..

Now you can use a new method in SA:MP named GetVehicleRotationQuat which is probably more accurate, but more mathematically complicated for most (I've never worked with quaternions nor do I have the dying need to at this time :P)
« Last Edit: March 27, 2011, 06:06:34 AM by Hazard »