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
SOLVED: Script based on the Orb Pillars not working...
39Games Offline
Junior Member

Posts: 48
Threads: 14
Joined: Jan 2013
Reputation: 0
#1
SOLVED: Script based on the Orb Pillars not working...

G'day guys,
I've been working on a map for my custom story, which involves essentially the same situation as the Daniel ending on the final map in TDD (knocking the orb pillars over).

I have transferred the scripts over from the map to mine, and I have it working so far and I've added room for a 4th pillar.
What works is that I can knock three of the pillars over, but with the fourth one the impluse trigger doesn't seem to work, I have to push the player against it to knock it over.
And once each pillar falls down, a specific event happens, and after the fourth one, I can't quite figure out how to trigger an event...

So what I am asking here is...
How can I trigger one event after certain conditions have been met? (in this case the four pillars knocked over)
And how can I edit the script from the original TDD map to include a 4th pillar rather than three?

If you guys need my script let me know.

Cheers!

(This post was last modified: 05-02-2016, 10:03 PM by 39Games.)
04-29-2016, 06:56 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Script based on the Orb Pillars not working...

I have not used those pillars myself so I don't know if there are some quirky restrictions placed upon them. Have you made sure nothing collides with the fourth pillar? Does it always happen to that pillar or does it change depending on which pillar you knock over last?

As for the trigger, you can place script areas around the top of all the pillars. Either place one for each pillar, or place one large one across them all (I'd prefer separate). Make them cover only the top, so that when the pillars fall over, they also fall out of the area. Then you can simply use a collision callback using -1 on the alState value (to check for area exit). Here's an example:

PHP Code: (Select All)
int pillarsKnocked 0;

void OnStart() 
{
    
//Creates 4 callbacks for Pillar_1 & Area_1 up till #4.
    
for(int i 1<= 4i++) AddEntityCollideCallback("Pillar_"+i"AreaPillar_"+i"PillarExit"true, -1);
}

void PillarExit(string &in asParentstring &in asChildint alState) {
    if(
alState != -1) return; //This isn't exactly necessary since it's only called upon exit.

    
pillarsKnocked++; //This adds 1 to the variable, counting total pillars knocked.

    
if(pillarsKnocked 4) return; //Unless knocked pillars have reached 4, no further code is ran.

    //Run your code here that you want to be called upon knocking all 4 pillars over.


04-29-2016, 07:37 AM
Find
39Games Offline
Junior Member

Posts: 48
Threads: 14
Joined: Jan 2013
Reputation: 0
#3
RE: Script based on the Orb Pillars not working...

(04-29-2016, 07:37 AM)Mudbill Wrote: Have you made sure nothing collides with the fourth pillar? Does it always happen to that pillar or does it change depending on which pillar you knock over last?
Nothing collides with each pillar, and I can take the pillars down in any order, the same pillar has trouble.
I'll give your code a try soon and get back to you with the results.
Cheers mate!

04-29-2016, 09:01 AM
Find
39Games Offline
Junior Member

Posts: 48
Threads: 14
Joined: Jan 2013
Reputation: 0
#4
RE: Script based on the Orb Pillars not working...

Ok so I tried your code and it didnt seem to work...
ERR: "pillarsKnocked" is not declared.
(04-29-2016, 07:37 AM)Mudbill Wrote:
PHP Code: (Select All)
int pillarsKnocked 0;

void OnStart() 
{
    
//Creates 4 callbacks for Pillar_1 & Area_1 up till #4.
    
for(int i 1<= 4i++) AddEntityCollideCallback("Pillar_"+i"AreaPillar_"+i"PillarExit"true, -1);
}

void PillarExit(string &in asParentstring &in asChildint alState) {
    if(
alState != -1) return; //This isn't exactly necessary since it's only called upon exit.

    
pillarsKnocked++; //This adds 1 to the variable, counting total pillars knocked.

    
if(pillarsKnocked 4) return; //Unless knocked pillars have reached 4, no further code is ran.

    //Run your code here that you want to be called upon knocking all 4 pillars over.


Ok so I tried it again on a fresh map, and it didnt crash this time but the entity call back didnt seem to work...

(This post was last modified: 04-30-2016, 09:38 AM by 39Games.)
04-30-2016, 05:42 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#5
RE: Script based on the Orb Pillars not working...

The undeclared error was probably caused by you missing the very top line.

Perhaps your areas are too close to where the pillars are when lying down. Remember that they need to cover the pillars as they stand, but let the pillars completely exit the area when fallen.

You can then test to see if it runs correctly by putting either debug messages (if you use dev env) or just SetMessage or similar into the code. I prefer using debug messages because you can check variables with them.

Something like this:

PHP Code: (Select All)
void PillarExit(string &in asParentstring &in asChildint alState) {
    
AddDebugMessage("Calling PillarExit"false);
    if(
alState != -1) return; //This isn't exactly necessary since it's only called upon exit.

    
pillarsKnocked++; //This adds 1 to the variable, counting total pillars knocked.
    
AddDebugMessage("pillarsKnocked = " pillarsKnockedfalse);

    if(
pillarsKnocked 4) return; //Unless knocked pillars have reached 4, no further code is ran.

    
AddDebugMessage("Complete!"false);
    
//Run your code here that you want to be called upon knocking all 4 pillars over.


Check here if you need to enable development environment:
https://wiki.frictionalgames.com/hpl2/am...evenvguide

Use F1 in-game and enable debug messages in the tools.

(This post was last modified: 04-30-2016, 12:12 PM by Mudbill.)
04-30-2016, 12:08 PM
Find
39Games Offline
Junior Member

Posts: 48
Threads: 14
Joined: Jan 2013
Reputation: 0
#6
RE: Script based on the Orb Pillars not working...

Check here if you need to enable development environment:
https://wiki.frictionalgames.com/hpl2/am...evenvguide

Use F1 in-game and enable debug messages in the tools.
[/quote]

I added all the code into a fresh map now, and it works! Thanks a heap man!!!
Also I had no idea Amnesia had a debug environment, that is extremely handy!
Thanks for the help mate!

One last thing also, id like a certain different to occur each time pillars knocked is launched, how would i go about this?

(This post was last modified: 05-01-2016, 04:56 PM by 39Games.)
05-01-2016, 03:58 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#7
RE: Script based on the Orb Pillars not working...

Change this:

PHP Code: (Select All)
if(pillarsKnocked 4) return; 

to something like this:

PHP Code: (Select All)
if(pillarsKnocked 4) {
    if(
pillarsKnocked == 1) {
        
//Code for when first falls.
    
}
    if(
pillarsKnocked == 2) {
        
//Code for when second falls.
    
}
    
//etc
    
return;


(This post was last modified: 05-01-2016, 05:07 PM by Mudbill.)
05-01-2016, 05:06 PM
Find
39Games Offline
Junior Member

Posts: 48
Threads: 14
Joined: Jan 2013
Reputation: 0
#8
RE: Script based on the Orb Pillars not working...

(05-01-2016, 05:06 PM)Mudbill Wrote: Change this:

PHP Code: (Select All)
if(pillarsKnocked 4) return; 

to something like this:

PHP Code: (Select All)
if(pillarsKnocked 4) {
    if(
pillarsKnocked == 1) {
        
//Code for when first falls.
    
}
    if(
pillarsKnocked == 2) {
        
//Code for when second falls.
    
}
    
//etc
    
return;


Ok so I tried that and it worked for the first three worked and the 4th event didnt so I changed the first value to 5 and it works,
thanks mate!

05-02-2016, 01:42 PM
Find




Users browsing this thread: 1 Guest(s)