The ultimate Cursor [Solved]

Started by Caracal, Fri 06/07/2012 10:40:29

Previous topic - Next topic

Caracal

Hello everyone. I am still working on a game that comes really close to Kings Quest 7.
But in order to keep ít authentic I need to create a cursor just like in the game!
This cursor combines the “walk, interact, talk, use inventory and look at” cursors all in one (the only exception is the “wait” cursor which appears in form of a crown).

Since AGS Default game comes with all of these cursors separately I wonder how I shall create the all uniting mother-cursor. Because in order to do that I have to switch off the “switch cursor mode function” (with right click). I am afraid to mess around blindly, fearing I might irreparably screw my default game (I already set up the death-functions).

Further I wonder if anyone has an idea which screen-size I should best use to reach the KQ7 flair? Which resolution is used in the original game, does anyone know or have a suggestion?
So far i use the maximum of 1024/768 because i usually draw highly detailed backgrounds.

Also I have a question besiedes that:
In the game I have set up a â€"for sierra typical- die function which is based on my former question, answered by Khris:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=45643.msg612963#msg612963
Now this time I don’t want to display different text- and images within the death guy. I would like to have a portrait of the “expired” character and it shall say different things every time.
I thought I could just create a new character called “Rosellaportrait” and then set a speech view. Each time the Gui appears the portrait says something. But how do I best set this up? Do I just replace a “DeathPicture” with a “Deathdialog”?


Thanks to everyone in advance!!!

Mouth for war

#1
One thing I'm doing with my game now is putting this in rep_exec in  room script

if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hwillsign){
mouse.Mode=eModeLookat;} //Where hwillsign is the scriptname for that particular hotspot)
else if (Object.GetAtScreenXY(mouse.x, mouse.y) == odoor && gInventory.Visible==false){
mouse.Mode=eModeInteract;}
else { mouse.Mode =eModeWalkto;}
}
and I'm using only one cursor...a white crosshair  which turns green if it's over a point of interest and I disabled right click. So walking and interacting etc. is all done with left clicking only. Maybe there's a much better way to achieve this but that's the way I did it and it works great. I guess Khris has something to say about this though (He do have better solutions to most things I've noticed) so bring it on man ;)
For that other question. Couldn't you have a label within the GUI where you display the dead character and have it randomize different texts? (If i understand you correctly)
mass genocide is the most exhausting activity one can engage in, next to soccer

Khris

I sure do :-D
Things as these are NEVER done on a per-room basis. Code for each and every object and hotspot? Good night.

Lookie here for a very similar solution: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=46367.0

Mouth for war

damn Mr. know it all...;) yeah that's ALOT better...I'm just doing stuff on my own so I'm still learning too hehe.
mass genocide is the most exhausting activity one can engage in, next to soccer

Caracal

Quote from: Khris on Fri 06/07/2012 15:30:00
I sure do :-D
Things as these are NEVER done on a per-room basis. Code for each and every object and hotspot? Good night.

Lookie here for a very similar solution: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=46367.0

@ Krhis :
"GlobalScript.asc(70): Error (line 70): '.GetLocationType' is not a public member of 'Game'. Are you sure you spelt it correctly (remember, capital letters are important)?"
is what AGS tells me as soon as i give in the suggested function in the threat you pointet out.
I have decited to do the following: i crossed out this function:
else if (button == eMouseRight || button == eMouseWheelSouth){
    // right-click our mouse-wheel down, so cycle cursor
   // mouse.SelectNextMode();                                                 // this is what i crossed out for the cursorwheel
  }
I left the other modes as they are (the player can not reach them since he can not leave the walk mode. Can i now basically change the symbol of the Walk icon... and put over every hotspot "any click on object/hotspot/character" the event i want.
This way I should archieve the same result, right??

And @ mouth of war:
Thanks for the idea. But for the death panel i always want the same things to be displayed, the Protrait is always going to look alike. Only the things, that the portrait says are diffrent, depending on the occured death scene.

Caracal

Oh i just noticed that my idea is not the smartest since the game will not properly work.
If i just rename the "walkto" button the game will be screwed unless i change every single "walkto" in the global script. The entire defaultgame is based on the idea of cursorchanges.

EchosofNezhyt

If you search there is a module that works fine, I think its called single cursor.

Caracal

Quote from: Frito Master on Fri 06/07/2012 19:26:59
If you search there is a module that works fine, I think its called single cursor.
Modules are not working for me... I just dont know how to use them if i havent set the skripting up myself i wont learn how to do it by myself next time! ;_;

EchosofNezhyt

#8
You could look at the module's code? Learn from that.
Also installing them is as easy as right clicking script and import.

Edit:

Linky

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=44421

Khris

Quote from: Caracal on Fri 06/07/2012 18:52:37"GlobalScript.asc(70): Error (line 70): '.GetLocationType' is not a public member of 'Game'. Are you sure you spelt it correctly (remember, capital letters are important)?"
Fixed the code in the other thread. Just remove the "Game." part.

Caracal

Ah at the first look it seems to work, i will double check this later. Greater problems have developed (as you can see in the "black pixel" threat) ;-P
But i thiank you!!!

Caracal

One itsy bits problems remains:
When i click on a (for example) hotspot then the triggered event occures twice for some reason.
I used "any click on object", rather then "when player looks at object" since this is obsolet.

Khris

All my code does is switch mouse.Mode.
The "any click on" event is triggered even if another event, for instance "interact with", has already been executed, maybe thats the reason for the duplication.

You don't need to use "any click on" though; just use the regular event interact/talk to event.

Caracal

Quote from: Khris on Sun 08/07/2012 18:29:36
You don't need to use "any click on" though; just use the regular event interact/talk to event.
Well the problem is, if i put this code into my script:
function repeatedly_execute() {
 
  int mm = mouse.Mode;                                                      // Ultimate Cursor code from Krhis!!!
  int lt = GetLocationType(mouse.x, mouse.y);
  int nm;
  if (lt == eLocationHotspot || lt == eLocationObject) nm = eModeInteract;
  else if (lt == eLocationCharacter) nm = eModeTalkto;
  else nm = eModeWalkto;
  if (nm != mm) mouse.Mode = nm;

-the code you created. and i trigger "any click on object (or hotspot)" then the event occures twice. If i trigger "look at object/hotspot" then nothing happens at all. So only any click on object works and this even twice. Looking at the mouse code i cant see how or why this happens, since everything (as far as i am able to understand) just focuses on the cursor.

ThreeOhFour

That code doesn't reference the eModeLookat anywhere, all it is doing is switching it to the Interact mode over a hotspot or an object, the Talkto mode over a character and the Walkto mode when it's not over any of these.

Therefore, instead of trying to trigger looking or any clicking, you should be using the talking function on characters and the interact with function on object and hotspots.

Khris

Yes, and for this to work properly, in on_mouse_click / eMouseRight, instead of switching to the next cursor mode, you should call ProcessClick(mouse.x, mouse.y, eModeLookat); (or is it eModeLook? I can never remember.)
Now, just to make sure: DON'T USE THE "ANY CLICK ON..." EVENT.

And until you post the code in your room script, we can only guess where the error is.

Caracal

Quote from: Khris on Mon 09/07/2012 14:41:51
Yes, and for this to work properly, in on_mouse_click / eMouseRight, instead of switching to the next cursor mode, you should call ProcessClick(mouse.x, mouse.y, eModeLookat); (or is it eModeLook? I can never remember.)
Now, just to make sure: DON'T USE THE "ANY CLICK ON..." EVENT.

And until you post the code in your room script, we can only guess where the error is.

Now wait. i am suppose to put this into the room script?
I thought i had to go to the globalscript.asc under the "repeadeately executed" function???!!

Caracal

Quote from: ThreeOhFour on Mon 09/07/2012 11:46:51
That code doesn't reference the eModeLookat anywhere, all it is doing is switching it to the Interact mode over a hotspot or an object, the Talkto mode over a character and the Walkto mode when it's not over any of these.

Therefore, instead of trying to trigger looking or any clicking, you should be using the talking function on characters and the interact with function on object and hotspots.
Ok. that was a helpful hint! Thank you, now that i use interact (rather than look at) on a hotspot it works. BUT the event is still triggered twice. How does that work???

ThreeOhFour

1. Do you still have "Any click" mode active? This could be a reason.
2. Do you have mouse clicks detected in the repeatedly_execute function AND the mouse click function? This could be a reason.

The most efficient way to get help is to show us your code. We're guessing blindly if you only tell us the symptoms. For us to give you comprehensive assistance you will need to find the following pieces of code and paste them in here so that we can see them:

-Your entire repeatedly_execute function from your global script.
-The entire contents of your repeatedly_execute_always function (unless you have nothing in there), from your global script.
-The entire contents of your on_mouse_click function, also from your global script.
-The entire contents of your hotspot/object interact function from your room script.
-The entire contents of your hotspot/object any click function from your room script.

These are all possible areas in which the error could be occurring, depending on what code you've written. Details are essential in order for people to assist you.

Khris

Quote from: Caracal on Tue 10/07/2012 17:39:02Now wait. i am suppose to put this into the room script?
I thought i had to go to the globalscript.asc under the "repeadeately executed" function???!!
Sure, but the hotspot event functions are in the room script, aren't they?
I just wanted to take a look at the contents of your hHotspot_Interact, hHotspot_AnyClick, etc. functions.

Caracal

Oh ok. My global script shows this:
Code: AGS
function repeatedly_execute() {
  
  int mm = mouse.Mode;                                                     
  int lt = GetLocationType(mouse.x, mouse.y);
  int nm;
  if (lt == eLocationHotspot || lt == eLocationObject) nm = eModeInteract;
  else if (lt == eLocationCharacter) nm = eModeTalkto;
  else nm = eModeWalkto;
  if (nm != mm) mouse.Mode = nm;

  // Put here anything you want to happen every game cycle, even when
  // the game is paused. This will not run when the game is blocked
  // inside a command like a blocking Walk()
  
  if (IsGamePaused() == 1) return;

  // Put here anything you want to happen every game cycle, but not
  // when the game is paused.
}

function repeatedly_execute_always() {
  
  // Put anything you want to happen every game cycle, even
  // when the game is blocked inside a command like a
  // blocking Walk().
  // You cannot run blocking commands from this function.
  
}


On Mouse click:

Code: AGS
function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
    player_loop = player.Loop;
    player_x = player.x; player_y = player_y;
    player_Room = player.Room;
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight || button == eMouseWheelSouth){
    // right-click our mouse-wheel down, so cycle cursor
   mouse.SelectNextMode();                                                                     
  }
  else if (button == eMouseMiddle) { 
    // Middle-button-click, default make character walk to clicked area (a little shortcut)
    // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
    // leave our options open - what if you have a special script triggered
    // on "walking" mode?
    ProcessClick(mouse.x, mouse.y, eModeWalkto); 
  }
  else if (button == eMouseWheelNorth) { 
    // Mouse-wheel up, cycle cursors 
    // If mode isn't WALK, set the previous mode (notice usage of numbers instead
    // of eNums, when it suits us)...
    if (mouse.Mode>0) mouse.Mode=mouse.Mode-1; 
    else 
    { 
      // ...but if it is WALK mode...
      if (player.ActiveInventory!=null) 
      {
        //...and the player has a selected inventory item, set mouse mode to UseInv. 
        mouse.Mode=eModeUseinv; 
      }
      else 
      {
        // If they don't, however, just set it to mode TALK (change this line if you add more cursor modes)
        mouse.Mode=eModeTalkto; 
      }
    }
  }
}


And thats the Room-interact script (basically all i have done in the room script concerning this issue jet) but i suppose thats insufficien:


Code: AGS
function hHotspot1_Interact()
{
cBellatrix.Say("WAAAH!");
cBellatrix.Say("Wo bin ich hier nur gelandet?");
}

So basically i changed nothing only that i inserted the mentioned code from the other tread into my "repeadetly execute" scrip function. And thats all.

ThreeOhFour

See this:

Code: ags

    ProcessClick(mouse.x, mouse.y, mouse.Mode );
    player_loop = player.Loop;
    player_x = player.x; player_y = player_y;
    player_Room = player.Room;
    ProcessClick(mouse.x, mouse.y, mouse.Mode );


You have the ProcessClick function twice in there. That means it will process your click twice.

Delete one of these.

Caracal

Quote from: ThreeOhFour on Wed 11/07/2012 12:23:00
You have the ProcessClick function twice in there. That means it will process your click twice.

Delete one of these.

Jes! This is IT! Thank you so mutch it seems to work the way i wanted it now! How did you see that so fast, i bed i looked at the exact line at least twice and did not notice. Thank you a lot! Now i have the ultimate Kings quest cursor and nobody can stop me!!! I did not even need to learn how to apply modules and such!
Thank you very mutch.
But i am afraid that there are already other issues comming up with the death-scenes again, for which i will start a new threat, soon.

Crimson Wizard

Quote from: Caracal on Wed 11/07/2012 15:55:24
Now i have the ultimate Kings quest cursor and nobody can stop me!!! I did not even need to learn how to apply modules and such!
...
But i am afraid that there are already other issues comming up with the death-scenes again, for which i will start a new threat, soon.
Now, I know I am probably breaking the board rules, but I can't help myself and not notice that this whole paragraph on its own sounds like an introductory to the hero quest like game :D

Caracal

As amazing as the new all in one cursor is... Could it be that the "use inventory function" is negotiated by it?
I have set up an inventory item and i set up the curos image and all but somehow if i click on the inventory item in the game...
Nothing happens. My thought was that the cursor immediately changes into the "interact" mode again.
I have the idea that it might be cuz of the cusor because inventory items are actually pretty basic and there is not much that could go wrong with them. (nonetheless i do have a problem here)

SMF spam blocked by CleanTalk