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
Having a slight problem...
TrollingForever Offline
Junior Member

Posts: 9
Threads: 2
Joined: Apr 2013
Reputation: 0
#1
Having a slight problem...

I`m having a slight problem. I am trying to figure out how to activate an entity when two altar_knifes are used, but I cannot. I tryed achieving this by using "if" commands as well, but with no success. Here is the part of my .hps in which this problem occurs:

}

void TurnRed2(string &in asEntity)

{
        SetEntityActive("special_altar_static_knife_4", false);
    SetEntityActive("special_altar_static_knife_5", true);
    GivePlayerDamage(5.0f, "BloodSplat", false, false);
}

void TurnRed(string &in asEntity)

{
        SetEntityActive("special_altar_static_knife_2", false);
    SetEntityActive("special_altar_static_knife_3", true);
    GivePlayerDamage(5.0f, "BloodSplat", false, false);
}

The SetEntityActive parts do this - after the Player "uses" the altar_static_knife, a static_knife_bloody appears.
Anyway, the thing I`m trying to achieve here is after the Player "uses" both knifes, an Orb spawns in it`s designated place, but I do not know how to do this. Hopefully I was clear enough xD Thanks for the help in advance! Big Grin
04-23-2013, 04:26 PM
Website Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#2
RE: Having a slight problem...

Try doing something like this:

PHP Code: (Select All)
OnStart()
{

//Sets up variable
SetLocalVarInt("OrbCheck",0);

}

...

void TurnRed()
{
...
//Adds local variable, checks if the other knife has been used
AddLocalVarInt("OrbCheck",1);
OrbCheckFunction();
}

void TurnRed2()
{
...
//Adds local variable, checks if other knife has been used
AddLocalVarInt("OrbCheck",1);
OrbCheckFunction();
}

void OrbCheckFunction()
{
//This function checks if both knives have been used
if(GetLocalVarInt("OrbCheck") == 2)
{
SetEntityActve("Orb",true);
}



Eh, that looks pretty rough and I haven't tested, but I hope it gives you a general idea.

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
04-23-2013, 04:54 PM
Find
TrollingForever Offline
Junior Member

Posts: 9
Threads: 2
Joined: Apr 2013
Reputation: 0
#3
RE: Having a slight problem...

(04-23-2013, 04:54 PM)Mr Credits Wrote: Try doing something like this:

PHP Code: (Select All)
OnStart()
{

//Sets up variable
SetLocalVarInt("OrbCheck",0);

}

...

void TurnRed()
{
...
//Adds local variable, checks if the other knife has been used
AddLocalVarInt("OrbCheck",1);
OrbCheckFunction();
}

void TurnRed2()
{
...
//Adds local variable, checks if other knife has been used
AddLocalVarInt("OrbCheck",1);
OrbCheckFunction();
}

void OrbCheckFunction()
{
//This function checks if both knives have been used
if(GetLocalVarInt("OrbCheck") == 2)
{
SetEntityActve("Orb",true);
}



Eh, that looks pretty rough and I haven't tested, but I hope it gives you a general idea.

Thanks for the reply! I think I did not fully understand you. Do I have to put the SetLocalVarInt in OnStart like this:

void OnStart()
{
    AddEntityCollideCallback("Player", "end_script", "FadeOut", true, 1);
    AddEntityCollideCallback("Player", "Start_lookat", "LookAtBodies", true, 1);
    AddEntityCollideCallback("Player", "Start_wakeup", "WakeDaFuckUp", true, 1);
    AddEntityCollideCallback("Player", "Start_music", "StartDaMusic", true, 1);
    AddEntityCollideCallback("Player", "Activate_Scary", "StartScary", true, 1);
    SetLocalVarInt("OrbCheck",0);    
    InteractConnectPropWithMoveObject("leverSlideDoor", "level_open_slide", "safety_normal_vert_1", true, false, 0);
}

Also, if you need it, here is my entire .hps (you can ignore the CollideCallbacks, it`s not connected to this):

////////////////////////////
// Run when the map starts
void OnStart()
{
    AddEntityCollideCallback("Player", "end_script", "FadeOut", true, 1);
    AddEntityCollideCallback("Player", "Start_lookat", "LookAtBodies", true, 1);
    AddEntityCollideCallback("Player", "Start_wakeup", "WakeDaFuckUp", true, 1);
    AddEntityCollideCallback("Player", "Start_music", "StartDaMusic", true, 1);
    AddEntityCollideCallback("Player", "Activate_Scary", "StartScary", true, 1);
    InteractConnectPropWithMoveObject("leverSlideDoor", "level_open_slide", "safety_normal_vert_1", true, false, 0);
}

void OpenWind(string &in asEntity, int alState)

{
    AddTimer("Start", 4.0f, "OpenWind2");
}

void OpenWind2(string &in asTimer)

{
if(GetSwingDoorClosed("castle_1"))  //Checks to see if the door is closed.
      {
       AddTimer("Start", 4.0f, "");
       SetSwingDoorDisableAutoClose("castle_1", true);  //This will stop the door from closing as soon as it opens.
       SetSwingDoorClosed("castle_1", false, true);  //This opens the door so that the force will do something, and not act like throwing a book at a closed door.
      
       AddPropForce("castle_1", 0, 0, 460, "world");
       CreateParticleSystemAtEntity("", "ps_dust_ghost.ps", "castle_1", false);
       }      
}

void TurnRed2(string &in asEntity)

{
    SetEntityActive("special_altar_static_knife_4", false);
    SetEntityActive("special_altar_static_knife_5", true);
    GivePlayerDamage(5.0f, "BloodSplat", false, false);
}

void TurnRed(string &in asEntity)

{
    SetEntityActive("special_altar_static_knife_2", false);
    SetEntityActive("special_altar_static_knife_3", true);
    GivePlayerDamage(5.0f, "BloodSplat", false, false);
}

void StartScary(string &in asParent, string &in asChild, int alState)

{
    PlaySoundAtEntity("fountain", "guardian_activated.snt", "Player", 0, false);
    StartPlayerLookAt("fountain_childsnake_blood_1", 10, 15, "");
    StartScreenShake(0.5f, 3, 1, 2);    
    StopMusic(2, 3);
    StartEffectFlash(3, 1.0, 2);
    AddTimer("Stop", 5.0f, "StopLook");
    
}

void StopLook(string &in asTimer)

{  
    PlayMusic("evilpart.ogg", true, 0.8, 2.0f, 3, false);
    StopPlayerLookAt();    
}    

void StartDaMusic(string &in asParent, string &in asChild, int alState)

{
    PlayMusic("evilpart.ogg", true, 0.8, 2.0f, 3, false);
}

void WakeDaFuckUp(string &in asParent, string &in asChild, int alState)

{
    FadePlayerRollTo(80, 500, 500);
}

void LookAtBodies(string &in asParent, string &in asChild, int alState)

{
    StartPlayerLookAt("hanging_prisoner_1", 2, 4, "");
    AddTimer("StopDaLookMan", 5.0f, "StopDaLook");
    PlaySoundAtEntity("", "scare_breath.snt", "Player", 0, false);
    SetPlayerMoveSpeedMul(0);
}

void StopDaLook(string &in asTimer)

{
    StopPlayerLookAt();
    SetPlayerMoveSpeedMul(1);
}

void FadeOut(string &in asParent, string &in asChild, int alState)

{
FadeOut(2);
AddTimer("", 2, "StopMusic");
AddTimer("", 5, "AddMessage");
FadeGlobalSoundVolume(0, 3);
}

void StopMusic(string &in asTimer)
{
StopMusic(1, 0);
}

void AddMessage(string &in asTimer)
{
SetMessage("Messages", "FinishStory", 10);
AddTimer("", 10, "FadeOut2");
SetPlayerActive(false);
}

void FadeOut2(string &in asTimer)
{
FadeOut(3);
AddTimer("", 3, "StartCredits");
}

void StartCredits(string &in asTimer)
{
FadeGlobalSoundVolume(100, 2);
StartCredits("end_music.ogg", false, "Ending", "MainCredits", 5);
}
////////////////////////////
// Run when entering map
void OnEnter()
{  
if(ScriptDebugOn())
    {
        AddTimer("TimerEIntro", 0.25f, "TimerEIntro");
    }
    else
    {
        AddTimer("TimerEIntro", 0.25f, "TimerEIntro");
    }
}

void TimerEIntro(string &in asTimer)
{
    int iMaxEventStep = 16;
    float fEventSpeed = 1.0f;
    string sEvent = asTimer;

    AddLocalVarInt(sEvent, 1);

    switch(GetLocalVarInt(sEvent)){
        case 1:
            FadeIn(2.0f);
            CreateParticleSystemAtEntity("dust", "ps_dust_elevator_crash.ps", "AreaDust", false);
            PlaySoundAtEntity("breath1", "react_breath_slow", "Player", 0.5f, false);
            StartPlayerLookAt("AreaLook_2", 1.2f, 1.2f, "");
            MovePlayerHeadPos(0.0f, -0.8f, 0.5f, 0.8f, 0.8f);
            FadePlayerRollTo(-30.0f, 2.0f, 2.0f);
            PlayMusic("15_event_elevator.ogg", false, 1.0f, 0.5f, 10, false);
            fEventSpeed = 1.0f;
        break;
        case 2:
            SetPlayerActive(true);
            PlaySoundAtEntity("cloth1", "player_crouch", "Player", 0.2f, false);
            SetPlayerMoveSpeedMul(0.05f);
            SetPlayerRunSpeedMul(0.05f);
            SetPlayerLookSpeedMul(0.05f);
            MovePlayerHeadPos(0.0f, -0.8f, -0.5, 1.2f, 1.2f);
            fEventSpeed = 1.0f;
        break;
        case 3:
            FadePlayerRollTo(30.0f, 6.0f, 6.0f);
            SetPlayerMoveSpeedMul(0.1f);
            SetPlayerRunSpeedMul(0.1f);
            SetPlayerLookSpeedMul(0.1f);
            StartPlayerLookAt("AreaLook_3", 0.5f, 0.5f, "");
            SetPlayerLookSpeedMul(0.2f);
            fEventSpeed = 2.0f;
        break;
        case 4:
            SetPlayerMoveSpeedMul(0.15f);
            SetPlayerRunSpeedMul(0.15f);
            SetPlayerLookSpeedMul(0.15f);
            FadeOut(5.0f);
            PlaySoundAtEntity("sight1", "react_sigh", "Player", 0.5f, false);
            StartPlayerLookAt("AreaLook_1", 0.5f, 0.5f, "");
            FadePlayerRollTo(-30.0f, 10.0f, 10.0f);
            fEventSpeed = 0.5f;
        break;
        case 5:
            PlaySoundAtEntity("cloth2", "player_climb", "Player", 0.2f, false);
            SetPlayerMoveSpeedMul(0.2f);
            SetPlayerRunSpeedMul(0.2f);
            SetPlayerLookSpeedMul(0.2f);
            MovePlayerHeadPos(0.0f, -0.5f, -0.25f, 0.5f, 0.5f);
            fEventSpeed = 0.5f;
        break;
        case 6:
            SetPlayerMoveSpeedMul(0.25f);
            SetPlayerRunSpeedMul(0.25f);
            SetPlayerLookSpeedMul(0.25f);
            FadePlayerRollTo(0.0f, 15.0f, 15.0f);
            fEventSpeed = 2.0f;
        break;
        case 7:
            PlaySoundAtEntity("sight2", "react_sigh", "Player", 0.4f, false);
            SetPlayerMoveSpeedMul(0.3f);
            SetPlayerRunSpeedMul(0.3f);
            SetPlayerLookSpeedMul(0.3f);
            FadeIn(2.0f);
            FadePlayerRollTo(30.0f, 8.0f, 8.0f);
            MovePlayerHeadPos(0.0f, -0.8f, -0.5f, 0.7f, 0.5f);
            PlaySoundAtEntity("cloth3", "player_crouch", "Player", 0.2f, false);
        break;
        case 8:
            SetPlayerMoveSpeedMul(0.35f);
            SetPlayerRunSpeedMul(0.35f);
            SetPlayerLookSpeedMul(0.35f);
            StartPlayerLookAt("AreaLook_3", 1.0f, 0.5f, "");
            fEventSpeed = 0.5f;
        break;
        case 9:
            SetPlayerMoveSpeedMul(0.4f);
            SetPlayerRunSpeedMul(0.4f);
            SetPlayerLookSpeedMul(0.4f);
            FadePlayerRollTo(-30, 30.0f, 30.0f);
            MovePlayerHeadPos(0.0f, 0.0f, 0.0f, 0.8f, 0.8f);
            PlaySoundAtEntity("cloth4", "player_stand", "Player", 0.2f, false);
            fEventSpeed = 0.5f;
        break;
        case 10:
            FadePlayerRollTo(30, 8.0f, 8.0f);
            PlaySoundAtEntity("cloth5", "player_climb", "Player", 0.5f, false);
            SetPlayerMoveSpeedMul(0.45f);
            SetPlayerRunSpeedMul(0.45f);
            SetPlayerLookSpeedMul(0.45f);
            FadeOut(4.0f);
            StartPlayerLookAt("AreaLook_2", 1.5f, 1.5f, "");
            fEventSpeed = 1.0f;
        break;
        case 11:
            FadePlayerRollTo(-30, 10.0f, 10.0f);
            fEventSpeed = 0.5f;
        break;
        case 12:
            FadePlayerRollTo(0, 8.0f, 8.0f);
            SetPlayerMoveSpeedMul(0.5f);
            SetPlayerRunSpeedMul(0.5f);
            SetPlayerLookSpeedMul(0.5f);
            FadeIn(1.0f);
            StopPlayerLookAt();
        break;
        case 13:
            SetPlayerMoveSpeedMul(0.6f);
            SetPlayerRunSpeedMul(0.6f);
            SetPlayerLookSpeedMul(0.7f);
        break;
        case 14:
            SetPlayerMoveSpeedMul(0.75f);
            SetPlayerRunSpeedMul(0.75f);
            SetPlayerLookSpeedMul(0.9f);
        break;
        case 15:
            SetPlayerMoveSpeedMul(0.85f);
            SetPlayerRunSpeedMul(0.85f);
            SetPlayerLookSpeedMul(1.0f);
        break;
        case 16:
            SetPlayerCrouchDisabled(false);
            SetPlayerJumpDisabled(false);
            SetPlayerMoveSpeedMul(1.0f);
            SetPlayerRunSpeedMul(1.0f);
            PlayMusic("15_event_elevator.ogg", true, 1.0f, 0.5f, 0, true);
        break;
    }

    if(GetLocalVarInt(sEvent) <= iMaxEventStep) AddTimer(sEvent, fEventSpeed, sEvent);
    }
////////////////////////////
// Run when leaving map
void OnLeave()
{
    StopMusic(2, 10);
    AutoSave();
}
04-23-2013, 05:07 PM
Website Find
immaturegames Offline
Junior Member

Posts: 18
Threads: 1
Joined: Apr 2013
Reputation: 0
#4
RE: Having a slight problem...

Sorry to say it but wrong sub forum, if a moderator could move it to development support I will be happy Smile once its there I can help ;D
04-23-2013, 05:13 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#5
RE: Having a slight problem...

Ah, yes, sorry. I meant for you to add the SetLocalVarInt to your existing OnStart.

Also, it doesn't seem you have any use item callbacks. Since you're using 2 knives, you'll need to add 2 of them.

PHP Code: (Select All)
AddUseItemCallback(stringasNamestringasItemstringasEntitystringasFunctionbool abAutoDestroy); 

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
(This post was last modified: 04-23-2013, 05:23 PM by Tomato Cat.)
04-23-2013, 05:16 PM
Find
TrollingForever Offline
Junior Member

Posts: 9
Threads: 2
Joined: Apr 2013
Reputation: 0
#6
RE: Having a slight problem...

(04-23-2013, 05:16 PM)Mr Credits Wrote: Ah, yes, sorry. I meant for you to add the SetLocalVarInt to your existing OnStart.

Also, it doesn't seem you have any use item callbacks.

Since you're using 2 knives, you'll need to add 2 of them.

PHP Code: (Select All)
AddUseItemCallback(stringasNamestringasItemstringasEntitystringasFunctionbool abAutoDestroy); 

Thanks! I have the ItemCallbacks, but to cut down the writing in the .hps file, I added them in the Map Editor Big Grin Also, I thought I posted in the right place, sry. Big Grin
(This post was last modified: 04-23-2013, 05:25 PM by TrollingForever.)
04-23-2013, 05:24 PM
Website Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#7
RE: Having a slight problem...

Oh, I didn't even know you could do that. =o Anyhow, does the script work?

Actually, I'm not sure putting the use item callbacks into the editor works.

The use item calback function is called when the item (one of the knives) is used on an entity (I'm guessing script area?). Adding the callback in the editor calls said function when the player interacts with the item, not the item with the entity.

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
(This post was last modified: 04-23-2013, 05:39 PM by Tomato Cat.)
04-23-2013, 05:26 PM
Find
TrollingForever Offline
Junior Member

Posts: 9
Threads: 2
Joined: Apr 2013
Reputation: 0
#8
RE: Having a slight problem...

I`m sorry to say, but now I got even more confused xD This is what I wrote in the .hps file:

void TurnRed2(string &in asEntity)

{
    SetEntityActive("special_altar_static_knife_4", false);
    SetEntityActive("special_altar_static_knife_5", true);
    GivePlayerDamage(5.0f, "BloodSplat", false, false);
    AddLocalVarInt("OrbCheck",1);
    OrbCheckFunction();
}

void TurnRed(string &in asEntity)

{
    SetEntityActive("special_altar_static_knife_2", false);
    SetEntityActive("special_altar_static_knife_3", true);
    GivePlayerDamage(5.0f, "BloodSplat", false, false);
    AddLocalVarInt("OrbCheck",1);
    OrbCheckFunction();
}

void OrbCheckFunction()

{
    if(GetLocalVarInt("OrbCheck") == 2)
{
SetEntityActve("orb_pedestal_1",true);
SetEntityActve("orb_pedistal_tar_1",true);
SetEntityActve("orb_1",true);
}

}

I`m hoping I did this correctly (I haven`t tryed it out yet).

EDIT: When I said I added the Callbacks in the Map Editor, I meant for the PlayerInteractCallback in Entity tab.
(This post was last modified: 04-23-2013, 05:43 PM by TrollingForever.)
04-23-2013, 05:37 PM
Website Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#9
RE: Having a slight problem...

That's correct.

But you'll have to add a use item callback (see my above post) if you want the player to use the knives on something.

...Unless you just want the player to pick up the knives? Which wouldn't make sense because they're both have "static" in their names.

Uh, I'm a bit confused. o.O

The "player interact" callback is when the player interacts with the entity, like picking it up. As opposed to "using" the item, which is an item-entity interaction.

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
(This post was last modified: 04-23-2013, 05:46 PM by Tomato Cat.)
04-23-2013, 05:44 PM
Find
TrollingForever Offline
Junior Member

Posts: 9
Threads: 2
Joined: Apr 2013
Reputation: 0
#10
RE: Having a slight problem...

(04-23-2013, 05:44 PM)Mr Credits Wrote: That's correct.

But you'll have to add a use item callback (see my above post) if you want the player to use the knives on something.

...Unless you just want the player to pick up the knives? Which wouldn't make sense because they're both have "static" in their names.

Uh, I'm a bit confused. o.O

To "unconfuze" you, here is the picture of the knife Big Grin
When the Player interacts with both knifes (same as this one), the Orb (with it`s pedestal) should spawn.

[Image: leveleditor201304231848.png]
(This post was last modified: 04-23-2013, 05:50 PM by TrollingForever.)
04-23-2013, 05:49 PM
Website Find




Users browsing this thread: 1 Guest(s)