Scripts / Ignite | script help thread

Author
Message
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 28th Apr 2019 19:19
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?

AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 28th Apr 2019 22:30
If you can work out the positional offset of the torch head from the player position, this will vary per frame if animated, then you can use the utillib Rotate3D function to position the particle emitter.

For each type of light entity simply put the per-frame offsets in a list and access them depending on the current animation frame.

Pirate Myke had a solution whereby the emitter was tied to a bone in the model (or maybe a fire-spot or something) so you may want to PM him about how that works.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
13
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 28th Apr 2019 22:37 Edited at: 28th Apr 2019 22:38
you want to use amen's functions to move the emitter in relation to the torch (i.e. look into utilib.lua, iirc it's called Rotate3D)
however if the torch is going to move in it's animation this will cause issues as the engine does not currently have any way to return the animated co-ords.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 28th Apr 2019 23:37 Edited at: 28th Apr 2019 23:42
Quote: "Pirate Myke had a solution whereby the emitter was tied to a bone in the model (or maybe a fire-spot or something) so you may want to PM him about how that works."


Myke and I have chatted about this privately. Basically the problem is the emitter relies on me specifying the entityid number and the limbindex, which is fine if we're talking about a character where I can literally just hover my cursor over them to find out their entityid. But, as I'm sure you're aware, weapons don't work like that; the entityid of the weapon lying on the table waiting to be picked up appears to be different to the id of the HUD.x called by the weapon. It also seems that WeaponID and entityid are two entirely different numbers.

EDIT: Just tried using the entityid of the weapon pickup on the table with the limbindex of the torch's 'FIRESPOT'; crashes back to editor every time. Tried subbing in the weaponid instead of the entityid and got a runtime 7023 error :/

AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 29th Apr 2019 00:36
Hmm, I'm not sure the actual weapon carried has an entity id. It is all handled by the engine.

Why not just turn the torches etc into ordinary entities and avoid the weapons system entirely?
Been there, done that, got all the T-Shirts!
PM
cybernescence
GameGuru Master
6
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 29th Apr 2019 13:09
The weapon system has its own built in way to emit particles and light e.g. if you fire a particle weapon like the magic staff.

You can tweak these values so the ‘weapon’ doesn’t fire far - effectively the in flight particles stay at weapon source point. It would require the weapon to continually ‘fire’ to keep the light and particles surrounding the lamp bones (smoke, fire and light emitters).

I’m not sure if this will let you control the strength of the fire light dynamically though.

Anyway another option to think about

Cheers.
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 29th Apr 2019 22:32 Edited at: 29th Apr 2019 22:35
Yes, cybernescence, I did research that method a few weeks ago, although I admit I never actually made any prototypes because - as you suspected - you can't adjust the muzzle flash light.

Quote: "Why not just turn the torches etc into ordinary entities and avoid the weapons system entirely?"

Quote: "you want to use amen's functions to move the emitter in relation to the torch (i.e. look into utilib.lua, iirc it's called Rotate3D)"

I'm afraid you overestimate my scripting capabilities. I'm not at that level yet, utilib.lua and Rotate3D functions don't make a lot of sense to me, so I don't have the first idea how to implement them. Partly the reason for this thread, I can puzzle out the basics but nothing nuanced.

Having said that, I had considered Amen's suggestion before so tonight I got prototyping and actually got something pretty good!


A couple of problems with this script so far:
Can't seem to toggle to emitter on or off. I've been trying the StartParticleEmitter(e) and StopParticleEmitter(e) commands but to no avail.
CAN NOT get the model to animate, despite specifying anim frames in the fpe.
Some juddering from the model as the player moves.
Some misalignment when looking up or down, not sure how to correct for this.
Shadows from the sun appear to be casting on the arm despite sunsurfacefactor being set to zero.

Here's the script. Feel free to critique/rewrite it:



I have been able to get the flame to die out though using the ParticlesSetAlpha command, which is pretty sweet, but it's very easy to blow the memory and end up with smoke.

AE
3com
5
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 30th Apr 2019 11:38
Quote: "Can't seem to toggle to emitter on or off. I've been trying the StartParticleEmitter(e) and StopParticleEmitter(e) commands but to no avail"

ParticlesDeleteEmitter( fire ) instead.

I assume you are using one of them as a weapon, if so, which one? (torch, flame, light) ?

if g_PlayerGunID == 59 then
Show(e)
end

Another way you can achieve it is modeling some flameless image, and change it when needed.

Take a look this script it is not exactly what you are looking for but it is well commented and might help'u.



hth
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
13
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 30th Apr 2019 18:31
that looks good
for animating it's probably stuck on the first frame of the animation as you're constantly calling it to animate, this might fix it
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 30th Apr 2019 20:50
Quote: "for animating it's probably stuck on the first frame of the animation as you're constantly calling it to animate, this might fix it"

Sadly that didn't help, it just made it flicker.

AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 30th Apr 2019 22:10
ParticlesSetLife( emitterId, lifeMin, lifeMax, maxParticles, 0, maxPerFrame )

Set maxParticles to 0 to effectively turn off the emitter.

Playing around with the other values may be one way to mimic a dying torch especially if combined with adjusting the scale and alpha settings at the same time.
Been there, done that, got all the T-Shirts!
PM
synchromesh
Forum Support
5
Years of Service
User Offline
Joined: 24th Jan 2014
Location:
Posted: 1st May 2019 01:51
Quote: "that looks good "

It does .. Most impressive to be honest ..
The only person ever to get all his work done by "Friday" was Robinson Crusoe..
PM
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 1st May 2019 18:07
Quote: "ParticlesSetLife( emitterId, lifeMin, lifeMax, maxParticles, 0, maxPerFrame )

Set maxParticles to 0 to effectively turn off the emitter."


I tried using this command but it didn't appear to do anything, and the notes in global.lua suggest it was never fully implemented. I'm on the public-preview, if that makes a difference.

On the plus side, I've got a solution now which involves ParticlesSetAlpha, which does work. Still a bit concerned Game Guru is still producing particles, albeit invisible ones, so I'm not sure how that'll effect memory.

I've also adjusted the decal shader to give me additive blending, but still with LUA control of alpha channel (which is why ParticlesSetAlpha works).



It's still not animating, but I'm now convinced this is an issue to do with the model, rather than the script. Even ai_viewanimations.lua shows no animation on this model, even though there should be. Must be an export setting from Fragmotion which I messed up, which is odd because this is the exact same model that animates perfectly well as a HUD.x weapon.

I'm also not a fan of the self-shadowing from the 'sun', would be nice to switch that off. I seem to remember there being a setting in the setup.ini that does just that.

AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 1st May 2019 20:13
To make the effect look better you should use multiple emitters btw, like I did for the campfire:
Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 1st May 2019 20:15
And yes I believe the Beta has a few more particles commands than the PP.
Been there, done that, got all the T-Shirts!
PM
GubbyBlips
User Offline
Joined: 14th Jan 2019
Location:
Posted: 2nd May 2019 02:18
Nifty deal! I like the way it reflects on the ground.
And- good enough for ARK, so not good enough for GG?!
PM
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 2nd May 2019 23:34 Edited at: 2nd May 2019 23:36
I finally got it working! The animation problems were being caused by me not specifying the correct shader in the fpe, it wouldn't animate unless I used apbr_anim.fx. Once I figured that out, animating the rest of the model was fairly straightforward, although it's taken a few iterations to get it looking just right. Changing that shader has also stopped the self-shadowing issue I was facing. Now the model can move, I've been able to write some more lines to cover when it should animate. It's still not 100%, so I could do with someone to proof-read my latest additions:



I have a feeling this is calling animation(3) every frame a movement key is pressed, whereas I only want it called when the model isn't animating but the movement keys are being pressed. And when one isn't being pressed, it needs to return to the idle animation (1).

I also added a second particle emitter, and adjusted the animations to better position the limb my particles spawn around, making the flame engulf the player-facing side of the torch a bit more. Again, still not perfect, but it'll do for now. I can't add smoke because my changes to the particle shader will make it too bright now. We could do with a LUA command to specify which shader a given particle emitter uses (hint hint, AmenMoses )



AE
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 6th May 2019 19:20 Edited at: 6th May 2019 19:21
OK I'm now fairly satisfied with the torch, apart from the aforementioned animation issues with moving. I decided to take a break from that to create the next light source, a candle. I now need to decide how to accomplish the candle flame and, as I see it, I have three options:

1: Use the particle system. The issue I'm currently having with this is that the location of the emitter always has a one frame delay on it, meaning I only need to move a little bit to have the whole effect separate away from the wick. Plus the size of the particles means they tend to separate away from each other.
2: Use a decal. This would need to be animated to move exactly with limb 25 of my model, and I don't know how to do that.
3: Model the flame, but then it won't animate...or at least, not very dynamically.

The particle system looks prettiest and allows for the most control so I've attempted to make something with it, but once I pop it in a level with the torch, I'm get weird interference between particle emitters, with the torch fire sort of showing up when it shouldn't. Here's a video of the problem. You'll also notice when the torch is selected, the candle particles will randomly appear for one frame and then disappear. What's going on here?


Finding a way to parent other entities and lights to specific limbs of an entity would be very advantageous to me, because I'd be able to place my light sources exactly where they should, not just guess. The current method of using player position looks alright, but when the player looks up or down the light stays at the same height, when really it too would raise or lower. I don't know what expression would allow me to do this.

AE
perelect
4
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 7th May 2019 18:28
Hi AE
This is looking good.
Id just thought i might mention that if you wanted a bit more direction light in front of where the player is looking, you could also use / blend in the players flashlight with what you are using.
You can control the players flashlight intensity with SetGamePlayerStateFlashlightControl(v) the standard gg v value is 1 when the flashight light is fully on, but i can be any value like 0.225. SetGamePlayerStateFlashlightControl(0.225)

just modify this section of
gameplayercontrol.lua


PS Where did you find a hand torch model for the players hud, i might have a go that this as well..
Desktop: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, Windows 10 Pro, 64-bit, 16 GB Ram, ASASUS Geforce TURBO GTX1080 8GB, 34" 21:9 2560x1080 Full HD UltraWide IPS Monitor

[RIP] Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
PT V9.0 3DMark=377, Passmark=1222.
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 8th May 2019 09:15 Edited at: 8th May 2019 09:15
Thanks for the tip, perelect.

The torch model came from Turbosquid. I bought it on special offer, then combined it with the stock Game Guru arms in Fragmotion, used the HUD.x of the colt 1911 as a base.
https://www.turbosquid.com/3d-models/max-wood-torch/1033596

AE
synchromesh
Forum Support
5
Years of Service
User Offline
Joined: 24th Jan 2014
Location:
Posted: 10th May 2019 02:38
Excellent work .. That's going to look so cool indoors
The only person ever to get all his work done by "Friday" was Robinson Crusoe..
PM
perelect
4
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 12th May 2019 21:28
Thanks Avenging Eagle

Quote: "
The torch model came from Turbosquid. I bought it on special offer, then combined it with the stock Game Guru arms in Fragmotion, used the HUD.x of the colt 1911 as a base.
https://www.turbosquid.com/3d-models/max-wood-torch/1033596"


it looks good but modifying huds are beyond my skill set,
But
I actually found a torch hud already rigged with hands in FPSC , so ill have a go at this when i get a chance to do so.

Cheers
Desktop: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, Windows 10 Pro, 64-bit, 16 GB Ram, ASASUS Geforce TURBO GTX1080 8GB, 34" 21:9 2560x1080 Full HD UltraWide IPS Monitor

[RIP] Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
PT V9.0 3DMark=377, Passmark=1222.
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 14th May 2019 14:55
Quote: "it looks good but modifying huds are beyond my skill set,"


It was for me too, took a few hours in Fragmotion to figure out what I was doing but I've got a workflow now. Wouldn't want to attempt a full weapon from scratch though, all that rigging, weight-painting, and animating is a lot more work!

- - - - - - - -


I'm still chipping away at these particle emitters, but also still getting the issues shown in my May 6th post (particles not always being transparent when they should be). I tried popping all the emitters into one master control script but it still happens. Anyone got any steer on how I can stop this? Amen/Myke/GraPhix!?

AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 14th May 2019 20:31
Show me the script and I can probably figure out what you are doing wrong.
Been there, done that, got all the T-Shirts!
PM
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 14th May 2019 21:41
So this is the control script version, with all the emitters controlled in the one script.



And this is a 'per-weapon' version. I'd prefer to use variants of this version because I don't have to call the entityid directly, I can just run the script from the model that should emit the particles.



AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th May 2019 22:19 Edited at: 15th May 2019 22:28
Ok so your scripts contain some things I don't have and some code I can't quite work out what it is trying to do.

Let's start simple; in the Mystic Library (part of Mega Pack one) I found a 3 pronged candlestick thing so I've knocked up a quick script that puts a rudimentary flame affect on it when moved with the player.



Using that as a starting point if you want me to add functionality bit by bit to it and hopefully you can adapt the code to your own scripts as needed.

Just let me know what you want me to add.


Edited to add flame image file just in case it's not a standard one.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 16th May 2019 18:45 Edited at: 16th May 2019 18:46
Don't really know what to say to this. It's incredibly generous of you to offer to rewrite the script, and your code immediately looks more elegant than mine, but it's going to take such a long time to implement all of the mechanisms I've spend 6 weeks scripting little by little that I fear it's too much to ask of you. Plus it would only really work if you had all the files I have here. I'm happy to take to PMs or email if you wish?

Really the main issue I'm having at the moment is that particles from emitters 1 and 2 are only supposed to be visible when the player has a certain 'weapon' selected, particles from emitters 3 and 4 should be transparent. When the player has the other weapon selected, particles from 1 and 2 are transparent, while 3 and 4 are now visible. When I say "weapon", what's actually happening is that when the player picks up, for example, the torch, it loads a blank HUD.x with nothing in it and triggers a torch with arms entity to show and follow the player around.

Might even have to end up making a video to explain how the system works currently

AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th May 2019 19:58 Edited at: 16th May 2019 20:19
Just delete the emitter when not in use.

I'll add a bit of code to show you what I mean and post it later.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 16th May 2019 21:50 Edited at: 16th May 2019 21:51
So the emitters are created as their own function, not in init? And then you call that function whenever needed, and delete when done? I sorta get how it works, but haven't got the foggiest how to replicate it in my script, even though you've literally written it there for me. I've never scripted a function before... Also, rather than a key press, how about if I used g_weaponId == ?

While you were writing that, I busied myself making an explanation of how the current system works. Seems a shame to waste that now, so see if this helps clarify what I'm aiming at.


Oh, and just so you can see, here's what happens when I use your script straight out of the box.


AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th May 2019 23:26
The weapons are for some reason rotated 180 degrees from the player angle, one of those weird GG things. Simply rotate the model in fragmotion or similar.

'Forward' for any model is +Z axis, makes the math nioce and simple if you ensure that is the case for any model that needs to be positioned via Lua.

The other thing to be aware of is that the angles are Euler angles. For really smooth motion and rotation (like in the pickuppables script) you should use quaternions and make everything frame rate independent.

I might have a trick up my sleeve to make the particles follow the entity better, not sure if it will work yet I'll need to test out my idea to see if it works.

You can put everything in one script btw, if you use the name of the entity that the script is attached to to decide whether it is the candle or the lantern or the torch then you can do away with having hard coded entity Ids (always a good idea imo).

Similarly you can use the weapon name rather than numbers to detect which the player is carrying, that will make the script much easier to read.

Are you on the GameGure Discord channel? If so you can contact me there and it's much easier to swap scripts back and forth etc.






Been there, done that, got all the T-Shirts!
PM
GraPhiX
Forum Support
14
Years of Service
User Offline
Joined: 15th Feb 2005
Playing: Fixing stuff ;)
Posted: 17th May 2019 23:46
Nice work here well done @Avenging Eagle I have started work on a torch working on the hud aspect over this weekend you are welcome to it once I have finished/refined it if its of any use to you.



Welcome to the real world!
Main PC - Windows 10 Pro x64 - Core i7-7700K @4.2GHz - 32GB DDR4 RAM - GeForce GTX 1060-6G 6GB - 1TB NVe SSD
Test PC - Windows 10 Pro x64 - G4400 @3.3GHz - 16GB DDR3 RAM - GeForce GTX 950 2GB - 500GB SSD
Laptop - Helios 300 Predator - i7 7700HQ - 32GB - Nvidia GTX1060 6GB - 525GB M2 - 500 SSD - 17.3" IPS LED Panel - Windows 10 Pro x64
Various Tutorials by me
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 3rd Jun 2019 19:16
Long time since I've posted in this thread, but I have been working pretty much continuously on this, albeit only progressing very slowly. My latest query comes courtesy of a script I've written to display a note onscreen. The script I've written works perfectly well for one note...



...but I'd like to have multiple notes. It seems really inefficient to have lots of minor variations of this script, so I'd like it so multiple objects can run the same script but it changes the text depending on the object name (you can see I've started to add the functionality to use object names, but I can't figure out what to do next). The script will always call the same parchment sprite, but the text to be displayed on the parchment should change depending of which one the player is interacting with.

Any suggestions?

AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 3rd Jun 2019 20:42 Edited at: 3rd Jun 2019 20:44
I'm still working this btw!

So for the notes, somewhere around here is a script I wrote to handle a multitude of the things but I think you should go for something a wee bit cleverer ….

So have your blank note model which you can place around the map wherever you like, then when the player 'reads' the note simply display the text using the particles system, to do this you will need to create a sprite sheet with all your messages where each frame is a different message, then using the same method I used for the bullet holes to position the text just in front of the note at run time.

A single sprite sheet could contain 64 different messages and the notes you place down could be named note_1, note_2 etc, the script simply uses the numeric part to set the frame to be displayed. You could have the message automagically fade away over time so if you come back to the same note later you will have to 'read' it again but if you revisit it within a short period of time you will still be able to read the text on it

I've attached the bullet holes script to show how it is done, it will need tweaking to select an appropriate frame as the default for particles is to choose a random frame each time a particle is spawned.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
Avenging Eagle
13
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 3rd Jun 2019 21:58
That certainly is clever, but I think in this instance it's probably reinventing the wheel a little bit too much. I wasn't planning on modelling the hand holding the note itself, I'm happy to just show it as a sprite. The whole point of not making 64 different note textures (not that I'd need that many) is that I don't want to have to load another enormous sprite sheet at the beginning of the level (as you know I'm already loading a few for the torch/lantern/candle etc.). Really only the text needs to change from note to note, unless specific notes call for diagrams, maps etc. Hence why I'm happy to call the same background sprite over and over, but just change what's printed with TextColor.

Was going to message you on Discord but I know you've been ill recently, and busy with other projects, so I thought I'd open it up to the floor!

Actually, where your sprite wizardry might come in handy is with fonts. I've got this nice olde world font I'm testing but because it looks handwritten, characters need to overlap slightly to look right, something the in-build font system can't do - can your sprite-based system make this look better?
Currently in Game Guru:


Would be better if it looked more like...(done in Paint Shop Pro):


AE
AmenMoses
GameGuru Master
3
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 3rd Jun 2019 22:27 Edited at: 8th Jun 2019 13:12
Yes, my sprite based system would be able to cope with that .. but two things spring to mind. 1) sprite sheets are tiny in comparison to 3D entities and their textures (especially as you can compress them) , 2) The particle rendering is very efficient and uses the minimum in 3D resources, I've had thousands of particles on screen at one with very little impact to FPS, 3) You don't need to have a fancy model with a hand etc, just leave the note where it is and either zoom into it with camera override or rely on the player to get close enough to read it, more realistic in a way. You could even have the notes attached to a wall or on a desk.

Like this:

https://forum.game-guru.com/thread/220804#msg2616252


Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
13
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Jun 2019 22:45 Edited at: 3rd Jun 2019 22:49
just loop through your text section based on the names[e]'s you will be providing
i.e.

as you will be needing to input all the text yourself anyway this will be fine as long as you remember to name all the notes the same as you put in the 'if' checks.

you will likely also need to make the 'showtext' variable an array to handle multiple notes (otherwise i'm guessing it will just instantly hide any note you attempted to pick up due to you being too far away from any other notes)

edit; as the image and sprite are the same for all notes you can move it outside the init function so it won't create multiples
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2019-07-23 16:18:33
Your offset time is: 2019-07-23 16:18:33