The "How do I..." Thread

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
TheMightyHeracross
Posts: 2100
Joined: Sun Aug 18, 2013 9:41 am
Location: Philadelphia, PA

Re: The "How do I..." Thread

Post by TheMightyHeracross »

Ooh, you want a refiring monster!
Have them use their aiming sprite for acouple of tics, while calling A_FaceTarget.
Then, make them shoot, wait 3-4 tics while still calling A_FaceTarget, then make an extra aiming state that calls A_MonsterRefire, or A_CPosRefire, etc. Put "Goto Missle+1"
Look at the Chaingunner for reference.
User avatar
Rowsol
Posts: 998
Joined: Wed Mar 06, 2013 5:31 am
Contact:

Re: The "How do I..." Thread

Post by Rowsol »

right on, thanks.
User avatar
TheMightyHeracross
Posts: 2100
Joined: Sun Aug 18, 2013 9:41 am
Location: Philadelphia, PA

Re: The "How do I..." Thread

Post by TheMightyHeracross »

Glad to be of help. :)
User avatar
Hell_Pike
Posts: 51
Joined: Thu Aug 29, 2013 4:51 am
Location: Afghanistan

Re: The "How do I..." Thread

Post by Hell_Pike »

Can anyone tell me.... How do I scale down a portrait for the doomguy? I mean to keep the resolution and still scale the image down so it fits in the frame (like using scale on decorate) Is there a way through acs?
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: The "How do I..." Thread

Post by Logan MTM »

What about that?
Logan MTM wrote:How do you create a Actor that only serves to open doors when you approach and close when away?
Any idea?
User avatar
Ral22
Posts: 531
Joined: Sun Sep 05, 2010 12:09 pm
Preferred Pronouns: He/Him
Location: The Fortress of Dr. Radiaki
Contact:

Re: The "How do I..." Thread

Post by Ral22 »

Is it possible to declare a static variable or string in an ACS library with a value, then access said variable with the same value in a map script?
Example from the ACS Library:

Code: Select all

#library "drtalk.acs"
#include "zcommon.acs"
int Talking1 = "Hello";
str Talking2 = "Hello again";
Example from the map ACS:

Code: Select all

#include "zcommon.acs"
#import "drtalk.acs"

Script 1 (Void)
{
SetFont("JFont");
HudMessage(s:Talking1, HUDMSG_PLAIN, 5, 0, 0.5, 0.5, 0);
HudMessage(s:Talking2, HUDMSG_PLAIN, 4, 0, 0.4, 0.4, 0);
}
As of right now, when the messages display, they mysteriously take the string I placed in set font, so I have two messages that state "JFont". If this cannot work, for whatever reason, is it possible to give a value to a global int/str right off the bat? Using "global int 1:Talking1 = "Hello." " causes an error. Any ideas or help with this?
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: The "How do I..." Thread

Post by wildweasel »

Hmm...is there some reason why you couldn't use Language strings for this instead?
User avatar
Ral22
Posts: 531
Joined: Sun Sep 05, 2010 12:09 pm
Preferred Pronouns: He/Him
Location: The Fortress of Dr. Radiaki
Contact:

Re: The "How do I..." Thread

Post by Ral22 »

It's a double-edged sword, really. While the addition of LANGUAGES does make the initial retrieval for HudMessage easier, it raises issues with the HudMessageTime (http://zdoom.org/wiki/Hudmessagetime) function that I use afterwards, since the "strlen" portion of the the script is unable to retrieve from LANGUAGES.

This essentially leaves me with two options: Document the number of characters that are in each string in the LANGUAGE lump, or suggest to the Features Suggestion that "strlen" have added support for LANGUAGE retrieval. I'll probably do both, suggest the feature and then count the characters of my strings in hopes that the suggestion is added. I believe that LANGUAGE use is the way to go, though. Thank you, WildWeasel. You're a god among men.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: The "How do I..." Thread

Post by cocka »

Using "global int 1:Talking1 = "Hello." " causes an error.
For messages use world or global arrays as I did.

ACS library:

Code: Select all

world str 9:uzenetek2[];
or global as you wish :)

Then below:

Code: Select all

script 200 OPEN
{
uzenetek2[0] = "msg1"; // here you can upload your array with elements
uzenetek2[1] = "msg2";
}
Then you can use two functions to calculate the delay for each message with the help of a speed parameter:

Code: Select all

function int ido2(int uzenetszam, int sebesseg) 
{
	int hossz = StrLen(uzenetek2[uzenetszam-1]) << 16;
	return FixedDiv(hossz, sebesseg);
}

function int kiiras(str szoveg, int szin, int x, int y, int uziszam, int sebesseg, int arany)
{
	int eltunes = FixedMul(arany, ido2(uziszam, sebesseg));
	int idotartam = FixedMul(1.0-arany,ido2(uziszam, sebesseg));
	hudmessage(s: szoveg; HUDMSG_FADEOUT|HUDMSG_LOG, 0, szin, x, y, idotartam, eltunes);
	return (FixedMul(35.0,idotartam+eltunes) + 0.5) >> 16;
}
Then you can use these functions in a message displaying script:

Code: Select all

script 112 (int uzenet, int szin, int pozicio) // kiírásos script
{
	int varas;
	int seb = 15.0;
	int elt = 0.35;
	int p = FixedDiv((pozicio << 16),100.0);
	if(uzenet == 5)
	{
	jelzo = 1;
	}
	varas = kiiras(uzenetek2[uzenet-1], szin, 1.5, p, uzenet, seb, elt);
	delay(varas);
	if(uzenet == 5)
	{
	jelzo = 0;
	}
}
The only problem here is that you cannot have five parameters for this script, so you have to give values in the script for the speed (seb) and for the ratio between the duration of showing the message and disappearing the message (elt).

So if you have 0.35, it means that disappearing will be 35% of the whole message displaying time and showing will be 65% of it. The whole message displaying time depends on the length of the message.

Then in your map scripts you can refer to the script 112 like this:

Code: Select all

ACS_ExecuteWait(112, 0, 28, 5, 40);
or if you don't want the actual script to be delayed until the message disappears, then omit the word Wait.
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: The "How do I..." Thread

Post by edward850 »

Ral22 wrote:or suggest to the Features Suggestion that "strlen" have added support for LANGUAGE retrieval.
Which is unlikely to happen (or at least it really really shouldn't happen), seeing as LANGUAGE strings are for creating strings shared between languages, and are unlikely to share the same length. This would make synchronization a bit of a cluster fuck. Well, more so then it is already at the moment.
User avatar
Ral22
Posts: 531
Joined: Sun Sep 05, 2010 12:09 pm
Preferred Pronouns: He/Him
Location: The Fortress of Dr. Radiaki
Contact:

Re: The "How do I..." Thread

Post by Ral22 »

Well, an addition to strlen for LANGUAGE retrieval shouldn't cause any type of issue if the scripts are format correctly. Actually, it would better allow for translations concerning their use in Print and HudMessage so that the messages could support a variety of languages, but still be used by strlen.

For example, your LANGUAGE text could look like this:

Code: Select all

[enu default]
LANG_STRING = "Hello.";

[esn]
LANG_STRING = "Hola.";
Using this LANGUAGE text, when you apply it to a HudMessage script:

Code: Select all

SetPlayerProperty(1,1,4);
SetFont("BIGFONT");
HudMessage(l:"LANG_STRING"; HUDMSG_TYPEON, 1, CR_WHITE, 10.1, 205.1, 0.5, 0.02, 0);
Delay(HudMessageTime(HUDMSG_TYPEON, strlen(l: "LANG_STRING"), 0.02, 0.5, 0));
SetPlayerProperty(1,0,4);
The delay portion will take into account the difference in characters for each language, but should have no synching problems.
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: The "How do I..." Thread

Post by edward850 »

I'm not really sure what you are getting at. One language string has a length of 6, the other has 5. Thus, the delay would be for different lengths, causing SetActorProperty to be called at inconsistent intervals. Now, if what you are saying is "strlen should use the longest string for the delay", then why don't you do that already? You already know how long the string is...
User avatar
Ral22
Posts: 531
Joined: Sun Sep 05, 2010 12:09 pm
Preferred Pronouns: He/Him
Location: The Fortress of Dr. Radiaki
Contact:

Re: The "How do I..." Thread

Post by Ral22 »

@Edward850: Well, I feel that we should continue this discussion in the Suggestion thread I have for this strlen issue (Here: http://forum.zdoom.org/viewtopic.php?f= ... 39#p713839) so we do not derail the purpose of this "How Do I" thread.
User avatar
NerdKoopa
Posts: 56
Joined: Sat Apr 20, 2013 3:20 am

Re: The "How do I..." Thread

Post by NerdKoopa »

Here's a difficult one: Would it be possible to have actors that spawn in random amounts and random positions every time a map is loaded? Let's say there's a sector that's a desk, and there's a coffee cup actor on that desk. Every time the map is loaded, the amount of coffee cups could be anything from one to four. They also could be positioned anywhere within that one desk sector.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: The "How do I..." Thread

Post by cocka »

I would use one or two acs script(s) for this.
Locked

Return to “Editing (Archive)”