Difference between revisions of "017B"

From GTAMods Wiki
Jump to navigation Jump to search
(code snippet)
m
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Icon|3}} {{Icon|SA}} '''SET_CHAR_AMMO'''
+
{{OpCode
<hr />
+
| games      = {{Icon|3}} {{Icon|SA}}
'''Description'''
+
| command    = SET_CHAR_AMMO
: Sets the character's weapon ammo
+
| description = Sets the character's [[weapon]] ammo
'''Syntax'''
+
| syntax1    = 017B: set_actor [''char handle''] weapon [''int1''] ammo_to [''int2'']
: 017B: set_actor [''char handle''] weapon [''int1''] ammo_to [''int2'']
+
| p1t        = [''char handle'']
'''Parameter'''
+
| p1d        = The handle of the character
: [''char handle'']
+
| p2t        = [''int1'']
:: The handle of the character
+
| p2d        = [[Weapon#Lists of weapons|Weapon type]]
: [''int1'']
+
| p3t        = [''int2'']
:: [[Weapon#Lists of Weapons|Weapon number]]
+
| p3d        = Ammo
: [''int2'']
+
}}
:: Ammo
 
  
 
This opcode sets the character's weapon ammo. If the character does not have the weapon, the weapon is given to it. Unlike opcode [[01B2]], it sets rather than adds to the ammo count and does not set the weapon as the current one for the character. You have to use opcode [[01B9]] to set it as the current one. When the character dies, it drops the weapon as a [[0213#Weapons|pickup type 4 with predefined ammo count]]. If the ammo count is already less than the predefined count, it drops that ammo count instead. This opcode was never called in the [[Main.scm|original script]] of GTA III.
 
This opcode sets the character's weapon ammo. If the character does not have the weapon, the weapon is given to it. Unlike opcode [[01B2]], it sets rather than adds to the ammo count and does not set the weapon as the current one for the character. You have to use opcode [[01B9]] to set it as the current one. When the character dies, it drops the weapon as a [[0213#Weapons|pickup type 4 with predefined ammo count]]. If the ammo count is already less than the predefined count, it drops that ammo count instead. This opcode was never called in the [[Main.scm|original script]] of GTA III.
  
 
== For Vice City ==
 
== For Vice City ==
This opcode does not exist in Vice City but it is possible to recreate this opcode based on [[017A]]. 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. Due to the way how 017A works in Vice City, if the character does not have the weapon or another weapon of the same group, nothing happens. If the character does not have the weapon but does have another weapon of the same group, weapon ammo will be set for that weapon instead. Place this at the end of the file:
+
This opcode does not exist in Vice City but it is possible to recreate this opcode based on [[017A]]. 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. Due to the way how 017A works in Vice City, if the character does not have the weapon or another weapon of the same slot, nothing happens. If the character does not have the weapon but does have another weapon of the same slot, weapon ammo will be set for that weapon instead. Place this at the end of the file:
<syntaxhighlight lang="scm">
+
{{Pre|class=sb-code|1=
:opcode_017B
+
<span class="nl">:opcode_017B</span>
05E6: 0@ = actor 0@ struct
+
<span class="c1">// 0@ - input param (char handle)</span>
05E3: call_method 0x4FF780 0@ num_params 2 pop 0 ammo 2@ weapon 1@  // CPed::SetAmmo
+
<span class="c1">// 1@ - input param (weapon type)</span>
05F6: ret 0
+
<span class="c1">// 2@ - input param (ammo count)</span>
</syntaxhighlight>
+
05E6: <span class="nv">0@</span> = actor <span class="nv">0@</span> struct
 +
05E3: call_method <span class="m">0x4FF780</span> <span class="nv">0@</span> num_params <span class="m">2</span> pop <span class="m">0</span> ammo <span class="nv">2@</span> weapon <span class="nv">1@</span> <span class="c1">// CPed::SetAmmo</span>
 +
05F6: ret <span class="m">0</span>
 +
}}
 +
 
 
Use this line as a substitute for opcode 017B. This can be placed anywhere within the external script:
 
Use this line as a substitute for opcode 017B. This can be placed anywhere within the external script:
<syntaxhighlight lang="scm">
+
{{Pre|class=sb-code|1=
05F5: call_scm_func @opcode_017B inputs 3 char_handle [char handle] weapon [int1] ammo [int2]
+
05F5: call_scm_func <span class="nl">@opcode_017B</span> inputs <span class="m">3</span> char_handle [char handle] weapon [int1] ammo [int2]
</syntaxhighlight>
+
}}
  
 
== Keywords ==
 
== Keywords ==
Line 32: Line 35:
  
 
== See also ==
 
== See also ==
* [[017A]], sets the player's weapon ammo
+
* {{Icon|3}} {{Icon|VC}} [[017A]], sets the player's weapon ammo
* [[01B2]], gives a weapon to a character
+
* {{Icon|t}} [[01B2]], gives a weapon to a character
 
 
[[Category:OpCodes]]
 
[[Category:Code Snippets]]
 

Latest revision as of 06:27, 8 July 2017

GTA III San Andreas SET_CHAR_AMMO


Description
Sets the character's weapon ammo
Syntax
017B: set_actor [char handle] weapon [int1] ammo_to [int2]
Parameter
[char handle]
The handle of the character
[int1]
Weapon type
[int2]
Ammo

This opcode sets the character's weapon ammo. If the character does not have the weapon, the weapon is given to it. Unlike opcode 01B2, it sets rather than adds to the ammo count and does not set the weapon as the current one for the character. You have to use opcode 01B9 to set it as the current one. When the character dies, it drops the weapon as a pickup type 4 with predefined ammo count. If the ammo count is already less than the predefined count, it drops that ammo count instead. This opcode 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 recreate this opcode based on 017A. 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. Due to the way how 017A works in Vice City, if the character does not have the weapon or another weapon of the same slot, nothing happens. If the character does not have the weapon but does have another weapon of the same slot, weapon ammo will be set for that weapon instead. Place this at the end of the file:

:opcode_017B
// 0@ - input param (char handle)
// 1@ - input param (weapon type)
// 2@ - input param (ammo count)
05E6: 0@ = actor 0@ struct
05E3: call_method 0x4FF780 0@ num_params 2 pop 0 ammo 2@ weapon 1@  // CPed::SetAmmo
05F6: ret 0

Use this line as a substitute for opcode 017B. This can be placed anywhere within the external script:

05F5: call_scm_func @opcode_017B inputs 3 char_handle [char handle] weapon [int1] ammo [int2]

Keywords

set, character, actor, weapon, ammo

See also

  • GTA III Vice City 017A, sets the player's weapon ammo
  • GTA III Vice City San Andreas 01B2, gives a weapon to a character