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
Level changing area script not working?
Shoop Offline
Junior Member

Posts: 36
Threads: 10
Joined: Feb 2011
Reputation: 0
#1
Level changing area script not working?

I want someone to fall down a hole and the level change, whats wrong with this?
void OnStart()
{
AddUseItemCallback("", "key1", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "key2", "metal_1", "UsedKeyOnDoor2", true);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("key1");
}

void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false);
RemoveItem("key2");
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("servant_grunt_1" , true);
}

  ChangeMap("Level2", "PlayerStartArea_1", "break_stairs", "water_lurker_eat");

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
The last two ones are sound file names... I think thats how you do it. (I put my whole script just in case I did something else wrong that makes it not work)
(This post was last modified: 04-02-2011, 07:51 PM by Shoop.)
04-02-2011, 07:50 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#2
RE: Level changing area script not working?

You can never have something outsude a function. It has to be inside a function somewhere.
04-02-2011, 08:03 PM
Find
Shoop Offline
Junior Member

Posts: 36
Threads: 10
Joined: Feb 2011
Reputation: 0
#3
RE: Level changing area script not working?

How would I do that? I copied this from the script functions wiki page.
04-02-2011, 08:06 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#4
RE: Level changing area script not working?

Oh, ok so when you fall down a hole. So you'll have to put an area in the hole, and put an entitycollide function there. It can't tell when you want to change a map if you just stick it randomly in your script. D:
(This post was last modified: 04-02-2011, 08:27 PM by MrBigzy.)
04-02-2011, 08:25 PM
Find
Shoop Offline
Junior Member

Posts: 36
Threads: 10
Joined: Feb 2011
Reputation: 0
#5
RE: Level changing area script not working?

Oh true aha. Could you give me an example how to do this?
04-02-2011, 08:40 PM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#6
RE: Level changing area script not working?

Shoop, learn some scripting.
Start by reading this: http://wiki.frictionalgames.com/hpl2/tut...t_beginner

04-02-2011, 09:00 PM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#7
RE: Level changing area script not working?

(04-02-2011, 08:40 PM)Shoop Wrote: Oh true aha. Could you give me an example how to do this?

It's pretty much the same way you did your monster func. When the player collides with and area, the callback would be the ChangeMap func.
04-02-2011, 09:00 PM
Find
Shoop Offline
Junior Member

Posts: 36
Threads: 10
Joined: Feb 2011
Reputation: 0
#8
RE: Level changing area script not working?

Oh, I think I understand this now. Is this correct?
void OnStart()
{
AddUseItemCallback("", "key1", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "key2", "metal_1", "UsedKeyOnDoor2", true);
AddUseItemCallback("", "key2", "castle_3", "UsedKeyOnDoor3", true);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "ChangeMap", true, 1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("key1");
}

void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false);
RemoveItem("key2");
}

void UsedKeyOnDoor3(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_3", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_3", 0, false);
RemoveItem("key3");
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("servant_grunt_1" , true);
}

  ChangeMap("Level2", "PlayerStartArea_1", "break_stairs", "water_lurker_eat");
(This post was last modified: 04-02-2011, 09:08 PM by Shoop.)
04-02-2011, 09:06 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#9
RE: Level changing area script not working?

You forgot to put ChangeMap in the changemap function.
04-02-2011, 09:37 PM
Find
Shoop Offline
Junior Member

Posts: 36
Threads: 10
Joined: Feb 2011
Reputation: 0
#10
RE: Level changing area script not working?

I don't understand, where would I need to put this?
04-02-2011, 09:39 PM
Find




Users browsing this thread: 1 Guest(s)