20.03.2011, 07:37
(
Последний раз редактировалось Gryphus One; 22.04.2011 в 14:48.
)
Hi, as you all know, Samp can't natively detect whether a Rustler destroys another vehicle the same way it can detect a player killing another. However, some time ago I saw something that gave me an idea: there's one server in which there are car races, and you can come with a Rustler and shoot the racers. Well, nothing related until here, but the key comes now: one day, in the forum of that server, some people were talking about preventing that (Rustlers attacking racers) from happening, and one of the scripters posted the following messages:
Although that's not strictly pawn code, you can see that apparently it's about a script that detects whenever a Rustler shoots to a racer, and in that case it bounces the Rustler upwards. And although this wasn't finally implemented in that server, it inspired me to think of a modified version of that script which might be useful for aircombats. For example, imagine that I'm flying a helicopter and another player (let's say that he's nicknamed "abc") comes with a Rustler and starts shooting to my heli: if the previous script detects that he is shooting to my vehicle AND if my vehicle takes damage, then the action taken by the script, instead of the attacking Rustler being bounced upwards, would be just that a timer starts counting X seconds (maybe 10, 15 or 20 to say a figure). If within that time my vehicle gets destroyed OR if I jump out of it, then the script would detect that player "abc" has destroyed my vehicle with a Rustler, even if I have survived to the attack.
But of course it can happen that the Rustler pilot needs to do several fly-by's to destroy my helicopter (for example if I'm flying slowly and/or in a different direction). In this case, the mentioned timer would be restarted with each new flyby in which my heli takes damage, so those X seconds would be always counted from the last flyby in which my heli 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.
With this example I have been focusing on Rustlers all the time, but I guess that it could apply also to other vehicles that have a gun mounted on them, like Seasparrows and RC Barons.
Do you think this would work with a reasonable scripting effort and without creating too much lag?
Quote:
It is not possible to detect bullet hits or who they came from accurately and efficiently. [...] It is possible however to detect the keys pressed by a rustler player, if the rustler is streamed in, if the player is a racer and there is also an event for when a player streams in/out.. |
Quote:
Was thinking more along the lines of... Код:
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. } |
Quote:
It is quite a simple solution once the math is figured out. This kind of mathematical function is common on the internet and should be quite easy to whip up using basic trigonometry.. it could run in it's own script too. Tidily and away from all our other code. |
But of course it can happen that the Rustler pilot needs to do several fly-by's to destroy my helicopter (for example if I'm flying slowly and/or in a different direction). In this case, the mentioned timer would be restarted with each new flyby in which my heli takes damage, so those X seconds would be always counted from the last flyby in which my heli 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.
With this example I have been focusing on Rustlers all the time, but I guess that it could apply also to other vehicles that have a gun mounted on them, like Seasparrows and RC Barons.
Do you think this would work with a reasonable scripting effort and without creating too much lag?