Woes Learning ACS Scripting

Need help with your project? Ask here.
User avatar
Herculine
Doom Kitty
Posts: 70
Joined: Mon Feb 22, 2010 3:44
Location: Ohio
Contact:

Woes Learning ACS Scripting

Post by Herculine » Sat May 26, 2012 15:14

I want to learn to do some ACS scripting, so I thought I'd start with something simple but I can't get it to work in the game. I followed a script example from the ZDoom wiki and acc151 compiled it with no errors, yet the script doesn't appear to do what it's intended to do in the game: make the SKY3 texture be shown instead of the SKY1 texture at the beginning of the first map of Doom II.

Code: Select all

#library "skyflip"
#include "zcommon.acs"

script 1 OPEN
 {
   ChangeSky("SKY1","SKY3");
 }
I'm loading the script in a WAD with A_START and A_END markers around the ACS lump and a LOADACS lump containing the exact name of the ACS lump. Still, I don't see anything happen in the game.

Obviously I must be doing something wrong, but I can't figure out what. Any help would be greatly appreciated.

User avatar
Gez
Developer
Developer
Posts: 1393
Joined: Mon Oct 22, 2007 16:47

Re: Woes Learning ACS Scripting

Post by Gez » Sat May 26, 2012 18:20

It's not "changesky(oldsky, newsky)", it's "changesky(sky1, sky2)". The sky2 part is because alternate skies and double skies are possible.

changesky("sky3", "sky3") should do what you want.

User avatar
Herculine
Doom Kitty
Posts: 70
Joined: Mon Feb 22, 2010 3:44
Location: Ohio
Contact:

Re: Woes Learning ACS Scripting

Post by Herculine » Sat May 26, 2012 18:32

Thanks. That works.

But now what I'm unclear on is how I could set that up to apply different skies in different instances; i.e. I don't want to replace every sky in Doom II with Sky3 but rather would like to replace Sky2 and Sky3 with different sky textures as well. That's why I thought the first variable would be the old sky.

User avatar
Gez
Developer
Developer
Posts: 1393
Joined: Mon Oct 22, 2007 16:47

Re: Woes Learning ACS Scripting

Post by Gez » Sat May 26, 2012 21:14

There are three ways to have multiple skies in ZDoom:

1. Alternate skies with sky1 and sky2. Limited to two skies. You can change both with ChangeSky.
2. [wiki]Static_Init[/wiki] sky transfer. You can then change the sky by changing the upper texture of the init line.
3. [wiki]Skybox[/wiki] with sky pickers. You can move the camera to a different place; or change the skybox sector's textures.

User avatar
Herculine
Doom Kitty
Posts: 70
Joined: Mon Feb 22, 2010 3:44
Location: Ohio
Contact:

Re: Woes Learning ACS Scripting

Post by Herculine » Sun May 27, 2012 4:29

I'm hoping to do it in an interchangeable way that isn't tied down to a specific map, so options 2 and 3 are probably out. In option 1 how would the scripts know which sky to load and when?

I apologize if these are lame noob questions, but the wiki really doesn't do much for beginners.

User avatar
Gez
Developer
Developer
Posts: 1393
Joined: Mon Oct 22, 2007 16:47

Re: Woes Learning ACS Scripting

Post by Gez » Sun May 27, 2012 7:27

A level normally has only one sky. Replacing sky1 changes it. In 95% of the cases, it'll be enough. If you don't want to replace the sky if the level uses SKY2 rather than SKY1, then too bad, there are no ways of knowing that from ACS.

A level can have two skies in the Hexen fashion (assuming it's not a doublesky). Replacing sky2 then also changes that other sky.

A level can have further skies in the manners I described. You will not be able to affect them at all with changesky. You can replace sky transfers selectively with [wiki]ReplaceTextures[/wiki], but that still won't cover skyboxes, which are used much more often than sky transfers in ZDoom levels.

User avatar
Herculine
Doom Kitty
Posts: 70
Joined: Mon Feb 22, 2010 3:44
Location: Ohio
Contact:

Re: Woes Learning ACS Scripting

Post by Herculine » Sun May 27, 2012 14:00

It sounds as though ChangeTexture is what I'll need to use, however...

Just for the sake of testing and learning, I copied the example from the wiki EXACTLY but the compiler doesn't seem to like it:

Code: Select all

script 1 OPEN
  {
    Delay(60);
    ChangeTexture("FLOOR0_1","BLOOD1");
  }
"Function changetexture is used but not defined."

Of course the wiki page does not tell one how to define it. It's almost as frustrating as one of Bethesda's wikis.

User avatar
Blue Shadow
Global Moderator
Global Moderator
Posts: 304
Joined: Sun Aug 29, 2010 6:09

Re: Woes Learning ACS Scripting

Post by Blue Shadow » Sun May 27, 2012 14:09

You need to have this line at the top of your script lump:

Code: Select all

#include "zcommon.acs"
Your script lump should look like this:

Code: Select all

#include "zcommon.acs"

script 1 OPEN
  {
    Delay(60);
    ChangeTexture("FLOOR0_1","BLOOD1");
  }

User avatar
Herculine
Doom Kitty
Posts: 70
Joined: Mon Feb 22, 2010 3:44
Location: Ohio
Contact:

Re: Woes Learning ACS Scripting

Post by Herculine » Sun May 27, 2012 14:25

Sorry, I omitted that when copying the code snippet to the post, but it was in fact in there when I tried to compile the script. Here's EXACTLY how my code looks:

Code: Select all

#library "skyflip"
#include "zcommon.acs"

script 1 OPEN
  {
    Delay(60);
    ChangeTexture("FLOOR0_1","BLOOD1");
  }
Still I get the error: "Function changetexture is used but not defined."

Again, apologies for my noobness.

User avatar
Blue Shadow
Global Moderator
Global Moderator
Posts: 304
Joined: Sun Aug 29, 2010 6:09

Re: Woes Learning ACS Scripting

Post by Blue Shadow » Sun May 27, 2012 15:54

Heh, that example you copied it from got it wrong; it's ReplaceTextures not ChangeTexture.

User avatar
Gez
Developer
Developer
Posts: 1393
Joined: Mon Oct 22, 2007 16:47

Re: Woes Learning ACS Scripting

Post by Gez » Sun May 27, 2012 15:56

I hadn't paid attention to the example, but it was obviously wrong as it didn't use the actual name of the function. Fixed the doc.

Still, I'm not sure you'll be able to do what you want with it. The texture used on a sky ceiling or sky floor is actually F_SKY1, not whatever is projected in the sky...

User avatar
Herculine
Doom Kitty
Posts: 70
Joined: Mon Feb 22, 2010 3:44
Location: Ohio
Contact:

Re: Woes Learning ACS Scripting

Post by Herculine » Sun May 27, 2012 17:06

:P

Now the script compiles fine. Thanks for that. Unfortunately, I don't see my script doing anything in the game.

I've tried:

Code: Select all

#library "skyflip"
#include "zcommon.acs"

script 1 OPEN
{
  ReplaceTextures("RSKY1","RSKY3");
}
...and this:

Code: Select all

#library "skyflip"
#include "zcommon.acs"

script 1 OPEN
{
  ReplaceTextures("SKY1","SKY3");
}
...and even this (though I didn't expect it to work):

Code: Select all

#library "skyflip"
#include "zcommon.acs"

script 1 OPEN
{
  ReplaceTextures("FSKY1","SKY3");
}
I'm puzzled, but I'm going to continue to tinker with it...

You may be right, Gez; it might not work for skies.

User avatar
Blue Shadow
Global Moderator
Global Moderator
Posts: 304
Joined: Sun Aug 29, 2010 6:09

Re: Woes Learning ACS Scripting

Post by Blue Shadow » Sun May 27, 2012 19:46

If you're only concerned about vanilla Doom maps then the following script might do what you need:

[spoiler]

Code: Select all

Script "Sky changer" Open
{
  int cluster = GetLevelInfo(LEVELINFO_CLUSTERNUM); // Stores the cluster number in the 'cluster' variable

  Switch(cluster) // Selects and applies the desired sky depending on the cluster
  {
    Case 1: // Cluster #1: Episode 1 of Ultimate Doom
      ChangeSky("SKY10", "SKY10");
      Break;

    Case 2: // Cluster #2: Episode 2 of Ultimate Doom
      ChangeSky("SKY11", "SKY11");
      Break;

    Case 3: // Cluster #3: Episode 3 of Ultimate Doom
      ChangeSky("SKY12", "SKY12");
      Break;

    Case 4: // Cluster #4: Episode 4 of Ultimate Doom
      ChangeSky("SKY13", "SKY13");
      Break;

    Case 5: // Cluster #5: Map01 - Map06 of Doom 2
      ChangeSky("SKY14", "SKY14");
      Break;

    Case 6: // Cluster #6: Map07 - Map11 of Doom 2
      ChangeSky("SKY15", "SKY15");
      Break;

    Case 7: // Cluster #7: Map12 - Map20 of Doom 2
      ChangeSky("SKY16", "SKY16");
      Break;

    Case 8: // Cluster #8: Map21 - Map30 of Doom 2
      ChangeSky("SKY17", "SKY17");
      Break;

    Case 9: // Cluster #9: Map31 of Doom 2
      ChangeSky("SKY18", "SKY18");
      Break;

    Case 10: // Cluster #10: Map32 of Doom 2
      ChangeSky("SKY19", "SKY19");
      Break;
  }
}
[/spoiler]
Edit: Don't forget to use valid sky textures. The ones I put there in the script are just examples.

User avatar
Herculine
Doom Kitty
Posts: 70
Joined: Mon Feb 22, 2010 3:44
Location: Ohio
Contact:

Re: Woes Learning ACS Scripting

Post by Herculine » Sun May 27, 2012 21:28

Thanks Blue Shadow! I think you've got me on the right path now. It looks like I can also use "LEVELINFO_LEVELNUM" to make this work on the basis of each individual map, which was what I had in mind all along. I owe you one!

User avatar
Herculine
Doom Kitty
Posts: 70
Joined: Mon Feb 22, 2010 3:44
Location: Ohio
Contact:

Re: Woes Learning ACS Scripting

Post by Herculine » Mon May 28, 2012 2:25

Oh, and just so I don't feel like I just popped in here to get somebody to write a script for me, here's how I've used what I've learned to create a script that will relentlessly seek out and replace those awful Wolfenstein textures no matter where they might try to hide:

Code: Select all

#library "WOLFCHANGER"
#include "zcommon.acs"

Script "WOLFCHANGER" Open
{
        ReplaceTextures("ZZWOLF1","WOLF100");
	ReplaceTextures("ZZWOLF2","WOLF200");
	ReplaceTextures("ZZWOLF3","WOLF300");
	ReplaceTextures("ZZWOLF4","WOLF400");
	ReplaceTextures("ZZWOLF5","WOLF500");
	ReplaceTextures("ZZWOLF6","WOLF600");
	ReplaceTextures("ZZWOLF7","WOLF700");
	ReplaceTextures("ZZWOLF9","WOLF900");
	ReplaceTextures("ZDOORF1","WOLF1000");
	ReplaceTextures("ZELDOOR","WOLF1100");
	ReplaceTextures("ZZWOLF10","WOLF1200");
	ReplaceTextures("ZZWOLF11","WOLF1300");
	ReplaceTextures("ZZWOLF12","WOLF1400");
	ReplaceTextures("ZZWOLF13","WOLF1700");
	ReplaceTextures("ZDOORB1","WOLF1800");
}
Thanks again guys for the help. I might try to tackle some other scripts now!

Post Reply

Return to “Editing Help”