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
Scripting problem
JonnyAnomaly Offline
Member

Posts: 179
Threads: 20
Joined: Nov 2012
Reputation: 14
#1
Question  Scripting problem

I'm trying to make a script to make an enemy randomly appear and disappear, then loop the script. The problem is, after he has been activated once, he never comes back. Here is my script at the moment -

void OnEnter()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "activatemonster1", true, 1);
}

void activatemonster1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("manhunter_1", true);
AddTimer("", RandFloat(5.0f, 20.0), "deactivatemonster1");
}

void deactivatemonster1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("manhunter_1", false);
AddTimer("", RandFloat(60.0f, 120.0), "activatemonster1");
}

Would someone be able to tell me why its not repeating itself?
08-01-2013, 01:00 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Scripting problem

void OnEnter()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "activatemonster1", true, 1);
}

void activatemonster1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("manhunter_1", true);
AddTimer("", RandFloat(5.0f, 20.0), "deactivatemonster1");
}

void deactivatemonster1(string &in asTimer)
{
SetEntityActive("manhunter_1", false);
AddTimer("", RandFloat(60.0f, 120.0), "activatemonster1");
}

You had the wrong callback syntax in the first AddTimer call.

"Veni, vidi, vici."
"I came, I saw, I conquered."
08-01-2013, 01:06 PM
Find
JonnyAnomaly Offline
Member

Posts: 179
Threads: 20
Joined: Nov 2012
Reputation: 14
#3
RE: Scripting problem

Ah I see, thanks for your help!
08-01-2013, 01:44 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: Scripting problem

PHP Code: (Select All)
void OnEnter() // should probably be OnStart
{
    
AddEntityCollideCallback("Player""ScriptArea_1""ActivateMonster"true1);
}

void ActivateMonster(string &in asParentstring &in asChildint alState)
{
    if (
asChild == "ScriptArea_1")
        
ActivateMonster("manhunter_1");
}

void ActivateMonster(string &in monster)
{
    
ResetProp(monster);
    
SetEntityActive(monstertrue);
    
AddTimer(monsterRandFloat(5.0f20.0), "DeactivateMonster");
}

void DeactivateMonster(string &in monster)
{
    
SetEntityActive(monsterfalse);
    
AddTimer(monsterRandFloat(60.0f120.0), "ActivateMonster");


Tutorials: From Noob to Pro
(This post was last modified: 08-01-2013, 05:20 PM by Your Computer.)
08-01-2013, 05:19 PM
Website Find
JonnyAnomaly Offline
Member

Posts: 179
Threads: 20
Joined: Nov 2012
Reputation: 14
#5
RE: Scripting problem

Thanks, I'm still trying to learn the basics of scripting, so many stupid mistakes are made. I'm still at the stage where I punch the air if my map loads without a fatal error.
(This post was last modified: 08-01-2013, 05:43 PM by JonnyAnomaly.)
08-01-2013, 05:39 PM
Find
DeAngelo Offline
Senior Member

Posts: 263
Threads: 26
Joined: Feb 2013
Reputation: 11
#6
RE: Scripting problem

As a scripter you'll have to walk the fine balance of figuring things out yourself so you get better, and asking the fine folk here. My general rule of thumb: don't ask until the error is causing you to re-evaluate your goals in life.

A Late Night Drink http://www.moddb.com/mods/a-late-night-drink
Check out my LP channel, CatBearGaming, I take all Custom Story requests!
08-01-2013, 11:37 PM
Find




Users browsing this thread: 1 Guest(s)