Jump to content

[WIP | SA | Thread] Air traffic mod


Recommended Posts

Air Traffic Mod version 1.0 (25.06.07)

 

user posted image user posted image

 

Credits:

======================================

Original code by Jay-Rocc aka Altman

(http://westcoast-4-life.msk.ru)

Thanks to Demarest (co-author, I think)

Thanks to all Seemann for advices.

 

Mod features:

======================================

- This mod enables air traffic around all San Andreas between LS, SF and LV airports.

- The AT400 planes take off, fly in certain routes and landing in all three airports

- The flights are not dependent on player behaviour and have totally random timetable

- You can make air accident in any place of plane route smile.gif

- If you have paintjob compatible planes you can see them with different airlines artwork on boards

 

More features to come (in v2):

- Parked planes with different paintjobs

 

Installation:

======================================

Make backup of your /script/ folder!

Replace main.scm and script.img in /data/script folder

...or just insert code from SB code.txt to your scm file

 

DOWNLOAD MOD

Link to comment
https://gtaforums.com/topic/279455-wip-sa-thread-air-traffic-mod/
Share on other sites

DOES ANYBODY REALLY KNOW HOW TO OPTIMIZE THIS CODE?

Because I know that this code is far from perfect.

Sure, but are you serious? Last guy that asked threw a hissy fit when I answered his call for optimization. From the beginning...

 

Nothing jumps to PLANEZZ23, so there's no reason to make a separate label there.

 

NEVER use DMA unless you know what you're doing and have to. Original code didn't use those vars, so I know you didn't have to. Besides, you're better off using locals anyways.

 

After you create the car from model 577 (?), you have a pair of waits. Neither are necessary.

 

Nothing jumps to PLANEZZ_01 except a failed path loaded check. An is loaded loop should never include the request inside the loop, so essentially nothing jumps to that label and therefore isn't needed.

 

Your is path 49 available is "upside down." By flipping it, you eliminate the need for the next label (and of course I've fixed the label it jumps back to to ONLY be the is loaded loop).

 

Once 49 is loaded, there is another wait that is not necessary. It's better to have too many than too little, but it's still good to get a feel for when you need it. With some of the stuff I've pulled off in Windshield, I think you'd be surprised at how much you do NOT need waits.

 

After you assign the car to the path, you have a wait 30000. That's 30 secons. A LOT can happen in 30 seconds, including the player dieing and returning here again. Better is using a local timer to check for 30 seconds elapsing AND constantly checking if the player is not defined or the car is wrecked. Because if either happens, it's safe to remove references to the car and reset the thread.

 

After that, you have a compound check that checks if car is wrecked AND a conditional that addresses the car. The whole point of having an is car wrecked check is to make sure that it's safe to talk to the engine about that car. Which means the check has to come BEFORE your other conditional, not at the same time. Your if operand was 0 anyways when you meant 1.

 

Since you had three long waits, the above two are true several times. When you impliment the right way, it gets considerably longer. I COULD compress this part down to be less than half as long. It would work the same, but the process might be confusing to newer coders. So I'll go without it and if you're interested in how I'd propose compressing it further, say so and I'll show you. If you're iffy, ask for it anyways as I think you'll be happy to see it smile.gif

 

You have a destroy car command AFTER removing references. When you command the engine to remove references to a car, you cannot refer to it any longer.

 

The release model command comes after you remove references to the car. This command should be used as soon as you no longer need the model loaded, which is right after it's created. Also, I didn't see a remove references or similar discarding of the path. I'll admit that I'm not terribly familiar with the paths. But you should double check existing code to make sure you don't need to. Otherwise, your code will stuff somebody's game up in time.

 

Finally, you have a couple commented out lines. No biggie, just if you're sharing code (especially in the showroom), you should probably clean that up first.

 

Put all of the above together, and this is what JUST THE FIRST THREAD would look like

:PLANEZ_403A4: name_thread 'PLANEZ2':PLANEZZ220001: wait  0 ms00D6: if  0 0256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLANEZZ220247: request_model  577038B: load_requested_models:PLANEZZ240001: wait  0 ms00D6: if  00248:   model  577  available004D: jump_if_false ££PLANEZZ240395: clear_area  1 at -1626.0 -137.3 13.0 range  40.0 00A5: @0 = create_car  577 at  -1626.0 -137.3 13.00175: set_car @0 z_angle_to  1800209: @1 = random_int  0  306ED: set_car @0 paintjob  @10249: release_model 57707C0: request_path 49                 :PLANEZZ_2840001: wait  0 ms00D6: if  0 07C1:    path 49 available004D: jump_if_false ££PLANEZZ_28400D6: if  0 8119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZZ_30605EB: assign_vehicle @0 to_path 490006: @32 =  0:PLANEZZ_3050001: wait  500 ms00D6: if  10256:   player $PLAYER_CHAR defined8119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZZ_30600D6: if  00019:   @32 >  30000004D: jump_if_false ££PLANEZZ_30500D6: if  0860E:   NOT   car @0 is_assigned_to_existing_path  004D: jump_if_false ££PLANEZZ_30608E6: set_plane @0 landing_gear  10006: @32 =  0:PLANEZZ_305B0001: wait  500 ms00D6: if  10256:   player $PLAYER_CHAR defined8119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZZ_30600D6: if  00019:   @32 >  90000004D: jump_if_false ££PLANEZZ_305B00D6: if  0860E:   NOT   car @0 is_assigned_to_existing_path 004D: jump_if_false ££PLANEZZ_30608E6: set_plane @0 landing_gear  00006: @32 =  0:PLANEZZ_305C0001: wait  500 ms00D6: if  10256:   player $PLAYER_CHAR defined8119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZZ_30600D6: if  00019:   @32 >  30000004D: jump_if_false ££PLANEZZ_305C         :PLANEZZ_30601C3: remove_references_to_car @00002: jump ££PLANEZ_4

 

You PROBABLY could (and should) make it all one thread. But since your intervals are different, it would be no easy task. Just keep in mind that using more threads than you need to can be dangerous, especially for people who like using multiple mods together (and they all overthread this way).

 

If you have any questions about why this or why that or you'd like me to revise the above with the three local timer loops consolidated, let me know smile.gif

@Demarest

Oh, thanks that amazing! These advices helps me so much to understand basics of coding.

I have few questions to you:

1. Is it possible to make time check (timetable) for running airport script to prevent airplane crashing on the same airfield stripe.

2. I have no idea how to make more than 1 flight wo copy/paste main part of the script. If it possible can you give me advice about this technique or example?

Thanks a lot!

Hmmm. I'm not sure I understand your question. If your first question has to do with your scripted planes colliding with planes that already exist (moving around), I have no idea. I don't think the SCM has anything to do with the generic plane traffic.

 

As for your second question, I don't understand. If I'm reading the code correctly, this is something that repeats every 2.5 minutes. What were you looking to accomplish?

@Demarest

1. I mean do you know is it possible to make flights timetable that can be created with time checking. In my first message I have time checking code, but I can't get it work. Was it mistaken?

 

2. For the second question:

I mean I have this script only for one flight, and If I need to make another route I need to copy the code and rename variables, so I will have the same doubled code except vars, coords and path names. I have no Idea how to shrink code to prevent copying same part for the script for every route. Is it possible?

 

Thanks.

 

@Hollaz

Yes, you can follow or destroy planes

@Demarest

1. I mean do you know is it possible to make flights timetable that can be created with time checking. In my first message I have time checking code, but I can't get it work. Was it mistaken?

It's inefficient. Mostly in ways that I've already covered. One way I did not: The MAIN thread already establishes $WEEKDAY, $TIME_HOURS, and $TIME_MINS and it stores them into global vars, meaning any thread has access to them. You don't need your mod to establish them again. Put that together with the tips I gave above and you should have something like
:PLANE_DAYCHECK0001: wait  0 ms00D6: if  210038:   $WEEKDAY ==  6;; integer values0038:   $WEEKDAY ==  7;; integer values004D: jump_if_false ££PLANE_NONWEEKEND00D6: if  210038:   $TIME_HOURS ==  7;; integer values0038:   $TIME_HOURS ==  11;; integer values004D: jump_if_false ££PLANE_DAYCHECK00BA: text_styled 'BEEFY'  2000 ms  2; Beefy Baron (whatever code you put here will run when it's 7 or 11 on days 6 and 7. I don't think there even is a day 7 because computers begin counting at 0)0002: jump ££PLANE_DAYCHECK:PLANE_NONWEEKEND00D6: if  210038:   $TIME_HOURS ==  8;; integer values0038:   $TIME_HOURS ==  10;; integer values004D: jump_if_false ££PLANE_DAYCHECK00BA: text_styled 'DRV3_9'  2000 ms  2; ~r~One of the packages was destroyed! (whatever code you put here will run when it's 8 or 10 on days 0-5)0002: jump ££PLANE_DAYCHECK

Please note that in addition to consolidation, I removed lines you had appearing after jump commands, such as return and end_thread. A jump commands jumps, so any code after it will never be run and is therefor added weight.

 

 

2. For the second question:

I mean I have this script only for one flight, and If I need to make another route I need to copy the code and rename variables

You will not need to rename variables. I STRONGLY urge you to read the MB readme again (don't feel bad; it's a file the people should return to many times because it's so much information, each read is bound to teach you more) to re-familiarize yourself with variables and the differences between local and global. If you do this and are still confused, PM me and maybe I can help clear it up for you. The point here is that if you copy pasted the code I posted, all you'd need to change is the label names. And since your threads had different time amounts, you'd need to change those as well. The fact that it will be a different thread altogether means that the locals used in it will not overlap with the locals used by other threads. Search original code and you will find that @0 and @34 for example can be found in MANY threads.

 

 

I have no Idea how to shrink code to prevent copying same part for the script for every route. Is it possible?
I don't know what you're asking here. If you're asking how I would compress the code further by consolidating the three local timer checks, here's what it would look like
:PLANEZ_403A4: name_thread 'PLANEZ2':PLANEZZ220001: wait  0 ms00D6: if  00256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLANEZZ220247: request_model  577038B: load_requested_models:PLANEZZ240001: wait  0 ms00D6: if  00248:   model  577  available004D: jump_if_false ££PLANEZZ240395: clear_area  1 at -1626.0 -137.3 13.0 range  40.000A5: @0 = create_car  577 at  -1626.0 -137.3 13.00175: set_car @0 z_angle_to  1800209: @1 = random_int  0  306ED: set_car @0 paintjob  @10249: release_model 57707C0: request_path 49              :PLANEZZ_2840001: wait  0 ms00D6: if  007C1:    path 49 available004D: jump_if_false ££PLANEZZ_28400D6: if  08119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZZ_30605EB: assign_vehicle @0 to_path 490006: @2 =  2:PLANEZZ_3050006: @32 =  0:PLANEZZ_305B0001: wait  500 ms00D6: if  10256:   player $PLAYER_CHAR defined8119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZZ_30600D6: if  00019:   @32 >  30000004D: jump_if_false ££PLANEZZ_305B00D6: if  218039:   NOT   @2 ==  10019:   @32 >  90000004D: jump_if_false ££PLANEZZ_305B00D6: if  0860E:   NOT   car @0 is_assigned_to_existing_path  004D: jump_if_false ££PLANEZZ_306000E: @2 -=  100D6: if  08039:   NOT   @2 ==  -1004D: jump_if_false ££PLANEZZ_30608E6: set_plane @0 landing_gear  @20002: jump ££PLANEZZ_305:PLANEZZ_30601C3: remove_references_to_car @00002: jump ££PLANEZ_4

This is made possible by the fact that you call for landing gear in a reverse sequential order, so I used a var to signify this. The code would be even shorter except you had the middle time to be 90 seconds instead of 30, so some code had to be tossed in to make sure that exception was addressed.

 

Now if instead you meant making it smaller by having one thread instead of three, that would get to be quite complicated. So much so that you're better off using multiple threads and just walking away with the knowledge that multiple threads should be avoided to possibly help you make future mods leaner. If you use time tables instead of differing time increments, then combining them into one thread will likely be easier and shorter to the point of being realistic.

 

As always, any questions, fire away smile.gif

 

Please note that in addition to consolidation, I removed lines you had appearing after jump commands, such as return and end_thread. A jump commands jumps, so any code after it will never be run and is therefor added weight.

hmm, interesting, I found this example in original game code...

 

 

You will not need to rename variables. I STRONGLY urge you to read the MB readme again (don't feel bad; it's a file the people should return to many times because it's so much information, each read is bound to teach you more) to re-familiarize yourself with variables and the differences between local and global. If you do this and are still confused, PM me and maybe I can help clear it up for you. The point here is that if you copy pasted the code I posted, all you'd need to change is the label names. And since your threads had different time amounts, you'd need to change those as well. The fact that it will be a different thread altogether means that the locals used in it will not overlap with the locals used by other threads. Search original code and you will find that @0 and @34 for example can be found in MANY threads.

Yeah, I understand that label names should be renamed. But can we put this code one time, instead of 6(number of flights) times?:

 

 

:PLANEZ230247: request_model  577038B: load_requested_models:PLANEZ240001: wait  0 ms00D6: if  00248:   model  577  available004D: jump_if_false ££PLANEZ240395: clear_area  1 at 1577.298 -2493.749 13.5895 range  40.000A5: $11479 = create_car  577 at  1577.298 -2493.749 13.58950175: set_car $11479 z_angle_to  1800209: $11480 = random_int  0  306ED: set_car $11479 paintjob  $114800001: wait  0 ms

 

Edited by altman

hmm, interesting, I found this example in original game code...
Oh I know. I wasn't judging you. Just letting you know. I imagine the reason you see such fat in R*'s code is because their code is the product of MANY people working on the same code for an extended period of time. What you see is section markers they never cleared out when they were finished. Which is a shame because it happens so much more in SA (being larger) and SA has a much lower ceiling compared to the original code than the other games. So it just makes modders hit the ceiling a WHOLE lot faster than they need to. Last summer, I started writing TTSA. As I fingered through R*'s code, I was astounded at how dirty their code is. You wouldn't believe how far I've been able to compress some of their work because I was one person looking at the finished product instead of a team of people working together to make it from scratch.

 

 

Yeah, I understand that label names should be renamed. But can we put this code one time, instead of 6(number of flights) times?:
Well not THAT code because it contains DMA globals when locals will suffice. If you're asking if you need to load the model six times, I'm afraid so. One of the many advantages to having one thread instead of six is not having to make this call six times. Report back to me if my cleanup of your timing code helped you reach your goal of timed flights any better. If so, it will be that much more possible to get this all into one thread.

@Demarest

 

I have an idea about combining of all flight routes in 1 thread to prevent duplicating code.

1. First I should create 6 separate threads. In every thread I will create hour and day checking. (I need separate threads to make hours checking for all flights in same time)

2. If script values and hours in game are congruent we will jump to the next label where we set local variables of coords, path number, plane var, etc.

3. Then we jump to part of the script, where plane will spawn. This part of the script is the same for all 6 threads.

The main idea of my method to set different values (coords, path, etc) for different flights, but execute the same script for plane spawning. I hope you understand what I mean, otherwise I draw basic sketch for you.

Edited by altman

Have you considered simplifying your approach? Based on the topic title, I'm guessing you made this to add random air traffic into the skies, eh? If so, why not make it RANDOM? Like say the thread starts and selects a random number of one through six. That will determine which flight is taking place right now. Put that one through its paces. When all is said and done, random one through six and repeat the process. Or you could have once an hour on the hour select a random one to six. And so on. The complexity in smashing it into one thread is that you're having the one thread monitor/direct all six flights at the same time. What I'm suggesting would be easier to write and the end result would be more random in game. Of course, this is only a good idea if I actually grasp your intent. If not, let me know.

 

Otherwise, you might have to get into strobe coding. R* did this a lot in SA. It's an approach whereby the thread is literally checking all bases one right after another. "Where's plane one? Oh, there is no plane one? Create it and send her on her way. Where's plane two? In flight? Very well. Where's plane three? Approaching its destination? Better extend the landing gear..." and so on. Not too hard, but a BIG undertaking. Which means a large potential for mistakes. But the end result would be a jammed airway and you having full control of all flights at all times.

 

Have you considered simplifying your approach? Based on the topic title, I'm guessing you made this to add random air traffic into the skies, eh? If so, why not make it RANDOM? Like say the thread starts and selects a random number of one through six. That will determine which flight is taking place right now. Put that one through its paces. When all is said and done, random one through six and repeat the process. Or you could have once an hour on the hour select a random one to six. And so on. The complexity in smashing it into one thread is that you're having the one thread monitor/direct all six flights at the same time. What I'm suggesting would be easier to write and the end result would be more random in game. Of course, this is only a good idea if I actually grasp your intent. If not, let me know.

 

I want to see more than 1 plane flying in same time, but I don't want to make planes crashing. But in this case you can see only one plane flying. I like your way, but how i can prevent airplane accidents?

Edited by altman
Well "my way" only has one at a time, so there'd be no accidents. Besides, what's wrong with accidents? Are you sure the path to and from LS and SF for example are on top of one another? In the original game, a plane randomly biting it is hilarious (as long as you're not at ground zero at the time). But if you insist on no accidents and are certain a path and return path would cause such a collision, then I guess the answer would be only have one plane in-between any two island at one time.
  • 2 weeks later...

I am starting on a similar mod myself and didn't realise someone had started an aircraft pattern mod till I checket out in here.

My take on it to reduce accidents would be to take a realistic approuch and handle the aircraft similar to air traffic control, assign them different routes and alltitudes to reduce collisions.

Personally I would only use the Nevada for local flights between airports, including using this for the airline tickets, and use the larger AT400s for outgoing and incoming International flights. More realistic as the AT400 is a bit large to fly around inland in a place as small as SA.

The ATs I would spawn out to sea and have them fly into and then leave the airport heading back out to sea, the vehicle then being destroyed or released as being no longer needed.

You could then fine tune the spawning times to remove/reduce air collisions between ATs and or Nevadas at airports.

Again you could introduce further domestic or pleasure flights at different altitudes and areas to add more diversity.

I would be tempted to either create randomly or script an occaisional air crash and maybe have search rescue helis on arriving on scene. That should keep the rubberneckers happy.

 

Be a while before I do any actuall air traffic programming as I am side tracked on creating dogfights and ped AI for fighting back when an aircraft is shot at and bailing out when it is near destroyed.

 

On a side note, the game seems to handle at least 12 AI aircraft trying to destroy you at the same time so in theory at least 12 aircraft running in game(not including your own) is possible without a glitch.

 

Quick question too.

Is there an op code to bring the gear up smoothly?

I can only get it to jump from up or down position with no animation in between, a small detail that annoys me a little.

@Demarest

Here the update of the script. I tried to randomize all 7 flights. But for now (i can't understand why) the planes won't wait until prev. flight is over.

Another fault that the references of the planes always removed after ~1 minute of flight and the plane fall down on the oil refinery near ocean docks. I can't understand why it happen. Is it possible to trigger this script run one flight each other. not in same time?

 

 

:PLANEZ_103A4: name_thread 'PLANEZ' :PLANEZ_20001: wait  0 ms00D6: if  0 0256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLANEZ_2 0209: @3 = random_int  0  6 0871: init_jump_table @3 total_jumps  7  0 ££PLANEZ_8 jumps  0 ££PLANEZ_8  1 ££PLANEZ_17  2 ££PLANEZ_26  3 ££PLANEZ_35  4 ££PLANEZ_44  5 ££PLANEZ_53  6 ££PLANEZ_62 :PLANEZ_80007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  42;; integer values0006: @9 =  30000;; integer values0006: @10 =  160000;; integer values00BA: text_styled 'CRASH_1'  1000 ms  2 ; Burning Desire0002: jump ££PLANEZ_71 :PLANEZ_170007: @4 = -1626.0;; floating-point values0007: @5 = -137.3;; floating-point values0007: @6 =  13.0;; floating-point values0006: @7 =  180;; integer values0006: @8 =  49;; integer values0006: @9 =  30000;; integer values0006: @10 =  90000;; integer values00BA: text_styled 'RYDER_1'  1000 ms  2 ; Home Invasion0002: jump ££PLANEZ_71 :PLANEZ_260007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  46;; integer values0006: @9 =  30000;; integer values0006: @10 =  110000;; integer values00BA: text_styled 'RYDER_3'  1000 ms  2 ; Catalyst0002: jump ££PLANEZ_71 :PLANEZ_350007: @4 =  1473.33;; floating-point values0007: @5 = -2600.0;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  41;; integer values0006: @9 =  30000;; integer values0006: @10 =  140000;; integer values00BA: text_styled 'RYDER_2'  1000 ms  2 ; Robbing Uncle Sam0002: jump ££PLANEZ_71 :PLANEZ_440007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  42;; integer values0006: @9 =  30000;; integer values0006: @10 =  160000;; integer values00BA: text_styled 'SMOKE_1'  1000 ms  2 ; OG Loc0002: jump ££PLANEZ_71 :PLANEZ_530007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  42;; integer values0006: @9 =  30000;; integer values0006: @10 =  160000;; integer values00BA: text_styled 'SMOKE_2'  1000 ms  2 ; Running Dog0002: jump ££PLANEZ_71 :PLANEZ_620007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  42;; integer values0006: @9 =  30000;; integer values0006: @10 =  160000;; integer values00BA: text_styled 'SMOKE_4'  1000 ms  2 ; Just Business0002: jump ££PLANEZ_71 :PLANEZ_710001: wait  0 ms00D6: if  0 0256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLANEZ_2 0247: request_model #AT400 038B: load_requested_models:PLANEZ_770001: wait  0 ms00D6: if  0 0248:   model #AT400 available004D: jump_if_false ££PLANEZ_77 0395: clear_area  1 at @4 @5 @6 range  40.0 00A5: @0 = create_vehicle #AT400 at @4 @5 @6;; Load the vehicle model before using this0175: set_car @0 z_angle_to @7 0209: @1 = random_int  0  3 06ED: set_car @0 paintjob @1 0249: release_model #AT400 07C0: request_path @8 :PLANEZ_880001: wait  0 ms00D6: if  0 07C1:   path @8 available004D: jump_if_false ££PLANEZ_88 00D6: if  0 8119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZ_119 05EB: assign_vehicle @0 to_path @8 0006: @2 =  2;; integer values:PLANEZ_970006: @32 =  0;; integer values:PLANEZ_980001: wait  500 ms00D6: if  1 0256:   player $PLAYER_CHAR defined8119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZ_119 00D6: if  0 001D:   @32 > @9;; integer values  004D: jump_if_false ££PLANEZ_98 00D6: if  21 8039:   NOT   @2 ==  1;; integer values001D:   @32 > @10;; integer values  004D: jump_if_false ££PLANEZ_98 00D6: if  0 860E:   NOT   car @0 is_assigned_to_existing_path004D: jump_if_false ££PLANEZ_119 000E: @2 -=  1;; integer values00D6: if  0 8039:   NOT   @2 == -1;; integer values004D: jump_if_false ££PLANEZ_119 08E6: set_plane @0 landing_gear @2 0002: jump ££PLANEZ_97 :PLANEZ_11901C3: remove_references_to_car @0;; Like turning a car into any random car0002: jump ££PLANEZ_1

 

Possibly add pilots to the planes using opcode 0129: (after requesting models of course).

 

0129: $Vent1pilot = create_actor_pedtype 5 model #FBI in_car $Venturas1 driverseat

 

NOTE: Sanny builder code.

This may stop them crashing but I suspect they will just turn into random vehicles judging by the previous crashing behaviour.

But for now (i can't understand why) the planes won't wait until prev. flight is over.

Another fault that the references of the planes always removed after ~1 minute of flight and the plane fall down on the oil refinery near ocean docks.

Perhaps they're connected. If for whatever reason, the code executes the remove references to command, that would cause it to spawn the next one and for the last one to maybe just drop out of the sky. If I'm correct, that would me fixing one "problem" would solve both symptoms. The trick is to figure out if it's running remove references too soon and if so, why. Maybe toss in another on screen text command there to see when it is being run.

 

Your approach here is really good. I hope you don't mind more constructive criticism to help you get even better. As you probably know, this mod doesn't actually need any if player defined checks. I'm guessing you probably kept them in so that the mod will reset when busted/wasted. But really, this isn't necessary as it's supposed to be totally random anyways. If you want to keep them in, there's still one point you can take it out of. In PLANEZ_71, if you take out the wait there (as it's not needed), you would no longer need to check if player defined again since there's been no wait since the last check. Also, just before PLANEZ_71 is a command to jump to it, which can be removed.

 

Since @9 always equals 30000, you can remove all lines that set it and then just change the one line that checks against it to check against 30000 instead. Don't forget to change the opcode too since you're no longer comparing one local to another. Also, you might as well load the model and the path at the same time. This would save some space as well as the need to check if it's wrecked before assigning it to the path.

@Pinky

I use default plane paths to make smooth take off and landing, of course planes keep their way on different paths to prevent crashing in air. The only place, where accidents may happen is airfield strip.

I'll make pilots soon, thanks for advice.

 

@Demarest

Interesting situation with code:

 

:PLANEZ_103A4: name_thread 'PLANEZ' 0001: wait  0 ms0209: @3 = random_int  0  6 0871: init_jump_table @3 total_jumps  7  0 ££PLANEZ_5 jumps  0 ££PLANEZ_5  1 ££PLANEZ_13  2 ££PLANEZ_21  3 ££PLANEZ_29  4 ££PLANEZ_37  5 ££PLANEZ_45  6 ££PLANEZ_53 :PLANEZ_50007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  42;; integer values0006: @10 =  160000;; integer values0002: jump ££PLANEZ_61 :PLANEZ_130007: @4 = -1626.0;; floating-point values0007: @5 = -137.3;; floating-point values0007: @6 =  13.0;; floating-point values0006: @7 =  180;; integer values0006: @8 =  49;; integer values0006: @10 =  90000;; integer values0002: jump ££PLANEZ_61 :PLANEZ_210007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  46;; integer values0006: @10 =  110000;; integer values0002: jump ££PLANEZ_61 :PLANEZ_290007: @4 =  1473.33;; floating-point values0007: @5 = -2600.0;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  41;; integer values0006: @10 =  140000;; integer values0002: jump ££PLANEZ_61 :PLANEZ_370007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  42;; integer values0006: @10 =  160000;; integer values0002: jump ££PLANEZ_61 :PLANEZ_450007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  42;; integer values0006: @10 =  160000;; integer values0002: jump ££PLANEZ_61 :PLANEZ_530007: @4 =  1577.298;; floating-point values0007: @5 = -2493.749;; floating-point values0007: @6 =  13.5895;; floating-point values0006: @7 =  270;; integer values0006: @8 =  42;; integer values0006: @10 =  160000;; integer values :PLANEZ_610001: wait  0 ms0247: request_model #AT400 038B: load_requested_models:PLANEZ_640001: wait  0 ms00D6: if  0 0248:   model #AT400 available004D: jump_if_false ££PLANEZ_64 0395: clear_area  1 at @4 @5 @6 range  40.0 00A5: @0 = create_vehicle #AT400 at @4 @5 @6;; Load the vehicle model before using this0175: set_car @0 z_angle_to @7 0209: @1 = random_int  0  3 06ED: set_car @0 paintjob @1 0249: release_model #AT400 07C0: request_path @8 :PLANEZ_750001: wait  0 ms00D6: if  0 07C1:   path @8 available004D: jump_if_false ££PLANEZ_75 00D6: if  0 8119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZ_111 05EB: assign_vehicle @0 to_path @8 0006: @2 =  2;; integer values:PLANEZ_840006: @32 =  0;; integer values:PLANEZ_850001: wait  500 ms00D6: if  0 8119:   NOT   car @0 wrecked004D: jump_if_false ££PLANEZ_111 [b]00BA: text_styled 'CRASH_1'  1000 ms  2 ; Burning Desire[/b] - I see only this blinking text for ~30 secs, then the airplane removes(?) from path and fall down on refinery. May be its problem place, but I can't find an error?00D6: if  0 0019:   @32 >  30000;; integer values004D: jump_if_false ££PLANEZ_85 00BA: text_styled 'RYDER_1'  1000 ms  2 ; Home Invasion00D6: if  21 8039:   NOT   @2 ==  1;; integer values0019:   @32 >  150000;; integer values (For test I set up constant flying time - 150000)004D: jump_if_false ££PLANEZ_85 00BA: text_styled 'RYDER_3'  1000 ms  2 ; Catalyst00D6: if  0 860E:   NOT   car @0 is_assigned_to_existing_path004D: jump_if_false ££PLANEZ_111 00BA: text_styled 'RYDER_2'  1000 ms  2 ; Robbing Uncle Sam000E: @2 -=  1;; integer values00D6: if  0 8039:   NOT   @2 == -1;; integer values004D: jump_if_false ££PLANEZ_111 00BA: text_styled 'SMOKE_1'  1000 ms  2 ; OG Loc08E6: set_plane @0 landing_gear @2 00BA: text_styled 'SMOKE_2'  1000 ms  2 ; Running Dog0002: jump ££PLANEZ_84 :PLANEZ_11100BA: text_styled 'SMOKE_4'  1000 ms  2 ; Just Business -------------> I never saw this text01C3: remove_references_to_car @0;; Like turning a car into any random car0002: jump ££PLANEZ_1 

 

 

and of course I cleaned up code.

The first two waits in that code aren't necessary. You can still combine the loading of the model and the path. Also, I only just noticed that your jump table uses all seven jumps when you only have six different flight paths. You can save even more space by killing the 7th set, lowering the random high value by one, and just making the final jump in the table dead end just as R* did when they didn't need all the jumps.

 

The fact that the text that SHOULD show up with the remove_references command is quite confusing. It would be different if any of your JF's pointed to before the loop, but none of them do. I'm wondering if it might have something to do with the fact that all your texts have a time of 1000, but the wait in the loop is only 500. This means that when all conditions are met, it would be displaying a few texts all at once. Maybe it IS showing and you're just not seeing it because it's being flooded. Maybe establish a global var and set it as some on screen numeral (like cash/time in the Trucking missions) and then have each section change the value of that number. If you do that, maybe also add a wait a few seconds after the remove reference command so you don't miss it.

 

That's all I can help right now. Reason is because I could say that since it's 30 seconds, perhaps it's something AFTER then is > 30 seconds command. We know this isn't the case because it would either loop back and display it again (which is isn't) or it would break out of the loop and remove_references and reset. Which as of this second, you don't believe is happening. If you follow my above advice and you find that remove references IS running, then that means that the checks after is > 30 seconds is being satisfied before you wish it to be. Though at first glance, everything seems alright. Let me know.

 

Also, as an aside, would you mind telling me how you're monitoring this ingame?

@Pinky

I use default plane paths to make smooth take off and landing, of course planes keep their way on different paths to prevent crashing in air. The only place, where accidents may happen is airfield strip.

I'll make pilots soon, thanks for advice.

I was beginning to figure the path thing out myself, I have noticed planes don't like to take off on a set course alone from runways. Fast planes are a real problem because they veer into the side buildings.

 

Shaping up to be a nice mod. smile.gif

I solve this sh*tty problem with script, it was just an error in "is vehicle assigned to path" opcode. For now everything works perfect. There are 7 destinations around state. Also I've added pilots in cockpit. The code in SB.

 

 

create_thread @PLANEZ0//------------------- Planes ---------------------------------:PLANEZ0thread 'PLANEZ':PLANEINIT_298wait 00209: 3@ = random_int 0 7 0871: init_jump_table 3@ total_jumps 7 0 @PLANEINIT_299 jumps 0 @PLANEINIT_299 1 @PLANEINIT_320 2 @PLANEINIT_341 3 @PLANEINIT_363 4 @PLANEINIT_385 5 @PLANEINIT_407 6 @PLANEINIT_429 :PLANEINIT_2994@ = 1473.33 // integer values 5@ = -2600.0 // integer values            6@ = 13.58957@ = 2708@ = 4110@ = 10000012@ = 1994.524513@ = -2487.456114@ = 13.0822jump @PLANEZ1 :PLANEINIT_320    4@ = 1577.298 // integer values 5@ = -2493.749 // integer values6@ = 13.58957@ = 2708@ = 4210@ = 12000012@ = 1994.524513@ = -2487.456114@ = 13.0822jump @PLANEZ1 :PLANEINIT_3414@ = 1577.298 // integer values 5@ = -2493.749 // integer values6@ = 13.58957@ = 2708@ = 4610@ = 8000012@ = 1994.524513@ = -2487.456114@ = 13.0822jump @PLANEZ1 :PLANEINIT_363              4@ = 1479.46 // integer values 5@ = 1641.41 // integer values            6@ = 10.48517@ = 1808@ = 4310@ = 5000012@ = 1479.942113@ = 1697.293214@ = 10.3581jump @PLANEZ1 :PLANEINIT_3854@ = 1479.46 // integer values 5@ = 1641.41 // integer values            6@ = 10.48517@ = 1808@ = 4810@ = 9000012@ = 1479.942113@ = 1697.293214@ = 10.3581jump @PLANEZ1 :PLANEINIT_4074@ = -1586.67 // integer values 5@ = -93.33 // integer values            6@ = 44.07@ = 3148@ = 4410@ = 12000012@ = -1541.49413@ = -47.527514@ = 13.6904 jump @PLANEZ1 :PLANEINIT_4294@ = -1626.0 // integer values 5@ = -137.3 // integer values6@ = 13.07@ = 3148@ = 4910@ = 7000012@ = -1541.49413@ = -47.527514@ = 13.6904:PLANEZ1wait 0 Model.Load(#AT400)Model.Load(#WMYPLT)038B: load_requested_models :PLANEZ1_38wait 0 if and  Model.Available(#AT400)  Model.Available(#WMYPLT) else_jump @PLANEZ1_380395: clear_area 1 at 4@ 5@ 6@ range 40.0 0@ = Car.Create(#AT400, 4@, 5@, 6@)Car.Angle(0@) = 7@0209: 1@ = random_int 0 3 06ED: set_car 0@ paintjob 1@0129: 11@ = create_actor_pedtype 4 model #WMYPLT in_car 0@ driverseat01C8: 12@ = create_actor 4 #WMYPLT in_car 0@ passenger_seat 0Model.Destroy(#WMYPLT)Model.Destroy(#AT400)07C0: load_path 8@ :PLANEZ1_139wait 0 if 07C1:   path 8@ available else_jump @PLANEZ1_139 if   not Car.Wrecked(0@)else_jump @PLANEZ1_324 05EB: assign_vehicle 0@ to_path 8@32@ = 0 // integer values :PLANEZ1_195wait 500 if  not Car.Wrecked(0@)else_jump @PLANEZ1_324 if  32@ > 30000 // integer values else_jump @PLANEZ1_195if 060E:   not  0@ else_jump @PLANEZ1_32408E6: set_plane 0@ landing_gear  132@ =  0:PLANEZZ_305Bwait  500 ms    if   not Car.Wrecked(0@)else_jump @PLANEZ1_324if001D:  32@ > 10@ // integer values else_jump @PLANEZZ_305B if 060E:   not  0@ else_jump @PLANEZ1_32408E6: set_plane 0@ landing_gear  032@ =  0:PLANEZZ_305Cwait  500 msif  not Car.Wrecked(0@)else_jump @PLANEZ1_3240395: clear_area 1 at 12@ 13@ 14@ range 40.0if 32@ > 60000else_jump @PLANEZZ_305C        :PLANEZ1_324wait 100Car.RemoveReferences(0@)Actor.RemoveReferences(11@)06C5: release_car 0@ from_path0873: release_path 8@jump @PLANEINIT_298

 

Edited by altman
  • 4 weeks later...

You should've posted a new reply instead of editing the old post. This would've bumped up your topic and would have notified the regulars of your update.

Editing a post (adding relevant information) after such a long time is not useful for you or your audience because there's absolutely no visual change that would indicate that there are new infos inside the thread. And double-posting is definitely allowed in such cases since there's no other possibility to make others take note of the updated content.

 

  • 7 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.