Mouse Cursor and Entity Select.

Post topics regarding Level Building/Design and Entity Usage with Reality Factory
Post Reply
webgovernor
Posts: 2
Joined: Fri Jan 05, 2007 11:59 pm

Mouse Cursor and Entity Select.

Post by webgovernor »

Hi all,

I'm kind of new at Reality Factory, but I've played with the scripting system, and I enjoy the World Editor a lot.

My Question is regarding the information found here: http://dhost.info/realityfactory/online ... .htm#MOUSE

Now, can I:

1) Dynamically change the cursor when over a certain entity (Like a message bubble or movement cursor)?
2) Change the buttons, instead of both doing attacks, one would "click-move" the player (like an RTS or Diablo), and the other would fire?
3) Have HUD buttons that are click-able, and if so, would I be detecting the mouse X and Y locations? Or is there an "OnPress" event that I could add to the HUD buttons?

I've been reading various topics on this subject, but most of them just point to the link I've posted above. I'm also curious where those commands are placed, but I'm assuming that they'd go in the Pawn file...

Thank you all for your time, if I didn't do enough research then please let me know, as I've been checking here for awhile now, and decided to register specifically for this question.

-Aaron
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

1) Dynamically change the cursor when over a certain entity (Like a message bubble or movement cursor)?
2) Change the buttons, instead of both doing attacks, one would "click-move" the player (like an RTS or Diablo), and the other would fire?
This can't be done yet (you may post this in the feature requests forum so it might get added eventually)
3) Have HUD buttons that are click-able, and if so, would I be detecting the mouse X and Y locations? Or is there an "OnPress" event that I could add to the HUD buttons?
This can be done via scripting. Have a look at the second demo level that comes with the RF installer to see this in action. (The script that controls the clickable buttons at the top can be found in the scripts directory and is called scripting_reply.s)
More about scripting can be found in the docs.
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

Question 1) You may not be able to change the cursor, but you can add a picture to it:

This is how to do it (i have done this once, for an inventory system where you could take the items and get them to another place):

1) First you need to make the bitmap: Make it with your favorite bitmap program. Then save it in the media\bitmaps folder and add '0' to the file name. If you need more than one bitmap then the second bitmap has '1' the third '2' and so on. Also make alpha mask bitmaps for them. I am not sure if they work with the script command 'DrawFlipBookImage' but it's better anyways and also good practice.
2) Now with that done, go into the level editor and add a FlipBook-Entity and a Pawn-Entity(if you already have a 'controller' pawn that runs every frame just use its script and add the script commands there)
3) Set up the FlipBook so that it loads the bitmap(s) and set the Trigger field to a value that never is triggered (Like 'Never') This causes the FlipBook to load the bitmap but not show it the whole time at its position in the level.
4) make a script for the pawn and assign it to the pawn, something like this:

Code: Select all

{
 SELECT [null]
 FirstOrder[ ()
 {
  LowLevel("LoopLowLevel");
 } ]
 LoopLowLevel[ () //here the work is done
 {
  SELECT=MouseSelect(true,true);
  if(SELECT="ENTITYNAME") //Type in the name of the Entity where you want to show it
  {
   DrawFlipBookImage("FLIPBOOKENTITYNAME",0,GetMouseX(),GetMouseY(),255,255,255,255);
   //(Type in the EntityName of the flipbook)
  }
 } ]
}
But that is not all, you can do even more:
Say you want that a sword appears, but only on enemies. You have already made the sword bitmap. So how do you do this? You add a Postfix (at the end) on the EntityName of all the Enemies there are, say 'E'.

and then you simply alter the code a bit:

Code: Select all

 LoopLowLevel[ () //here the work is done
 {
  SELECT = MouseSelect(true,true);
  if(RightCopy(SELECT,1)="E") //If postfix is 'E'
  {
   DrawFlipBookImage("FLIPBOOKENTITYNAME",0,GetMouseX(),GetMouseY(),255,255,255,255);
   //(Type in the EntityName of the flipbook)
   //If you want, uncomment the following line and see what happens...
   //ShowText(0, SELECT, "", LeftCopy(SELECT,GetStringLenght(SELECT)-1), 10, "", 0, 40, "center", 255); 
  }
 } ]
That should do it. By the way, welcome to the forums! :D
Everyone can see the difficult, but only the wise can see the simple.
-----
webgovernor
Posts: 2
Joined: Fri Jan 05, 2007 11:59 pm

Post by webgovernor »

Thank you guys very much, you have been very helpful.

I'll be trying this out shortly, but I have some exams due soon, so I haven't the free time.

Even if I can't do exactly what I want with this engine, it still offers features that I feel are much better then the leading competing engine (I'm assuming that'd be A6). Some major pro's over A6 are the Actor Viewer, License, and Scripting Language. I can't stand A6's "C-Script" crap.

Once again, thanks for the replies, I'll be sure to post a complete solution if I can find one...

-Aaron

EDIT: About appending "E" to enemies, my problem with this is that the world would be sort of RPG-ish, like you could attack someone, but originally they'd just be an actor you can communicate with. So, let's say Gorgon the Wizard wants to give me some magic beans in exchange for a quest, but instead I decide to attack Gorgon and steal his beans... gorgon wouldn't have an "E" at the end to begin with, but after I chop his arm off he would... Should I just make two copies of Gorgon, like Gorgon_N (Neutral) and Gorgon_E (Enemy), and then switch them on collision with my "sword of righteousness + 10"?
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

Ah you want to do it this way. Then we can use another approach:

In the script file of Gorgon you use the AddAttribute() command at the beginning and give him an attribute that is basically his attitude to the player. And then make yourself a table where you can look at which number represents which atttude, for example 1 as friendly and 2 as hostile. However do not use the 0 in this case because when you get an Attribute from a pawn and he hasn't got the attribute 0 is returned and so you don't know what is the case: is it really 0 or does he not have the attribute (this could also be the case for StaticEntityProxys for example, they also can have attributes).

so when you attack him he then changes his Attribute (let's say it's called 'AttitudeTowardsPlayer') to 2 (meaning hostile) which then can be checked in order for him to attack the player - or for example to draw a different image.

Like this:

Code: Select all

 LoopLowLevel[ () //here the work is done 
 { 
  SELECT = MouseSelect(true,true); 
  if(GetAttribute("AttitudeTowardsPlayer",SELECT)=0) //static thingy
  {
    //Show image for static things, like plants, named NAME0
    DrawFlipBookImage("FLIPBOOKENTITYNAME",0,GetMouseX(),GetMouseY(),255,255,255,255);
  }
  if(GetAttribute("AttitudeTowardsPlayer",SELECT)=1) //friendly
  {
    //Show image for friendly pawn, named NAME1
    DrawFlipBookImage("FLIPBOOKENTITYNAME",1,GetMouseX(),GetMouseY(),255,255,255,255);
  }
  if(GetAttribute("AttitudeTowardsPlayer",SELECT)=2) //hostile
  {
    //Show image for hostile pawn, named NAME2
    DrawFlipBookImage("FLIPBOOKENTITYNAME",2,GetMouseX(),GetMouseY(),255,255,255,255);
  }
 } ] 
you can also write it a bit shorter: (i don't know if this is faster, but i believe there is somehow a limit of lines, somewhere around 500+ in one order, so if you add more and more and more, you reach this limit)

Code: Select all

 LoopLowLevel[ () //here the work is done 
 { 
  SELECT = MouseSelect(true,true); 
  //Show image
  DrawFlipBookImage("FLIPBOOKENTITYNAME", GetAttribute("AttitudeTowardsPlayer",SELECT), GetMouseX(), GetMouse), 255, 255, 255, 255);
 } ] 
With this way it is important that you have exactly the number of bitmaps that you have types of 'Attitudes' a pawn can have. Otherwise RF will crash sooner or later.
Everyone can see the difficult, but only the wise can see the simple.
-----
Post Reply