Frictional Games Forum (read-only)

Full Version: Scenario
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am wondering how to have a monster pop up, and then the player runs away into another script area that makes the bridge break (set inactive) and then fade the vision to black, then teleport the player to another map, and lastly fade the vision back in. Is this too much to ask? I'm just curious and would appreciate any help.
Do you know how to script?

Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "EnableMonster", "EnableMonster", true, 0);//Activate the Monster when colliding with an area
    AddEntityCollideCallback("Player", "CollideRun", "CollideRun", true, 0);//The bridge breaks when colliding
}

void EnableMonster(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_1", true);
    SetLocalVarInt("MonsterActive", 1);
}


void CollideRun(string &in asParent, string &in asChild, int alState)
{
    if(GetLocalVarInt("MonsterActive")==1)
    {
SetPropHealth("Bridge", 0);
AddTimer("Fade", 1, "Falling");
AddTimer("ChangeMap", 2, "Falling");

    }
    else
    {
//Do nothing
    }
}

void Falling(string &in asTimer)
{
    if(asTimer==("Fade"))
    {
FadeOut(1);
    }
    else if(asTimer==("ChangeMap"))

    {
ChangeMap("MapName", "StartPosition", "", "");
    }
}
Let me know if there's any errors.
Quote:I am wondering how to have a monster pop up,

Monster popup needs to be triggered, for example by a script area.

Add in OnEnter of your .hps following:

Code:
AddEntityCollideCallback("Script_area_x", "Player", "function_monster", true, 1);
[if "Player" enters (definded by the 1, -1 would be leaves and 0 would be both) the "script_Area_x", the function "function_monster" gets called and the CollideCallback gets removed(defined by "true")]

and then somewhere else in the script the following:
Code:
function_monster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("monster_name", true);
}

script_Area_x is the area, which activates the Monster when the player enters.
monster name is the name of the monster which should be activated…take care of deactivating the monster in the level editor.

Quote: and then the player runs away into another script area that makes the bridge break (set inactive) and then fade the vision to black,
then teleport the player to another map, and lastly fade the vision back in. Is this too much to ask? I'm just curious and would appreciate any help.

Add another entity collide callback with the area the player runs into and replace the function_monster with another name, here function_name.
Then add, again OUTISDE OnEnter oder OnStart (and OnLeave), these functions:

Code:
void function_name(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("bridge_name", 0);
FadeOut(15);
AddTimer("", 15, "teleport");
}

void teleport(string &in asParent, string &in asChild, int alState)
{
ChangeMap("map_name.map", "start_player_1", "", "");
}
bridge_name is for sure the name of the bridge which should break(the 0 sets the bridge to a health of 0=dead)
15 is the time until screen is completely black in seconds in the FadeOut-function, and the time till teleportfunction gets called in the timer.
at changemap is map_name.map the name of the map you want to load and start_player_1 the startarea in the map where the player should spawn.
Within the last two "" you could define a sound which is played when the function gets called (in the first "") or when the new map is loaded (in the second "").

Take a look at the wiki.frictionalgames.com page…there is everything.
I'm quiet sure that it works this way, maybe some spelling errors. Or i'm wrong, no warranty^^ For example the content of the brackets behind void teleport and void function_name is just guessed, not sure.
I'm actually scripting beginner, but i thought i would know the right answer so i wrote^^

Edit: Didn't see the answer above me, but it looks more professional (but also more complicated) than mine. Wanted to delete my post, but doesn't work-.-
I don't wanna discourage you from making a custom story, but please learn the basics before directly just asking for help. You're not going to be able to make a custom story just by the help from others. Use Google, Youtube, FG's wiki and Engine scripts to learn how to make a custom story. Start from the basics and work your way up.
(02-03-2013, 07:29 PM)Tigerwaw Wrote: [ -> ]I don't wanna discourage you from making a custom story, but please learn the basics before directly just asking for help. You're not going to be able to make a custom story just by the help from others. Use Google, Youtube, FG's wiki and Engine scripts to learn how to make a custom story. Start from the basics and work your way up.

I have been scripting, but there are some scripts that I couldn't find. I am just wondering how to change maps and if there is a way to set script areas active.
ChangeMap("Mapname", "StartArea", "StartSound", "StopSound");
SetEntityActive("EntityOrArea", false);
true for setting it active and false reverse
Just use the engine scripts http://wiki.frictionalgames.com/hpl2/amn..._functions,


and Ctrl+F or Cmd+F.

You'll be able to find nearly everything if you use "Scripting-words".

Entity, active, fade, prop, stuck, state, get,