ZScript Console Print for only 1 Player in coop

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

ZScript Console Print for only 1 Player in coop

Postby peewee_RotA » Fri Jun 04, 2021 10:38 am

I am having a lot of trouble making heads or tails of all of the console print commands. I just want to print a string to the screen of one player if I have a reference to their actor. For example in TakeSpecialDamage I have the source actor, and I want to print a message only to that player's screen.

Pretty much only the ACS versions of print commands are fully documented. The majority of all printing to the screen (like item pickups) seems to be behind native functions, and the remaining examples are in the StatusBar code and seem to be a dead end. All of the existing versions of Print I can find print to all players in the coop game. So I'm wondering if there is any resource anywhere that explains how the console print commands work in ZSCRIPT and how they can be scoped only to a single actor (if that actor is a player of course)

Here's the code snippet so far:

Code: Select allExpand view
const SNEAK_ATTACK_BONUS = 3.0;
class MyBaseMonsterClass : Actor
{
...
   override int TakeSpecialDamage(Actor inflictor, Actor source, int damage, Name damagetype)
   {
      let hereticPlayer = CustomPlayerClass(source);
      if (hereticPlayer)
      {
         //Sneak attack
         if (target != hereticPlayer)
         {
            damage *= SNEAK_ATTACK_BONUS;
            Console.Printf("Surprise Attack!"); //Want this to print only to the hereticPlayer actor
               
            sneakDelay = 0;
         }
      }
      
      return Super.TakeSpecialDamage(inflictor, source, damage, damagetype);
   }   
...
}
peewee_RotA
 
Joined: 07 Feb 2014

Re: ZScript Console Print for only 1 Player in coop

Postby Jarewill » Fri Jun 04, 2021 1:17 pm

ZScript can also make use of DECORATE's A_Print functions.
You can try using this:
Code: Select allExpand view
source.A_Print("Surprise Attack!");

This will make the source actor use the A_Print function, printing a text on their screen.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: ZScript Console Print for only 1 Player in coop

Postby peewee_RotA » Fri Jun 04, 2021 2:37 pm

Awesome! Thanks!
peewee_RotA
 
Joined: 07 Feb 2014


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests