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

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Monster won't spawn after changing script.
Author Message
Robosprog Offline
Posting Freak

Posts: 2,219
Joined: Apr 2012
Reputation: 57
Post: #1
Monster won't spawn after changing script.
I created a script that spawns a monster after picking up an item, which worked, however when I made the script to remove an entity it suddenlly stopped spawning the monster. Here's the script:


Quote:void OnStart()
{
AddUseItemCallback("", "house_key", "mansion", "FUNCTION", true);
SetEntityPlayerInteractCallback("knife", "ActivateMonster", true);
SetEntityPlayerInteractCallback("knife", "GruntFade", true);
}

void FUNCTION(string &in item, string &in door)
{
SetSwingDoorLocked(door, false, true);
PlaySoundAtEntity("", "unlock_door", door, 0, false);
RemoveItem(item);
}
void DoorLockedPlayer(string &in entity)


{
if(GetSwingDoorLocked("mansion") == true)
{

SetMessage("Messages", "msgname", 0);

}
}

void ActivateMonster(string &in item)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "Idle");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "Idle");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "Idle");
}

void GruntFade (string &in item)
{
SetEntityActive("grunt", false);
}
Any idea why the monster won't spawn now? (And no, this isn't really a jumpscare so don't jump to conclusions)

06-06-2012 03:47 PM
Find all posts by this user Quote this message in a reply
Your Computer Offline
SCAN ME!

Posts: 3,236
Joined: Jul 2011
Reputation: 216
Post: #2
RE: Monster won't spawn after changing script.
If you're going to create interact callbacks for the same item, then keep it all within one callback.

Tutorials: From Noob to Pro
06-06-2012 03:59 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Robosprog Offline
Posting Freak

Posts: 2,219
Joined: Apr 2012
Reputation: 57
Post: #3
RE: Monster won't spawn after changing script.
(06-06-2012 03:59 PM)Your Computer Wrote:  If you're going to create interact callbacks for the same item, then keep it all within one callback.
.. *facepalms at own stupidity* I'm a retard.


Tried that, now neither happens.

(This post was last modified: 06-06-2012 04:07 PM by Robosprog.)
06-06-2012 04:04 PM
Find all posts by this user Quote this message in a reply
Putmalk Offline
Senior Member

Posts: 275
Joined: Apr 2012
Reputation: 15
Post: #4
RE: Monster won't spawn after changing script.
Rewrote the code because I don't know what you were using as function parameters, but they weren't right. :/

void OnStart()
{

    AddUseItemCallback("", "house_key", "mansion", "FUNCTION", true);

    //Right here is confusing...you activate a monster, and remove another monster??? Or activate/remove the same upon interaction.
    SetEntityPlayerInteractCallback("knife", "ActivateMonster", true);
    SetEntityPlayerInteractCallback("knife", "GruntFade", true);
}

//add use item callback parameters are string &in asItem, string &in asEntity
void FUNCTION(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked(door, false, true);
    PlaySoundAtEntity("", "unlock_door", door, 0, false);
    RemoveItem(asItem);
}

//going to assume this came from an Interact Callback from editor? if so, string &in asEntity
void DoorLockedPlayer(string &in asEntity)
{
    if(GetSwingDoorLocked("mansion") == true)
    {
        SetMessage("Messages", "msgname", 0);
    }
}

//from the OnStart() function, string &in asEntity as it's an Interact Callback
void ActivateMonster(string &in asEntity)
{
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "Idle");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "Idle");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "Idle");
}

//same as above, I'm assuming there's another grunt on the map called "grunt" and it's being removed with this function.
void GruntFade(string &in asEntity)
{
    SetEntityActive("grunt", false);
}

Check me out at my youtube channel: http://www.youtube.com/user/Putmalk?feature=mhee

I post videos of my Amnesia creations.
06-06-2012 04:15 PM
Find all posts by this user Quote this message in a reply
Robosprog Offline
Posting Freak

Posts: 2,219
Joined: Apr 2012
Reputation: 57
Post: #5
RE: Monster won't spawn after changing script.
(06-06-2012 04:15 PM)Putmalk Wrote:  Rewrote the code because I don't know what you were using as function parameters, but they weren't right. :/

void OnStart()
{

    AddUseItemCallback("", "house_key", "mansion", "FUNCTION", true);

    //Right here is confusing...you activate a monster, and remove another monster??? Or activate/remove the same upon interaction.
    SetEntityPlayerInteractCallback("knife", "ActivateMonster", true);
    SetEntityPlayerInteractCallback("knife", "GruntFade", true);
}

//add use item callback parameters are string &in asItem, string &in asEntity
void FUNCTION(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked(door, false, true);
    PlaySoundAtEntity("", "unlock_door", door, 0, false);
    RemoveItem(asItem);
}

//going to assume this came from an Interact Callback from editor? if so, string &in asEntity
void DoorLockedPlayer(string &in asEntity)
{
    if(GetSwingDoorLocked("mansion") == true)
    {
        SetMessage("Messages", "msgname", 0);
    }
}

//from the OnStart() function, string &in asEntity as it's an Interact Callback
void ActivateMonster(string &in asEntity)
{
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "Idle");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "Idle");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "Idle");
}

//same as above, I'm assuming there's another grunt on the map called "grunt" and it's being removed with this function.
void GruntFade(string &in asEntity)
{
    SetEntityActive("grunt", false);
}
Yeah, I probably should have explained it for you - I'm not removing another grunt but the chest and head piece of the dead grunt. Making that vanish to give the impression of it "coming alive".
Right, using this code with a tiny amount of editing on the key and door as that messed up and wouldn't let me load, it just leads to the same result as the first time.

(This post was last modified: 06-06-2012 04:30 PM by Robosprog.)
06-06-2012 04:19 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)