inkoalawetrust

GPT-4 failing with coding

May 20th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.79 KB | None | 0 0
  1. ## You
  2. What is ZScript?
  3. ## Copilot
  4. ZScript (formerly known as DoomScript) is a text-based lump used in the ZDoom source port. Created by Marisa Heit and Graf Zahl, it serves as a powerful scripting language for creating custom functionality in ZDoom-based games. Here are some key features of ZScript:
  5. - DECORATE Compatibility: ZScript fully replaces DECORATE, allowing you to create custom classes, structs, and menus. DECORATE classes can even inherit from ZScript ones.
  6. - Advanced Control: ZScript provides more advanced control over gameplay facets (such as actors, levels, and game modes) compared to DECORATE.
  7. - UI Creation: You can use ZScript to create custom HUDs, menus, and other user interface elements.
  8. - File Structure: ZScript files can be included using either full or relative paths. For example:
  9. - Full path: #include "ZScript/Const.txt"
  10. - Relative paths: #include "./Items/Health.txt" or #include "../Items/Armor.txt"
  11. - Load Order: ZScript files are loaded automatically in GZDoom. For ZIP (PK3) archives, it loads zscript.txt, and for WADs, it loads the lump named ZSCRIPT.
  12. - Combining with DECORATE: You can use both DECORATE and ZScript together. ZScript code is processed and compiled before DECORATE code, allowing DECORATE actors to inherit from ZScript actors.
  13. Despite some oddities and deficiencies, ZScript remains the most powerful Doom modding tool since editing the source code directly . If you're interested in learning more, there are resources available, including tutorials and documentation. Feel free to explore this fascinating scripting language! 🚀
  14. ## You
  15. Can you give me an example of ZScript?
  16. ## Copilot
  17. Certainly! Here's a simple example of a ZScript actor that creates a custom pickup item in a Doom mod. Let's say we want to create a health potion that gives the player 20 health points when picked up:
  18.  
  19. class HealthPotion : CustomInventory
  20. {
  21. // Constructor: Set properties for the health potion
  22. default
  23. {
  24. Inventory.Icon "HEALTH1" // Use the health icon from the game's resources
  25. Inventory.PickupMessage "You found a health potion!"
  26. Inventory.MaxAmount 1 // Only one health potion can be carried
  27. }
  28.  
  29. // When the player picks up the health potion
  30. override void PickupUse(PlayerPawn player)
  31. {
  32. // Increase player's health by 20 (or up to their maximum health)
  33. player.Health += 20;
  34. if (player.Health > player.GetDefaultHealth())
  35. player.Health = player.GetDefaultHealth();
  36.  
  37. // Play a sound effect
  38. player.PlaySound("misc/healthup", CHAN_ITEM);
  39.  
  40. // Remove the health potion from the player's inventory
  41. Destroy();
  42. }
  43. }
  44.  
  45. Explanation:
  46. - We define a new class called HealthPotion that inherits from CustomInventory.
  47. - In the constructor (default block), we set properties for the health potion:
  48. - Icon: Uses the health icon from the game's resources.
  49. - Pickup message: Displays "You found a health potion!" when picked up.
  50. - MaxAmount: Limits the player to carrying only one health potion.
  51. - The PickupUse function is called when the player picks up the health potion:
  52. - It increases the player's health by 20 points (or up to their maximum health).
  53. - Plays a sound effect.
  54. - Removes the health potion from the player's inventory.
  55. Feel free to modify and expand upon this example to create your own custom items in ZScript! 🎮🔍
  56. ## You
  57. Can you show me an example of a ZScript weapon?
  58. ## Copilot
  59. Certainly! Here's an example of a basic ZScript weapon that closely imitates Doom's Super Shotgun. Let's break down the code:
  60.  
  61. class UberShotgun : Weapon
  62. {
  63. Default
  64. {
  65. Inventory.PickupSound "misc/usgpickup";
  66. Inventory.PickupMessage "Picked up the Uber Shotgun!";
  67. Weapon.SelectionOrder 350;
  68. Weapon.AmmoType "Shell";
  69. Weapon.AmmoGive 12;
  70. Weapon.AmmoUse 4;
  71. Weapon.SlotNumber 3;
  72. AttackSound "weapons/ubersgf";
  73. }
  74.  
  75. States
  76. {
  77. // This sequence is entered when the weapon spawns in the world or is dropped from inventory:
  78. Spawn:
  79. USGP A -1;
  80. Stop;
  81.  
  82. // This sequence is used while you have this weapon selected:
  83. Ready:
  84. USHG A 1 A_WeaponReady;
  85. Loop;
  86.  
  87. // This sequence is entered when you select this weapon:
  88. Select:
  89. USHG A 1 A_Raise;
  90. Loop;
  91.  
  92. // This sequence is entered when you deselect the current selected weapon:
  93. Deselect:
  94. USHG A 1 A_Lower;
  95. Loop;
  96.  
  97. // The attack sequence. Entered while the player presses the Fire button while the weapon was ready:
  98. Fire:
  99. USHG A 3;
  100. USHG A 7
  101. {
  102. A_FireBullets(13.4, 9.2, 50, 10);
  103. A_GunFlash(); // Plays the weapon's Flash sequence on a separate layer
  104. }
  105. USHG B 7;
  106. USHG C 7 A_CheckReload; // If the weapon runs out of ammo here, it'll be deselected
  107. USHG D 7 A_StartSound("weapons/sshoto", CHAN_WEAPON);
  108. USHG E 7;
  109. USHG F 7 A_StartSound("weapons/sshotl", CHAN_WEAPON);
  110. USHG G 6;
  111. TNT1 A 0 A_StartSound("weapons/sshotc", CHAN_WEAPON);
  112. USHG HHHHHHAAAAA 1 A_ReFire;
  113. Goto Ready;
  114.  
  115. // The weapon's flash animation which is drawn on a separate layer:
  116. Flash:
  117. USGF A 6 bright A_Light1;
  118. Goto LightDone; // LightDone resets the light created by A_Light1
  119. }
  120. }
  121.  
  122. Explanation:
  123. - We define a new class called UberShotgun based on the Weapon class.
  124. - In the Default block, we set properties for the Uber Shotgun:
  125. - Pickup sound and message.
  126. - Ammo type, amount given, and usage.
  127. - Slot number and attack sound.
  128. - The States section defines various sequences:
  129. - Spawn: When the weapon spawns or is dropped.
  130. - Ready: While the weapon is selected.
  131. - Select: When the weapon is chosen.
  132. - Deselect: When the weapon is deselected.
  133. - Fire: The attack sequence, including firing bullets and playing the gun flash.
  134. - Flash: The weapon's flash animation.
  135. Feel free to modify and expand upon this example to create your own custom weapons in ZScript! 🎮🔫
  136. : Creating new weapons (ZScript) - ZDoom Wiki
  137. : Weapon slots - ZDoom Wiki
  138. : ZScript_Basics | ZScript entry guide
  139. : ZScript - ZDoom Wiki
  140. : ZScript - Beginner/Intermediate Weapons Tutorial - PureZC
  141. ## You
  142. Can you write a simple homing Imp fireball in ZScript?
  143. ## Copilot
  144. Certainly! Let's create a simple homing fireball in ZScript. We'll base it on the Imp's fireball attack. Here's an example of how you can modify the Imp's fireball to make it homing:
  145.  
  146. class HomingImpFireball : DoomImpBall
  147. {
  148. Default
  149. {
  150. Radius 6;
  151. Height 8;
  152. Speed 10;
  153. FastSpeed 20;
  154. Damage 3;
  155. Projectile;
  156. +HOMING; // Enable homing behavior
  157. }
  158.  
  159. States
  160. {
  161. Spawn:
  162. FIRE A 1 Bright;
  163. Goto SeekTarget;
  164.  
  165. SeekTarget:
  166. FIRE B 3 Bright A_Chase;
  167. FIRE B 0 A_CustomMissile("HomingFireballTrail", 0, 0, 0, 0);
  168. Goto SeekTarget;
  169. }
  170. }
  171.  
  172. Explanation:
  173. - We create a new class called HomingImpFireball based on the existing DoomImpBall.
  174. - In the Default block, we set properties for the homing fireball:
  175. - Same radius, height, speed, and damage as the Imp's fireball.
  176. - We add the +HOMING flag to enable homing behavior.
  177. - In the States section:
  178. - Spawn: The fireball spawns and immediately transitions to the SeekTarget state.
  179. - SeekTarget: The fireball chases the player (homing behavior) and leaves a trail (custom missile) behind.
  180. Feel free to adjust the properties and behavior to suit your needs. Happy modding! 🚀🔥
Add Comment
Please, Sign In to add comment