Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → An alarm sound cog..... (SP)
An alarm sound cog..... (SP)
2003-02-22, 12:22 PM #1
I need a cog that, once an adjoin is crossed, OR a sector is entered, a ghost object is created right above the player and follows the player around the level. A sound is played from that ghost (looped) until a switch is activated, then the ghost is deleted and the sound stops.

You should get when im trying to do, player enters a restricted area, and the intruder alarm sounds until the player finds a switch and deactivates it.

------------------

Restless 2

Sanctum de la Mort
2003-02-22, 1:03 PM #2
Code:
# JK Cog Script
#
# annoying_alarm.cog
#
# Play an alarm sound at the player untill a switch is activated
#
# Created by: Hell Raiser [Jon Harmon]

symbols

sector		alrm_sct
sound		alrm_snd
surface		switch

thing		player		local

int			On			local

int			alrm_chn	local

message		startup
message		entered
message		activated

end

code

startup:

	On=1;

return;

entered:

	if(GetSenderRef() == alrm_sct && GetThingType(GetSourceRef())==10 && On==1)
	{
		alrm_chn=PlaySoundThing(alrm_snd, GetSourceRef(), 1, -1, -1, 0x81);
	}

return;

activated:

	if(On==1 && GetSenderRef()==switch)
	{
		StopSound(alrm_chn, 0);
		On=0;
	}

return;

end


I was bored. [http://forums.massassi.net/html/wink.gif]

------------------
-Hell Raiser
Remember kiddies, trial and error.
Without struggles there is no progress
DBZ: The Destruction is Real
-Hell Raiser
2003-02-22, 2:26 PM #3
Thanks, it works, but there is a problem. If you exit and enter the sector after the sound is playing the first time, it starts again resulting in many slarm sound overlapping each other at once.

Oh, and a click noise for the switch would be nice too [http://forums.massassi.net/html/smile.gif]

------------------

Restless 2

Sanctum de la Mort

[This message has been edited by Dash_rendar (edited February 22, 2003).]
2003-02-22, 7:57 PM #4
Gah, I put On=0; in the wrong place [http://forums.massassi.net/html/redface.gif]

Code:
# JK Cog Script
#
# annoying_alarm.cog v1.1
#
# Play an alarm sound at the player untill a switch is activated
#
# Created by: Hell Raiser [Jon Harmon]

symbols

sector		alrm_sct
sound		alrm_snd
sound		switch_snd
surface		switch


thing		player		local

int			On			local

int			alrm_chn	local

message		startup
message		entered
message		activated

end

code

startup:

	On=1;

return;

entered:

	if(GetSenderRef() == alrm_sct && GetThingType(GetSourceRef())==10 && On==1)
	{
		alrm_chn=PlaySoundThing(alrm_snd, GetSourceRef(), 1, -1, -1, 0x81);
		On=0;
	}

return;

activated:

	if(GetSenderRef()==switch)
	{
		PlaySoundPos(switch_snd, GetSurfaceCenter(switch), 1, -1, -1, 0); 
		StopSound(alrm_chn, 0);
	}

return;

end


There ya go. [http://forums.massassi.net/html/smile.gif]

------------------
-Hell Raiser
Remember kiddies, trial and error.
Without struggles there is no progress
DBZ: The Destruction is Real
-Hell Raiser
2003-02-22, 11:45 PM #5
There is something else you can use instead of PlaySoundThing!
If it is SP, no one else has to here it. You can use PlaySoundLocal or PlaySoundGlobal. The syntaxes are (sound,volume(flex),balance(flex),flags).

/Edward
Edward's Cognative Hazards
2003-02-23, 9:10 AM #6
If it's SP, it's all the same. [http://forums.massassi.net/html/tongue.gif]

------------------
-Hell Raiser
Remember kiddies, trial and error.
Without struggles there is no progress
DBZ: The Destruction is Real
-Hell Raiser

↑ Up to the top!