Difference between revisions of "0136"

From GTAMods Wiki
Jump to navigation Jump to search
(Created page with "{{OpCode | games = {{Icon|3}} | command = SHAKE_CAM_WITH_POINT | description = Shakes the in-game camera | syntax1 = 0136: shake_camera [''int''] with_point [''f...")
 
m
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
{{TocRight}}
 
{{OpCode
 
{{OpCode
 
| games      = {{Icon|3}}
 
| games      = {{Icon|3}}
Line 14: Line 15:
 
}}
 
}}
  
This opcode shakes the in-game camera for a while. The higher the integer value is, the more and the longer the camera shakes. The shaking of the camera depends if the camera's location, not the player's location, is within 100 units of the specified coordinates point. The duration and intensity is independent of that point. Leaving or entering the area after the opcode is called does not change the behavior of the shaking. This opcode was never called in the [[Main.scm|original script]] of GTA III.
+
This opcode shakes the in-game camera for a while. The higher the integer value is, the more intense and the longer the camera shakes. The shaking of the camera depends if the camera's location, not the player's location, is within 100 [[unit]]s of the specified coordinates point. The duration and intensity is independent of that point. Leaving or entering the area after the opcode is called does not change the behavior of the shaking. This opcode was never called in the [[Main.scm|original script]] of GTA III.
 +
 
 +
== Example ==
 +
The following example spawns a Trashmaster close to the player. If the Trashmaster's health is below 90%, it creates an explosion larger than a regular car explosion.
 +
{{Pre|class=sb-code|1=
 +
<span class="c1">// set constants</span>
 +
<span class="k">const</span>
 +
CAR_MODEL = <span class="nt">#TRASH</span>
 +
CAR_HANDLE = <span class="nv">0@</span>
 +
X_POS = <span class="nv">1@</span>
 +
Y_POS = <span class="nv">2@</span>
 +
Z_POS = <span class="nv">3@</span>
 +
<span class="k">end</span>
 +
 
 +
<span class="c1">// spawn vehicle</span>
 +
[[0247]]: request_model CAR_MODEL
 +
[[038B]]: load_requested_models
 +
[[0054]]: store_player <span class="nv">$PLAYER_CHAR</span> position_to X_POS Y_POS Z_POS
 +
X_POS += <span class="m">4.0</span>
 +
[[00A5]]: CAR_HANDLE = create_car CAR_MODEL at X_POS Y_POS Z_POS
 +
[[0249]]: release_model CAR_MODEL
 +
 
 +
<span class="k">while</span> [[0119|8119]]:  <span class="k">not</span> car CAR_HANDLE wrecked
 +
    <span class="k">wait</span> <span class="m">10</span>
 +
    <span class="k">if</span>
 +
        8185:  <span class="k">not</span> car CAR_HANDLE health >= <span class="m">900</span>
 +
    <span class="k">then</span>
 +
        <span class="c1">// generate larger car explosion</span>
 +
        [[00AA]]: store_car CAR_HANDLE position_to X_POS Y_POS Z_POS
 +
        [[020C]]: create_explosion <span class="m">5</span> at X_POS Y_POS Z_POS  <span class="c1">// EXPLOSION_HELI</span>
 +
        0136: <span class="k">shake_camera</span> <span class="m">1600</span> with_point X_POS Y_POS Z_POS
 +
        020B: explode_car CAR_HANDLE
 +
    <span class="k">end</span>
 +
<span class="k">end</span>
 +
[[01C3]]: mark_car_as_no_longer_needed CAR_HANDLE
 +
}}
  
 
== For Vice City ==
 
== For Vice City ==
This opcode does not exist in Vice City but it is possible to recreate this opcode since camera shaking based on location is already featured in the game (like when cars explode). Vice City improved upon this feature in that the initial duration and intensity of the shaking is dependent on the camera's distance from the point. The following example, using Sanny Builder with [[CLEO]] for Vice City in an external script (not the main one) and tested on US v1.0, should work similarly to this opcode. Place this at the end of the file:
+
This opcode does not exist in Vice City but it is possible to recreate this opcode since camera shaking based on location is already featured in the game (like when cars explode). Vice City improved upon this feature in that the initial duration and intensity of the shaking is dependent on the camera's distance from the point. The following example is a stand-alone [[CLEO]] script for Vice City tested on US v1.0 and should work similarly to the example above.
<syntaxhighlight lang="scm">
+
{{Pre|class=sb-code|1=
:opcode_0136
+
<span class="no">{$CLEO .cs}</span>
// 0@ - input param (intensity/duration)
+
 
// 1@ - input param (x-coordinate)
+
<span class="c1">// set constants</span>
// 2@ - input param (y-coordinate)
+
<span class="k">const</span>
// 3@ - input param (z-coordinate)
+
CAR_MODEL = <span class="nt">#TRASH</span>
0093: 0@ = integer_to_float 0@
+
CAR_HANDLE = <span class="nv">0@</span>
0@ *= 0.001
+
X_POS = <span class="nv">1@</span>
05E3: call_method 0x46FF21 0x7E4688 num_params 4 pop 0 z 3@ y 2@ x 1@ time 0@
+
Y_POS = <span class="nv">2@</span>
05F6: ret 0
+
Z_POS = <span class="nv">3@</span>
</syntaxhighlight>
+
<span class="k">end</span>
 +
 
 +
<span class="c1">// spawn vehicle</span>
 +
[[0247]]: request_model CAR_MODEL
 +
[[038B]]: load_requested_models
 +
[[0054]]: store_player <span class="nv">$PLAYER_CHAR</span> position_to X_POS Y_POS Z_POS
 +
X_POS += <span class="m">4.0</span>
 +
[[00A5]]: CAR_HANDLE = create_car CAR_MODEL at X_POS Y_POS Z_POS
 +
[[0249]]: release_model CAR_MODEL
 +
 
 +
<span class="k">while</span> [[0119|8119]]:  <span class="k">not</span> car CAR_HANDLE wrecked
 +
    <span class="k">wait</span> <span class="m">10</span>
 +
    <span class="k">if</span>
 +
        8185:  <span class="k">not</span> car CAR_HANDLE health >= <span class="m">900</span>
 +
    <span class="k">then</span>
 +
        <span class="c1">// generate larger car explosion</span>
 +
        [[00AA]]: store_car CAR_HANDLE position_to X_POS Y_POS Z_POS
 +
        [[020C]]: create_explosion <span class="m">6</span> at X_POS Y_POS Z_POS  <span class="c1">// EXPLOSION_HELI</span>
 +
        05F5: call_scm_func <span class="nl">@opcode_0136</span> inputs <span class="m">4</span> -- <span class="k">shake_camera</span> <span class="m">1600</span> with_point X_POS Y_POS Z_POS  <span class="c1">// 0136 substitute</span>
 +
        020B: explode_car CAR_HANDLE
 +
    <span class="k">end</span>
 +
<span class="k">end</span>
 +
[[01C3]]: mark_car_as_no_longer_needed CAR_HANDLE
 +
05DC: end_custom_thread
 +
 
 +
<span class="nl">:opcode_0136</span>
 +
<span class="c1">// 0@ - input param (intensity/duration)</span>
 +
<span class="c1">// 1@ - input param (x-coordinate)</span>
 +
<span class="c1">// 2@ - input param (y-coordinate)</span>
 +
<span class="c1">// 3@ - input param (z-coordinate)</span>
 +
[[0093]]: <span class="nv">0@</span> = integer_to_float <span class="nv">0@</span>
 +
<span class="nv">0@</span> *= <span class="m">0.001</span>
 +
[[0AA6|05E3]]: call_method <span class="m">0x46FF21</span> <span class="m">0x7E4688</span> num_params <span class="m">4</span> pop <span class="m">0</span> z <span class="nv">3@</span> y <span class="nv">2@</span> x <span class="nv">1@</span> intensity <span class="nv">0@</span>  <span class="c1">// CCamera::CamShake</span>
 +
[[0AB2|05F6]]: ret <span class="m">0</span>
 +
}}
  
Use this line as a substitute for opcode 0136. This can be placed anywhere within the external script:
+
== Disassembled code ==
<syntaxhighlight lang="scm">
+
This is disassembled code for this opcode from PC v1.0 US.
05F5: call_scm_func @opcode_0136 inputs 4 time [int] x [flt1] y [flt2] z [flt3]
+
<syntaxhighlight lang="nasm">
 +
loc_43EDCA:
 +
    lea    eax, [ebp+10h]                    ; get address of script's current instruction pointer
 +
    mov    ecx, ebp                          ; get address of script for thiscall
 +
    push    4                                ; push 4 for four parameters to collect
 +
    push    eax                              ; push address of script's current instruction pointer
 +
    call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters(uint *,short)
 +
    fild    ds:ScriptParams[0]                ; get value of first parameter, the intensity, and push onto floating-point stack
 +
    push    ds:ScriptParams[3]               ; push value of fourth parameter, the z-coordinate
 +
    push    ds:ScriptParams[2]               ; push value of third parameter, the y-coordinate
 +
    fmul    flt_5EEDB4                        ; multiply the intensity by 0.001
 +
    push    ds:ScriptParams[1]               ; push value of second parameter, the x-coordinate
 +
    push    eax                              ; push to make space for the intensity
 +
    mov    ecx, offset TheCamera            ; get address of TheCamera for thiscall
 +
    fstp    [esp]                             ; store the intensity and pop floating-point stack
 +
    call    CCamera::CamShake                ; call CCamera::CamShake(float,float,float,float)
 +
    xor    al, al                            ; return 0
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 40: Line 126:
 
== See also ==
 
== See also ==
 
* {{Icon|t}} [[0003]], shake camera without point
 
* {{Icon|t}} [[0003]], shake camera without point
 
[[Category:Code Snippets]]
 

Latest revision as of 16:20, 27 May 2019

GTA III SHAKE_CAM_WITH_POINT


Description
Shakes the in-game camera
Syntax
0136: shake_camera [int] with_point [flt1] [flt2] [flt3]
Parameter
[int]
Intensity and duration of the shaking
[flt1]
X-coordinate
[flt2]
Y-coordinate
[flt3]
Z-coordinate

This opcode shakes the in-game camera for a while. The higher the integer value is, the more intense and the longer the camera shakes. The shaking of the camera depends if the camera's location, not the player's location, is within 100 units of the specified coordinates point. The duration and intensity is independent of that point. Leaving or entering the area after the opcode is called does not change the behavior of the shaking. This opcode was never called in the original script of GTA III.

Example

The following example spawns a Trashmaster close to the player. If the Trashmaster's health is below 90%, it creates an explosion larger than a regular car explosion.

// set constants
const
CAR_MODEL = #TRASH
CAR_HANDLE = 0@
X_POS = 1@
Y_POS = 2@
Z_POS = 3@
end

// spawn vehicle
0247: request_model CAR_MODEL
038B: load_requested_models
0054: store_player $PLAYER_CHAR position_to X_POS Y_POS Z_POS
X_POS += 4.0
00A5: CAR_HANDLE = create_car CAR_MODEL at X_POS Y_POS Z_POS
0249: release_model CAR_MODEL

while 8119:   not car CAR_HANDLE wrecked
    wait 10
    if
        8185:   not car CAR_HANDLE health >= 900
    then
        // generate larger car explosion
        00AA: store_car CAR_HANDLE position_to X_POS Y_POS Z_POS
        020C: create_explosion 5 at X_POS Y_POS Z_POS  // EXPLOSION_HELI
        0136: shake_camera 1600 with_point X_POS Y_POS Z_POS
        020B: explode_car CAR_HANDLE
    end
end
01C3: mark_car_as_no_longer_needed CAR_HANDLE

For Vice City

This opcode does not exist in Vice City but it is possible to recreate this opcode since camera shaking based on location is already featured in the game (like when cars explode). Vice City improved upon this feature in that the initial duration and intensity of the shaking is dependent on the camera's distance from the point. The following example is a stand-alone CLEO script for Vice City tested on US v1.0 and should work similarly to the example above.

{$CLEO .cs}

// set constants
const
CAR_MODEL = #TRASH
CAR_HANDLE = 0@
X_POS = 1@
Y_POS = 2@
Z_POS = 3@
end

// spawn vehicle
0247: request_model CAR_MODEL
038B: load_requested_models
0054: store_player $PLAYER_CHAR position_to X_POS Y_POS Z_POS
X_POS += 4.0
00A5: CAR_HANDLE = create_car CAR_MODEL at X_POS Y_POS Z_POS
0249: release_model CAR_MODEL

while 8119:   not car CAR_HANDLE wrecked
    wait 10
    if
        8185:   not car CAR_HANDLE health >= 900
    then
        // generate larger car explosion
        00AA: store_car CAR_HANDLE position_to X_POS Y_POS Z_POS
        020C: create_explosion 6 at X_POS Y_POS Z_POS  // EXPLOSION_HELI
        05F5: call_scm_func @opcode_0136 inputs 4 -- shake_camera 1600 with_point X_POS Y_POS Z_POS  // 0136 substitute
        020B: explode_car CAR_HANDLE
    end
end
01C3: mark_car_as_no_longer_needed CAR_HANDLE
05DC: end_custom_thread

:opcode_0136
// 0@ - input param (intensity/duration)
// 1@ - input param (x-coordinate)
// 2@ - input param (y-coordinate)
// 3@ - input param (z-coordinate)
0093: 0@ = integer_to_float 0@
0@ *= 0.001
05E3: call_method 0x46FF21 0x7E4688 num_params 4 pop 0 z 3@ y 2@ x 1@ intensity 0@  // CCamera::CamShake
05F6: ret 0

Disassembled code

This is disassembled code for this opcode from PC v1.0 US.

loc_43EDCA:
    lea     eax, [ebp+10h]                    ; get address of script's current instruction pointer
    mov     ecx, ebp                          ; get address of script for thiscall
    push    4                                 ; push 4 for four parameters to collect
    push    eax                               ; push address of script's current instruction pointer
    call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters(uint *,short)
    fild    ds:ScriptParams[0]                ; get value of first parameter, the intensity, and push onto floating-point stack
    push    ds:ScriptParams[3]                ; push value of fourth parameter, the z-coordinate
    push    ds:ScriptParams[2]                ; push value of third parameter, the y-coordinate
    fmul    flt_5EEDB4                        ; multiply the intensity by 0.001
    push    ds:ScriptParams[1]                ; push value of second parameter, the x-coordinate
    push    eax                               ; push to make space for the intensity
    mov     ecx, offset TheCamera             ; get address of TheCamera for thiscall
    fstp    [esp]                             ; store the intensity and pop floating-point stack
    call    CCamera::CamShake                 ; call CCamera::CamShake(float,float,float,float)
    xor     al, al                            ; return 0

Keywords

shake, jostle, cam, camera, point

See also

  • GTA III Vice City San Andreas 0003, shake camera without point