![]() ![]() |
![]() ![]() Post #1 | |
![]() Coding like a Rockstar! ![]() Posts: 1,468 From: ??? Joined: 28-May 09 ![]() | You Don't Know How To Load Models Properly I'm gonna have a lot of fun with this rant! And hopefully these points will pass through:
I know, there are some big statements there. Especially since 3 of these points have been argued against and 1 of them hasn't actually been done for the past 6-8 years! In case you didn't guess, the last point is the one that hasn't actually been done. People continue to listen to others and respect their opinion with honour. Screw that! Let me take this seemingly perfect script and poke holes in it. SANNY fade 0 500 while fading 003D: wait_0_ms end 0247: load_model #BFYBE 0247: load_model #HFYBE 0247: load_model #WFYBE while true if or 8248: not model #BFYBE available 8248: not model #HFYBE available 8248: not model #WFYBE available jf break 003D: wait_0_ms end 009A: 0@ = create_actor_pedtype 5 model #BFYBE at 603.6829 -1888.9531 3.7709 009A: 1@ = create_actor_pedtype 5 model #HFYBE at 614.4362 -1879.3818 4.178 009A: 2@ = create_actor_pedtype 5 model #WFYBE at 623.5018 -1894.4589 3.4878 fade 1 500 while fading 003D: end Pretty nice, eh? Nahhh! Why wait for the models to load in such a way? The screen is faded out, the player has nothing else to wait for. Every iteration of the while loop (it will probably be about 1 iteration, trust me.. maybe one or two more on slow computers) will waste time by rendering the rest of the game. When you use 0247, the model is added to a "queue" of sorts. The game will load this but will still pay more attention to the other laborious tasks, making sure that the player doesn't have to stop playing while the model is loading. Which is somewhat okay with large models being loaded during gameplay. But not in this case. When you type a car or weapon spawning cheat, it loads instantly. The game actually waits for it to load, as well (on the PS2, you can sometimes notice a pause while the vehicles/weapons are being loaded, before the cheat activated text box appears, remember?) - all adding up so far, eh? So because our SCM isn't considered important enough, the game won't spend time loading it like it does with the cheats. It's like it's loading a bit every time the game circulates. However, we can force the game to load all our SCM models instantly, freezing the game while it does so (which won't matter, 'cause we're faded out, right?) and save ourself lots of code. Yes, this is where 038B comes in! So here's a much better script: SANNY fade 0 500 while fading 003D: wait_0_ms end 0247: load_model #BFYBE 0247: load_model #HFYBE 0247: load_model #WFYBE 038B: load_requested_models 009A: 0@ = create_actor_pedtype 5 model #BFYBE at 603.6829 -1888.9531 3.7709 009A: 1@ = create_actor_pedtype 5 model #HFYBE at 614.4362 -1879.3818 4.178 009A: 2@ = create_actor_pedtype 5 model #WFYBE at 623.5018 -1894.4589 3.4878 fade 1 500 while fading 003D: end Now, all you "noobs" who were moaned at when asking for help on certain GTA "Forums" (not that I'm mentioning any in particular ![]() One more thing which may be raised... Why didn't Rockstar do this? Honestly? You're going to pull out that card? This is the same team of Rockstar coders who left a sex minigame in and couldn't find the time to remove it to prevent the company they work for from being sued to high hell. Okay, a less harsh example.. This is the same team of coders who messed up the quadrouple insane stunt bonus on (probably more than) 3 games and leave stuff like this: SANNY 010B: 11@ = player $PLAYER_CHAR money if 0019: 11@ > -1 then end SANNY 0051: return // Lol noobz xP end end end 0051: return (thanks to Silent for doing the legwork and recovering some of our old (or maybe still going) project source) There's also loads of extra potential I've discovered in a lot of opcodes (see my other rants and stuff) which was never used. Lack of communication between game programmers and mission coders seemed to be very high while creating this game. Heheheee... ![]() -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
![]() Post #2 | |
![]() Devil's Advocate ![]() Posts: 413 From: CA US Joined: 26-July 09 ![]() | Oh my god it's a revolution! Why were we lied to? WHY?? Deji is now crowned "King of San Andreas." Now go forth to further unlock the mysteries of San Andreas on your 5-inch 1970's monitor! -------------------- ![]() |
![]() Post #3 | |
![]() In motus... ![]() Posts: 361 From: Portugal Joined: 28-May 09 ![]() | I'm also King of SA ![]() |
![]() Post #4 | |
![]() Devil's Advocate ![]() Posts: 413 From: CA US Joined: 26-July 09 ![]() | ... but there can only be one King. Perhaps you'd like to be queen? ![]() -------------------- ![]() |
![]() Post #5 | |
![]() In motus... ![]() Posts: 361 From: Portugal Joined: 28-May 09 ![]() | ![]() \Off-topic stop/ |
![]() Post #6 | |
The New Guy! Posts: 10 Joined: 31-May 11 ![]() | Just a minor disagreement on using 0248 or not; I would rather use this to ensure that with all the various editing on the game I do, I'm not going to get a crash if the model doesn't show up, because I forgot to add it to the img file or whatever. I love coding shortcuts and eliminating redundancies. But I think loading your models and making sure the game indeed finds them loaded ok is worth a few extra lines of code. After doing this for so long, I mangle enough code on my own that knowing I did the basics properly, it's one less thing to trace. Just MODO, nothing personal or anything. Good post! ![]() |
![]() Post #7 | |
![]() Coding like a Rockstar! ![]() Posts: 1,468 From: ??? Joined: 28-May 09 ![]() | That logic is true to a point. If you use 038B to load a model, the game will freeze. If you use 0248 in a loop, the script will be stuck in a loop. It's sod's law. You're damned if you do, you're damned if you don't. It's best to just check if the model exists first, if it's an issue: SANNY 0488: model #TAXI exists // versionA There's still a time and a place for 0248. -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
![]() Post #8 | |
The New Guy! Posts: 10 Joined: 31-May 11 ![]() | Ok then, let's take it a step further then, does Sanny allow building of classes and/or functions? I do this in the hook, so in my "Game" class I have this: CODE void ScriptObject::LoadModel(int iModel) { SCMThread *owner = currentThread; ScriptCommand(&request_model, iModel); ScriptCommand(&load_requested_models); while (!ScriptScript::ModelAvailable(iModel)) SCRIPT_WAIT(10); } So I'm really on coding one line in the main script ( pGame->LoadModel(this model); ) but I'm letting the compiler make it "compliant" (best word I could come up with, sorry) with what I consider to be a basic coding procedure, for GTA anyway. Best of both worlds maybe? Not sure if it's relevant though, since I don't know how much control Sanny allows with things like this. BTW, I love just being able to discuss coding and such; over at GTAF it's "post a question or useful info, or leave", which has always bugged me. Figured I was safe to discuss here, since it's a rant and all. ![]() This post has been edited by ceedj: Jun 27 2011, 02:08 AM |
![]() Post #9 | |
![]() Coding like a Rockstar! ![]() Posts: 1,468 From: ??? Joined: 28-May 09 ![]() | This is basically a modding forum (soon it will officially be) modding discussion is a must ![]() Sanny has it's own "classes" for opcodes and such. There are very few but come GTAG v2, the Opcode Database should start having the power to generate files for them. There's definitely no point in using "load_requested_models" and "ModelAvailable" because either load_requested_models makes them available or the game is over anyway. You can create SCM Functions, which is very useful: SANNY :LoadModel{\__(bool)__[iModel]__} if 0488: model 0@ exists then 0247: load_model 0@ 038B: load_requested_models end 0AB2: ret 0 A few coding and compiling tricks are in use here. First of all, the comment at the end of the function label will be printed on the list of labels that Sanny generates when you begin typing one. It will also be placed in the editor when you select it from that list. Just a simple little thing to remind you what the function does and how many parameters it uses. SCM Functions have a variable amount of parameters and a whole load can be passed to them (about 30-ish). They are simply stored in the appropriate variable number. They can return multiple values, too. However, returns are not as free as parameters. You can't take 2 returns when there are 3. Wheras with SCM Functions you can pass 4 parameters when there are 5, etc. The last trick causes this to be valid: SANNY if 0AB1: @LoadModel (num_params) 1 (params) #TAXI then 00A5: 0@ = create_car #TAXI at 0.0 0.0 0.0 end You might know from looking at the "CScriptThread" structure that condition results are stored as one single byte. Although SCM Functions have their own set of variables, the condition byte is the same. So SCM Funcs can change the result of it's last condition. The last condition in "LoadModel" is checking if the model exists. So this returns true if model loading could be carried out. SANNY :LoadModel{\__(bool)__[wModel,_bQuickLoad]__} if 0488: model 0@ exists then 0247: load_model 0@ if 1@ == 1 then 038B: load_requested_models else while 8248: not model 0@ available wait 0 end end end 0AB2: ret 0 But then how to make this work? The while loop returns false to the condition when it exits. Luckily there is an opcode to change the result of the conditional byte (also using another condition that will turn true can work). SANNY :LoadModel{\__(bool)__[wModel,_bQuickLoad]__} if 0488: model 0@ exists then 0247: load_model 0@ if 1@ == 1 then 038B: load_requested_models else while 8248: not model 0@ available wait 0 end 0485: return_true end end 0AB2: ret 0 There is also SANNY 059A: return_false For when it's needed. These opcodes don't actually return. They just set the conditional byte in the thread struct. Still, I've never brought myself to actually use a SCM Function just to load a model. Okay, quite a long post. But it was all related to loading models. Every post makes a modding topic that much better ![]() -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
![]() ![]() |