Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How i can reload script area when i die ? And how to create loopable sounds ?
rakakak11 Offline
Junior Member

Posts: 20
Threads: 3
Joined: Jul 2012
Reputation: 0
#1
Question  How i can reload script area when i die ? And how to create loopable sounds ?

(sorry for bad english)

Like the title says....


I have working checkpoint and when i die by monsters i want to encounter the same monsters again...
I want some script areas reload when i die....i know that there is same thread like i have but i really dont understand what i have to do....

"http://www.frictionalgames.com/forum/thread-17384.html"



Too i don't understand how i can have ambient sounds (loopable sounds, like baby start crying every 1 minute...lol)
(This post was last modified: 08-01-2012, 01:23 AM by rakakak11.)
07-31-2012, 08:59 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: How i can reload script area when i die ? And how to create loopable sounds ?

To do the baby thing the answer is TIMERS Wink

Put this inside a function:

AddTimer("", 60, "Baby_cry");
This means it takes 60 seconds before it calls the function "Baby_cry"


Then make the function:

void Baby_cry(string &in asTimer)
{
PlaySoundAtEntity("", "[BABYCRY SOUND]", "Player", 0.5f, false);

AddTimer("", 60, "Baby_cry");
}

See? I call the same timer inside the timerfunction. This means it will repeat doing this to infinity

Trying is the first step to success.
07-31-2012, 09:02 PM
Find
drunkmonk Offline
Member

Posts: 109
Threads: 7
Joined: Jun 2012
Reputation: 4
#3
RE: How i can reload script area when i die ? And how to create loopable sounds ?

For the checkpoint, what you must do is you have to re-apply all the functions that happen when encountering the monster. I will use my script for example
What this does is before you die the function will run normally as it should the first time through. Now when you die and you respawn at the checkpoint, the script will register that the monster encounter has already happened and doesn't need to do it again unless you declare it in the checkpoint function, that way when you die the script knows that it has to run the function again
Hope this helped Smile
void OnStart
{
AddEntityCollideCallback("Player", "monster_spawn", "monsterspawn", true, 1);
CheckPoint("check01", "PlayerStartArea_2", "CheckPoint01", "", "");
}
void CheckPoint01(string &in asName, int alCount)
{
SetPlayerHealth(RandFloat(80, 95));
AddEntityCollideCallback("Player", "monster_spawn", "monsterspawn", true, 1);
ResetProp("monster_door");
}
void monsterspawn(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_2", true);
SetPropHealth("monster_door", 0.0);
ShowEnemyPlayerPosition("servant_grunt_2");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_6", 0.0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_7", 0.0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_8", 0.0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_9", 0.0, "");
}
(This post was last modified: 07-31-2012, 09:12 PM by drunkmonk.)
07-31-2012, 09:11 PM
Find
Mackiiboy Offline
Member

Posts: 101
Threads: 7
Joined: Jan 2012
Reputation: 11
#4
RE: How i can reload script area when i die ? And how to create loopable sounds ?

I'll try to simplify it a bit more than I did in the 1st thread. I suppose you have a collide callback function or something similar that spawns the monster, right? Inside that function that activates the monster you should put a checkpoint, you could also put it inside void OnStart() instead, but not both. I recommend to use your monster function if your are going to have more checkpoints than just one.

You can put this one inside your function with the monster (or OnStart):

CheckPoint("", "NameOfTheAreaYouWantToSpawnAtAfterDeath", DeathFunction, "", "");

Your deathfunction would be something like this:

void DeathFunction(string &in asName, int alCount)
{
ResetProp("NameOfYourScriptAreaThatActivatesTheMonster");
ResetProp("NameOfYourMonster");
ResetProp("NameOfOtherScriptAreasYouWantToReset");
}
.
(07-31-2012, 08:59 PM)rakakak11 Wrote: Like the title says....
I have working checkpoint and when i die by monsters i want to encounter the same monsters again...
I want some script areas reload when i die....i know that there is same thread like i have but i really dont understand what i have to do....

"http://www.frictionalgames.com/forum/thread-17384.html"
(This post was last modified: 07-31-2012, 09:22 PM by Mackiiboy.)
07-31-2012, 09:22 PM
Website Find
rakakak11 Offline
Junior Member

Posts: 20
Threads: 3
Joined: Jul 2012
Reputation: 0
#5
RE: How i can reload script area when i die ? And how to create loopable sounds ?

thanks for all replies Big Grin i try everything now...


EDIT:
WOW thanks! drunkmonk scripts helped me....

this is how i has it before...:
Quote:void Zombik(string &in asParent, string &in asChild, int alState)
{
CheckPoint ("", "PlayerStartArea_1", "Obnovenie", "Checkpoints", "Checkpoint3");
SetEntityActive("grunt", true);
ShowEnemyPlayerPosition("grunt");
SetPropHealth("monsterdoor", 5.0f);
AddTimer("monstertimer", 1, "monstertimer");
StartPlayerLookAt("grunt", 15, 15, "");
GiveSanityDamage(5.0f, true);
PlayGuiSound("notice_long01.ogg", 0.5f);
PlayMusic("29_amb_end_intense.ogg", true, 1, 1, 10, true);
}
void Obnovenie(string &in asName, int alCount)
{
ResetProp("ScriptArea_1");
ResetProp("ScriptArea_2");
ResetProp("ScriptArea_3");
ResetProp("grunt");
ResetProp("brute");
}

And this is Fixed version :



Quote:void Zombik(string &in asParent, string &in asChild, int alState)
{
CheckPoint ("", "PlayerStartArea_1", "Obnovenie", "Checkpoints", "Checkpoint3");
SetEntityActive("grunt", true);
ShowEnemyPlayerPosition("grunt");
SetPropHealth("monsterdoor", 5.0f);
AddTimer("monstertimer", 1, "monstertimer");
StartPlayerLookAt("grunt", 15, 15, "");
GiveSanityDamage(5.0f, true);
PlayGuiSound("notice_long01.ogg", 0.5f);
PlayMusic("29_amb_end_intense.ogg", true, 1, 1, 10, true);
}
void Obnovenie(string &in asName, int alCount)
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Zombik", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "Sekac", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_3", "Zombici", true, 1);
AddEntityCollideCallback("Player", "Smrt", "Spadnutie", true, 1);
ResetProp("ScriptArea_1");
ResetProp("ScriptArea_2");
ResetProp("ScriptArea_3");
ResetProp("grunt");
ResetProp("brute");

}
So i did everything right (probably) like mackiiboy says, but you forgot that i have to add collidecallback things too....

And too i dont need to reset monsters..they resets automaticaly with my script Smile


Now i go try the loopable sounds...really thanks all for help Big Grin
(This post was last modified: 07-31-2012, 10:17 PM by rakakak11.)
07-31-2012, 09:52 PM
Find
rakakak11 Offline
Junior Member

Posts: 20
Threads: 3
Joined: Jul 2012
Reputation: 0
#6
RE: How i can reload script area when i die ? And how to create loopable sounds ?

hmm but the sounds not work....i really dont know why...

there is my script:


Quote:void OnEnter()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Zavalenie", true, 1);
}

void Zavalenie(string &in asParent, string &in asChild, int alState)
{
PlayGuiSound("explosion_rock_large.ogg", 0.8f);
StopMusic( 0, 50);
SetEntityActive("kamen1", true);
SetEntityActive("zombik", false);
StartScreenShake(0.5f, 1, 1, 0);
AddTimer("", 60, "ambients");
AddTimer("", 120, "ambients1");
AddTimer("", 10, "ambients2");
AddTimer("", 120, "ambients3");
}

void ambients(string &in asTimer)
{
PlaySoundAtEntity("", "scare_male_terrified1.ogg", "Player", 0.5f, false);
AddTimer("", 60, "ambients");
}
void ambients1(string &in asTimer)
{
PlaySoundAtEntity("", "scare_male_terrified2.ogg", "Player", 0.5f, false);
AddTimer("", 100, "ambients1");
}
void ambients2(string &in asTimer)
{
PlaySoundAtEntity("", "scare_wall_stomp4.ogg", "Player", 0.5f, false);
AddTimer("", 300, "ambients2");
}
void ambients3(string &in asTimer)
{
PlaySoundAtEntity("", "scare_male_terrified3.ogg", "Player", 0.5f, false);
AddTimer("", 250, "ambients3");
}

As you can see i putted more loopable sounds at once.. probably this is error


EDIT: deleted other sounds and still not working...
(This post was last modified: 07-31-2012, 11:08 PM by rakakak11.)
07-31-2012, 11:02 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#7
RE: How i can reload script area when i die ? And how to create loopable sounds ?

They probably do work, you just have very large amounts of time between them (several minutes in fact). Just to clarify, those times are in seconds, not milliseconds Tongue

I rate it 3 memes.
07-31-2012, 11:05 PM
Find
rakakak11 Offline
Junior Member

Posts: 20
Threads: 3
Joined: Jul 2012
Reputation: 0
#8
RE: How i can reload script area when i die ? And how to create loopable sounds ?

(07-31-2012, 11:05 PM)andyrockin123 Wrote: They probably do work, you just have very large amounts of time between them (several minutes in fact). Just to clarify, those times are in seconds, not milliseconds Tongue
yes i know but i was waiting like few minutes...but i try lower the second amount.

I lowered and still not working...

And what the hell is PreloadSound(string& asSoundFile); ???? Maybe this is solution
(This post was last modified: 07-31-2012, 11:19 PM by rakakak11.)
07-31-2012, 11:10 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#9
RE: How i can reload script area when i die ? And how to create loopable sounds ?

PlaySoundAtEntity uses .snt files, not .ogg files (at least not directly). You're probably better off using random integers to generate a random time to play, as well as a random sound. Try using this instead:


void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Zavalenie", true, 1);
}

void Zavalenie(string &in asParent, string &in asChild, int alState)
{
PlayGuiSound("explosion_rock_large.ogg", 0.8f);
StopMusic( 0, 50);
SetEntityActive("kamen1", true);
SetEntityActive("zombik", false);
StartScreenShake(0.5f, 1, 1, 0);

AddTimer("", RandInt(30, 60), "ambients");
AddTimer("", RandInt(30, 60), "ambients2");
}

void ambients(string &in asTimer)
{
PlaySoundAtEntity("", "scare_male_terrified"+RandInt(1, 3), "Player", 0.5f, false);
AddTimer("", RandInt(30, 60), "ambients");
}
void ambients2(string &in asTimer)
{
PlaySoundAtEntity("", "scare_wall_stomp", "Player", 0.5f, false);
AddTimer("", RandInt(30, 60), "ambients2");
}

This script will randomly choose a time between 30 and 60 seconds to play a random noise at.

Hope that helped!

I rate it 3 memes.
07-31-2012, 11:16 PM
Find
rakakak11 Offline
Junior Member

Posts: 20
Threads: 3
Joined: Jul 2012
Reputation: 0
#10
RE: How i can reload script area when i die ? And how to create loopable sounds ?

(07-31-2012, 11:16 PM)andyrockin123 Wrote: PlaySoundAtEntity uses .snt files, not .ogg files (at least not directly). You're probably better off using random integers to generate a random time to play, as well as a random sound. Try using this instead:


void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Zavalenie", true, 1);
}

void Zavalenie(string &in asParent, string &in asChild, int alState)
{
PlayGuiSound("explosion_rock_large.ogg", 0.8f);
StopMusic( 0, 50);
SetEntityActive("kamen1", true);
SetEntityActive("zombik", false);
StartScreenShake(0.5f, 1, 1, 0);

AddTimer("", RandInt(30, 60), "ambients");
AddTimer("", RandInt(30, 60), "ambients2");
}

void ambients(string &in asTimer)
{
PlaySoundAtEntity("", "scare_male_terrified"+RandInt(1, 3), "Player", 0.5f, false);
AddTimer("", RandInt(30, 60), "ambients");
}
void ambients2(string &in asTimer)
{
PlaySoundAtEntity("", "scare_wall_stomp", "Player", 0.5f, false);
AddTimer("", RandInt(30, 60), "ambients2");
}

This script will randomly choose a time between 30 and 60 seconds to play a random noise at.

Hope that helped!
This is what im looking for !!! Heart

Sound now work but the "scare_male_terrified" didnt work... i deleted this "scare_male_terrified"
+RandInt(1, 3) and now "scare_male_terrified" sound work ! Big Grin Im again really grateful for help.

But what is this thing that i deleted ? "+RandInt(1, 3)"
08-01-2012, 12:25 AM
Find




Users browsing this thread: 1 Guest(s)