Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Craigs

How do I change the color of an NPC marine's armor

Recommended Posts

I've noticed that in a lot of wads, those NPC marines have different colored armor. At first, I thought it was a voodoo doll trick, but it isn't. Then I thought they were custom sprites but still no. So how do you change one of those Zdoom NPC's armor color?

Share this post


Link to post
Enjay said:

I'm having a little trouble with this.

#include "zcommon.acs"
  script 1 OPEN
  {
	PrintBold(s:"Palleteshifting...");
	//Pallete shifting the four marines at level start
	CreateTranslation (1, 112:127=32:47);
	CreateTranslation (2, 112:127=32:47);
	CreateTranslation (3, 112:127=32:47);
	CreateTranslation (4, 112:127=32:47);
  }
It prints the message, but doesn't do the specified recolours on those Things.

Share this post


Link to post

You also have to give the marines the translation:

http://www.zdoom.org/wiki/index.php?title=Thing_SetTranslation

You have set up 4 identical translations. You don't need to do that. You can set up one translation and give it to 4 different things. Assuming you are giving your marines tids 1,2,3 and 4 it should look something like this:

script 1 OPEN
{
CreateTranslation (1, 112:127=32:47);
Thing_SetTranslation(1, 1);
Thing_SetTranslation(2, 1);
Thing_SetTranslation(3, 1);
Thing_SetTranslation(4, 1);
}

The first number in CreateTranslation is an index for the translation you have created. So, you use Thing_SetTranslation to give that translation number to any items with the specified tid. Of course, unless you need your marines to all have different tids, they can all share the same tid and cut down on the script still further.

script 1 OPEN
{
CreateTranslation (1, 112:127=32:47);
Thing_SetTranslation(1, 1);
}

Share this post


Link to post

Bumping this thread for a follow-up question.

I'd like to change an actor's color dynamically within one of its actor states. Unfortunately the list of action functions doesn't seem to offer anything to accomplish this, so I'm guessing I'll have to create a custom ACS script for this instead, passing the R,G,B values as arguments in ACS_NamedExecute.

I came up with the following script:

Script "Colorize" (int R, int B, int G)
 {
  CreateTranslation (99, 0:255=%[0,0,0]:[R,G,B]);
  Thing_SetTranslation(5, 99);
  Delay(1);
 }
The Thing ID (5) is just something I made up for now. What should I replace it with, considering that I may be calling this script from a number of different actors, all of which I'm assuming have their own IDs? Can it be done this way?

Share this post


Link to post

If you use CallACS from the actor's DECORATE code, you can use 0 as the TID for Thing_SetTranslation.

I'm not sure, however, redefining the same translation all the time will work out as you expect it...

Share this post


Link to post

I see. So it would be more advisable to simply create a script for each colorization, assigning each translation a unique ID (95,96,97...)?

EDIT:

It's not working yet:

Script "ColorizeRed" (void)
 {
  CreateTranslation (98, 0:255=%[0,0,0]:[1,0,0]);
  Thing_SetTranslation(0, 98);
  Delay(1);
 }
This is how I call it in decorate:
TNT1 A 0 ACS_NamedExecute("ColorizeRed")
What did I miss?

Share this post


Link to post

Still trying to get this work. I could simply create new sprites with the desired color in image editing program, but I'd like to learn to do this in a smarter way.

Are there any WADs that might already have a script like this, that I could take look at? I don't mean recoloring monsters or players upon entering a map, but instead during the play.

Share this post


Link to post

I don't know why you posted that link, as I already knew what functions I'm going to need.

Anyway, I also happened to find the problem.

This was wrong: "CreateTranslation (98, 0:255=%[0,0,0]:[1,0,0])"
It has to be: "CreateTranslation (98, 0:255=%[0.0,0.0,0.0]:[1.0,0.0,0.0])" (though slightly more compact 0:255=%[0,0,0]:[1.0,0,0] seems to work as well)

What a headache over a simple matter...

Share this post


Link to post
D2Jk said:

I don't know why you posted that link, as I already knew what functions I'm going to need.


You have this:

TNT1 A 0 ACS_NamedExecute("ColorizeRed")


The WIKI states this:

ACS_ExecuteWithResult — runs a script and uses its return value.
ACS_NamedExecuteWithResult — runs a named script and uses its return value.
CallACS — shorter alias for ACS_NamedExecuteWithResult.

From that I would assume that you have to use

TNT1 A 0 ACS_NamedExecuteWithResult("ColorizeRed")


Or as Gez suggested:

TNT1 A 0 CallACS("ColorizeRed")

Share this post


Link to post

Well, ACS_NamedExecute has worked well in my previous scripts.

But in fact, I'm currently just using "TNT1 A 0 Thing_SetTranslation(0, 98)" (a script creates the translation). Apparently this works too.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×