Control Issues

Topics regarding Scripting with Reality Factory
User avatar
Xemnas
Posts: 11
Joined: Thu Apr 12, 2007 4:05 am
Location: TX
Contact:

Control Issues

Post by Xemnas »

I'm a begginner (obviously) and after tampering for a good amount of time I was wondering if the control scheme can be modified so the mouse doesn't need to be used.

:arrow: EX: Directional Movement in the style of Zelda, Sonic, or anyother platformer or rpg type game.

:arrow: OR: Can it be modified so the contols work as in classic Resident Evil Games, Clock Tower, Silent Hill, Etc.

Please & Thanks :wink:
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

First and foremost, welcome to the forums! :D

Secondly, the directional movement could be done. It's possible to disable the use of the mouse with the MouseControlledPlayer() scripting command. So the player character could only face one direction and move forward/backward and strafe left/right. The problem, however, would be that the player wouldn't turn to the direction where he is going. You could probably work your way around this with the animations, I guess.

Another way (and far more advanced) would be to script the player. Then it would be rather easy to make this stuff. Though I would really recommend familiarizing yourself with the RF basics before jumping into scripting.
Pain is only psychological.
User avatar
Xemnas
Posts: 11
Joined: Thu Apr 12, 2007 4:05 am
Location: TX
Contact:

Post by Xemnas »

Thanks for the warm welcome and advice.

I may be new to RF but not to the game design world, I have other systems in which scripting was everything so I think handling a few basic scripting needs is not a problem for me. I was actually curious if there is a tutorial on this some where or, if a base script can be posted.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

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.
Pain is only psychological.
User avatar
Xemnas
Posts: 11
Joined: Thu Apr 12, 2007 4:05 am
Location: TX
Contact:

Post by Xemnas »

:) Thanks for all the help so far, I've read scripting tutorials and learned as much as a can as fast as I can about 98% percent of your code is understandable to me now.

Buuuttt... After I disable control.ini how do I make the script run in place of control, I'm a little embarressed as I know the answer is probably common sense. :oops:
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Post by darksmaster923 »

add a pawn to ur map and give it the script
Herp derp.
User avatar
Xemnas
Posts: 11
Joined: Thu Apr 12, 2007 4:05 am
Location: TX
Contact:

Post by Xemnas »

:o I thought of that but I figured it only worked for enemies or... y'know what I knew I was gonna feel real stupid. Thank you!
User avatar
Xemnas
Posts: 11
Joined: Thu Apr 12, 2007 4:05 am
Location: TX
Contact:

Post by Xemnas »

Edit: *After Sobering Up*
Alright how do I place an .act in a level.
I Love Jesus!
(Notice: Contradictory Avatar)
Image
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Post by darksmaster923 »

you have to add an entry to ur Pawn.ini file describing where your act file is then make a pawn in the map.
Herp derp.
User avatar
Xemnas
Posts: 11
Joined: Thu Apr 12, 2007 4:05 am
Location: TX
Contact:

Post by Xemnas »

Can you be more elaborate? Thanks for being patient, remember I'm a beginner.
I Love Jesus!
(Notice: Contradictory Avatar)
Image
User avatar
QuestOfDreams
Site Admin
Posts: 1525
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

The pawn.ini file is located in the install folder of your reality factory installation. This file contains all pawn type definitions of your game. A pawn type definition describes the details of the pawn's actor (act filename, size, rotation, color etc). A pawn type called 'BigRat' would be defined by a section like the following:

[BigRat]
actorname = rat.act - name of actor to use
actorrotation = 0 180 0 - rotation, in degrees to stand actor up
actorscale = 1 - scale of actor
actoralpha = 255 - initial alpha of actor, default is 255
animationspeed = 1 - multiplier for speed of actor animation
fillcolor = 255 255 255 - color of actor
ambientcolor = 255 255 255 - brightness of actor
subjecttogravity = true - true if subject to gravity
boundingboxanimation = idle1 - name of animation used for bounding box
shadowsize = 0 - size of shadow bitmap
shadowalpha = 128 - transparency of shadow bitmap
shadowalphamap = shadowalpha.bmp - name of alpha bitmap for shadow
shadowbitmap = shadow.bmp - name of bitmap used as shadow
projectedshadows = false - whether this pawn casts a projected shadow or not
stencilshadows = false - whether this pawn casts stencil shadows or not
icon = man.bmp - name of the bitmap used as the conversation icon
environmentmapping = true - if true then apply environment mapping to actor material
allmaterial = true - if true apply environment mapping to all actor materials
percentmapping = 75 - percentage of mapping to apply to material (0 to 100)
percentmaterial = 75 - percentage of material to use while mapping

To place your pawn in a level, you need to add a pawn entity to your level. The PawnType entry of this entity specifies the section name of the pawn type definition in the pawn.ini file (e.g. BigRat). The ScriptName entry specifies the script (must be located in the scripts folder of your rf installation) this pawn should use...

For more information read the corresponding section in the manual (entity reference -> pawn).
User avatar
Xemnas
Posts: 11
Joined: Thu Apr 12, 2007 4:05 am
Location: TX
Contact:

Post by Xemnas »

Everytime I load the level the camera just sticks to the player instead of the pawn. I've tried attaching with a fixed camera and with a script but either way nothing changes, I must be a problem magnet.

Thanks for those who've helped so far.

Edit: Ohh, I get it! Thanks for your time everyone! :D
I Love Jesus!
(Notice: Contradictory Avatar)
Image
User avatar
zany_001
Posts: 1047
Joined: Fri Mar 02, 2007 8:36 am
Location: Aotearoa

Post by zany_001 »

so rf can be used for games like fifa,where everything is controlled with the keyboard?
Once I was sad, and I stopped being sad and was awesome instead.
True story.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Post by darksmaster923 »

yeah
Herp derp.
User avatar
zany_001
Posts: 1047
Joined: Fri Mar 02, 2007 8:36 am
Location: Aotearoa

Post by zany_001 »

sweet

@do you really love Jesus,like your sig says
Once I was sad, and I stopped being sad and was awesome instead.
True story.
Post Reply