(12-10-2016, 07:48 PM)Mudbill Wrote: Ok, well, I think then the safest (and possibly simplest though subjective) way would be:
Create a custom entity for the chair by opening the original and "Save As" a different name. Make it a MoveObject type. Set the axis to be the direction you want the chair to move in the level (either X or Z). You do this in the User Defined Variables in the Model Editor.
Spoiler below!
In the map, place the entity. Once the player hits a collision box, use SetMoveObjectState to move the chair along the axis. That's all you need to do.
In the User Defined Variables you can also specify the speed and accelleration of the chair, but instead of doing it here, you can use the function SetMoveObjectStateExt instead to specify it in the script (it's a bit easier if you need to change values often).
PS: If you want the player to be able to also grab the chair after it has moved, use ReplaceEntity to turn the entity back into a normal chair (which is a Grab object).
However if you don't mind the chair possibly falling over, you can probably just use the function AddPropForce alone...
Thanks, bud!
Guys, I tried everything..
-If I make the chair a waterlurker with pathnodes it's invisible and doesn't follow the pathnode
-If I make the chair a moveobject with the SetMoveObjectState script it does nothing.
(This post was last modified: 12-10-2016, 08:57 PM by goodcap.)
I tried to make a map to display the three techniques, third one is currently broken and I don't know enough about the script to fix it, second one is noisy. I know there's a way to shut off music for the enemies and disable insanity effects but heck if I can remember!
Everything's in the file attached to this post, script is below in the spoilers
/////////////////// // CHAIR SPOOK A // void func_ChairA(string &in asParent, string &in asChild, int alState) { AddPropForce("chair_nice01_1", 2000.0f, 0.0f, 0.0f, "World"); // pushes chair along X axis towards door } // END SPOOK A // /////////////////
/////////////////// // CHAIR SPOOK B // void func_ChairB(string &in asParent, string &in asChild, int alState) { SetEnemyDisableTriggers("chair_mean01_1", false); AddEntityCollideCallback("Player", "announce_playerandchair", "func_DisableEnemy", false, 1); // stops enemy chasing when player leaves area } void func_DisableEnemy(string &in asParent, string &in asChild, int alState) { SetEnemyDisableTriggers("chair_mean01_1", true); } // END SPOOK B // ///////////////// /* /////////////////// // CHAIR SPOOK C // void func_ChairC(string &in asParent, string &in asChild, int alState) { TimerPushLoop("timer_Chair"); // start pushing loop AddEntityCollideCallback("Player", "area_triggerchairC", "func_StopChase", false, 1); // make a way to stop loop }
(12-10-2016, 08:58 PM)CarnivorousJelly Wrote: I tried to make a map to display the three techniques, third one is currently broken and I don't know enough about the script to fix it, second one is noisy. I know there's a way to shut off music for the enemies and disable insanity effects but heck if I can remember!
Everything's in the file attached to this post, script is below in the spoilers
/////////////////// // CHAIR SPOOK A // void func_ChairA(string &in asParent, string &in asChild, int alState) { AddPropForce("chair_nice01_1", 2000.0f, 0.0f, 0.0f, "World"); // pushes chair along X axis towards door } // END SPOOK A // /////////////////
/////////////////// // CHAIR SPOOK B // void func_ChairB(string &in asParent, string &in asChild, int alState) { SetEnemyDisableTriggers("chair_mean01_1", false); AddEntityCollideCallback("Player", "announce_playerandchair", "func_DisableEnemy", false, 1); // stops enemy chasing when player leaves area } void func_DisableEnemy(string &in asParent, string &in asChild, int alState) { SetEnemyDisableTriggers("chair_mean01_1", true); } // END SPOOK B // ///////////////// /* /////////////////// // CHAIR SPOOK C // void func_ChairC(string &in asParent, string &in asChild, int alState) { TimerPushLoop("timer_Chair"); // start pushing loop AddEntityCollideCallback("Player", "area_triggerchairC", "func_StopChase", false, 1); // make a way to stop loop }
The first one was exactly what I was looking for. Thanks a lot dude. I was about to pull my hairs out of frustration. In your test level the chair falls over, but in mine it does not and just moves itself in front of the player to block it's path.
(12-10-2016, 06:05 PM)CarnivorousJelly Wrote: Spelos, you'd want the X and Z coordinates. Y is vertical in HPL2
You're right, thanks.
(12-10-2016, 08:58 PM)CarnivorousJelly Wrote: I tried to make a map to display the three techniques, third one is currently broken and I don't know enough about the script to fix it, second one is noisy. I know there's a way to shut off music for the enemies and disable insanity effects but heck if I can remember!
Everything's in the file attached to this post, script is below in the spoilers
/////////////////// // CHAIR SPOOK A // void func_ChairA(string &in asParent, string &in asChild, int alState) { AddPropForce("chair_nice01_1", 2000.0f, 0.0f, 0.0f, "World"); // pushes chair along X axis towards door } // END SPOOK A // /////////////////
/////////////////// // CHAIR SPOOK B // void func_ChairB(string &in asParent, string &in asChild, int alState) { SetEnemyDisableTriggers("chair_mean01_1", false); AddEntityCollideCallback("Player", "announce_playerandchair", "func_DisableEnemy", false, 1); // stops enemy chasing when player leaves area } void func_DisableEnemy(string &in asParent, string &in asChild, int alState) { SetEnemyDisableTriggers("chair_mean01_1", true); } // END SPOOK B // ///////////////// /* /////////////////// // CHAIR SPOOK C // void func_ChairC(string &in asParent, string &in asChild, int alState) { TimerPushLoop("timer_Chair"); // start pushing loop AddEntityCollideCallback("Player", "area_triggerchairC", "func_StopChase", false, 1); // make a way to stop loop }
If used, I highly suggest refactoring. Remove all the comments that state the obvious like //Gets player position --- Try explaining things though code as supposed to comments.
(This post was last modified: 12-11-2016, 09:04 AM by Spelos.)
The commenting's there so goodcap can understand what I've written without having to search the entire document and figure it out for himself. There's nothing wrong with stating the obvious if it helps someone learn!
Also your code - or rather my rendition of your code - didn't work, any suggestions as to why? I ended up having to comment out the section so it won't run in order to get the other two examples to work.
(12-11-2016, 09:38 PM)CarnivorousJelly Wrote: Also your code - or rather my rendition of your code - didn't work, any suggestions as to why? I ended up having to comment out the section so it won't run in order to get the other two examples to work.
second argument expected "," but found "f". [f is not defined]
fourth argument, same thing.
Remove the "f" from both of those.
1) You don't need to specify a type since both variables are floats.
2) That's not how you specify a type. Would be casting it, but not in .hps
After that, I think it should work. =)
Thank you for the reminder.
I actually added those while trying to debug it and forgot to remove them before posting. Without the "f" the script still won't load or calls an error on line 76, column 15 (line 77 in this version due to the /* */ added in, no I didn't have the section commented out during testing)
(This post was last modified: 12-13-2016, 03:38 PM by CarnivorousJelly.)
Alright, I finally got to check the script. It seems that you forgot to change the playerY and chairY variable names to their Z variants when renaming.
I'm not going to stress this too much, but:
"chairY is not defined" is a very simple error, especially when it tells you the line.
But sure, happens to all of us.
void TimerPushLoop(string &in asTimer) { AddTimer(asTimer, 0.1f, "TimerPushLoop"); NudgeChairTowardsPlayer(); // Add some kind of break so that the chair doesn't follow you forever. // Or perhaps don't. =) }