Frictional Games Forum (read-only)

Full Version: Entity's physics not setting to static
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a script that's supposed to switch a certain entity's physics to static. However, since there are 4 different versions of the aforementioned entity on the map I only want the one that player grabs and places in a certain spot to become static. I used for ints.

Here's the code:

PHP Code:
for(int i=1;i<=4;i++) AddEntityCollideCallback("rock_"+i"Puzzle_UseSoil""UseRockOnPedestal"true1); 

void UseRockOnPedestal(string &in asParentstring &in asChildint alState)
{
    
AddGlobalVarInt("ElementsPuzzle"1);
    
PuzzleCheck();
    for(
int i=0;i<4;i++) SetPropStaticPhysics(asParent+itrue);
    
PlaySoundAtEntity("""impact_rock_high.snt""Player"0false);
    
GiveSanityBoost();


So as you can see since I have 4 entities named rock_1, rock_2, etc, it would be pretty stupid to make the static function for each one. I thus instead tried to avoid doing it like
PHP Code:
SetPropStaticPhysics("Rock_"true); 
because that would pretty much eat too much time, and would set all those various entities around the map static. I tried using asParent name instead, but it doesn't help.

Any ideas on how I can fix this up?
Wait, you're using asParent+i ? That would be incorrect, since you've already done "rock_"+i above. How about this:

PHP Code:
void UseRockOnPedestal(string &in asParentstring &in asChildint alState)
{
    
AddGlobalVarInt("ElementsPuzzle"1);
    
PuzzleCheck();
    
SetPropStaticPhysics(asParenttrue);
    
PlaySoundAtEntity("""impact_rock_high.snt""Player"0false);
    
GiveSanityBoost();


No need to do the for-loop twice, because you've already created callbacks for each individual rock. Doing so would effectively just double it, making it become rock_1_1 or in your case rock_10, rock_21, rock_32, rock_43 because you're adding another number (the +i onto asParent) to a name that already has a number.
(08-07-2016, 10:17 PM)Mudbill Wrote: [ -> ]Wait, you're using asParent+i ? That would be incorrect, since you've already done "rock_"+i above. How about this:

PHP Code:
void UseRockOnPedestal(string &in asParentstring &in asChildint alState)
{
    
AddGlobalVarInt("ElementsPuzzle"1);
    
PuzzleCheck();
    
SetPropStaticPhysics(asParenttrue);
    
PlaySoundAtEntity("""impact_rock_high.snt""Player"0false);
    
GiveSanityBoost();


No need to do the for-loop twice, because you've already created callbacks for each individual rock. Doing so would effectively just double it, making it become rock_1_1 or in your case rock_10, rock_21, rock_32, rock_43 because you're adding another number (the +i onto asParent) to a name that already has a number.

I already tried doing it that way before. It didn't work either. The functions are called because I'm able to complete the puzzle but I can still carry the rock with me.
Maybe the entity can't be set to static physics ? If there's no tickbox in it's properties then yes. But it's an entity you can pick up, and those usually can be set to static. Anyway, just sayin.

Other thing, which is even more stupid: Try swapping child and parent in the function. I have a vague memory it fixed something for me once.
I'm probably just (unpurposely) bullshitting you, but it's worth a try if everything else fails.

EDIT You can also try using Sticky areas, just be sure to untick the "can detach" box. Should have the same effects you're trying to script. You would just have to add some script using if(getentitiescollide etc) or addentitycollidecallback to finish the puzzle.
(08-07-2016, 11:05 PM)Darkfire Wrote: [ -> ]Maybe the entity can't be set to static physics ? If there's no tickbox in it's properties then yes. But it's an entity you can pick up, and those usually can be set to static. Anyway, just sayin.

Other thing, which is even more stupid: Try swapping child and parent in the function. I have a vague memory it fixed something for me once.
I'm probably just (unpurposely) bullshitting you, but it's worth a try if everything else fails.

EDIT You can also try using Sticky areas, just be sure to untick the "can detach" box. Should have the same effects you're trying to script. You would just have to add some script using if(getentitiescollide etc) or addentitycollidecallback to finish the puzzle.

Unfortunately your tips didn't work, but I appreciate the help anyway. This is getting fucking ridiculous, I swapped the script so that it sets all the rocks static on the map and it still doesn't work.

EDIT:

I added a SetEntityInteractionDisabled func to my script and it seemed to have fixed that issue! The thread can be locked up now.
Issue seems to be solved, so locking on behalf of Slanderous' request!