Your first PK3 project with ZScript

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.

Your first PK3 project with ZScript

Postby Kruno » Sat Apr 27, 2019 6:11 am

It took me 2 days to cobble the information together to create my first ZScript PK3 project. I will now present it here so future users can benefit.

You need 3 files (no file extensions unless added):

The bare data you need in these files are as follows:

Code: Select allExpand view
GameInfo {
   AddEventHandlers = "Cat"
   forcetextinmenus = true

AddEventHandlers is a list of EventHandlers you have overwritten.

Code: Select allExpand view
version "4.0"

#include "script.zs"

You can include all ZScript files of your project in here. Make sure you place things in the order they are used.

Code: Select allExpand view
class Cat : EventHandler
   Actor player;

   override void WorldLoaded(WorldEvent e)
      self.player = players[consoleplayer].mo;

      Console.Printf("%s", "Activating Mod...");

   override void WorldThingSpawned(WorldEvent e)

      Actor npc = e.Thing;

      if (!npc.bIsMonster
         || npc.IsFriend(self.player)
         || npc.GetClassName() == "Lost Soul") {

      double rand = Random(0, 1);
      if (rand) {

      npc.Health *= Random(2.0, 3.0);

Grabs the player on Map load and prints a message. Also increases health and damage of monsters roughly 50% of the time. I shaded them in at one point but could not get the monsters to look the way I wanted to. I will play with this in future. I also hate Lost Souls!

Create a zip file called whatever name you want, but rename it so the extension is "pk3", copy the above files to it, and drag it onto GZDoom.exe and pick a game to play.


Why post this? I spent 2 days reading the forum, watching videos and reading the wiki, and looking at other people's work before I could get a simple hello world mod working. I figured if I posted this here I can use this as a reference in future and others will have a place to start. I will hopefully follow up with a simple set of tutorials that do things, but in a way that is very simple to follow and understand.
Joined: 27 Apr 2019

Re: Your first PK3 project with ZScript

Postby Tartlman » Thu Sep 05, 2019 7:33 am

Gonna be honest, the title is misleading and this is more of a guide on how to do your first event handler rather than something else. Also, you can probably roll back the required version of zscript to something older, which is a good practice in my opinion.
User avatar
shitposting with zscript
Joined: 11 Oct 2018
Location: meme hell
Discord: bogus#2947
Github ID: boogiebogus

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests