[ACS] Individual messages per classes in a message for everyone?

Discuss all aspects related to modding Zandronum here.
User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Individual messages per classes in a message for everyone?

#1

Post by FranckyFox2468 » Sun Mar 19, 2017 7:36 pm

I'm not sure how to do this but, i'm currently wondering how to make a hudmessage assigned to everyone. No not HudMessageBold. Like when a single player walks on a line for instance a dialogue done via hudmessage appear, but depending on the current player's class, they get a different message based upon what they are currently playing all simultaneously. Like everyone gets a dialogue at the same time based upon the current event of the map but the message the player will see will vary on their current player class. Is this possible?

User avatar
Fused
Contributor
Posts: 658
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

[ACS] Re: Individual messages per classes in a message for everyone?

#2

Post by Fused » Sun Mar 19, 2017 7:45 pm

Code: Select all

script 1 OPEN {
	for(int i = 0; i < 64; ++i)
	{
		if(!playeringame(i))
			continue;
			
		SetActivator(i + UNIQUEIDMAYBE);
		hudmessage(s:"a message"; HUDMSG_FADEINOUT, 0, CR_WHITE, 0.0, 1.0, 5.0, 0.4, 1.0);
	}
}
this will go through all ids used by a player and send a message to them.
My mods
Image Image

My socials
Image Image

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#3

Post by FranckyFox2468 » Sun Mar 19, 2017 8:15 pm

Fused wrote:

Code: Select all

script 1 OPEN {
	for(int i = 0; i < 64; ++i)
	{
		if(!playeringame(i))
			continue;
			
		SetActivator(i + UNIQUEIDMAYBE);
		hudmessage(s:"a message"; HUDMSG_FADEINOUT, 0, CR_WHITE, 0.0, 1.0, 5.0, 0.4, 1.0);
	}
}
this will go through all ids used by a player and send a message to them.
I'm not too sure i understand this script but i suppose all i have to had is a branch that verifies the player class and it gives them a dialogue based upon the class they are currently playing?

EDIT:
I tried a thing

Code: Select all

script 1 (void)
{
	SetActivator(0,AAPTR_NULL);
	if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_PLAYERCLASS) == 0)
		ACS_Execute(2, 0);
	else
		Print(s:"you are class 2, holy shit");
}
Problem is that it checks who activated the script first and no not what YOU are playing
EDIT2: Nevermind it just doesn't check the class whatever the value...

User avatar
Kaminsky
Developer
Posts: 193
Joined: Sun Apr 14, 2013 7:17 pm
Location: Canada

[ACS] Re: Individual messages per classes in a message for everyone?

#4

Post by Kaminsky » Sun Mar 19, 2017 9:10 pm

Try using PlayerClass() to get the class number the player is playing as. You can use Fused's code as an example and do a bunch of checks or use arrays to preview different messages for each distinct class.

Another thing to know if you're using GetPlayerInfo(..., PLAYERINFO_PLAYERCLASS) is that it doesn't always return what class the player is currently but what they have selected from a CVAR. Here's what it says on the ZDoom Wiki:
Note that this is the player class the player has selected (playerclass cvar), not necesarilly the one the player is currently playing with - to get the current player class number, use PlayerClass.

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#5

Post by FranckyFox2468 » Sun Mar 19, 2017 10:54 pm

Hm, cause the mod i am currently working on has some story dialogue activated by scripts and i want the dialogue to be different depending on the character the player is playing, so in co-op each get a unique dialogue on their own depending on who they took. But i suppose that's not possible?

Also i still have no clue how Fuse's script work...

User avatar
Kaminsky
Developer
Posts: 193
Joined: Sun Apr 14, 2013 7:17 pm
Location: Canada

[ACS] Re: Individual messages per classes in a message for everyone?

#6

Post by Kaminsky » Mon Mar 20, 2017 2:03 am

The script iterates through all 64 players, first checking if the player currently exists in the game. If so, it sets them as the activator of the script using their TID and player number. From there, HudMessage can display a message for that specific player only. Of course, this script doesn't always have to be an OPEN script in order to work.

From what I said before, there are ways to check which class a player is using so you can execute different things specific to that class. The function I mentioned is a suggestion for how you could accomplish this. Keep in mind that the order in which you define player classes in either the MAPINFO/KEYCONF lumps is what gives each class their unique number which is returned from this function.

User avatar
Fused
Contributor
Posts: 658
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

[ACS] Re: Individual messages per classes in a message for everyone?

#7

Post by Fused » Thu Mar 30, 2017 7:37 am

Here's the code again, but with a bunch of comments.

Code: Select all

script 1 OPEN {
	// This loop will run 64 times, because the maximum amount of players allowed in Zandronum is 64.
	// Although you should try and learn how a constant works, because this should be one, for convenience sake.
	for(int i = 0; i < 64; ++i)
	{
		// This function checks if the player with the given ID is currently in the game (i in this case will be 0 - 63, your ID is zero-indexed, so that's why i isn't 1-64)
		// This function takes an ID and not a TID, because you can't check if things are in the game.
		if(!playeringame(i))
		{
			// This will continue the loop. i will be incremented by one before restarting.
			continue;
		}
		
		// This function will change the activator of the script. Right now the activator is the server (-1) because the script is an OPEN script.
		// If the script was an ENTER script, whoever joined at the time, triggering the script, will be the activator.
		// If the script was of type void, whoever activated the script will be the activator.
		// This function takes a TID and not an ID, because anyone or anything can claim activation of this script.
		// This means that you can literally make a stimpack the activator of this script, aslong as you gave it its own TID.
		// You should give each player his own TID, by running an ENTER script with Thing_ChangeTid(0, PLAYER_TID + PlayerNumber()).
		// So in this case i is the playernumber() of the player, and PLAYER_TID is the number added to the player so we can distinguish their TID with others.
		SetActivator(i + PLAYER_TID);
		
		// This will print a message.
		// This is different to hudmessagebold, because this will only run for the activator of the script, which we changed with the line above.
		hudmessage(s:"a message"; HUDMSG_FADEINOUT, 0, CR_WHITE, 0.0, 1.0, 5.0, 0.4, 1.0);
	}
}
My mods
Image Image

My socials
Image Image

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#8

Post by FranckyFox2468 » Sat Apr 01, 2017 7:34 pm

Oh, so like at the final part i can do a class check and jump to the proper message or even activate an entirely different script to play the proper dialogue?

Also this is getting complicated. according to Zdoom wiki i should re-assign the damn TID whenever a player respawn.

also im not sure if i am doing this right. i did:

Code: Select all

script 1 enter
{
Thing_ChangeTid(0, 66666 + PlayerNumber());
}
and then

Code: Select all

script 3 (void) {

   for(int i = 0; i < 64; ++i)
   {

      if(!playeringame(i))
      {
         continue;
      }
      SetActivator(i + 66666 + PlayerNumber());
      hudmessage(s:"a message"; HUDMSG_FADEINOUT, 0, CR_WHITE, 0.0, 1.0, 5.0, 0.4, 1.0);
   }
}
but it doesn't do anything when i activate it.

EDIT: nvm, it was because the message was in the middle of the hud and i had to change its positionning to see it. Anyway thanks a ton, i'll play around with this further more and give you some news when i experimented a bit more

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#9

Post by FranckyFox2468 » Sat Apr 01, 2017 8:13 pm

Okay i came into another issue. The script if activated by the player is fine and even checks the specific class., but then i decided to spawn a bot to let him walk on the test activation line and the script does not activate at all for me when it should. What am i doing wrong?

Code: Select all

script 1 enter
{
Thing_ChangeTid(0, 66666 + PlayerNumber());
}

script 2 (void) {

   for(int i = 0; i < 64; ++i)
   {

      if(!playeringame(i))
      {
         
         continue;
      }
 
      SetActivator(i + 66666 + PlayerNumber());
      

            switch(PlayerClass(PlayerNumber()))
      {
            case 0:
                 ACS_Execute(3, 0);
                 break;
            case 1:
                 ACS_Execute(4, 0);
                 break;
            case -1:
                 break;
            default:
                 //something happened but we are just gonna break
                 break;
        }
   }
}

User avatar
Fused
Contributor
Posts: 658
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

[ACS] Re: Individual messages per classes in a message for everyone?

#10

Post by Fused » Sat Apr 01, 2017 8:31 pm

Do you mean it wont activate anymore for you as soon as the bot has walked over it?

Also, just get used to making a seperate player.acs files which will handle every single way a player can enter/interact with scripts. It takes getting used to but is a great help.
Here's what I use for DoomZ

Code: Select all

script "Player_Enters" ENTER
{
	Thing_ChangeTid(0, PLAYER_TID + PlayerNumber());
	
	delay (35);
	SetZombies(5);
}

script "Player_Enters_Client" ENTER CLIENTSIDE
{
	ACS_NamedExecuteAlways("music_main", 0);
	
	while (PlayerInGame(PlayerNumber()) && IsAlive())
	{
		GetItemInfo(PlayerNumber());
		Delay(1);
	}
}

script "Player_Respawns" RESPAWN
{
	ACS_NamedExecute("Player_Enters", 0);
}

script "Player_Respawns_Client" RESPAWN CLIENTSIDE
{
	ACS_NamedExecute("Player_Enters_Client", 0);
}
Although much more is possible if you need it. Just call the main enter script for respawning, which saves a lot of size.
My mods
Image Image

My socials
Image Image

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#11

Post by FranckyFox2468 » Sat Apr 01, 2017 9:00 pm

Fused wrote:Do you mean it wont activate anymore for you as soon as the bot has walked over it?
Yes, exactly, and it won't even give me my own message. Cause im trying to do a single use script that activates for EVERYONE and gives them a respective message depending on the class they play but when i send a bot walk on the line to test it i get nothing and when i walk over i still get nothing.

User avatar
Fused
Contributor
Posts: 658
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

[ACS] Re: Individual messages per classes in a message for everyone?

#12

Post by Fused » Sat Apr 01, 2017 10:08 pm

try

Code: Select all

if (!playeringame(i) || PlayerIsBot(i))
My mods
Image Image

My socials
Image Image

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#13

Post by FranckyFox2468 » Sat Apr 01, 2017 11:47 pm

Fused wrote:try

Code: Select all

if (!playeringame(i) || PlayerIsBot(i))
Won't budge. I replaced the "if(!playeringame(i))" section. Unless i had to put this earlier?

User avatar
Fused
Contributor
Posts: 658
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

[ACS] Re: Individual messages per classes in a message for everyone?

#14

Post by Fused » Sat Apr 01, 2017 11:49 pm

Nope, that should've worked. Are you sure your line is set to trigger multiple times? Does no error appear? Does no error appear either when enabling cl_showwarnings and using zandronum 3.0?
My mods
Image Image

My socials
Image Image

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#15

Post by FranckyFox2468 » Sun Apr 02, 2017 12:02 am

I have all of these verified and nothing.

Ill resend the script and part of the dialogue to verify:

Code: Select all

script 1 enter
{
Thing_ChangeTid(0, 66666 + PlayerNumber());
}

script 2 (void) {
   for(int i = 0; i < 64; ++i)
   {
      if (!playeringame(i) || PlayerIsBot(i))
      {
         continue;
      }
            switch(PlayerClass(PlayerNumber()))
      {
            case 0: //class 1
                 ACS_Execute(3, 0);
                 break;
            case 1: //class 2
                 ACS_Execute(4, 0);
                 break;
            case -1:
                 break;
            default:
                 break;
        }
   }
}

SCRIPT 3 (void)
{
  SetFont("SMALLFONT");
  HudMessage (s:"Hey Marine.\nI'm just here to remind you that you are still \na disapointement.";HUDMSG_TYPEON, 5, CR_GOLD, 0.5,0.05, 2.5, 0.05, 0.2);
  Delay(1);
  SetFont("GUMFA002");
  HudMessage(s:"A"; HUDMSG_PLAIN, 6, 0, 0.85, 0.025, 0);
   Delay(5*35);
  SetFont("GUMFA001");
  HudMessage(s:"A"; HUDMSG_PLAIN, 6, 0, 0.85, 0.025, 0);
  //
  Delay(1*35);
  SetMugShotState("Talk");
  SetFont("SMALLFONT");
  HudMessage (s:"Uh...Thanks?";HUDMSG_TYPEON, 5, CR_GOLD, 0.5,0.05, 2.5, 0.05, 0.2);
  Delay(2*35);
  SetMugShotState("Normal");
}
tbh i only understand how half of this works .-.

User avatar
ZZYZX
Posts a lot
Posts: 742
Joined: Thu Jun 07, 2012 5:56 pm
Location: Ukraine
Clan: A3
Clan Tag: [A3]

[ACS] Re: Individual messages per classes in a message for everyone?

#16

Post by ZZYZX » Sun Apr 02, 2017 10:19 am

FranckyFox2468 wrote:Also this is getting complicated. according to Zdoom wiki i should re-assign the damn TID whenever a player respawn.
That's done in a RESPAWN script.
Also don't forget to deassign the old one first, corpses have TIDs and that is very likely to break everything.

Alternatively a more reliable way is having a looping 1-tic ENTER script that constantly sets your TID to something if your health is above 0, and DEATH script that sets your TID to 0.
The difference with the more known classic method is that this also supports "resurrect" CCMD (which doesn't really invoke ENTER or RESPAWN scripts...) and still ensures that player corpses don't have a TID.

Here's an example from my old map.

Code: Select all

script 6 ENTER
{
    while (true)
    {
        if (GetActorProperty(0, APROP_Health) > 0)
            Thing_ChangeTID(0, 12000+PlayerNumber());
        Delay(1);
    }
}

script 9 DEATH
{
    Thing_ChangeTID(0, 0);
}

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#17

Post by FranckyFox2468 » Sun Apr 02, 2017 12:58 pm

I feel like this script is gon get so complicated, knowing my skill with ACS its almost 100% sure to get in the way of other things at this rate <_>

User avatar
Cutman
 
Posts: 66
Joined: Mon Jun 04, 2012 2:25 pm
Contact:

[ACS] Re: Individual messages per classes in a message for everyone?

#18

Post by Cutman » Sun Apr 02, 2017 3:06 pm

The ACS_Executes in the switch statement should probably be ACS_ExecuteAlways otherwise they will not run if the script is already running (for example if two classes are the same). Also the activator of the script needs to be changed in the for loop, or else only the player who activated script 2 is going to see those HudMessages. SetActivator(66666 + i) before the switch statement should do the trick.

Here's my take:

Code: Select all

script 2 (void) {

   for(int i = 0; i < 64; ++i)
   {
      if (!playeringame(i) || PlayerIsBot(i))
      {
         continue;
      }
	  
	  SetActivator(66666 + i);
	  
            switch(PlayerClass(PlayerNumber()))
      {
            case 0: //class 1
                 ACS_ExecuteAlways(3, 0);
                 break;
            case 1: //class 2
                 ACS_ExecuteAlways(4, 0);
                 break;
            case -1:
                 break;
            default:
                 break;
        }
   }
}

SCRIPT 3 (void)
{
  SetFont("SMALLFONT");
  HudMessage (s:"Hey Marine.\nI'm just here to remind you that you are still \na disapointement.";HUDMSG_TYPEON, 5, CR_GOLD, 0.5,0.05, 2.5, 0.05, 0.2);
  Delay(1);
  SetFont("GUMFA002");
  HudMessage(s:"A"; HUDMSG_PLAIN, 6, 0, 0.85, 0.025, 0);
   Delay(5*35);
  SetFont("GUMFA001");
  HudMessage(s:"A"; HUDMSG_PLAIN, 6, 0, 0.85, 0.025, 0);
  //
  Delay(1*35);
  SetMugShotState("Talk");
  SetFont("SMALLFONT");
  HudMessage (s:"Uh...Thanks?";HUDMSG_TYPEON, 5, CR_GOLD, 0.5,0.05, 2.5, 0.05, 0.2);
  Delay(2*35);
  SetMugShotState("Normal");
}

script 500 respawn
{
ACS_ExecuteAlways(501,0);
}

script 501 enter
{
Thing_ChangeTid(0, 66666 + PlayerNumber());
}

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#19

Post by FranckyFox2468 » Sun Apr 02, 2017 3:21 pm

Cutman wrote:The ACS_Executes in the switch statement should probably be ACS_ExecuteAlways otherwise they will not run if the script is already running (for example if two classes are the same). Finally the activator of the script needs to be changed in the for loop, or else only the player who activated script 2 is going to see those HudMessages. SetActivator(66666 + i) before the switch statement should do the trick.

Here's my take:

Code: Select all

script 2 (void) {

   for(int i = 0; i < 64; ++i)
   {
      if (!playeringame(i) || PlayerIsBot(i))
      {
         continue;
      }
	  
	  SetActivator(66666 + i);
	  
            switch(PlayerClass(PlayerNumber()))
      {
            case 0: //class 1
                 ACS_ExecuteAlways(3, 0);
                 break;
            case 1: //class 2
                 ACS_ExecuteAlways(4, 0);
                 break;
            case -1:
                 break;
            default:
                 break;
        }
   }
}

SCRIPT 3 (void)
{
  SetFont("SMALLFONT");
  HudMessage (s:"Hey Marine.\nI'm just here to remind you that you are still \na disapointement.";HUDMSG_TYPEON, 5, CR_GOLD, 0.5,0.05, 2.5, 0.05, 0.2);
  Delay(1);
  SetFont("GUMFA002");
  HudMessage(s:"A"; HUDMSG_PLAIN, 6, 0, 0.85, 0.025, 0);
   Delay(5*35);
  SetFont("GUMFA001");
  HudMessage(s:"A"; HUDMSG_PLAIN, 6, 0, 0.85, 0.025, 0);
  //
  Delay(1*35);
  SetMugShotState("Talk");
  SetFont("SMALLFONT");
  HudMessage (s:"Uh...Thanks?";HUDMSG_TYPEON, 5, CR_GOLD, 0.5,0.05, 2.5, 0.05, 0.2);
  Delay(2*35);
  SetMugShotState("Normal");
}

script 500 respawn
{
ACS_ExecuteAlways(501,0);
}

script 501 enter
{
Thing_ChangeTid(0, 66666 + PlayerNumber());
}
Thanks for the help but neither works.

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Individual messages per classes in a message for everyone?

#20

Post by FranckyFox2468 » Sun Apr 02, 2017 7:09 pm

Been thinking, wouldn't making a script that gives an inventory item that upon activation checks the inventory and gives the proper script be simpler? Unless that would be bad?

Post Reply