I'm making a game which involves fire
, but I will need a lot of help creating some of the scripts to make it work, so rather than make a ton of separate threads, I'm going to bundle them all into this one.
Premise / What I've got so far
Ignite is all based around the idea of trying to keep a flame alight, or else you die. I've accomplished the basic functionality on my own, this includes:
A choice of three 'weapons' (i.e. light sources) the player can choose from.
Each light source has a designated dynamic light that follows the player at all times, but it is only called to switch on when the player is 'armed' with that particular light source.
Over time, each light source decreases in range and becomes redder.
Torches can be relit by approaching other torches and clicking on them.
Oil lamps can be refueled by finding pots of oil.
Lanterns can't be refueled, but the player can increase or decrease the brightness of the light to see further (but the burn speed increases if they do this), or decreases to see less but converse fuel.
Your choice of light source effects how fast you can walk.
As each light dies, the gradual sound of whispering demons fades in. If the light level gets too low, you die. I have successfully coded death, respawning, and resetting of light source default states.
'Safezones' can be designated at the start and end of the level where the demons can't get you.
With that in mind, I'm now moving onto more complex functionality. This thread is where I will ask for help when I get stuck. And right now I'm stuck on one of the most fundamental aspects of the game...
Problem #1: Flaming torches
I'd like to find a way to make the flaming torch the player carries actually appear on fire, and have this fire decrease in intensity as the torch burns out. I have two theories on how to do this; 1) animated textures, but I don't think this will permit me the control I need over the flames themselves, and 2) particles, which is where I'm stuck.
I've studied up on how to attach particle emitters to specific limbs, which is fine for characters, but doing this for weapons seemed to be impossible because I don't know how to call the entityid of whichever HUD.X the player is using. If anyone knows how to do this, this would be a godsend.
Not being able to attach a particle emitter to the weapon itself is a bit of the problem, especially because the torch will eventually itself be animated.
My current workaround is to attach the particle emitter to the dynamic light assigned to the torch, which I can
get the id of. I was surprised to find the SetLightPosition command does not infact move the light entity itself, just the point light source. This has meant trying to script the entity itself to move with the player, but offset slightly because the torch is held slightly ahead of and to the right of the player. This is...sort of...working, apart from when the player looks up or down.
Parenting the position of the light to the player will help, though I can't help thinking this isn't the best solution for the particle emitter. If anyone knows how to parent particles emitters to weapons, let me know!
Here is the torch script I'm currently messing with; it's attached to a dynamic light. The script references entityid's and weaponid's you may not have, so if you want to have a play with it, you'll need to adjust it slightly.
So, um, yeah...help?