Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## You
- What is ZScript?
- ## Copilot
- 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:
- - DECORATE Compatibility: ZScript fully replaces DECORATE, allowing you to create custom classes, structs, and menus. DECORATE classes can even inherit from ZScript ones.
- - Advanced Control: ZScript provides more advanced control over gameplay facets (such as actors, levels, and game modes) compared to DECORATE.
- - UI Creation: You can use ZScript to create custom HUDs, menus, and other user interface elements.
- - File Structure: ZScript files can be included using either full or relative paths. For example:
- - Full path: #include "ZScript/Const.txt"
- - Relative paths: #include "./Items/Health.txt" or #include "../Items/Armor.txt"
- - 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.
- - 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.
- 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! 🚀
- ## You
- Can you give me an example of ZScript?
- ## Copilot
- 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:
- class HealthPotion : CustomInventory
- {
- // Constructor: Set properties for the health potion
- default
- {
- Inventory.Icon "HEALTH1" // Use the health icon from the game's resources
- Inventory.PickupMessage "You found a health potion!"
- Inventory.MaxAmount 1 // Only one health potion can be carried
- }
- // When the player picks up the health potion
- override void PickupUse(PlayerPawn player)
- {
- // Increase player's health by 20 (or up to their maximum health)
- player.Health += 20;
- if (player.Health > player.GetDefaultHealth())
- player.Health = player.GetDefaultHealth();
- // Play a sound effect
- player.PlaySound("misc/healthup", CHAN_ITEM);
- // Remove the health potion from the player's inventory
- Destroy();
- }
- }
- Explanation:
- - We define a new class called HealthPotion that inherits from CustomInventory.
- - In the constructor (default block), we set properties for the health potion:
- - Icon: Uses the health icon from the game's resources.
- - Pickup message: Displays "You found a health potion!" when picked up.
- - MaxAmount: Limits the player to carrying only one health potion.
- - The PickupUse function is called when the player picks up the health potion:
- - It increases the player's health by 20 points (or up to their maximum health).
- - Plays a sound effect.
- - Removes the health potion from the player's inventory.
- Feel free to modify and expand upon this example to create your own custom items in ZScript! 🎮🔍
- ## You
- Can you show me an example of a ZScript weapon?
- ## Copilot
- Certainly! Here's an example of a basic ZScript weapon that closely imitates Doom's Super Shotgun. Let's break down the code:
- class UberShotgun : Weapon
- {
- Default
- {
- Inventory.PickupSound "misc/usgpickup";
- Inventory.PickupMessage "Picked up the Uber Shotgun!";
- Weapon.SelectionOrder 350;
- Weapon.AmmoType "Shell";
- Weapon.AmmoGive 12;
- Weapon.AmmoUse 4;
- Weapon.SlotNumber 3;
- AttackSound "weapons/ubersgf";
- }
- States
- {
- // This sequence is entered when the weapon spawns in the world or is dropped from inventory:
- Spawn:
- USGP A -1;
- Stop;
- // This sequence is used while you have this weapon selected:
- Ready:
- USHG A 1 A_WeaponReady;
- Loop;
- // This sequence is entered when you select this weapon:
- Select:
- USHG A 1 A_Raise;
- Loop;
- // This sequence is entered when you deselect the current selected weapon:
- Deselect:
- USHG A 1 A_Lower;
- Loop;
- // The attack sequence. Entered while the player presses the Fire button while the weapon was ready:
- Fire:
- USHG A 3;
- USHG A 7
- {
- A_FireBullets(13.4, 9.2, 50, 10);
- A_GunFlash(); // Plays the weapon's Flash sequence on a separate layer
- }
- USHG B 7;
- USHG C 7 A_CheckReload; // If the weapon runs out of ammo here, it'll be deselected
- USHG D 7 A_StartSound("weapons/sshoto", CHAN_WEAPON);
- USHG E 7;
- USHG F 7 A_StartSound("weapons/sshotl", CHAN_WEAPON);
- USHG G 6;
- TNT1 A 0 A_StartSound("weapons/sshotc", CHAN_WEAPON);
- USHG HHHHHHAAAAA 1 A_ReFire;
- Goto Ready;
- // The weapon's flash animation which is drawn on a separate layer:
- Flash:
- USGF A 6 bright A_Light1;
- Goto LightDone; // LightDone resets the light created by A_Light1
- }
- }
- Explanation:
- - We define a new class called UberShotgun based on the Weapon class.
- - In the Default block, we set properties for the Uber Shotgun:
- - Pickup sound and message.
- - Ammo type, amount given, and usage.
- - Slot number and attack sound.
- - The States section defines various sequences:
- - Spawn: When the weapon spawns or is dropped.
- - Ready: While the weapon is selected.
- - Select: When the weapon is chosen.
- - Deselect: When the weapon is deselected.
- - Fire: The attack sequence, including firing bullets and playing the gun flash.
- - Flash: The weapon's flash animation.
- Feel free to modify and expand upon this example to create your own custom weapons in ZScript! 🎮🔫
- : Creating new weapons (ZScript) - ZDoom Wiki
- : Weapon slots - ZDoom Wiki
- : ZScript_Basics | ZScript entry guide
- : ZScript - ZDoom Wiki
- : ZScript - Beginner/Intermediate Weapons Tutorial - PureZC
- ## You
- Can you write a simple homing Imp fireball in ZScript?
- ## Copilot
- 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:
- class HomingImpFireball : DoomImpBall
- {
- Default
- {
- Radius 6;
- Height 8;
- Speed 10;
- FastSpeed 20;
- Damage 3;
- Projectile;
- +HOMING; // Enable homing behavior
- }
- States
- {
- Spawn:
- FIRE A 1 Bright;
- Goto SeekTarget;
- SeekTarget:
- FIRE B 3 Bright A_Chase;
- FIRE B 0 A_CustomMissile("HomingFireballTrail", 0, 0, 0, 0);
- Goto SeekTarget;
- }
- }
- Explanation:
- - We create a new class called HomingImpFireball based on the existing DoomImpBall.
- - In the Default block, we set properties for the homing fireball:
- - Same radius, height, speed, and damage as the Imp's fireball.
- - We add the +HOMING flag to enable homing behavior.
- - In the States section:
- - Spawn: The fireball spawns and immediately transitions to the SeekTarget state.
- - SeekTarget: The fireball chases the player (homing behavior) and leaves a trail (custom missile) behind.
- Feel free to adjust the properties and behavior to suit your needs. Happy modding! 🚀🔥
Add Comment
Please, Sign In to add comment