Creating a torch in GZDoom

Hello there!

I'm currently developing a survival horror mod for GZDoom that makes use of all its OpenGL features. One feature that I would like to implement in the game is the function to pick up torches that are placed on the wall, and the player can walk around with them for a while before burning out. The idea is that the torch has a dynamic light function, and I'm hoping that it would be possible to get the torch to work on the player (so walking around actually lits the dark envirements somewhat.

Since I'm terrible at DECORATE, I'm hoping that somebody can help me out with this, and that in turn I learn a little more about making my own objects for later use. :)

Share this post


Link to post

this is a quick-made actor that should do the work... i have not tested it so you may have to mess a bit with the frame duration and the frames number to get it work.

Actor torch : weapon
{
Weapon.AmmoGive 100
Weapon.AmmoType "torchammo"
Weapon.AmmoUse 4
Weapon.SlotNumber 1
inventory.pickupmessage "a torch"
inventory.pickupsound "optional sound lump name here"
+WEAPON.NOAUTOFIRE
+WEAPON.NOALERT
states
{
Spawn:
TORC A -1
stop
Ready:
TORC A 0 A_CheckReload
TORC ABCABC 5 bright A_WeaponReady
TORC A 0 A_TAKEINVENTORY ("torch", 1)
loop
Deselect:
TORC A 1 bright A_Lower
loop
Select:
TORC A 1 bright A_Raise
loop
Fire:
TORC CDEF 3 bright
TORC G 3 bright A_CustomMeleeAttack (7,"optional attack sound here", "optional miss sound here", "fire")
TORC A 0 A_CheckReload
goto Ready
}
}

actor torchammo : Ammo
{
inventory.pickupmessage ""
inventory.amount 100
inventory.maxamount 100
inventory.icon ""
ammo.backpackamount 100
ammo.backpackmaxamount 200
states
{
Spawn:
TORG A -1
stop
}
}

Share this post


Link to post

Thanks alot Cacowad! I'm trying to read the code a bit so I don't get confused.

The code specifies its own set of ammo, for which there is 100 by default. There's a pickup sound I can specify.

Also some very retarded DECORATE questions: If I just place the sound that I want in my WAD, can I link it to the pickup sound like that?

Edit: I also can't get the torch to show up in Doom Builder 2...

Share this post


Link to post
Agentbromsnor said:

Thanks alot Cacowad! I'm trying to read the code a bit so I don't get confused.

The code specifies its own set of ammo, for which there is 100 by default. There's a pickup sound I can specify.

Also some very retarded DECORATE questions: If I just place the sound that I want in my WAD, can I link it to the pickup sound like that?

Edit: I also can't get the torch to show up in Doom Builder 2...


1: you are welcome, i do not know anything about gzdoom light settings, i just hope it work somehow.

2: yep, you can directly link your sound lump to the decorate.

3: just add a very large number ( > 14165 ) near the name of the actor.

es:

Actor torch : weapon 16000
{
[...]
}

Share this post


Link to post
Cacowad said:

1: you are welcome, i do not know anything about gzdoom light settings, i just hope it work somehow.

2: yep, you can directly link your sound lump to the decorate.

3: just add a very large number ( > 14165 ) near the name of the actor.

es:

Actor torch : weapon 16000
{
[...]
}


I had some help with the rest of the decorate, you can check it out above because I'm having some kind of error. I tried sticking an GLDEFS to it, for the dynamic light but its not working.

For the sound, I'm guessing I need to put in a sounddef lump to define it right?

Share this post


Link to post

flickerlight FLICKER
{
    color <RED> <GREEN> <BLUE>
    size <SIZE>
    secondarySize <SECSIZE>
    chance <CHANCE>
    [offset <X> <Y> <Z>]
    [subtractive <SUB>]
    [dontlightself <DLS>]
}

    SECSIZE: The second size to flicker (will alternate between SIZE and SECSIZE). SECSIZE must be greater than SIZE.
    CHANCE: The chance, each frame, that it will flicker to the second size. 
you missed some instructions. secsize must be greater than size and there must be a chance to get from one to another.

i'm trying to set it working properly, tomorrow i will retry it again.

also i made some errors in the decorate code, i will post the fixed version very soon.

another thingy thing: how do you want your torch? it have infinite time of usage or not? it will drop particles?

Share this post


Link to post
Cacowad said:

flickerlight FLICKER
{
    color <RED> <GREEN> <BLUE>
    size <SIZE>
    secondarySize <SECSIZE>
    chance <CHANCE>
    [offset <X> <Y> <Z>]
    [subtractive <SUB>]
    [dontlightself <DLS>]
}

    SECSIZE: The second size to flicker (will alternate between SIZE and SECSIZE). SECSIZE must be greater than SIZE.
    CHANCE: The chance, each frame, that it will flicker to the second size. 
you missed some instructions. secsize must be greater than size and there must be a chance to get from one to another.

i'm trying to set it working properly, tomorrow i will retry it again.

also i made some errors in the decorate code, i will post the fixed version very soon.

another thingy thing: how do you want your torch? it have infinite time of usage or not? it will drop particles?


My idea is to have the torch run for like 2 minutes or something before it runs out. From that point you can just pick another one. Particles? Will it look 'realistic'? I'm trying to make the mod as realistic as possible within the convines of GZDoom ofcourse, but if it looks nice like that then why not. :)

You are awesome! I'll make sure to credit your work when I'm reaching beta!

Share this post


Link to post
GreyGhost said:

Why not just borrow the Heretic torch and adapt it for your purposes?


Do you have to use it through inventory? Because I'd like to have the player use the torch as a 'weapon', not fondle though their inventory.

Share this post


Link to post
GreyGhost said:

Why not just borrow the Heretic torch and adapt it for your purposes?


i have already thinked about that, but it lit the whole map, probably Agentbromsnor want a limited-ranged one instead...

btw: i am studing gldef propertyes and dynamic object binding, i will post a quite correct code this evening.

Share this post


Link to post

there is! a beta version of the torch, it have a ridiculus ammo usage (each ammo last 1/8 second on a total of 2 minutes duration), i will find out a way to make it work smooth enougth and reduce ammo.

//this is a comment.
//this is a comment too.

Actor torch : weapon 6000 
{
Game Doom
Weapon.AmmoGive 960 //is 120*8, this actor use 8 ammo units for second, for a total of 120 seconds usage.
Weapon.AmmoType "torchammo"
Weapon.AmmoUse 32
Weapon.SlotNumber 1
inventory.pickupmessage "a torch"
inventory.pickupsound "optional sound lump name here"
+WEAPON.NOAUTOFIRE
+WEAPON.NOALERT     //this weapon will not alert monsters
states
{
Spawn:
	TORC A -1
	stop
       Ready:
        TORC A 0 A_WeaponReady
        TORC A 4 bright A_spawnitemex ("torchlight", 0, 0,28, 0, 0, 0, 0, SXF_SETMASTER, 0) //spawn a dummy actor that light the area.
        TORC A 0 A_jump (256, "burning")
	loop
      Burning:
        TORC A 0 bright A_CheckReload //deselect the torch if there is no more ammo.
        TORC A 0 bright A_TakeInventory ("torchammo", 1) //take away 1 unit of ammo. 
        Goto Ready
      Deselect:
	TORC A 1 bright A_Lower
	TORC A 1 bright 
	loop
	Select:
	TORC A 1 bright A_Raise
	loop
	Fire:
	TORC CDEF 3 bright A_spawnitemex ("torchlight", 0, 0,28, 0, 0, 0, 0, SXF_SETMASTER, 0) //a dummy torch attak, just in case you want it.
	TORC A 0 bright A_Light2
	TORC G 4 bright A_CustomMeleeAttack (7,"optional attack sound here", "optional miss sound here", "fire")
	TORC A 1 bright A_Light0
	TORC A 0 A_CheckReload
	goto Ready
	}
}

actor torchammo : Ammo
{
Game Doom
inventory.pickupmessage ""
inventory.amount 960
inventory.maxamount 960
inventory.icon ""
ammo.backpackamount 1920
ammo.backpackmaxamount 1920
states
{
Spawn:
TORG A -1
stop
}

}


ACTOR torchlight //this actor was needed in order to use dynamic ligthing, it seems that can be used only on spawned actors, not on the weapons of the player.
{
        Game Doom
	Radius 1
	Height 1
	Speed 0
        Damage 0
        Projectile
        reactiontime 1
        States
        {
        Spawn:
                TNT1 A 4 BRIGHT Light ("FLICKER3") A_CountDown //tnt1 is an invisible sprite native in (G)zdoom, this actor will vanish as long as it enter to fake the light of a moving torch.
                Loop
        Death:
                TNT1 A 0 BRIGHT Light ("FLICKER3")
                Stop
        }
}
i will comment the code later, so you may learn something from it.

no particles added yet.

also i had to modify a bit the gldef. i will try after dinner the other options.
pulselight FLICKER3
{
    color 0.30 0.21 0.12
    size 800
    secondarySize 900
    interval 10
} 

Share this post


Link to post

Did you test it out yet? I'm curious!

Cacowad said:

i have already thinked about that, but it lit the whole map, probably Agentbromsnor want a limited-ranged one instead...

btw: i am studing gldef propertyes and dynamic object binding, i will post a quite correct code this evening.


Indeed, I think the limited range is the better option.

If everything works out, I will ofcourse give you full credit! :)

Share this post


Link to post

yes i have tested it already, just copy the text to make it work.

WARNING: this actor NEED a dummy weapon (like non-damanging fist) to swict to in order to save ammo and/or when there is no more ammo to use.

also if there is something that you want to change, just ask, i will try to do it ;)

Share this post


Link to post

Haha, it works like a charm! I love how it is subtle in a realistic way, but gives you enough light for it to be helpfull!

Are you on MSN perhaps, so I can consult you more often for DECORATE in my mod?

Share this post


Link to post

glad you liked it ;)

you mean messenger? i never really used it, but i log on doomworld every day nowaday, just pm me if you need something, i will be glad to help (even if i am still a newbye here...).

Share this post


Link to post
Cacowad said:

glad you liked it ;)

you mean messenger? i never really used it, but i log on doomworld every day nowaday, just pm me if you need something, i will be glad to help (even if i am still a newbye here...).


I'm logged on MSN almost all day, but if you don't use it then this will work too. :)

Did you say that this torch was just a beta?

Share this post


Link to post

oh, well, yes, it has a ridiculus ammo amount/usage that's all, but it is fully effective, also it is in fact a beta until you decide to make it definitive :P i will mess a bit on the code now.

regarding MSN i am usually out all day long without an internet connection, so i don't know how much it could be effective (also i had forgot what was my account, so i probably have to redo it).

Share this post


Link to post

Well, you don't perse need MSN, but I figured it would be handy for communication since I'm pretty much online on there all the time. :) I don't mind posting here though.

I'm contemplating a bit on if I should do a HUD sprite for the torch. Probably not because I don't want to make the game seem 'cartoony'. It does need a pick up actor though, and I think I would need to make a 3D model for that. I could go with a sprite but again, it would make the game look cartoony and I don't want to throw the atmosphere out the window.

I can make the model in Wings 3D and use MilkShape to export it to MD3 format. Would you know how to use this as a pick up representation for the torch, in DECORATE?

I also noticed that the torch doesn't seem to run out. I think it would be nice to have it run out in 2 minutes or so, and present the player with a short message "Torch burned up" or something like that, so that the player knows whats going on.

I hope I'm not overwhelming you with requests here, haha! :)

Share this post


Link to post
Cacowad said:

WARNING: this actor NEED a dummy weapon (like non-damanging fist) to swict to in order to save ammo and/or when there is no more ammo to use.

ACTOR UselessFist : Fist replaces Fist
{
+WEAPON.NOALERT
States
  {
   Fire:
     Goto Ready
   }
}
that's it. you may add this as a "sister weapon" to the torch, or add it trought ACS. if you want the torch totally removed after it's use, you have once again to rely on ACS.

I can make the model in Wings 3D and use MilkShape to export it to MD3 format. Would you know how to use this as a pick up representation for the torch, in DECORATE?


yes, surely.


a message can be done with a little modification of the code. just replace the old "burning" state with this one.

Burning:
        TORC A 0 bright A_JumpIfNoAmmo ("Noammo") //deselect the torch if there is no more ammo.
        TORC A 0 bright A_TakeInventory ("torchammo", 1) //take away 1 unit of ammo. 
        Goto Ready
Noammo:
        TORC A 0 A_Print ("the torch burned up")
        Goto Deselect

I hope I'm not overwhelming you with requests here, haha! :)


i don't mind, you are welcome ;) yes msn would be handy, if i only remember what was my account... i will send it to you when i will find it .-. until that there is a pm function on the forum (that i never used btw) tht will supply for now.

Share this post


Link to post

The message part worked perfectly. As soon as it ran out though, the torch started flickering (the white block placeholder started going up and down).

Could it be that there's some kind of loop in the code that causes this?

Also, if you remember your MSN account let me know. :) I can send you the texture WAD through PM if you like? Makes testing a bit smoother I think.

Share this post


Link to post

you added the dummy weapon at the start of the map or when you pickup the torch? it is VERY important until i find a way to remove the torch itself from the inventory [oh, well i have already found it, the command is A_TakeInventory ("torch",1) i just need to test it].
regarding the texture pack, if you already have the torch's sprites it could help.

OT: man, your project could be a lot more interesting than the slenderman series, there is very simple code behind it, only fixed points; if you don't alredy know, take a look at "ImScared".

Share this post


Link to post
Cacowad said:

you added the dummy weapon at the start of the map or when you pickup the torch? it is VERY important until i find a way to remove the torch itself from the inventory [oh, well i have already found it, the command is A_TakeInventory ("torch",1) i just need to test it].
regarding the texture pack, if you already have the torch's sprites it could help.

OT: man, your project could be a lot more interesting than the slenderman series, there is very simple code behind it, only fixed points; if you don't alredy know, take a look at "ImScared".


Ah! I've put the "takeinventory" command in the ACS of my level to make sure you start with no weapons. I think you can also turn off cheating with a mapinfo lump, so that should prevent players from running around with a shotgun. :)

I don't have any sprite for the torch, but I have made a basic model for it. I hope I'm not making it too difficult for you to make a modeldef? I've made the model with a ring around the torch that attaches to the wall. My idea is to make two seperate models, one with both the torch and the ring, and one with just the ring, so it will look as if you picked the torch out of the ring. Would that be possible to do?

Thanks alot, and yes, I've seen a lets play of ImScared and it looked great! :) My mod was somewhere in the 700 spot of most popular mods on ModDB today, so that makes me anxious to get a beta out and see how well people will pick it up.

Also, you've got PM! :)

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