A Liilte Scripting Help Please

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.
Locked
User avatar
mac53
Posts: 251
Joined: Sun Dec 17, 2006 11:15 am
Location: Delmarva Peninsula, MD USA
Contact:

Post by mac53 »

Zippy wrote:
mac53 wrote:Yes, those commands are supposed to available on the Linedef commands!
There's no "supposed to". They ARE available for use as linedef actions. All you have to do is put in the correct number. If you put in the number and nothing shows up in the editor, it just means the editor doesn't recognize it. ZDoom, however, will recognize it with no problems, and will do the appropriate action.

If you want your editor to recognize it you either: 1) wait for a new version of the editor to come out, or 2) update the editor's configuration yourself.
That's cool... yeah someone else said that... I just have a small problem understanding how Zdoom will see and recognise something if the editor doesn't see, it in order to put it in the map, for Zdoom to see it! !.... :?

--------------------------------------------------------------------------------------
How do I write the script to get a monster to drop an item, such as a key, mega-sphere, etc. when he's killed?
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Post by Zippy »

mac53 wrote:I just have a small problem understanding how Zdoom will see and recognise something if the editor doesn't see, it in order to put it in the map, for Zdoom to see it!
You're just not understanding exactly how it works. It goes something like this:

In your editor when you edit the linedef, you get the option to put a number on it which represents some sort of action. If you put 16 on it, the editor will go "Well, alright, I'll do it, but as far as I know 16 is absolutely nothing." So no extra information, like the name of the special, gets displayed. The line still, however, gets 16 assigned to it.

When the map gets loaded up into ZDoom, ZDoom will come across this linedef and look at it. It will see that is has number 16 and go, "Ah! 16! That's [wiki]Transfer_WallLight[/wiki]! I better go apply that special."

See the thing is that ZDoom knows what the number means, and the editor doesn't know what it means. All that matters to get it to work is that ZDoom knows what it is.
mac53 wrote:How do I write the script to get a monster to drop an item, such as a key, mega-sphere, etc. when he's killed?
Scripting isn't the best choice for this. [wiki]DECORATE[/wiki] works better. Create a new monster inherited from the old and just have it drop the item. For example, if you want a Hell Knight that drops a red key:

Code: Select all

ACTOR HellKnightRedKey : HellKnight 12345
{
   DropItem RedCard
}
The number 12345 in this example is the Doom editor number. This lets you actually place your red key dropping monster on the map (by placing a thing and using this number.)
User avatar
mac53
Posts: 251
Joined: Sun Dec 17, 2006 11:15 am
Location: Delmarva Peninsula, MD USA
Contact:

Post by mac53 »

:lol: ha ha ha ...

Excellent, excellent explaination! Man, you have No idea how greatful I am by you taking the time explain that to me as you did... Thank you my friend!

Zip... I'm not familiar with Decorate at-all. I heard a ton about and seen it in maps when I open them up in Xwe, but I have not a clue. Now, I have written my own Animdefs though. I also know that the coding for the Decorate Lumps is a diiferent language then that of acc scripting. Is a Decorate entry done like doing an animdef? Using notepad?
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Post by Zippy »

mac53 wrote:Is a Decorate entry done like doing an animdef? Using notepad?
Yes, DECORATE is plain text, so the only thing you need to make it is a text editor. If you know how to do ANIMDEFS then doing some very basic DECORATE shouldn't be a problem.

If you just want to do the item dropping thing for now, then you aren't going to need to do much more than what I posted above. I'd still recommend reading up about [wiki]DECORATE[/wiki] on the wiki if you have time at some point. It is one of the key features of ZDoom.

So, making an monster which can drop an item. If you are planning on having an already existing monster drop an already existing item it should be pretty quick an simple. All you need to do is define a new ACTOR which inherits from the existing one, and is given a new drop list composed of the item you want to drop (just as posted above.) For the correct class names of items and monsters, you can look at the [wiki]Classes[/wiki] list on the wiki. So all you have to do is find the monster you want to drop the item, and the item you want to drop in the list. Then just do something like posted above. In fact, I'll copy it and explain it.

Code: Select all

ACTOR HellKnightRedKey : HellKnight 12345
{
   DropItem RedCard
}
Here's what's going on:
  • ACTOR - This is declaring that you are defining a new actor for the game.

    HellKnightRedKey - This is the name of the new actor you are defining. It can be anything you want, so long as it is unique (meaning you can't name it just "HellKnight", since there is already an actor with that name.) It's best to name it something that makes some sense. In this case, since the monster is just going to be a Hell Knight which drops a red key card, "HellKnightRedKey" makes plenty of sense.

    : HellKnight - This colon is saying that the new actor that is being defined is inheriting from the actor class which follows. Since we want to make a HellKnight which drops a red key, inheriting from the HellKnight class is what we want to do. This means the new actor copies all the properties, flags, and states of a HellKnight (in otherwords, it behaves exactly like a HellKnight except for what we change.) When you look at the [wiki]Classes[/wiki] list on the wiki you'll notice that HellKnight is there. Getting the class names correct is IMPORTANT. If, for example, you wanted to make an imp which drops something, you have to inherit from the class DoomImp, and not just Imp (which doesn't exist.)

    12345 - This is the Doom editor number. Again, it can be any number you want so long as it is unique. Making it unique is pretty simple as most of the stock things in the game have low numbers. Any good 5 digit number should cover it. You don't have to give new actors Doom editor numbers, but if you want to place them directly in maps via an editor then you need to. When you place a thing in a map, its type is specified by a Doom editor number. To place your new actor in a map, put in a thing with the number you have specified here.

    { ... } - Inside these two braces is the definition of the new actor. Since it inherits from [wiki=Classes:HellKnight]HellKnight[/wiki], it already has everything from that. All we have to do here is put what we want to change.

    DropItem RedCard - This property says that when the actor dies it will drop an actor of the class "RedCard", which, if you look on the [wiki]Classes[/wiki] list, you will see it is the class name of the red key card.
That's the rough of how it works. If you want to make a monster which drops something all you basically have to do is copy that and change the class names for what monster you want to inherit from and which item you want to drop. This all goes into a plaintext lump called DECORATE, done the same way you put together an ANIMDEFS lump.

Again, read up about [wiki]DECORATE[/wiki] when you can.
User avatar
mac53
Posts: 251
Joined: Sun Dec 17, 2006 11:15 am
Location: Delmarva Peninsula, MD USA
Contact:

Post by mac53 »

I sure will....

Thank you, Zippy... Again, I don't know how to express my gratitude, for the time you have taken to teach me these things! In my eyes, you are brilliant...
User avatar
mac53
Posts: 251
Joined: Sun Dec 17, 2006 11:15 am
Location: Delmarva Peninsula, MD USA
Contact:

Post by mac53 »

Zippy wrote:You're just not understanding exactly how it works. It goes something like this:

In your editor when you edit the linedef, you get the option to put a number on it which represents some sort of action. If you put 16 on it, the editor will go "Well, alright, I'll do it, but as far as I know 16 is absolutely nothing." So no extra information, like the name of the special, gets displayed. The line still, however, gets 16 assigned to it.

When the map gets loaded up into ZDoom, ZDoom will come across this linedef and look at it. It will see that is has number 16 and go, "Ah! 16! That's [wiki]Transfer_WallLight[/wiki]! I better go apply that special."

See the thing is that ZDoom knows what the number means, and the editor doesn't know what it means. All that matters to get it to work is that ZDoom knows what it is.
Ok, I understand now about the entry of "16", Transfer_WallLight" command. My next question is; Now, that Zdoom knows I want to apply wall light to something, how does it know where, how much and other attributes to apply? Like when I set the Transfer_FloorLight, I need to tag the dummy sector to show where I want this applied. Is it done the same way? By applying a tag? I think it just dawned on me as I was writing this! :oops:
User avatar
Phobus
Posts: 5984
Joined: Thu May 05, 2005 10:56 am
Location: London
Contact:

Post by Phobus »

There is a line action which is Set_LineID (same place as Set_LineHorizon). Set the first argument to the ID you want and then reference that ID in the wall light transfer line.
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Post by Zippy »

To get [wiki]Transfer_WallLight[/wiki] to work you'll want to also use [wiki]Line_SetIdentification[/wiki], as Phobus has suggested. What Line_SetIdentification does is apply a "tag" to a line, much the same way as you can tag sectors. So, as the wiki page describes for Transfer_WallLight, you need the lineID of the line you want to receive the properties, so this is the line whose ID you set.

So, a full example would be like this. You want some wall in the map to be full bright in a 128 light level room. If that wall is a single linedef, you select that line and give it the special Line_SetIdentification. Line_SetIdentification has 3 meaningful parameters right now, but we only care about the first one, which is the actual lineID. This is the "tag" that the line will receive. For an example, "1" will do. It helps to write all the tags you have used down somewhere. I find putting them in a comment at the top of the level's script is a handy place to put them; e.g

Code: Select all

#include "zcommon.acs"

/*
 * LineIDs
 * 1 - 8   : Bright walls in the big room
 * 9 & 10  : Custom switch
 * 11 - 14 : Fading walls
 */

...
Now that the wall we want to light up is "tagged" with an ID, we can refer to it with certain specials. Transfer_WallLight takes an ID as its first parameter. If we want the wall we tagged to be full bright, then we find (or make) a line in a sector whose light level is 255 and give it the special Transfer_WallLight. We give the first parameter as 1 (the ID of the line we want to light up) and the second parameter as 1 also (if we only want the front side to light up. As the wiki shows, the second parameter is a flag parameter. You can pick any of the values or add them together to combine effects. E.g. 1 transfers the light level to the front, 2 transfers it to the back, and 3, which is 1 + 2 transfer it to the front and back.)

Now when you load the map up in ZDoom, the wall which was tagged with an ID of 1 should be at full brightness, despite the rest of the sector it is a part of having 128 brightness.
User avatar
mac53
Posts: 251
Joined: Sun Dec 17, 2006 11:15 am
Location: Delmarva Peninsula, MD USA
Contact:

Post by mac53 »

Zip...

I working on my first Decorate Lump and I have a question because the monster I'm working with is the revenant.

What's confusing to me is that when I get the drop-down from my editor for the monsters to get the necessary info I need for the lump, I'm getting "revenant2"! When I look into the Zdef.acs the monster is showing as just a "revenant" [T_Revenant]. Will this cause any issues?
-------------------------------------------------------------------------------------

Ok...

I tried the decorate's format you have shown me and I can't get it function!
I went to the wiki and tried to understand about the "Actor's" properties and flags. For me.... useless!

I just want to thank everyone here who has tried to help me for their time and efforts!
User avatar
mac53
Posts: 251
Joined: Sun Dec 17, 2006 11:15 am
Location: Delmarva Peninsula, MD USA
Contact:

Another Request

Post by mac53 »

Code: Select all

#include "zcommon.acs"

script 1 (void)
{
   while(getactorproperty(2, APROP_Health) > 0)
   {
    Thing_SpawnNoFog (const:1,38,64);
    }
}
I've tried to study the wiki the best of my ability and I still can't get this one to work. What I'm trying to do is to get the "Revenant" [tid2] to spawn a "Red Skull Key" [38] when killed. I keep getting this error...

Code: Select all

 Regular Hexen Format

Line    5:    while(getactorproperty(2, APROP_Health) > 0)
Function getactorproperty is used but not defined
Please help.... Thank you.
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Post by Zippy »

First, the DECORATE solution:

Code: Select all

ACTOR RevenantRedSkullKey : Revenant 12345
{
   DropItem RedSkull
}
This works because you are making a new ACTOR which inherits from the class "Revenant" (which is the Doom Revenant) and makes the change of having it drop an actor of "RedSkull" (which is Doom's red skull key) upon death. Its Doom editor number is 12345, so you can place it in a map by dropping in a thing and using that number for the type number.

Second, the ACS solution is almost correct. There are only two problems. First, you'd want to put a [wiki]delay[/wiki] in the loop so that it doesn't become a runaway script. When a script executes, everything actually stops for that script to run. If your script loops without some kind of delay, then nothing else in the game would get a chance to go, so ZDoom terminates it as a runaway script. Second, the number 38 for the red skull key is wrong. Thing_SpawnNoFog is looking one of the [wiki]Doom Spawn Numbers[/wiki], and not a Doom editor number (that's a little confusing with so many numbers, I'll give you that. 38 was a very good guess.) The spawn number for the red skull key is 89, as listed on the Doom Spawn Numbers page. In order to increase script readability, there's actually a define for it: T_REDSKULLKEY. You can put that anywhere in a script where a number it taken and it just means 89. So:

Code: Select all

#include "zcommon.acs"

script 1 (void)
{
   while( GetActorProperty(2, APROP_Health) > 0)
   {
      Thing_SpawnNoFog (const:1, T_REDSKULLKEY, 64); // Spawn a red skull key at MapSpot tagged 1
      delay(4);  // Prevent runaway script
   }
}
That should compile. It does for me. If it doesn't for you, then there is some outside problem (perhaps not the latest version of [wiki]ACC[/wiki]?)

Using DECORATE means you get the Revenant to actually drop the key upon death. With the scripting solution, you can have the key spawn at a specific spot, along with adding other actions later if you wish.
User avatar
mac53
Posts: 251
Joined: Sun Dec 17, 2006 11:15 am
Location: Delmarva Peninsula, MD USA
Contact:

Post by mac53 »

I tried the docorate solution before... no good. It just won't drop the key.

Other than that... Thank you..

-------------------------------------------------------------------------------------

Tried the script, this is what I got...

Code: Select all

Regular Hexen Format

Line    5:    while( GetActorProperty(2, APROP_Health) > 0) 
Function getactorproperty is used but not defined
> }  
>  ^
-------------------------------------------------------------------------------------

Ok... I took your advise and changed my compiler from the deepacc I was using to the most recent acc.exe I downloaded from here. After this I got no errors but, the red skullkey was there all the time whether the revenant was killed or not. So, I tried a couple of things. 1st, I changed the (void) to open, instead of using a trigger line, no change! 2nd, I changed the [> 0] to [< 0] and the damn key didn't show up at all! I used [=] in place of [<>] and the compiler errored. Somehow or another the script is not paying attention to the [GetActorProperty] statement and it's either giving me the key whether the revenant's dead or not.
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Post by Zippy »

mac53 wrote:I tried the docorate solution before... no good. It just won't drop the key.
I can copy and paste what I posted above into a new DECORATE lump and it works for me. If I summon a RevenantRedSkullKey it drops it on death. You may not be placing it in the map properly. Try placing an imp in the map somewhere and going into its properties. You want to find the field which has 3001, which is an imp's Doom editor number. Change that to 12345 (the editor number of the new monster) and it should work.
mac53 wrote:After this I got no errors but, the red skullkey was there all the time whether the revenant was killed or not. So, I tried a couple of things. 1st, I changed the (void) to open, instead of using a trigger line, no change! 2nd, I changed the [> 0] to [< 0] and the damn key didn't show up at all! I used [=] in place of [<>] and the compiler errored. Somehow or another the script is not paying attention to the [GetActorProperty] statement and it's either giving me the key whether the revenant's dead or not.
Sounds to me like maybe the Revenant doesn't have the right TID. Are you it has a TID number of 2? The first argument of GetActorProperty is the TID of the actor you want information on. If the revenant doesn't have 2 as its TID, then it probably isn't working because GetActorProperty would be returning either the health of something else, or the health of nothing at all, which would be 0, thus spawning the key immediately.
User avatar
mac53
Posts: 251
Joined: Sun Dec 17, 2006 11:15 am
Location: Delmarva Peninsula, MD USA
Contact:

Post by mac53 »

Zippy wrote:Sounds to me like maybe the Revenant doesn't have the right TID. Are you it has a TID number of 2? The first argument of GetActorProperty is the TID of the actor you want information on. If the revenant doesn't have 2 as its TID, then it probably isn't working because GetActorProperty would be returning either the health of something else, or the health of nothing at all, which would be 0, thus spawning the key immediately.
Yes, the revenant does have a Tid of 2, I made sure of that. What you said here does make sense though. Then there has to be some way to enter it properly so that the script is constantly monitoring the health of the revenant to know when its health reaches "0".

I'll try that Lump entry again. I use Xwe to open my test map. I then click on 'new entry" from the drop-down and name it "DECORATE", then I open that and copy-paste the command into that entry. I'm then asked if I want to save the changes and I click yes. I close Xwe, then open the map in my editor... on the revenant I open up the "Things Special" option and here is where I see my new entry. I click on that and save it. I drop the test map in my port engine to fire it up. I head on in and play around with the revenant until it bites the big one! Nothing happens. This is what I've done before with the Decorate entry Zip. The instruction you just laid out for is exactly what I've done before. I'll try it again, though. I really need to try to get this straightened out in script. I've learned that Decorate is mainly used for changing things!
User avatar
mac53
Posts: 251
Joined: Sun Dec 17, 2006 11:15 am
Location: Delmarva Peninsula, MD USA
Contact:

Post by mac53 »

Zippy wrote:I can copy and paste what I posted above into a new DECORATE lump and it works for me. If I summon a RevenantRedSkullKey it drops it on death. You may not be placing it in the map properly. Try placing an imp in the map somewhere and going into its properties. You want to find the field which has 3001, which is an imp's Doom editor number. Change that to 12345 (the editor number of the new monster) and it should work.
------------------------------------------------------------------------------------

Following your instructions about "Decorate" was a mistake!!! Doing so, this is what I got from my port engine when I tried to launch the test wad;

Error: [ "while" is an unknown actorproperty. ]

Error: [ "getactorproperty" is an unknown actor property. ]
Locked

Return to “Editing (Archive)”