Frictional Games Forum (read-only)

Full Version: Rotating Bookshelf, Goblets move with it, but not books?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:
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);} 
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.
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.
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.
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)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.
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)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.
Why don't you just turn the book rows to entities and there we go
(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)