Quantcast

Jump to content

» «
Photo

[WIP | SA | Thread] Air traffic mod

101 replies to this topic
altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#1

Posted 26 May 2007 - 09:47 AM

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

drozle
  • drozle

    Big D

  • Members
  • Joined: 09 Mar 2007

#2

Posted 26 May 2007 - 09:57 AM

Great job COULD say,but...I am lol in coding so can you host .scm file.Please biggrin.gif

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#3

Posted 26 May 2007 - 10:37 AM

@drozle

For now it's not public release, I need to test and optimize code. The game could crash in case of plane accident. It never happened with me because of lack of air traffic but if I add new plane paths...

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#4

Posted 26 May 2007 - 11:58 AM

QUOTE (altman @ May 26 2007, 04:47)
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
CODE
:PLANEZ_4
03A4: name_thread 'PLANEZ2'

:PLANEZZ22
0001: wait  0 ms
00D6: if  0
0256:   player $PLAYER_CHAR defined
004D: jump_if_false ££PLANEZZ22
0247: request_model  577
038B: load_requested_models

:PLANEZZ24
0001: wait  0 ms
00D6: if  0
0248:   model  577  available
004D: jump_if_false ££PLANEZZ24
0395: clear_area  1 at -1626.0 -137.3 13.0 range  40.0
00A5: @0 = create_car  577 at  -1626.0 -137.3 13.0
0175: set_car @0 z_angle_to  180
0209: @1 = random_int  0  3
06ED: set_car @0 paintjob  @1
0249: release_model 577
07C0: request_path 49        
       
:PLANEZZ_284
0001: wait  0 ms
00D6: if  0
07C1:    path 49 available
004D: jump_if_false ££PLANEZZ_284
00D6: if  0
8119:   NOT   car @0 wrecked
004D: jump_if_false ££PLANEZZ_306
05EB: assign_vehicle @0 to_path 49
0006: @32 =  0

:PLANEZZ_305
0001: wait  500 ms
00D6: if  1
0256:   player $PLAYER_CHAR defined
8119:   NOT   car @0 wrecked
004D: jump_if_false ££PLANEZZ_306
00D6: if  0
0019:   @32 >  30000
004D: jump_if_false ££PLANEZZ_305
00D6: if  0
860E:   NOT   car @0 is_assigned_to_existing_path  
004D: jump_if_false ££PLANEZZ_306
08E6: set_plane @0 landing_gear  1
0006: @32 =  0

:PLANEZZ_305B
0001: wait  500 ms
00D6: if  1
0256:   player $PLAYER_CHAR defined
8119:   NOT   car @0 wrecked
004D: jump_if_false ££PLANEZZ_306
00D6: if  0
0019:   @32 >  90000
004D: jump_if_false ££PLANEZZ_305B
00D6: if  0
860E:   NOT   car @0 is_assigned_to_existing_path
004D: jump_if_false ££PLANEZZ_306
08E6: set_plane @0 landing_gear  0
0006: @32 =  0

:PLANEZZ_305C
0001: wait  500 ms
00D6: if  1
0256:   player $PLAYER_CHAR defined
8119:   NOT   car @0 wrecked
004D: jump_if_false ££PLANEZZ_306
00D6: if  0
0019:   @32 >  30000
004D: jump_if_false ££PLANEZZ_305C
         
:PLANEZZ_306
01C3: remove_references_to_car @0
0002: 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

SteaVor
  • SteaVor

    Professional investor

  • Members
  • Joined: 17 Dec 2005

#5

Posted 26 May 2007 - 12:20 PM Edited by SteaVor, 26 May 2007 - 05:38 PM.

Just wanted to mention that 038B (load_requested_models) is a NOP in SA (you do need it for III/VC coding though), 0247 could therefore be called request_and_load_model.

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#6

Posted 26 May 2007 - 05:36 PM

@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!

Hollaz
  • Hollaz

    Bleh.

  • Members
  • Joined: 15 Feb 2007

#7

Posted 26 May 2007 - 06:09 PM

This mod is cool.. but can you follow or destroy the airplanes?

Just wondering!

alien.gif

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#8

Posted 26 May 2007 - 07:28 PM

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?

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#9

Posted 27 May 2007 - 09:16 AM

@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

Blackadder.
  • Blackadder.

    Luck. Runs. Out.

  • Andolini Mafia Family
  • Joined: 19 Jun 2005

#10

Posted 27 May 2007 - 12:23 PM

Woah! Nice mod, can you get in the planes? or are they just for show?

Either way, good job icon14.gif I'll be sure to try this out some time.

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#11

Posted 27 May 2007 - 02:52 PM

Some of them will be placed around airports and you can get in.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#12

Posted 27 May 2007 - 06:19 PM

QUOTE (altman @ May 27 2007, 04:16)
@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
CODE
:PLANE_DAYCHECK
0001: wait  0 ms
00D6: if  21
0038:   $WEEKDAY ==  6;; integer values
0038:   $WEEKDAY ==  7;; integer values
004D: jump_if_false ££PLANE_NONWEEKEND
00D6: if  21
0038:   $TIME_HOURS ==  7;; integer values
0038:   $TIME_HOURS ==  11;; integer values
004D: jump_if_false ££PLANE_DAYCHECK
00BA: 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_NONWEEKEND
00D6: if  21
0038:   $TIME_HOURS ==  8;; integer values
0038:   $TIME_HOURS ==  10;; integer values
004D: jump_if_false ££PLANE_DAYCHECK
00BA: 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.

QUOTE (altman @ May 27 2007, 04:16)
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.

QUOTE (altman @ May 27 2007, 04:16)
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
CODE
:PLANEZ_4
03A4: name_thread 'PLANEZ2'

:PLANEZZ22
0001: wait  0 ms
00D6: if  0
0256:   player $PLAYER_CHAR defined
004D: jump_if_false ££PLANEZZ22
0247: request_model  577
038B: load_requested_models

:PLANEZZ24
0001: wait  0 ms
00D6: if  0
0248:   model  577  available
004D: jump_if_false ££PLANEZZ24
0395: clear_area  1 at -1626.0 -137.3 13.0 range  40.0
00A5: @0 = create_car  577 at  -1626.0 -137.3 13.0
0175: set_car @0 z_angle_to  180
0209: @1 = random_int  0  3
06ED: set_car @0 paintjob  @1
0249: release_model 577
07C0: request_path 49        
     
:PLANEZZ_284
0001: wait  0 ms
00D6: if  0
07C1:    path 49 available
004D: jump_if_false ££PLANEZZ_284
00D6: if  0
8119:   NOT   car @0 wrecked
004D: jump_if_false ££PLANEZZ_306
05EB: assign_vehicle @0 to_path 49
0006: @2 =  2

:PLANEZZ_305
0006: @32 =  0

:PLANEZZ_305B
0001: wait  500 ms
00D6: if  1
0256:   player $PLAYER_CHAR defined
8119:   NOT   car @0 wrecked
004D: jump_if_false ££PLANEZZ_306
00D6: if  0
0019:   @32 >  30000
004D: jump_if_false ££PLANEZZ_305B
00D6: if  21
8039:   NOT   @2 ==  1
0019:   @32 >  90000
004D: jump_if_false ££PLANEZZ_305B
00D6: if  0
860E:   NOT   car @0 is_assigned_to_existing_path  
004D: jump_if_false ££PLANEZZ_306
000E: @2 -=  1
00D6: if  0
8039:   NOT   @2 ==  -1
004D: jump_if_false ££PLANEZZ_306
08E6: set_plane @0 landing_gear  @2
0002: jump ££PLANEZZ_305

:PLANEZZ_306
01C3: remove_references_to_car @0
0002: 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

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#13

Posted 27 May 2007 - 07:52 PM Edited by altman, 27 May 2007 - 07:55 PM.

QUOTE
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...

QUOTE
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?:

CODE
:PLANEZ23
0247: request_model  577
038B: load_requested_models

:PLANEZ24
0001: wait  0 ms
00D6: if  0
0248:   model  577  available
004D: jump_if_false ££PLANEZ24
0395: clear_area  1 at 1577.298 -2493.749 13.5895 range  40.0
00A5: $11479 = create_car  577 at  1577.298 -2493.749 13.5895
0175: set_car $11479 z_angle_to  180
0209: $11480 = random_int  0  3
06ED: set_car $11479 paintjob  $11480
0001: wait  0 ms

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#14

Posted 28 May 2007 - 04:05 AM

QUOTE (altman @ May 27 2007, 14:52)
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.

QUOTE (altman @ May 27 2007, 14:52)
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.

evilrex
  • evilrex

    Foot Soldier

  • Members
  • Joined: 27 May 2006

#15

Posted 29 May 2007 - 12:21 PM

Great mod, I would love to see different types of aeroplanes land/take off at the airports, is this possible?

SteaVor
  • SteaVor

    Professional investor

  • Members
  • Joined: 17 Dec 2005

#16

Posted 29 May 2007 - 12:29 PM

Of course, you'd just have to change which model is used for the plane (in the mod it's always 577, but that can be changed/randomized of course).

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#17

Posted 31 May 2007 - 07:35 AM Edited by altman, 31 May 2007 - 07:37 AM.

@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.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#18

Posted 31 May 2007 - 07:49 AM

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.

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#19

Posted 31 May 2007 - 10:36 AM Edited by altman, 31 May 2007 - 03:53 PM.

QUOTE (Demarest @ May 31 2007, 11:49)
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?

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#20

Posted 31 May 2007 - 06:31 PM

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.

pinky
  • pinky

    "Tooled up and chibbin' ye, ya Bass".

  • Members
  • Joined: 06 Jan 2005

#21

Posted 12 June 2007 - 01:23 PM

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.

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#22

Posted 12 June 2007 - 02:19 PM

@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?

CODE
:PLANEZ_1
03A4: name_thread 'PLANEZ'

:PLANEZ_2
0001: wait  0 ms
00D6: if  0
0256:   player $PLAYER_CHAR defined
004D: 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_8
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  42;; integer values
0006: @9 =  30000;; integer values
0006: @10 =  160000;; integer values
00BA: text_styled 'CRASH_1'  1000 ms  2 ; Burning Desire
0002: jump ££PLANEZ_71

:PLANEZ_17
0007: @4 = -1626.0;; floating-point values
0007: @5 = -137.3;; floating-point values
0007: @6 =  13.0;; floating-point values
0006: @7 =  180;; integer values
0006: @8 =  49;; integer values
0006: @9 =  30000;; integer values
0006: @10 =  90000;; integer values
00BA: text_styled 'RYDER_1'  1000 ms  2 ; Home Invasion
0002: jump ££PLANEZ_71

:PLANEZ_26
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  46;; integer values
0006: @9 =  30000;; integer values
0006: @10 =  110000;; integer values
00BA: text_styled 'RYDER_3'  1000 ms  2 ; Catalyst
0002: jump ££PLANEZ_71

:PLANEZ_35
0007: @4 =  1473.33;; floating-point values
0007: @5 = -2600.0;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  41;; integer values
0006: @9 =  30000;; integer values
0006: @10 =  140000;; integer values
00BA: text_styled 'RYDER_2'  1000 ms  2 ; Robbing Uncle Sam
0002: jump ££PLANEZ_71

:PLANEZ_44
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  42;; integer values
0006: @9 =  30000;; integer values
0006: @10 =  160000;; integer values
00BA: text_styled 'SMOKE_1'  1000 ms  2 ; OG Loc
0002: jump ££PLANEZ_71

:PLANEZ_53
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  42;; integer values
0006: @9 =  30000;; integer values
0006: @10 =  160000;; integer values
00BA: text_styled 'SMOKE_2'  1000 ms  2 ; Running Dog
0002: jump ££PLANEZ_71

:PLANEZ_62
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  42;; integer values
0006: @9 =  30000;; integer values
0006: @10 =  160000;; integer values
00BA: text_styled 'SMOKE_4'  1000 ms  2 ; Just Business
0002: jump ££PLANEZ_71

:PLANEZ_71
0001: wait  0 ms
00D6: if  0
0256:   player $PLAYER_CHAR defined
004D: jump_if_false ££PLANEZ_2
0247: request_model #AT400
038B: load_requested_models

:PLANEZ_77
0001: wait  0 ms
00D6: if  0
0248:   model #AT400 available
004D: 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 this
0175: 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_88
0001: wait  0 ms
00D6: if  0
07C1:   path @8 available
004D: jump_if_false ££PLANEZ_88
00D6: if  0
8119:   NOT   car @0 wrecked
004D: jump_if_false ££PLANEZ_119
05EB: assign_vehicle @0 to_path @8
0006: @2 =  2;; integer values

:PLANEZ_97
0006: @32 =  0;; integer values

:PLANEZ_98
0001: wait  500 ms
00D6: if  1
0256:   player $PLAYER_CHAR defined
8119:   NOT   car @0 wrecked
004D: 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 values
001D:   @32 > @10;; integer values  
004D: jump_if_false ££PLANEZ_98
00D6: if  0
860E:   NOT   car @0 is_assigned_to_existing_path
004D: jump_if_false ££PLANEZ_119
000E: @2 -=  1;; integer values
00D6: if  0
8039:   NOT   @2 == -1;; integer values
004D: jump_if_false ££PLANEZ_119
08E6: set_plane @0 landing_gear @2
0002: jump ££PLANEZ_97

:PLANEZ_119
01C3: remove_references_to_car @0;; Like turning a car into any random car
0002: jump ££PLANEZ_1

pinky
  • pinky

    "Tooled up and chibbin' ye, ya Bass".

  • Members
  • Joined: 06 Jan 2005

#23

Posted 12 June 2007 - 03:44 PM

Possibly add pilots to the planes using opcode 0129: (after requesting models of course).
CODE
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.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#24

Posted 12 June 2007 - 04:03 PM

QUOTE (altman @ Jun 12 2007, 09:19)
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.

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#25

Posted 12 June 2007 - 08:39 PM

@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:
CODE
:PLANEZ_1
03A4: name_thread 'PLANEZ'
0001: wait  0 ms
0209: @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_5
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  42;; integer values
0006: @10 =  160000;; integer values
0002: jump ££PLANEZ_61

:PLANEZ_13
0007: @4 = -1626.0;; floating-point values
0007: @5 = -137.3;; floating-point values
0007: @6 =  13.0;; floating-point values
0006: @7 =  180;; integer values
0006: @8 =  49;; integer values
0006: @10 =  90000;; integer values
0002: jump ££PLANEZ_61

:PLANEZ_21
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  46;; integer values
0006: @10 =  110000;; integer values
0002: jump ££PLANEZ_61

:PLANEZ_29
0007: @4 =  1473.33;; floating-point values
0007: @5 = -2600.0;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  41;; integer values
0006: @10 =  140000;; integer values
0002: jump ££PLANEZ_61

:PLANEZ_37
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  42;; integer values
0006: @10 =  160000;; integer values
0002: jump ££PLANEZ_61

:PLANEZ_45
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  42;; integer values
0006: @10 =  160000;; integer values
0002: jump ££PLANEZ_61

:PLANEZ_53
0007: @4 =  1577.298;; floating-point values
0007: @5 = -2493.749;; floating-point values
0007: @6 =  13.5895;; floating-point values
0006: @7 =  270;; integer values
0006: @8 =  42;; integer values
0006: @10 =  160000;; integer values

:PLANEZ_61
0001: wait  0 ms
0247: request_model #AT400
038B: load_requested_models

:PLANEZ_64
0001: wait  0 ms
00D6: if  0
0248:   model #AT400 available
004D: 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 this
0175: 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_75
0001: wait  0 ms
00D6: if  0
07C1:   path @8 available
004D: jump_if_false ££PLANEZ_75
00D6: if  0
8119:   NOT   car @0 wrecked
004D: jump_if_false ££PLANEZ_111
05EB: assign_vehicle @0 to_path @8
0006: @2 =  2;; integer values

:PLANEZ_84
0006: @32 =  0;; integer values

:PLANEZ_85
0001: wait  500 ms
00D6: if  0
8119:   NOT   car @0 wrecked
004D: 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 values
004D: jump_if_false ££PLANEZ_85
00BA: text_styled 'RYDER_1'  1000 ms  2 ; Home Invasion
00D6: if  21
8039:   NOT   @2 ==  1;; integer values
0019:   @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 ; Catalyst
00D6: if  0
860E:   NOT   car @0 is_assigned_to_existing_path
004D: jump_if_false ££PLANEZ_111
00BA: text_styled 'RYDER_2'  1000 ms  2 ; Robbing Uncle Sam
000E: @2 -=  1;; integer values
00D6: if  0
8039:   NOT   @2 == -1;; integer values
004D: jump_if_false ££PLANEZ_111
00BA: text_styled 'SMOKE_1'  1000 ms  2 ; OG Loc
08E6: set_plane @0 landing_gear @2
00BA: text_styled 'SMOKE_2'  1000 ms  2 ; Running Dog
0002: jump ££PLANEZ_84

:PLANEZ_111
00BA: text_styled 'SMOKE_4'  1000 ms  2 ; Just Business -------------> I never saw this text
01C3: remove_references_to_car @0;; Like turning a car into any random car
0002: jump ££PLANEZ_1


and of course I cleaned up code.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#26

Posted 13 June 2007 - 05:38 AM

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
  • pinky

    "Tooled up and chibbin' ye, ya Bass".

  • Members
  • Joined: 06 Jan 2005

#27

Posted 13 June 2007 - 03:41 PM

QUOTE (altman @ Jun 12 2007, 20:39)
@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

altman
  • altman

    Artur Rox

  • Members
  • Joined: 24 Jan 2004

#28

Posted 13 June 2007 - 08:50 PM Edited by altman, 25 June 2007 - 07:14 AM.

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.

CODE
create_thread @PLANEZ0

//------------------- Planes ---------------------------------

:PLANEZ0
thread 'PLANEZ'

:PLANEINIT_298
wait 0
0209: 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_299
4@ = 1473.33 // integer values
5@ = -2600.0 // integer values            
6@ = 13.5895
7@ = 270
8@ = 41
10@ = 100000
12@ = 1994.5245
13@ = -2487.4561
14@ = 13.0822
jump @PLANEZ1

:PLANEINIT_320    
4@ = 1577.298 // integer values
5@ = -2493.749 // integer values
6@ = 13.5895
7@ = 270
8@ = 42
10@ = 120000
12@ = 1994.5245
13@ = -2487.4561
14@ = 13.0822
jump @PLANEZ1

:PLANEINIT_341
4@ = 1577.298 // integer values
5@ = -2493.749 // integer values
6@ = 13.5895
7@ = 270
8@ = 46
10@ = 80000
12@ = 1994.5245
13@ = -2487.4561
14@ = 13.0822
jump @PLANEZ1

:PLANEINIT_363              
4@ = 1479.46 // integer values
5@ = 1641.41 // integer values            
6@ = 10.4851
7@ = 180
8@ = 43
10@ = 50000
12@ = 1479.9421
13@ = 1697.2932
14@ = 10.3581
jump @PLANEZ1

:PLANEINIT_385
4@ = 1479.46 // integer values
5@ = 1641.41 // integer values            
6@ = 10.4851
7@ = 180
8@ = 48
10@ = 90000
12@ = 1479.9421
13@ = 1697.2932
14@ = 10.3581
jump @PLANEZ1

:PLANEINIT_407
4@ = -1586.67 // integer values
5@ = -93.33 // integer values            
6@ = 44.0
7@ = 314
8@ = 44
10@ = 120000
12@ = -1541.494
13@ = -47.5275
14@ = 13.6904
jump @PLANEZ1

:PLANEINIT_429
4@ = -1626.0 // integer values
5@ = -137.3 // integer values
6@ = 13.0
7@ = 314
8@ = 49
10@ = 70000
12@ = -1541.494
13@ = -47.5275
14@ = 13.6904

:PLANEZ1
wait 0
Model.Load(#AT400)
Model.Load(#WMYPLT)
038B: load_requested_models

:PLANEZ1_38
wait 0
if and
  Model.Available(#AT400)
  Model.Available(#WMYPLT)
else_jump @PLANEZ1_38
0395: 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@ driverseat
01C8: 12@ = create_actor 4 #WMYPLT in_car 0@ passenger_seat 0
Model.Destroy(#WMYPLT)
Model.Destroy(#AT400)
07C0: load_path 8@

:PLANEZ1_139
wait 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_195
wait 500
if
  not Car.Wrecked(0@)
else_jump @PLANEZ1_324
if
 32@ > 30000 // integer values
else_jump @PLANEZ1_195
if
060E:   not  0@
else_jump @PLANEZ1_324
08E6: set_plane 0@ landing_gear  1
32@ =  0

:PLANEZZ_305B
wait  500 ms    
if
  not Car.Wrecked(0@)
else_jump @PLANEZ1_324
if
001D:  32@ > 10@ // integer values
else_jump @PLANEZZ_305B
if
060E:   not  0@
else_jump @PLANEZ1_324
08E6: set_plane 0@ landing_gear  0
32@ =  0

:PLANEZZ_305C
wait  500 ms
if
  not Car.Wrecked(0@)
else_jump @PLANEZ1_324
0395: clear_area 1 at 12@ 13@ 14@ range 40.0
if
 32@ > 60000
else_jump @PLANEZZ_305C
       
:PLANEZ1_324
wait 100
Car.RemoveReferences(0@)
Actor.RemoveReferences(11@)
06C5: release_car 0@ from_path
0873: release_path 8@
jump @PLANEINIT_298

SteaVor
  • SteaVor

    Professional investor

  • Members
  • Joined: 17 Dec 2005

#29

Posted 09 July 2007 - 07:24 PM

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.

haki_PL
  • haki_PL

    Player Hater

  • Members
  • Joined: 08 Feb 2008

#30

Posted 19 February 2008 - 01:12 PM

Where should I paste this script or could someone post reply with ready main.scm (with this script included)?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users