Difference between revisions of "0393"
Jump to navigation
Jump to search
(Created page with "{{OpCode | games = {{Icon|3}} {{Icon|SA}} | command = SET_CHAR_ANIM_SPEED | description = Sets the character's animation speed | syntax1 = {{Icon|3}} 0393: set_a...") |
|||
Line 1: | Line 1: | ||
+ | __NOTOC__ | ||
{{OpCode | {{OpCode | ||
| games = {{Icon|3}} {{Icon|SA}} | | games = {{Icon|3}} {{Icon|SA}} | ||
Line 14: | Line 15: | ||
This opcode sets the character's animation speed. It was never called in the [[Main.scm|original script]] of GTA III. | This opcode sets the character's animation speed. It was never called in the [[Main.scm|original script]] of GTA III. | ||
+ | |||
+ | == For Vice City == | ||
+ | This opcode does not exist in Vice City but it is possible to set the speed of a character's animation. 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. | ||
+ | {{Pre|class=sb-code|1= | ||
+ | <span class="nl">:opcode_0393</span> | ||
+ | <span class="c1">// 0@ - input param (character handle)</span> | ||
+ | <span class="c1">// 1@ - input param (speed)</span> | ||
+ | 05E6: <span class="nv">0@</span> = actor <span class="nv">0@</span> struct | ||
+ | <span class="nv">0@</span> += <span class="m">0x4C</span> | ||
+ | [[0A8D|05E0]]: <span class="nv">0@</span> = read_memory <span class="nv">0@</span> size <span class="m">4</span> virtual_protect <span class="m">0</span> <span class="c1">// get address of RpClump</span> | ||
+ | 05E2: call_method <span class="m">0x402E20</span> num_params <span class="m">1</span> pop <span class="m">1</span> <span class="nv">0@</span> <span class="nv">0@</span> <span class="c1">// RpAnimBlendClumpGetFirstAssociation</span> | ||
+ | <span class="k">if</span> | ||
+ | <span class="k">not</span> <span class="nv">0@</span> == <span class="m">0</span> | ||
+ | <span class="k">then</span> | ||
+ | <span class="nv">0@</span> += <span class="m">0x24</span> | ||
+ | [[0A8C|05DF]]: write_memory <span class="nv">0@</span> size <span class="m">4</span> value <span class="nv">1@</span> virtual_protect <span class="m">0</span> <span class="c1">// set anim speed</span> | ||
+ | <span class="k">end</span> | ||
+ | [[0AB2|05F6]]: ret <span class="m">0</span> | ||
+ | }} | ||
+ | |||
+ | Use this line as a substitute for opcode 0393. This can be placed anywhere within the external script: | ||
+ | {{Pre|class=sb-code|1= | ||
+ | 05F5: call_scm_func <span class="nl">@opcode_0393</span> inputs <span class="m">2</span> char_handle [char handle] speed [flt] | ||
+ | }} | ||
+ | |||
+ | * [https://www.youtube.com/watch?v=1zuoO87G9uI Demonstration of the opcode simulated in Vice City] | ||
== Disassembled code == | == Disassembled code == |
Latest revision as of 21:27, 5 July 2017
- Description
- Sets the character's animation speed
- Syntax
- 0393: set_actor [char handle] anim_speed [flt]
- 0393: actor [char handle] perform_animation "[string]" at [flt] times_normal_rate
- Parameter
- [char handle]
- The handle of the character
- [flt]
- Speed (default 1.0)
- [string]
- Animation name
This opcode sets the character's animation speed. It was never called in the original script of GTA III.
For Vice City
This opcode does not exist in Vice City but it is possible to set the speed of a character's animation. 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.
:opcode_0393 // 0@ - input param (character handle) // 1@ - input param (speed) 05E6: 0@ = actor 0@ struct 0@ += 0x4C 05E0: 0@ = read_memory 0@ size 4 virtual_protect 0 // get address of RpClump 05E2: call_method 0x402E20 num_params 1 pop 1 0@ 0@ // RpAnimBlendClumpGetFirstAssociation if not 0@ == 0 then 0@ += 0x24 05DF: write_memory 0@ size 4 value 1@ virtual_protect 0 // set anim speed end 05F6: ret 0
Use this line as a substitute for opcode 0393. This can be placed anywhere within the external script:
05F5: call_scm_func @opcode_0393 inputs 2 char_handle [char handle] speed [flt]
Disassembled code
This is disassembled code for this opcode from PC v1.0 US.
GTA III
loc_44D7BD:
mov eax, [esp+208h+var_204]
mov ecx, [esp+208h+var_204] ; get address of script for thiscall
add eax, 10h ; get address of script's current instruction pointer
push 2 ; push 2 for two parameters to collect
push eax ; push address of script's current instruction pointer
call CRunningScript::CollectParameters ; call CRunningScript::CollectParameters(uint *,short)
mov eax, ds:ScriptParams[0] ; get value of first parameter, the ped handle
mov ecx, ds:CPools::ms_pPedPool ; get address of ped pool for thiscall
push eax ; push ped handle
call CPool_CPed_CPlayerPed::GetAt ; call CPool<CPed, CPlayerPed>::GetAt(int) to get address of ped
mov eax, [eax+4Ch] ; offset ped address by 0x4C to get address of RpClump
push eax ; push address of RpClump
call RpAnimBlendClumpGetFirstAssociation ; call RpAnimBlendClumpGetFirstAssociation(RpClump *)
test eax, eax ; check whether or not returned address is nonzero
pop ecx
jz short loc_44D7F8
fld ds:ScriptParams[1] ; get value of second parameter, a floating-point value representing the speed
fstp dword ptr [eax+24h] ; offset returned address by 0x24 and set it to the value
loc_44D7F8:
xor al, al ; return 0
Keywords
set, character, actor, anim, animation, speed, rate