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
Same issue again; Activating a script area.
ApeCake Offline
Member

Posts: 116
Threads: 20
Joined: Jun 2012
Reputation: 4
#1
Same issue again; Activating a script area.

It seems simple, but for-the-love-of-god I just CAN'T get it to work. It's delaying my map and pisses me off. I just want a script area set to active when I pick up a rod. Here's my script.


void OnPickup(string &in asEntity, string &in type)
{
if(asEntity == "usekey")
{
StopPlayerLookAt();
}
else if(asEntity == "rod_2")
{
SetEntityActive("spawnmonster", true);
AddEntityCollideCallback("Player", "spawnmonster", "activatethegrunt", true, 1);
}
}

void activatethegrunt(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_4", true);
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_13", 0.001, "");
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_14", 0.001, "");
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_15", 0.001, "");
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_16", 0.001, "");
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_17", 0.001, "");
}

The rod is called rod_2, the script area is called spawnmonster and is set inactive, the monster is called servant_grunt_4 and the pathnodes have the right name. And yes, the name of the map and the .hps are the same.
(This post was last modified: 07-04-2012, 02:20 PM by ApeCake.)
07-03-2012, 08:12 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Same issue again; Activating a script area.

Such a script should have exited with an error. You closed the OnPickup function before the else-if statement.

Tutorials: From Noob to Pro
07-03-2012, 08:21 PM
Website Find
ApeCake Offline
Member

Posts: 116
Threads: 20
Joined: Jun 2012
Reputation: 4
#3
RE: Same issue again; Activating a script area.

I left out some other pickup-items while making this post and pasted this script together to keep it short, so I accidentely added that bracket. So no, that's not the problem. Good point though, I'll edit it.
(This post was last modified: 07-03-2012, 09:18 PM by ApeCake.)
07-03-2012, 09:17 PM
Find
himynamebob1 Offline
Member

Posts: 57
Threads: 12
Joined: Jun 2012
Reputation: 0
#4
RE: Same issue again; Activating a script area.

Sometimes, at least for me, re-arranging the order of things fixes it. Try putting the monster active part after the callback.
07-03-2012, 11:05 PM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#5
RE: Same issue again; Activating a script area.

give us the part about the pick up callback too, not just the resulting function. Might be something there that doesn't work?
Or does "usekey" inside OnPickup work? If so, check again if the script area in the level editor is really named "spawnmonster"

Think, before you speak Google, before you post
07-03-2012, 11:16 PM
Find
ApeCake Offline
Member

Posts: 116
Threads: 20
Joined: Jun 2012
Reputation: 4
#6
RE: Same issue again; Activating a script area.

Nope, still not working.
07-03-2012, 11:16 PM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#7
RE: Same issue again; Activating a script area.

Did you mean himynamebob1? because I asked something you couldn't answer with "still not working"

Think, before you speak Google, before you post
07-03-2012, 11:20 PM
Find
ApeCake Offline
Member

Posts: 116
Threads: 20
Joined: Jun 2012
Reputation: 4
#8
RE: Same issue again; Activating a script area.

void OnPickup(string &in asEntity, string &in type)
{
if(asEntity == "usekey")
{
StopPlayerLookAt();

}
else if(asEntity == "lantern")
{
StopPlayerLookAt();
}
else if(asEntity == "MachineNote")
{
StartPlayerLookAt("puzzleholes", 2, 3, "");
SetMessage("Messages", "puzzleholes", 0);
AddTimer("Z1", 5, "lookatfirstbox");
AddTimer("Z2", 6.5, "lookatfirstbox");
SetPlayerActive(false);
}
else if(asEntity == "rod_2")
{
AddEntityCollideCallback("Player", "spawnmonster", "activatethegrunt", true, 1);
}
}

Yeah sorry FastHunteR my first reply was indeed meant for himynamebob1. But when I posted that your post wasn't there yet, probably due to my terribad internet. But here's my whole pickup script. And I can confirm the first three are working well. And I was messing around putting SetEntityActive in the last part and setting the script area in the level editor inactive and that kinda stuff, but that still didn't work.

And it is kinda weird, because in my very first problem with this this solved it;

void OnPickup(string &in asEntity, string &in type)
{
if(asEntity == "tocarnellroomkey")
{
AddEntityCollideCallback("Player", "pusharea", "Push", true, 1);
PlaySoundAtEntity("", "scare_male_terrified5.snt", "randomatticdoor", 2, false);
}

void Push(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "react_pant.snt", "push", 0, false);
AddPlayerBodyForce(0, 0, -45000, false);
GiveSanityDamage(15, true);
}

SECOND EDIT: I've added PlayGuiSound("break_glass_bottle.snt", 1); to else if(asEntity == "rod_2") and IT DOES NOT PLAY. So it has to be a problem with the pickup, but I have no idea what to fix, I do not get an error and the script doesn't seem out of the ordinary, and the rod is called rod_2.
(This post was last modified: 07-04-2012, 11:50 AM by ApeCake.)
07-04-2012, 11:11 AM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#9
RE: Same issue again; Activating a script area.

the script you posted should work, make sure the script area is set active, and you don't need to set them inactive as long as you place the callback where it is needed. The script area will only "work" when there is a added callback for it in any way. You can of course set the script area inactive, but it's rarely needed.

Think, before you speak Google, before you post
07-04-2012, 11:43 AM
Find
ApeCake Offline
Member

Posts: 116
Threads: 20
Joined: Jun 2012
Reputation: 4
#10
RE: Same issue again; Activating a script area.

FUCK YES. I finally got it working. I just used PlayerInteractCallback on the rod in the level editor and that worked out great. Yay!
07-04-2012, 02:18 PM
Find




Users browsing this thread: 1 Guest(s)