Figured that I might have more questions about scripting in the feature, so I pretty much made one topic in which I'm planning to ask all my scripting related questions, hence the title.
Anyway, I'm currently struggling with checkpoints. I'm including the full script at the bottom of this post, but first what I wish to do and what I have achieved so far.
What does the script actually do now.
The script makes an enemy spawn when the player enters a script zone named "ScriptArea_1", at least, not right away, first a door which is wide open from the start slams shut, and after 2 seconds 'mister_moody' the Grunt spawns and starts to patrol to the room. If 'mister_moody' succesfully finishes his routine, the script area "AreaGruntCheckedRoom" he leaves resets his path and leads him to the level door. Also "ScriptArea_2" is made active which causes 'mister_moody' to be set non-active after a second if he touches the area. Now this all goes like planned, but now it comes...
What does the script not do or do wrong now.
Now I made a checkpoint of "PlayerStartArea_1", in hope that when the player interrupts 'mister_moody's' patrol for coffee and gets killed by him, that the majority of the encounter gets reset and can be performed all over again to the letter. Now the following goes wrong: Firstly, the door named "mansion_1" gets reset, but is now closed instead of wide open. And, when the player enters the enemy trigger area, 'mister_moody' is spawned but gets caught by "ScriptArea_2" and immediately despawns when the timer is finished. This I find to be odd as the checkpoint function should deactivate "ScriptArea_2" but I guess "AreaGruntCheckedRoom" still tries to activate the second script area as it has detected 'mister_moody' leaving already. At least, this I think is happening, but I cannot find out how to tell "AreaGruntCheckedRoom" to stop activating "ScriptArea_2" and wait for 'mister_moody' to enter and activate "ScriptArea_2" again when he leaves.
Can anyone perhaps help?
Edit: Forgot to mention, the enemy 'mister_moody' spawns at "ScriptArea_2", that's why the area needs to be deactivated until 'mister_moody' has moved out of it.
Edit 2: Made some mistakes in this post with the Script Areas, should be correct now, sorry if it confused anyone...
It seems to me that there are a few problems in the script.
When you put a // before a function, it treats it as a comment on the script and won't do anything.
Also, just so you know, you don't need the two "{"s and "}"s for functions, only one, Like:
void Collide_Callback(string &in asParent, string &in asChild, int alState)
{
//Functions here
}
If removing the //s before some of the functions doesn't help, then I don't know, sorry. As for having the door wide open, however, The thing that comes to mind for me is to force the door open, like this:
SetSwingDoorClosed("mansion_1", false, false);
SetSwingDoorDisableAutoClose("mansion_1", true);
AddPropImpulse("mansion_1", X, Y, Z, "world");
Replace X,Y,and Z with the coordinates that the force comes from. Check the coordinates of the door in the editor and play around with it a bit to get it right.
The commented out functions are meant to be like that, I was trying around and when I'm not sure if I want it removed entirely yet, I comment it out to disable it, just didn't get to removing them before posting the example here. Will try the door though, thanks, still need to figure out why the checkpoint is being an arse.
For the scriptarea_2, you're setting it as false before the new callback for it is made. Put the callback before it. Also, try taking out the SetMoveObjectState. If you're resetting the prop, you shouldn't need it.
(This post was last modified: 04-20-2011, 12:51 PM by MrBigzy.)
Gah, still did not solve it, weird thing is, 'mister_moody' sometimes succesfully tries to attack the player again, and sometimes exits the door that's supposed to be deactivated until he walks into the area named 'AreaGruntCheckedRoom' before finishing his routine. It seems to happen randomly...
Here's the script as it looks now, also removed the outquoted functions to keep it clean:
Are you certain the checkpoint is actually working? Put a second playerstart area and make it so it spawns you there to test if it actually works or not.