Allright, good thing that you are not completely new to this thing.
There is no tutorial about this. At least I'm not aware of any. I could post my own little script for a player character, but I'm afraid that would be of little use. It's not commented at all (although I'm planning to comment it and then release it for the community), and most of all, it's a first person script and would need lots of modifications to make it 3rd person. Although, if you really want it, I can post it here.
Anyway, I'm going to try and explain some basics of this whole scripting thing.
I assume you know the basics of Simkin, like what orders are and stuff. If you aren't familiar with it yet, I'm sure you can learn it easily by reading the manual. All the commands are listed in the manual too, BTW.
Ok now to the actual thing:
Writing a 'player script' isn't much different from writing an enemy AI script. Basically, the 'scripted player' is a Pawn-entity, just like the NPCs or enemies in your game. But instead of being totally independent, the script is written so that it "obeys" the player, for example it checks if a certain key is pressed and then does something. Like if the uparrow is pressed, the script tells the Pawn to move forward. Also, it's possible to attach the camera to the Pawn and disable the built-in player causing the scripted Pawn to act as the main character of the game.
So, how does one actually write the script, you ask?
I'll write a very basic sample script here and hope you can understand how it is done.
Code: Select all
{
WALK [walk] // define the walking animation in a variable
IDLE [idle] // define the walking animation in a variable
MOVESPEED [50] // define the speed of this Pawn in a variable
Spawn[ ()
{
Console(true); //enable console for debugging
LowLevel("setup"); // Go to low level
} ]
setup[ ()
{
self.ThinkTime = 0.1;
PlayerRender(false); // Don't render the built-in player
AttachCamera(); // attach the camera to this entity
self.yaw_speed = 10000; // Rotate VERY fast
AnimateHold(IDLE);
self.think = "loop"; // Start executing order called "loop"
} ]
loop[ ()
{
self.ThinkTime = 0; // execute this order every frame
if(IsKeyDown(15)) // Check if key number 15 is pressed
{
walkmove(self.current_yaw,MOVESPEED); // move forward
if(self.animate_at_end) // check if the current animation is finished before starting a new one
{
AnimateHold(WALK); // play the walking animation
}
}
else // if the key is not pressed...
{
if(self.animate_at_end) // play idle animation, if it is at end
{
AnimateHold(IDLE);
}
}
} ]
}
I have not tested this script, so it may have some errors.
Some notes:
I'm sure you are familiar with using variables. They don't absolutely have to be there, you could just put the animation names and stuff in the commands, but that way changing them afterwards would be harder. You would have to change the whole string in each command rather than just one variable in the top of the script.
The built-in variable 'self.key_pressed' returns the number of the key that is being pressed. Just use 'debug(self.key_pressed)' in the 'loop' order and you should see what key is pressed in the console.
Check the scripting part of the manual for details about what the commands do.
I hope this helps to get you started, I hope I even made sense. Please do let me know if there is a part that you don't understand.
***EDIT***
Oh, and to prevent the built-in player from moving, disable ALL the controls in install/control.ini.