Jump to content

[REL|SRC] Camera Lock mod


Bigun

Recommended Posts

When the game was released, many people complained that the camera doesn't automatically stay behind the car, which makes it hard to see where you are going when doing turns. It is known that you can turn on "mouse steering" and the camera will somewhat follow the back of the car now. It doesn't 'stick hard' to the back of the car like in VC and GTA3.

This very simple mod is here to fix.

 

While in a car, press 'Trip Skip' (default Y) to turn autolock on, then again to turn it off.

The camera will only be reset if you are turning, which I thought is appropriate.

It also isn't very smooth, but good enough.

Hopefully some more talented coders will be able to optimize it/

Oh, this is my first released mod and yada yada. It's even too simple and small to be considered a mod.

 

Anyhows, here it is:

 

Add this to the other create_thread's:

 

004F: create_thread ££camlockChk

 

Add this just above Mission 0:

 

:camlockChk0001: wait  800 ms0004: $CAMLOCK =  0;; integer values00D6: if  40256:   player $PLAYER_CHAR defined0256:   actor $PLAYER_ACTOR defined 8118:   NOT actor $PLAYER_ACTOR dead00DF:   actor $PLAYER_ACTOR driving80E1:   key_pressed  0  11004D: jump_if_false ££camlockChk0004: $CAMLOCK =  1;; integer values0373: set_camera_directly_behind_player  :camlock0001: wait  0 ms00D6: if  20038:   $CAMLOCK ==  1;; integer values00DF:   actor $PLAYER_ACTOR driving00E1:   key_pressed  0  0004D: jump_if_false ££camlock00D6: if  080E1:   NOT   key_pressed  0  11004D: jump_if_false ££camlockChk0373: set_camera_directly_behind_player 0002: jump ££camlock

 

 

I have found no side-effects or bugs of this, except that it isn't 100% smooth. I'll see what I can do about that.

If there is any demand, I will add a pre-compiled SCM and a Darkpactor.

 

EDIT: It seems like the toggle option isnt workign blush.gif The mod is always on. Well its late here so I'll get around to fixing it tomorrow.

Edited by Bigun
Link to comment
Share on other sites

Hey Bigun, not bad for a first mod tounge.gif

 

This should make it work:

 

 

:CAMLOCK_1  03A4: name_thread 'CAMLOCK':CAMLOCK_20001: wait  250 ms00D6: if  00256:   player $PLAYER_CHAR defined 004D: jump_if_false ££CAMLOCK_200D6: if  0  00DF:   actor $PLAYER_ACTOR driving004D: jump_if_false ££CAMLOCK_200D6: if  000E1:   key pressed  0  11004D: jump_if_false ££CAMLOCK_203C0: @0 = actor $PLAYER_ACTOR car 0001: wait  250 ms:CAMLOCK_3  0001: wait  0 ms00D6: if  00256:   actor $PLAYER_ACTOR defined  004D: jump_if_false ££CAMLOCK_400D6: if  0  00DB:   actor $PLAYER_ACTOR in_car @0004D: jump_if_false ££CAMLOCK_400D6: if  080E1:   NOT   key pressed  0  11004D: jump_if_false ££CAMLOCK_40373: set_camera_directly_behind_player 0002: jump ££CAMLOCK_3:CAMLOCK_4 01C3: remove references to car @002EB: restore camera with jumpcut 0002: jump ££CAMLOCK_2

 

 

 

Link to comment
Share on other sites

@Pavel: There's no need to specify the car at all. Also, there's no reason why the first keypress check couldn't be lumped with the one before it in your code. Finally, your code only works if a person holds trip skip.

 

@Bigun: I'll be nice wink.gif First off, as Pavel pointed out, using local vars in place of globals is a good idea. Likewise, a name_thread is a good idea too. Your if use was superlative, but this part wasn't

0256:   player $PLAYER_CHAR defined0256:   actor $PLAYER_ACTOR defined8118:   NOT actor $PLAYER_ACTOR dead00DF:   actor $PLAYER_ACTOR driving

 

First of all, 0256 is a player conditional. You can't just rewrite it and frankly, I'm surprised you using it with an actor didn't crash the game. My guess is because that actor happens to also bear the player classification. The actor dead check is not needed at all because is player defined essentially gets most everything you'd need it for out of the way. Last but not least, using ANY conditional in the same lump as is player defined risks crashing the game. You use conditionals/commands that reference the player AFTER establishing he is in fact defined.

 

There's really not a need for any variables. Using multiple sections is essentially your flag. The only difference would be that your 2nd player defined check would jump back to the first section if false since you're no longer in a car once dead/arrested. Last but not least, you should have a keypress release check for trip skip so that you're not forever looping in and out of it.

 

:CAMLOCK_1  03A4: name_thread 'CAMLOCK':CAMLOCK_20001: wait  250 ms00D6: if  00256:   player $PLAYER_CHAR defined004D: jump_if_false ��CAMLOCK_200D6: if  100DF:   actor $PLAYER_ACTOR driving00E1:   key pressed  0  11004D: jump_if_false ��CAMLOCK_20050: gosub ��CAMLOCK_5:CAMLOCK_30001: wait  50 ms00D6: if  00256:   actor $PLAYER_ACTOR defined  004D: jump_if_false ��CAMLOCK_200D6: if  000DF:   actor $PLAYER_ACTOR driving004D: jump_if_false ��CAMLOCK_200D6: if  000E1:   key pressed  0  11004D: jump_if_false ��CAMLOCK_40050: gosub ��CAMLOCK_50002: jump ��CAMLOCK_2:CAMLOCK_400D6: if  000E1:   key pressed  0  0004D: jump_if_false ��CAMLOCK_30373: set_camera_directly_behind_player0002: jump ��CAMLOCK_3:CAMLOCK_50001: wait  50 ms00D6: if  080E1:   NOT   key pressed  0  11004D: jump_if_false ��CAMLOCK_5018C: play_sound  65535 at  0.0  0.0  0.00051: return

 

Link to comment
Share on other sites

Thanks, Dem and Pavel. turn.gif

 

@Dem: About that 'if actor defined', well yeah, I tried that a long time ago just for kicks, and since it works I've been using it ever since blush.gif .

Originally I tried to make the actual restore code (2nd label) as quick as possible, which why I used 2 labels.

 

 

Well I was really tired when I made that, so nevermind that ph34r.gif

 

I will test both of your codes now, "optimize" ( lol.gif ) and edit the first post with 'em.

 

EDIT: Dem, how come the "£"'s are gibberish in your posted code wow.gif

Not that they werent already.

Edited by Bigun
Link to comment
Share on other sites

The important thing is that you understand WHY. Using good code works, but understanding it allows you to take it with you for whatever you get into next. If you don't understand, please ask. colgate.gif

 

I've alerted them here. As you can see, nobody knows for sure why.

Link to comment
Share on other sites

Alright, then.

What is the 'name thread' for, since we don't call the thread by it's name?

Link to comment
Share on other sites

Name_thread is like is player defined. It doesn't appear to be necessary, but using it is correct. I'm pushing it more lately because with Darkpact out, it should be just as possible to make a tool that kills mods. But the mods will have to be "properly" installed with Darkpact to be elligible for savegame compatibility with the original game. Of the limitations, one would be that the thread needs to have a proper name. Ironically, the ONLY reason I see for US (as in not the game EXE) to establish names is to allow ourselves to be able to later use end_thread_named command.
Link to comment
Share on other sites

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
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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