Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Headlamp / personal flashlight script

Author
Message
MandoAndy
14
Years of Service
User Offline
Joined: 10th May 2010
Location: New Hampshire
Posted: 19th May 2010 02:25
Hullo, geeks and gamers.

I just got the Project Blue mod, and I've been toying around with all kinds of cool things.

When I read about the "movable lights", I was totally stoked because I realized how easy that makes scripting a flashlight or headlamp. Yay!

Here's my script -- it works beautifully -- you just need to apply it to a dynamic light in the scene, and place the light close to the player's start position.



So that's all pretty cool and nifty. I have a problem though that I CANNOT solve, so I need the help of the super awesome smart people here.

There's a trap in one of my levels, and if the player falls into the hole, s/he dies. (original, no?) My problem is that when the player respawns, the light never follows the player back to the respawn position!

I realize that I could probably solve this problem by repositioning the x, y, and z coordinates of the light when the player's health is less than 1 -- but this might not solve all problems, (multiple respawn points, etc.) and it just feels like there should be a better answer.

Any thoughts?

Shadowtroid
14
Years of Service
User Offline
Joined: 23rd Dec 2009
Location: nope
Posted: 19th May 2010 02:43
Wow, I should play around with that movable light feature. Haven't had a chance.

To be honest, I don't think that that is your best option unfortunately. I think the only way around it is to have 1 life. That's how most modern games do it nowadays, if you die, you respawn from an earlier save (autosave or not) and not in the same area.

However in the future when Fenix Mod merges with PB it should have the Horror Mod flashlight, which is really cool.

MandoAndy
14
Years of Service
User Offline
Joined: 10th May 2010
Location: New Hampshire
Posted: 19th May 2010 04:21
Thanks, Shadowtroid -- yeah, I agree. Even if I decide to go with only 1 life (which is probably how I will end up designing it) it still frustrates me that I can't quite figure this one out.

I'm not an expert at coding. Can you state the player's position as a variable? For instance, would this script (hypothetically) work? Or, is there a way to make the script's concept work?



Is there an easy way to keep track of and call the player's current X, Y, and Z coordinates? It should be easy to do... I feel like I should be able to state the coordinates as a variable somehow, but I'm not sure how to do it. (I just used the term "plrposx, plrposy, and plrposz" for demonstrative purposes - I have no idea if that would actually work)

Thanks for your insight, though I can't way to see that horror mod flashlight!
Marc Steene
FPSC Master
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Bahrain
Posted: 19th May 2010 10:40 Edited at: 19th May 2010 10:41
Already did this with the release of my Modern Warfare pack a while ago .

Here's my script if you interested in comparing.

;Artificial Intelligence Script

;Header

desc = Flashlight Script

;Script which activates Flashlight when "F" is pressed
;Adjust the range and light colour in the code in state 0.
;Script by Marc Steene from the Modern Warfare Script Pack

;Triggers

:state=0:dimvar=flashlight,setvar=flashlight 0,etimerstart,mlightrange=200,mlighttype=1,mlightid=250,mlightred=228,mlightgreen=220,mlightblue=218,state=1
:state=1,scancodekeypressed=33,varequal=flashlight 0,etimergreater=500:setvar=flashlight 1,sound=audiobank\music\flashlight off.wav,etimerstart
:state=1,scancodekeypressed=33,varequal=flashlight 1,etimergreater=500:setvar=flashlight 0,sound=audiobank\music\flashlight off.wav,etimerstart

:varequal=flashlight 0:mlightoff
:varequal=flashlight 1:mlighton,mlightfollowplr

;End of Script

Good work.


[b]FPSC MIGRATION: http://forum.thegamecreators.com/?m=forum_view&t=142497&b=21
MandoAndy
14
Years of Service
User Offline
Joined: 10th May 2010
Location: New Hampshire
Posted: 19th May 2010 16:25
Marc, I tested out your code.

Do you want to know my EXACT reaction when I tried it out?

"Damn it!! ...AWESOME!!! "

Your code is cleaner than mine, AND it manages to follow the player around perfectly even after respawning. I'm not sure what I was doing wrong with my code, but I know your code is perfect. Thanks!

Mind if I steal it? I'll give you full credit in the finished product and in any demos I make.

Marc Steene
FPSC Master
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Bahrain
Posted: 19th May 2010 21:36
Thank you And yes, you may steal it.


[b]FPSC MIGRATION: http://forum.thegamecreators.com/?m=forum_view&t=142497&b=21
meteorite
18
Years of Service
User Offline
Joined: 19th Nov 2006
Location: The Capital Wasteland
Posted: 23rd May 2010 23:23 Edited at: 23rd May 2010 23:29
Hmm, try this as a mod for your script Mando


Personally I like to just direct it right at the player pos rather than a middle man variable, but either way works.

Marc, the timer in your script is to make sure holding f wont toggle faster than the user can react or even see? Try this:



Sorry if I butchered any code, havent looked at fpi in about 3 months :S

Also, if you want the flashlight to turn off when you die, add in a line that says:
:plrhealthless=1:mlightoff


I'm the exception to every rule, that rule withstanding

Login to post a reply

Server time is: 2024-11-25 00:48:48
Your offset time is: 2024-11-25 00:48:48