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
Script help required
Zokrar Offline
Member

Posts: 85
Threads: 16
Joined: May 2013
Reputation: 0
#1
Script help required

What I'm trying to accomplish is this:

There are two grunts at first. gruntOne, gruntTwo. If you look at one, it disappears, a sound plays, and a particle system appears where the grunt disappeared. I have this much working so far.

What's NOT working is when I try and add a timer between when the other one can spawn. In this case, say gruntOne is active, and gruntTwo is not. I want it so that when I look at gruntOne, it'll disappear, do all the particles/sounds etc., and 3 seconds after it disappears, gruntTwo spawns in, and vice versa. Could someone take a look at my script to see if they can fix it please?

Spoiler below!
void OnStart()
{
    if(ScriptDebugOn())
    {
        GiveItemFromFile("lantern", "lantern.ent");
    }
    
    
    //****** ATTACKING GRUNTS *********
    SetEntityPlayerLookAtCallback("gruntOne", "GruntOne", false);
    SetEntityPlayerLookAtCallback("gruntTWo", "GruntTwo", false);
    //****** ATTACKING GRUNTS *********
    
    
    SetSkyBoxActive(true);
       SetSkyBoxTexture("nighttime.dds");
       
       
       PlayMusic("ending_alexander.ogg", true, 0.30, 2.00, 5, true);
}




//****** ATTACKING GRUNTS *********
void GruntOne(string &in asEntity, int alState)
{
    if(alState == 1)
    {
        SetEntityActive("gruntOne", false);
        CreateParticleSystemAtEntity("electro1", "ps_electro_charge.ps", "gruntOne", true);
        PlaySoundAtEntity("grunt1", "15_bang.snt", "Player", 0, false);
        
        
        AddTimer("GruntTwoSpawnDelay", 3.00, "");
        GetTimerTimeLeft("GruntTwoSpawnDelay");
        if(GetTimerTimeLeft("GruntTwoSpawnDelay") > 0)
        {
            GetTimerTimeLeft("GruntTwoSpawnDelay");
        }
        else if(GetTimerTimeLeft("GruntTwoSpawnDelay") == 0)
        {
            SetEntityActive("gruntTwo", true);
            DestroyParticleSystem("electro2");
        }
    }
}

void GruntTwo(string &in asEntity, int alState)
{
    if(alState == 1)
    {
        SetEntityActive("gruntTwo", false);
        CreateParticleSystemAtEntity("electro2", "ps_electro_charge.ps", "gruntTwo", true);
        PlaySoundAtEntity("grunt2", "15_bang.snt", "Player", 0, false);
        
        
        AddTimer("GruntOneSpawnDelay", 3.00, "");
        if(GetTimerTimeLeft("GruntOneSpawnDelay") > 0)
        {
            GetTimerTimeLeft("GruntOneSpawnDelay");
        }
        else if(GetTimerTimeLeft("GruntOneSpawnDelay") == 0)
        {
            SetEntityActive("gruntOne", true);
            DestroyParticleSystem("electro1");
        }
    }
}
//****** ATTACKING GRUNTS *********


UPDATED SCRIPT: Still not working, but closer to solution I think.

Spoiler below!
void OnStart()
{
    if(ScriptDebugOn())
    {
        GiveItemFromFile("lantern", "lantern.ent");
    }
    
    
    //****** ATTACKING GRUNTS *********
    
    SetEntityPlayerLookAtCallback("gruntOne", "GruntOne", false);
    SetEntityPlayerLookAtCallback("gruntTWo", "GruntTwo", false);
    AddLocalVarInt("Grunt1State", 1);
    AddLocalVarInt("Grunt2State", 1);
    
    //****** ATTACKING GRUNTS *********
    
    
    SetSkyBoxActive(true);
       SetSkyBoxTexture("nighttime.dds");
       
       
       PlayMusic("ending_alexander.ogg", true, 0.30, 2.00, 5, true);
}




//****** ATTACKING GRUNTS *********
void GruntOne(string &in asEntity, int alState)
{
    if(alState == 1)
    {
          SetEntityActive("gruntOne", false);
          CreateParticleSystemAtEntity("electro1", "ps_electro_charge.ps", "gruntOne", true);
          PlaySoundAtEntity("grunt1", "15_bang.snt", "Player", 0, false);
          AddTimer("GruntOneSpawnDelay", 3.00, "");
          SetLocalVarInt("Grunt1State", 0);
  
    }
    else if(alState == -1)
    {
          if(GetLocalVarInt("Grunt1State") == 0)
          {
               if(GetTimerTimeLeft("GruntOneSpawnDelay") <= 0)
               {
                SetEntityActive("gruntTwo", true);
                DestroyParticleSystem("electro1");
                SetLocalVarInt("Grunt1State", 1);
               }
          }
    }
}

void GruntTwo(string &in asEntity, int alState)
{
    if(alState == 1)
    {
        SetEntityActive("gruntTwo", false);
        CreateParticleSystemAtEntity("electro2", "ps_electro_charge.ps", "gruntTwo", true);
        PlaySoundAtEntity("grunt2", "15_bang.snt", "Player", 0, false);
        AddTimer("GruntTwoSpawnDelay", 3.00, "");
        SetLocalVarInt("Grunt2State", 0);
    
    }
    else if(alState == -1)
    {
        if(GetLocalVarInt("Grunt2State") == 0)
        {
            if(GetTimerTimeLeft("GruntTwoSpawnDelay") <= 0)
            {
                SetEntityActive("gruntOne", true);
                DestroyParticleSystem("electro2");
                SetLocalVarInt("Grunt2State", 1);
            }
        }
    }
}
//****** ATTACKING GRUNTS *********


(This post was last modified: 06-23-2013, 02:32 AM by Zokrar.)
06-22-2013, 09:14 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Script help required

AddTimer("GruntOneSpawnDelay", 3, "GruntOneTimer");
AddTimer("GruntTwoSpawnDelay", 3, "GruntTwoTimer");

You forgot to add a function to the AddTimer functions. Third argument. If you're using full numbers (such as 1, 2, 3, 4, etc.), you don't need to add .00. Just write it as the number.

EXTRA PROBLEM

SetEntityPlayerLookAtCallback("gruntTwo", "GruntTwo", false);

Found a typo there, in the first argument. You wrote "gruntTWo" instead of "gruntTwo".

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 06-23-2013, 02:06 AM by PutraenusAlivius.)
06-23-2013, 02:05 AM
Find
Zokrar Offline
Member

Posts: 85
Threads: 16
Joined: May 2013
Reputation: 0
#3
[SOLVED] Script help required

What would I do with the GruntOneTimer and GruntTwoTimer? The big problem for me with this code is that I don't know how to go about organizing it to flow properly with the timer included. I tried using variables and alState, and for reasons I can't see it didn't work. I fixed the typo too, thanks for catching that.

EDIT: Got it working! I feel stupid now, lol. I went about it the hard way.

Here's the code, incase anyone's wondering.

Spoiler below!
void OnStart()
{
    if(ScriptDebugOn())
    {
        GiveItemFromFile("lantern", "lantern.ent");
    }
    
    
    //****** ATTACKING GRUNTS *********
    
    SetEntityPlayerLookAtCallback("gruntOne", "GruntOne", false);
    SetEntityPlayerLookAtCallback("gruntTwo", "GruntTwo", false);
    AddLocalVarInt("Grunt1State", 1);
    AddLocalVarInt("Grunt2State", 1);
    
    //****** ATTACKING GRUNTS *********
    
    
    SetSkyBoxActive(true);
       SetSkyBoxTexture("nighttime.dds");
       
       
       PlayMusic("ending_alexander.ogg", true, 0.30, 2.00, 5, true);
}




//****** ATTACKING GRUNTS *********
void GruntOne(string &in asEntity, int alState)
{
    if(alState == 1)
    {
        if(GetLocalVarInt("Grunt1State") == 1)
        {
              SetEntityActive("gruntOne", false);
              CreateParticleSystemAtEntity("electro1", "ps_electro_charge.ps", "gruntOne", true);
              PlaySoundAtEntity("grunt1", "15_bang.snt", "Player", 0, false);
              AddTimer("GruntOneSpawnDelay", 3, "GruntOneTimer");
              SetLocalVarInt("Grunt1State", 0);
        }
    }
}

void GruntTwo(string &in asEntity, int alState)
{
    if(alState == 1)
    {
        if(GetLocalVarInt("Grunt2State") == 1)
        {    
            SetEntityActive("gruntTwo", false);
            CreateParticleSystemAtEntity("electro2", "ps_electro_charge.ps", "gruntTwo", true);
            PlaySoundAtEntity("grunt2", "15_bang.snt", "Player", 0, false);
            AddTimer("GruntTwoSpawnDelay", 3, "GruntTwoTimer");
            SetLocalVarInt("Grunt2State", 0);
        }
    }
}

void GruntOneTimer(string &in asTimer)
{
    SetEntityActive("gruntTwo", true);
    DestroyParticleSystem("electro2");
    SetLocalVarInt("Grunt1State", 1);
}

void GruntTwoTimer(string &in asTimer)
{
    SetEntityActive("gruntOne", true);
    DestroyParticleSystem("electro1");
    SetLocalVarInt("Grunt2State", 1);
}
//****** ATTACKING GRUNTS *********


(This post was last modified: 06-23-2013, 02:32 AM by Zokrar.)
06-23-2013, 02:21 AM
Find




Users browsing this thread: 1 Guest(s)