BSL:Inventory management: Difference between revisions

From OniGalore
Jump to navigation Jump to search
m (+cat)
m (small copy-edit; removing confusing pointless tip on ID wrap-around, needless use of bullet points)
Line 2: Line 2:
==Giving items to characters==
==Giving items to characters==
====Weapons====
====Weapons====
You can choose from four commands when giving a weapon to a character :
You can choose from four commands when giving a weapon to a character:
*<tt>void chr_giveweapon(string ai_name, string weapon_name)</tt>
*<tt>void chr_giveweapon(string ai_name, string weapon_name)</tt>
*<tt>void chr_giveweapon(int script_id, string weapon_name)</tt>
*<tt>void chr_giveweapon(int script_id, string weapon_name)</tt>
*<tt>void chr_weapon(int chr_index, string weapon_name)</tt>
*<tt>void chr_weapon(int chr_index, string weapon_name)</tt>
*<tt>void chr_weapon(int chr_index, int weapon_num)</tt>
*<tt>void chr_weapon(int chr_index, int weapon_num)</tt>
All those have the effect of giving a new weapon to a character. The first argument can be :
All those have the effect of giving a new weapon to a character. The first argument can be:
*the "AI name", most often used for spawned AI, but also applicable to AI-less characters, such as Konoko (the name has then to be looked up).
*the "AI name", most often used for spawned AI, but also applicable to AI-less characters, such as Konoko (the name then has to be looked up).
*the "script ID", used for characters without an AI (Konoko and some cutscene puppets). Konoko's script ID is always 0.
*the "script ID", used for characters without an AI (Konoko and some cutscene puppets). Konoko's script ID is always 0.
*the "character index", used for any character : it's related to the position of the characters in memory (basically to the order in which they were spawned, Konoko's character index is thus always 0)
*the "character index", used for any character: it's related to the position of the characters in memory (basically to the order in which they were spawned, Konoko's character index is thus always 0)
The second argument can be :
The second argument can be:
*the "weapon name", a string
*the "weapon name", a string
*the "weapon number" an integer
*the "weapon number" an integer
A table summing up the weapon names and IDs :
A table summing up the weapon names and IDs:
{|border = "1"
{|border = "1"
!Weapon
!Weapon
!name
!name
!ID (+/- 12)
!ID
|-
|-
|Campbell Equalizer
|Campbell Equalizer
Line 80: Line 80:
|NONE
|NONE
|}
|}
*By (+/- 12) I mean that you can e.g. use <tt>chr_weapon(0, -11)</tt> or <tt>chr_weapon(0, 13)</tt> to give Konoko a Wave Motion Cannon.
*'''w10_sni''' is also known as the "fireworks" weapon because of the appearance of the projectile it shoots, but it's the same particle as Mukade's "Devilstar" attack ("sni" stands for "superninja").
*'''w10_sni''' is also known as the "fireworks" weapon because of the projectile it shoots
:It's the same particle as Mukade's "Devilstar" ("sni" stands for "superninja")
*'''w12_ba2''' is like '''w10_sni''' except it doesn't shoot... '''w13_muro''', '''w14_muro''' and '''w0_sec''' don't work at all.
*'''w12_ba2''' is like '''w10_sni''' except it doesn't shoot... '''w13_muro''', '''w14_muro''' and '''w0_sec''' don't work at all.


====Powerups====
====Powerups====
You can choose from a few commands when giving powerups to a character :
You can choose from a few commands when giving powerups to a character:
*<tt>void chr_givepowerup(string ai_name, string powerup_name, int amount)</tt>
*<tt>void chr_givepowerup(string ai_name, string powerup_name, int amount)</tt>
*<tt>void chr_givepowerup(string ai_name, string powerup_name)</tt>
*<tt>void chr_givepowerup(string ai_name, string powerup_name)</tt>
Line 94: Line 92:
*<tt>void give_powerup(string powerup_name, int amount)</tt>
*<tt>void give_powerup(string powerup_name, int amount)</tt>
*<tt>void give_powerup(string powerup_name)</tt>
*<tt>void give_powerup(string powerup_name)</tt>
All those have the effect of giving a powerup to a character. The character is referred to by one of the following :
All those have the effect of giving a powerup to a character. The character is referred to by one of the following:
*the "AI name", same as in the case of weapons (see above)
*the "AI name", same as in the case of weapons (see above)
*the "script ID", same as in the case of weapons (see above)
*the "script ID", same as in the case of weapons (see above)
*the "character" index, same as "character index" in the case of weapons (see above)
*the "character" index, same as "character index" in the case of weapons (see above)
The new thing here is that there is no "powerup ID", and some of the arguments are optional.<br>
The new thing here is that there is no "powerup ID", and some of the arguments are optional.<br>
In fact, those arguments have a default value, and omitting the argument is the same as providing that default value :
In fact, those arguments have a default value, and omitting the argument is the same as providing that default value:
*the default value of "character" for the <tt>give_powerup</tt> command is 0 (Konoko's "character ID"). If you specify "character", you can't omit "amount".
*the default value of "character" for the <tt>give_powerup</tt> command is 0 (Konoko's "character ID"). If you specify "character", you can't omit "amount".
*the default "amount" of powerups are summed up in the following table.
*the default "amount" of powerups are summed up in the following table.
{|border = "1"
{|border = "1"
!Powerup
!Powerup
!name
!Name
!Default amount
!Default amount
!Max amount
!Max amount
Line 123: Line 121:
|65535
|65535
|-
|-
|Special
|Special<sup>(1)</sup>
|lsi
|lsi
|?
|?<sup>(2)</sup>
|?
|?
|-
|-
Line 136: Line 134:
|invis
|invis
|1800
|1800
|65535
|65535<sup>(3)</sup>
|}
|}
*Giving negative amounts means taking away. Taking away more than you can means ''giving a lot''. If you have 1 clip of ammo and use <tt>give_powerup(ammo, -3)</tt>, you'll have 65534 ammo clips.
 
*Phase Cloak decays by 1 point every frame (1 second = 60 frames), so default is 30 seconds, max is 65534/60=1000 seconds
Giving negative amounts means taking away. Since inventory amounts can only be positive numbers, taking away more than the character originally had will have the effect of ''giving them a lot''. If you have 1 clip of ammo and use <tt>give_powerup(ammo, -2)</tt>, the "-1" result will wrap around to the max value of the 16 bits allotted for the clip count, giving them 65535 ammo clips.
*When the Phase Cloak amount is set to 65535, there is ''no'' decay ('''moonshadow''' effectively sets this amount to either -1=65535 or 0)
 
*"Special" aka '''lsi''' can be one of the following : Datapad, Rappelling Harness, Laser Torch, Zip Line Rider, Truck Keys. Depending on the level.
<sup>(1)</sup>"Special" items, AKA '''[[LSI|LSIs]]''', can be one of the following, depending on the level: Datapad, Rappelling Harness, Laser Torch, Zip Line Rider, or Truck Keys.
*"amount" seems to be ignored in the case of '''lsi''', as the associated variable is a [[BSL:Data|boolean]]. In particular, you can't take an '''lsi''' item away.
 
<sup>(2)</sup>The "amount" to give/take seems to be ignored in the case of '''LSIs''', as the associated variable is a [[BSL:Data|Boolean]]. In particular, you can't take an '''LSI''' away.
 
<sup>(3)</sup>The phase cloak decays by 1 point every frame (1 second = 60 frames), so the default value of 1800 is 30 seconds of cloak time. The maximum value for a temporary cloak is 65534 (1092 seconds, or 18.2 minutes), because when the value is set to 65535, there is ''no'' decay and the cloak lasts forever (the same effect as using "[[Cheats|moonshadow]]").


==Spawning loose items==
==Spawning loose items==
It's less complicated that giving items... or spawning characters.
It's less complicated than giving items... or spawning characters.
 
===Spawning a weapon===
===Spawning a weapon===
<tt>void weapon_spawn(string weapon_name, int flag_id)</tt>
<tt>void weapon_spawn(string weapon_name, int flag_id)</tt>
*The first argument is a valid weapon name (see table above)
*The first argument is a valid weapon name (see table above)
*The second argument is the index of a [[BSL:Flags|flag]] (preset position + orientation).
*The second argument is the index of a [[BSL:Flags|flag]] (preset position + orientation).
===Spawning a powerup===
===Spawning a powerup===
<tt>void powerup_spawn(string powerup_name, int flag_id)</tt>
<tt>void powerup_spawn(string powerup_name, int flag_id)</tt>
Line 158: Line 161:
===Commands===
===Commands===
====chr_inv_reset====
====chr_inv_reset====
*this takes all items away from a character (weapons, ammo, hypos, Force Shield, Phase Cloak, lsi)
This takes all items away from a character (weapons, ammo, hypos, Force Shield, Phase Cloak, LSI). As for most "character" commands, valid arguments are an "AI name" and a "script ID".
*as for most "character" commands, valid arguments are an "AI name" and a "script ID"
 
*chr_inv_reset(0) resets the inventory of the character with script ID 0 i.e. Konoko.
*chr_inv_reset(0) resets the inventory of the character with script ID 0, i.e., Konoko.
*chr_inv_reset(SomeAI) would reset the inventory of an AI called SomeAI.
*chr_inv_reset(SomeAI) would reset the inventory of an AI called SomeAI.
====chr_disarm====
====chr_disarm====
*doesn't seem to work...
Doesn't seem to work...


===Predicates===
===Predicates===
i.e. small functions returning a boolean (YES/NO) value informing you on the current state of the characters' inventory  
These are small functions returning a Boolean (YES/NO) value informing you on the current state of the characters' inventory.
 
====chr_has_lsi====
====chr_has_lsi====
*this one lets you know e.g. if the player character has found and picked up an '''lsi''' item.
This one lets you know if the player character has found and picked up an LSI.
 
====chr_has_empty_weapon====
====chr_has_empty_weapon====
*this one lets you know if the character has run out of ammo for his weapon (and has nothing to reload with)
This one lets you know if the character has run out of ammo for his weapon (and has no clips to reload it with).
 
===Variables===
===Variables===
====wp_disable_fade====
====wp_disable_fade====
*setting this to 1 will make dropped weapons ''not'' fade i.e. stay on the ground forever.
Setting this to 1 will make dropped weapons stay on the ground forever instead of fading away.
 
====wp_fade_time====
====wp_fade_time====
*should specify the time (in frames) over which weapons disappear, but setting it doesn't seem to have an effect
This should specify the time (in frames) over which weapons disappear, but setting it doesn't seem to have an effect.
 
====ai2_barabbas_run====
====ai2_barabbas_run====
*setting this variable to 0 will prevent the AI from running with the Wave Motion Cannon. The player character can never run with a WMC.
Setting this to 0 will prevent the AI from running with the Wave Motion Cannon. The player character can never run with a WMC.


[[Category:Bungie scripting language docs]]
[[Category:Bungie scripting language docs]]

Revision as of 20:07, 29 July 2015

Management of inventory items

Giving items to characters

Weapons

You can choose from four commands when giving a weapon to a character:

  • void chr_giveweapon(string ai_name, string weapon_name)
  • void chr_giveweapon(int script_id, string weapon_name)
  • void chr_weapon(int chr_index, string weapon_name)
  • void chr_weapon(int chr_index, int weapon_num)

All those have the effect of giving a new weapon to a character. The first argument can be:

  • the "AI name", most often used for spawned AI, but also applicable to AI-less characters, such as Konoko (the name then has to be looked up).
  • the "script ID", used for characters without an AI (Konoko and some cutscene puppets). Konoko's script ID is always 0.
  • the "character index", used for any character: it's related to the position of the characters in memory (basically to the order in which they were spawned, Konoko's character index is thus always 0)

The second argument can be:

  • the "weapon name", a string
  • the "weapon number" an integer

A table summing up the weapon names and IDs:

Weapon name ID
Campbell Equalizer w1_tap 3
Hughes Black Adder w2_sap 4
Plasma Rifle w3_phr 5
Phase Stream Projector w4_psm 6
Super Ball Gun w5_sbg 7
Van de Graaff Pistol w6_vdg 8
Scram Cannon w7_scc 9
Mercury Bow w8_mbo 10
Screaming Cannon w9_scr 11
Homing Red Balls :D w10_sni 0
Wave Motion Cannon w11_ba1 1
w12_ba2 2
w13_muro NONE
w14_muro NONE
w0_sec NONE
  • w10_sni is also known as the "fireworks" weapon because of the appearance of the projectile it shoots, but it's the same particle as Mukade's "Devilstar" attack ("sni" stands for "superninja").
  • w12_ba2 is like w10_sni except it doesn't shoot... w13_muro, w14_muro and w0_sec don't work at all.

Powerups

You can choose from a few commands when giving powerups to a character:

  • void chr_givepowerup(string ai_name, string powerup_name, int amount)
  • void chr_givepowerup(string ai_name, string powerup_name)
  • void chr_giveweapon(int script_id, string powerup_name, int amount)
  • void chr_giveweapon(int script_id, string powerup_name)
  • void give_powerup(string powerup_name, int amount, int character)
  • void give_powerup(string powerup_name, int amount)
  • void give_powerup(string powerup_name)

All those have the effect of giving a powerup to a character. The character is referred to by one of the following:

  • the "AI name", same as in the case of weapons (see above)
  • the "script ID", same as in the case of weapons (see above)
  • the "character" index, same as "character index" in the case of weapons (see above)

The new thing here is that there is no "powerup ID", and some of the arguments are optional.
In fact, those arguments have a default value, and omitting the argument is the same as providing that default value:

  • the default value of "character" for the give_powerup command is 0 (Konoko's "character ID"). If you specify "character", you can't omit "amount".
  • the default "amount" of powerups are summed up in the following table.
Powerup Name Default amount Max amount
Ballistic Ammo ammo 1 65535
Energy Cell cell 1 65535
Hypo Spray hypo 1 65535
Special(1) lsi ?(2) ?
Force Shield shield 100 65535
Phase Cloak invis 1800 65535(3)

Giving negative amounts means taking away. Since inventory amounts can only be positive numbers, taking away more than the character originally had will have the effect of giving them a lot. If you have 1 clip of ammo and use give_powerup(ammo, -2), the "-1" result will wrap around to the max value of the 16 bits allotted for the clip count, giving them 65535 ammo clips.

(1)"Special" items, AKA LSIs, can be one of the following, depending on the level: Datapad, Rappelling Harness, Laser Torch, Zip Line Rider, or Truck Keys.

(2)The "amount" to give/take seems to be ignored in the case of LSIs, as the associated variable is a Boolean. In particular, you can't take an LSI away.

(3)The phase cloak decays by 1 point every frame (1 second = 60 frames), so the default value of 1800 is 30 seconds of cloak time. The maximum value for a temporary cloak is 65534 (1092 seconds, or 18.2 minutes), because when the value is set to 65535, there is no decay and the cloak lasts forever (the same effect as using "moonshadow").

Spawning loose items

It's less complicated than giving items... or spawning characters.

Spawning a weapon

void weapon_spawn(string weapon_name, int flag_id)

  • The first argument is a valid weapon name (see table above)
  • The second argument is the index of a flag (preset position + orientation).

Spawning a powerup

void powerup_spawn(string powerup_name, int flag_id)

  • The first argument is a valid powerup name (see table above)
  • The second argument is the index of a flag (preset position + orientation).

Associated stuff

Commands

chr_inv_reset

This takes all items away from a character (weapons, ammo, hypos, Force Shield, Phase Cloak, LSI). As for most "character" commands, valid arguments are an "AI name" and a "script ID".

  • chr_inv_reset(0) resets the inventory of the character with script ID 0, i.e., Konoko.
  • chr_inv_reset(SomeAI) would reset the inventory of an AI called SomeAI.

chr_disarm

Doesn't seem to work...

Predicates

These are small functions returning a Boolean (YES/NO) value informing you on the current state of the characters' inventory.

chr_has_lsi

This one lets you know if the player character has found and picked up an LSI.

chr_has_empty_weapon

This one lets you know if the character has run out of ammo for his weapon (and has no clips to reload it with).

Variables

wp_disable_fade

Setting this to 1 will make dropped weapons stay on the ground forever instead of fading away.

wp_fade_time

This should specify the time (in frames) over which weapons disappear, but setting it doesn't seem to have an effect.

ai2_barabbas_run

Setting this to 0 will prevent the AI from running with the Wave Motion Cannon. The player character can never run with a WMC.