Scripting a ringing telephone?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Scripting a ringing telephone?

Post by Hidden Hands »

I need a little help... There's a part in my game in which you enter a sector that has a telephone in it. My goal here is to have a script, that once you walk over a linedef, it triggers the telephone to ring.

My setup is like this:
1.I have the linedef, but no script attached yet.
2. The telephone sprite sits on a table at the far end.
3. Pressing action on the linedefs around the phone (that makes up the table top) triggers a script to play a message on the other end of the phoneline. This script is written up, but not yet tested:

Code: Select all

//telephone with one time message.
bool phonescript = false;
script 101 (void)
{
  if (!phonescript)  {
       AmbientSound("Telephone/Audio1", 180);
	  	   phonescript = true;
   } else
       ambientsound ("Phone/Dead", 150);
	   SetHudSize(600,400,TRUE);
       HudMessageBold(s:"The phone-line is dead."; HUDMSG_FADEOUT, 500, CR_GOLD, 300.0, 100.0, 8.0, 0.3);
	   delay (100);
}
As you can see, I have the phone, the room and the linedef but I'm having trouble getting the "phone to start ringing" once its crossed.

Does anyone know a good method I could use that would work? I need the phone to begin ringing once this linedef is crossed but using AmbientSound and PlaySound have proven useless, because the sound is all around the player with that method.. I need it to come from the phones location. I figured maybe something like placing an ambientsound local over there and triggering it with the linedef, but I'm not sure thats the best route to take... I also only want it to ring for a set amount of time if not answered. Maybe 10 rings then it stops, and the chance to answer has been missed. Of course, this would also mean I need to somehow alter my code for answering the phone, so that it knows you missed the chance to answer and goes straight to the ELSE section. Does this make sense?

Hopiing someone can assist me with this.
Many thanks in advance.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Scripting a ringing telephone?

Post by ramon.dexter »

You need to place a mapspot and play the sound from that mapspot.
Blue Shadow
Posts: 5040
Joined: Sun Nov 14, 2010 12:59 am

Re: Scripting a ringing telephone?

Post by Blue Shadow »

ramon.dexter wrote:You need to place a mapspot and play the sound from that mapspot.
You don't need a dedicated mapspot, since the telephone itself is the mapspot, in this case.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Scripting a ringing telephone?

Post by ramon.dexter »

Yeah, true. You can play the sound from the phone actor.

If you read carefully the playsound definition on the zdoom wiki, you would instantly know how to do it.

https://zdoom.org/wiki/PlaySound
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Scripting a ringing telephone?

Post by Hidden Hands »

Ok, thank you both very much. I'm going to experiment with this method now.

EDIT: Ok so I thought I had this down to a T, but seems I'm having this issue with my phone ringing script... as you can see its marked it as broken? I've checked over it numerous times, I can't see anything wrong with it? It's also saying I'm missing a "(" but I can't see anything like this missing?
Attachments
brokens.png
brokens.png (2.37 KiB) Viewed 733 times
wankyphonescript.png
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Scripting a ringing telephone?

Post by ramon.dexter »

The last argument is either true or false, not 'localambientsound'.
Post Reply

Return to “Scripting”