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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I suck at scripting
Author Message
Daktoa Offline
Member

Posts: 98
Threads: 10
Joined: Jul 2014
Reputation: 1
#1
I suck at scripting

I don't know what I'm doing.

I have 2 separate scripts for different monsters spawning when you enter different areas. The game crashes if they're both in the script, but if there's only one at a time it runs perfectly.

void OnStart()
{
    AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 0.0001, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_5", 0.0001, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_10", 0.001, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_13", 0.0001, "");
        AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_17", 0.0001, "");
    SetEntityActive("servant_brute_1", true);
}

void OnStart()

{
    AddEntityCollideCallback("Player", "PlayerCollide_2", "MonsterFunction", true, 1);
}

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
    AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_18", 5, "");

    AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_26", 0.0001, "");
    AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_29", 0.0001, "");
    SetEntityActive("servant_brute_2", true);
}
07-28-2014, 04:16 AM
Find Reply
Mudbill Offline
Posting Freak

Posts: 3,651
Threads: 58
Joined: Apr 2013
Reputation: 169
#2
RE: I suck at scripting

You can't have 2 functions of the same name (unless they use different parameters).

07-28-2014, 05:07 AM
Find Reply
Daktoa Offline
Member

Posts: 98
Threads: 10
Joined: Jul 2014
Reputation: 1
#3
RE: I suck at scripting

I tried changing it and it still doesn't work

void OnStart()
{
    AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 0.0001, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_5", 0.0001, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_10", 0.001, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_13", 0.0001, "");
        AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_17", 0.0001, "");
    SetEntityActive("servant_brute_1", true);
}

{
    AddEntityCollideCallback("Player", "PlayerCollide_2", "MonsterFunction_2", true, 1);
}

    void MonsterFunction_2(string &in asParent, string &in asChild, int alState)
{
    AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_18", 5, "");

    AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_26", 0.0001, "");
    AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_29", 0.0001, "");
    SetEntityActive("servant_brute_2", true);
}
07-28-2014, 07:55 AM
Find Reply
Slanderous Offline
Posting Freak

Posts: 1,608
Threads: 78
Joined: Dec 2012
Reputation: 63
#4
RE: I suck at scripting

All of the EntityCollideCallbacks, SetEntityCallback and other shit have to be either in Void OnStart(), void onEntern(), and you use void OnLeave() to do shit when leaving a map for example preparing loading text and background, halting the music etc


it should look like this...

PHP Code: (Select All)
void OnStart()
{
AddEntityCollideCallback("Player","AreaYell_1","Yell",true,1);
AddEntityCollideCallback("Player","Scare","Yell2",true,1);
}

void Yell2(string &in asParentstring &in asChildint alState)
{
    
//use your stuff here
}

void Yell(string &in asParentstring &in asChildint alState)
{
        
//do shit here

(This post was last modified: 07-28-2014, 08:25 AM by Slanderous.)
07-28-2014, 08:25 AM
Find Reply
Mudbill Offline
Posting Freak

Posts: 3,651
Threads: 58
Joined: Apr 2013
Reputation: 169
#5
RE: I suck at scripting

Making a code block without a constructor will crash you. Instead of having 2 with the same name, just merge them into 1 and have both scripts inside your first OnStart() like Lazzer provided.

07-28-2014, 05:14 PM
Find Reply
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#6
RE: I suck at scripting

Daktoa, not sure whether this'll be much help for the future, but I found scripting got a ton easier when I started taking programming courses (which are required for first year engineering). I still have the notes in a .rar file. It's all designed for people who have never even looked at programming before. Since angelscript (what hpl2 uses) is similar to C++, most of the stuff overlaps (except apparently arrays and vectors - but that's beyond the basics for hpl2).

If you want to practice that stuff and see it actually do things, Visual Studio 2010 is free and fairly easy to use (it's what the notes use as well). I was able to make simple guessing games and text adventures using that.

[Image: quote_by_rueppells_fox-d9ciupp.png]
07-29-2014, 01:24 AM
Find Reply
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#7
RE: I suck at scripting

That's good advice, but what you linked to is not Visual Studio itself, but rather the Microsoft Visual C++ 2010 Redistributable Package - which is a set of libraries required to run programs developed with Visual C++ (I don't think that it includes the command line compiler.)

Actually, Microsoft publishes a free version of the Visual Studio IDE with every release, called Microsoft Visual Studio Express - and it's not some crappy version with limited functionality, it's really good - it can satisfy the needs of even intermediate developers, or advanced enthusiasts. What it lacks are some advanced/professional features that a beginner will not need anyway. So, it doesn't have to be VS 2010, you can take your pick from any of these:

Visual Studio 2010 Express
Visual Studio 2012 Express
Visual Studio 2013 Express - scroll down to where it says Express 2013 for Windows Desktop


P.S. If you want to understand amnesia scripting a bit deeper, you can check out my Script Language Reference and Guide on the wiki. It's unfinished, but it covers pretty much everything you'd normally encounter when scripting. I'll see if I can add some more content one of these days - the final section is a bit rushed/confusing, and I'd love to write about classes and objects before SOMA is released.
07-29-2014, 03:15 PM
Find Reply
Mudbill Offline
Posting Freak

Posts: 3,651
Threads: 58
Joined: Apr 2013
Reputation: 169
#8
RE: I suck at scripting

(07-29-2014, 03:15 PM)TheGreatCthulhu Wrote: P.S. If you want to understand amnesia scripting a bit deeper, you can check out my Script Language Reference and Guide on the wiki.

This section looks really well made. I took a look at it and it really is easy to follow and explains well with a good overview. I like it Smile

07-29-2014, 06:08 PM
Find Reply
Daemian Offline
Posting Freak

Posts: 1,130
Threads: 42
Joined: Dec 2012
Reputation: 49
#9
RE: I suck at scripting

OMG Cthulhu is back? xD
So many posts about code brought him back.

07-30-2014, 03:10 AM
Find Reply




Users browsing this thread: 1 Guest(s)