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


Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Rotating Bookshelf, Goblets move with it, but not books?
Ananaias Offline
Junior Member

Posts: 20
Threads: 7
Joined: Jun 2012
Reputation: 0
#1
Rotating Bookshelf, Goblets move with it, but not books?

In my custom story, I have a bookshelf that moves to reveal a secret doorway, that is activated by a switch being pulled. I had no items on it, and it looked really plain, so I added books and some Goblets to spice it up. However, I've come across an issue.

When the bookshelf rotates, the goblets go with it, but the books themselves don't. They just stay in their original position, but floating in the air.

[Image: Aesb]

Here's my script:

PHP Code: (Select All)
void OnStart()
{
    
SetEntityConnectionStateChangeCallback("lever""func_shelf");
    
AddUseItemCallback("""MasterRoomKey""MasterRoomDoor""unlock_door"true);
}

void func_shelf(string &in asEntityint alState)
{
    if (
alState == 1)
{
AddTimer(""3"Forcelook");
    
SetSwingDoorClosed("MasterRoomDoor"truetrue);
    
SetLampLit("light1room2"falsetrue);
    
SetLampLit("light2room2"falsetrue);
    
SetLampLit("light3room2"falsetrue);
    
SetLampLit("light4room2"falsetrue);
    
SetLampLit("light5room2"falsetrue);
    
SetLampLit("light6room2"falsetrue);
    
SetLampLit("light7room2"falsetrue);
    
SetLampLit("light8room2"falsetrue);
    
SetLampLit("light9room2"falsetrue);
    
SetLampLit("light1hall1"falsetrue);
    
SetLampLit("light2hall1"falsetrue);
    
SetLampLit("light3hall1"falsetrue);
    
SetLampLit("light4hall1"falsetrue);
    
SetLampLit("light5hall1"falsetrue);
    
SetLampLit("light6hall1"falsetrue);
    
SetLampLit("light7hall1"falsetrue);
    
SetLampLit("light8hall1"falsetrue);
    
SetLampLit("light1room1"falsetrue);
    
SetLampLit("light2room1"falsetrue);
    
SetLampLit("light3room1"falsetrue);
    
SetLampLit("light4room1"falsetrue);
    
SetLampLit("light5room1"falsetrue);
    
SetLampLit("light6room1"falsetrue);
    
SetLampLit("light7room1"falsetrue);
    
SetLampLit("light8room1"falsetrue);
    
SetLightVisible("point1room2"false);
    
SetLightVisible("point2room2"false);
    
SetLightVisible("point3room2"false);
    
SetLightVisible("point4room2"false);
    
SetLightVisible("point5room2"false);
    
SetLightVisible("point6room2"false);
    
SetLightVisible("point7room2"false);
    
SetLightVisible("point8room2"false);
    
SetLightVisible("point9room2"false);
    
SetLightVisible("point1hall1"false);
    
SetLightVisible("point2hall1"false);
    
SetLightVisible("point3hall1"false);
    
SetLightVisible("point4hall1"false);
    
SetLightVisible("point5hall1"false);
    
SetLightVisible("point6hall1"false);
    
SetLightVisible("point7hall1"false);
    
SetLightVisible("point8hall1"false);
    
SetLightVisible("point1room1"false);
    
SetLightVisible("point2room1"false);
    
SetLightVisible("point3room1"false);
    
SetLightVisible("point4room1"false);
    
SetLightVisible("point5room1"false);
    
SetLightVisible("point6room1"false);
    
SetLightVisible("point6room1"false);
    
SetLightVisible("point8room1"false);
    
SetMoveObjectState("shelf"1.0f);
    
SetMoveObjectState("bookset1"1.0f);
    
SetMoveObjectState("bookset2"1.0f);
    
SetMoveObjectState("bookset3"1.0f);
    
SetMoveObjectState("bookset4"1.0f);
    
SetMoveObjectState("bookset5"1.0f);
    
SetMoveObjectState("bookset6"1.0f);
    
SetMoveObjectState("bookset7"1.0f);
    
SetMoveObjectState("bookset8"1.0f);
    
SetMoveObjectState("bookset9"1.0f);
    
SetMoveObjectState("bookset10"1.0f);
    
SetMoveObjectState("bookset11"1.0f);
    
SetMoveObjectState("openbook1"1.0f);
    
SetMoveObjectState("goblet1"1.0f);
    
SetMoveObjectState("goblet2"1.0f);
    
SetMoveObjectState("goblet3"1.0f);
    
SetMoveObjectState("goblet4"1.0f);
    
SetEntityActive("hallwaypoofer"true);
    
AddEnemyPatrolNode("hallwaypoofer""PathNodeArea_1"2"");
    
AddEnemyPatrolNode("hallwaypoofer""PathNodeArea_2"0"");
    
AddEnemyPatrolNode("hallwaypoofer""PathNodeArea_3"0"");
    
AddEnemyPatrolNode("hallwaypoofer""PathNodeArea_4"0"");
    
AddEnemyPatrolNode("hallwaypoofer""PathNodeArea_5"0"");
    
AddEnemyPatrolNode("hallwaypoofer""PathNodeArea_6"0"");
    
AddEnemyPatrolNode("hallwaypoofer""PathNodeArea_7"0"");
    
AddEnemyPatrolNode("hallwaypoofer""PathNodeArea_8"0"");
    
AddEnemyPatrolNode("hallwaypoofer""PathNodeArea_9"2"");
    
PlaySoundAtEntity("""quest_completed.snt""rotatearea"0false);
        return;
    }
}
void Forcelook(string &in asTimer){StartPlayerLookAt("bedscare"1010"");      AddTimer(""1"ActivateScare");}
void ActivateScare(string &in asTimer){    SetEntityActive("deadbodya"true);
    
SetEntityActive("deadbodyb"true);
    
SetEntityActive("deadbodyc"true);
    
SetEntityActive("redlighta"true);
    
SetEntityActive("redlightb"true);
    
SetLightVisible("redlight"true); 
    
GiveSanityDamage(40true);
    
PlaySoundAtEntity("""react_breath.snt""Player"0false);
      
AddTimer(""2"ScareOver");}
void ScareOver(string &in asTimer){StopPlayerLookAt();
    
SetEntityActive("deadbodyb"false);
    
SetEntityActive("deadbodyc"false);
    
SetEntityActive("deadbodya"false);
    
SetEntityActive("redlighta"false);
    
SetEntityActive("redlightb"false);
    
SetLightVisible("redlight"false);} 
06-11-2012, 04:33 PM
Find
Ermu Offline
Member

Posts: 86
Threads: 13
Joined: Jan 2012
Reputation: 2
#2
RE: Rotating Bookshelf, Goblets move with it, but not books?

Are the books entities or static_objects?

If they're static_objects, i don't think there's anything to do, except to remove them.

If they're entities, try this:
AddAttachedPropToProp(string& asPropName, string& asAttachName, string& asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);


Attaches a prop to another prop.
asPropName - the prop to attach another prop at
asAttachName - internal name of the prop that gets attached
asAttachFile - the prop that gets attached extension .ent
afPosX - X position of the attach from the prop
afPosY - Y position of the attach from the prop
afPosZ - Z position of the attach from the prop
afRotX - rotation around X axis of the attach
afRotY - rotation around Y axis of the attach
afRotZ - rotation around ZX axis of the attach
Note: for the purposes of “AddEntityCollideCallback”, attached props will not call the callback function if they collide with a “static_object” or a “StaticProp” entity type!
Bug: afRotZ is used for both the ZX rotation and the Z position of the attached prop. Unwanted rotation can be avoided by using:
AddAttachedPropToProp(asPropName,asAttachName,asAttachFile,afPosX,afPosY,0,afPosZ,90.0f,afPosZ)
Bug: Attaching a breakable prop to a physically active prop, and then breaking the attached prop, will cause the game to crash should the parent object be moved or reset.






I personally don't have really much experience on this, so i have no idea if that will work. Hope someone else has.
06-11-2012, 04:46 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#3
RE: Rotating Bookshelf, Goblets move with it, but not books?

Those books you are using aren't even meant to be moved.

Tip: Use the regular books instead, the ones you can move by hand.

"What you think is irrelevant" - A character of our time

A Christmas Hunt
(This post was last modified: 06-11-2012, 04:59 PM by i3670.)
06-11-2012, 04:58 PM
Find
MaZiCUT Offline
Senior Member

Posts: 536
Threads: 31
Joined: Jun 2012
Reputation: 17
#4
RE: Rotating Bookshelf, Goblets move with it, but not books?

If these are static objects theres not much to do, unless you use entities or you're a good scripter that can do this instead:




Make each of the static bookpiles/books a script for it to move once you use the lever giving them their own position to move and rotate and then you try to get the rotation and position same as the bookshelves, but i recommend using entities and go with the guy above me.

Hi.
06-11-2012, 04:59 PM
Website Find
Ananaias Offline
Junior Member

Posts: 20
Threads: 7
Joined: Jun 2012
Reputation: 0
#5
RE: Rotating Bookshelf, Goblets move with it, but not books?

Okay, instead of doing all that stuff (sounds complicated, and I'm tired), would it be possible to make it so that they despawn, then instead, maybe there's a pile of books infront of the shelf after being moved?

I tried using SetEntityActive("bookset1" false); and that didn't work.
06-12-2012, 07:40 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#6
RE: Rotating Bookshelf, Goblets move with it, but not books?

(06-12-2012, 07:40 AM)Ananaias Wrote: Okay, instead of doing all that stuff (sounds complicated, and I'm tired), would it be possible to make it so that they despawn, then instead, maybe there's a pile of books infront of the shelf after being moved?

I tried using SetEntityActive("bookset1" false); and that didn't work.
I think everyone's overcomplicating this; just put books on the shelf that you can normally interact with in the game; no book rows or piles because those are static entities(aka they won't move) but single (unopened) books are normal entities and can be interacted with/used because they will move with the bookshelf.

I rate it 3 memes.
06-12-2012, 09:39 AM
Find
Ananaias Offline
Junior Member

Posts: 20
Threads: 7
Joined: Jun 2012
Reputation: 0
#7
RE: Rotating Bookshelf, Goblets move with it, but not books?

Alright. But is there a way to make them despawn, or no? If not, I'll do it that way.
06-12-2012, 10:52 AM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#8
RE: Rotating Bookshelf, Goblets move with it, but not books?

(06-12-2012, 10:52 AM)Ananaias Wrote: Alright. But is there a way to make them despawn, or no? If not, I'll do it that way.

You cant set static_objects inactive(atleast i think).Unless you turn them into entities.

06-12-2012, 07:03 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#9
RE: Rotating Bookshelf, Goblets move with it, but not books?

Why don't you just turn the book rows to entities and there we go

06-12-2012, 07:14 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#10
RE: Rotating Bookshelf, Goblets move with it, but not books?

(06-12-2012, 07:14 PM)SilentStriker Wrote: Why don't you just turn the book rows to entities and there we go
Book rows are technically entities, but they are static entities (confusing, I know). Static entities are things like cogs; they have the same interactions as static objects unless acted upon by a script (ie using rotateprop to make cogs spin for a machine)

I rate it 3 memes.
06-12-2012, 07:20 PM
Find




Users browsing this thread: 2 Guest(s)