Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - jfarwyke

#1
Whenever my playable character dies in the game, I wanted him to fade out, while his soul (now in his position floats off the screen. Originally, I thought the soul would just be another view. But I don't know how to fade one view into another, so I devised making the soul an NPC and well, basically, here's the die function I made in the global...

Code: ags

function die() {
    StopMusic();
    PlayMusic(5);
    int trans = player.Transparency;
while (trans < 100) {
  trans++;
  player.Transparency = trans;
  cJiva1.FollowCharacter(player, FOLLOW_EXACTLY, 1);
  cJiva1.Walk(Random(340), 0, eNoBlock, eAnywhere);
  Wait(1);
}
    gDead.Visible = true;
    gDead.Centre();
    mouse.Mode = eModePointer;
}


Because I don't know what room the player will be in or what screen position he'll be in when he dies, it's difficult for me to figure how to bring the NPC (Jiva1)  in. The reason I've used FollowExactly is so that he'll appear directly behind the player. And then after the player fade's out, there's the NPC floating away. But again, how do I script "bring cJiva1 into player's current room on player's current position"?

I was up all night working on this and am ready to give up on it altogether.
#2
Sorry to be having another problem so soon (I've actually had several but solved them using available resources), can't find any info on this one though...

I have a GUI called gDead which would appear when the player dies. It enables him to restore or quit. That works fine. Basically, I would very much like it to display a different message according to the way in which he dies. For example, a chicken pecks him to death, so it would say "You 'pecked' the wrong the choice" or something corny along those lines (the Quest for Glory games used to do the same). I already made a text box on my GUI even though I understand this is for the player to enter text. Here's what I have in my GlobalScript under the repeatedly_execute:

Code: ags

  if (IsTimerExpired(3)){
    StopMusic();
    PlayMusic(5);
    gDead.Visible = true;
    gDead.Centre();
  }


I was hoping I could put a command at the end specifying what text I'd like displayed, but I don't see anything in the call box, nor would I expect it to be that easy. Any ideas? Thanks.
#3
Basically, after the player interacts with a hotspot, I have animations that perform perfectly, until an object is supposed to move, then my game freezes. Also, when I was typing the script command: oFrame, it gave me a choice of "oFrame_Interact" and when I typed the period, it automatically put in "oFrame_Interact" and I don't know why, but that may have something to do with the problem. Here is my code...

Code: ags

function hImpact_Interact()
{
cPup.Walk(397, 349, eBlock);
cPup.FaceLocation(373, 212, eBlock);
Wait(10);
cPup.SetWalkSpeed(20, 20);
cPup.AnimationSpeed = 1;
cPup.Walk(374, 255, eBlock);
PlaySound(5);
cPup.SetWalkSpeed(6, 6);
cPup.AnimationSpeed = 4;
cPup.Move(376, 265, eBlock);
oFrame.Move(358, 161, 1, eBlock);
}


It's probably something simple I'm not seeing. I'm returning to AGS after a hiatus and maybe I've forgotten a few things. I've already consulted the manual and did a search on the forums and have not came up on a solution. Anyone got any ideas? Much appreciated.
#4
Hi. First off, I apologize if this has been covered. But I've searched the forums to no end. All I want to do, is assign keys to play particular sounds. In the global script under the function on_key_press I have
if (keycode == 'A') PlaySound(1);
I am replacing the mouse modes that are set with the default, as I have no playable character anyway and am trying to turn my keyboard into a musical instrument. I've also tried
if (keycode == eKeyA) PlaySound(1);
What am I doing wrong?

Code: ags

function on_key_press(eKeyCode keycode) {
  // The following is called before "if game is paused keycode=0", so
  // it'll happen even when the game is paused.
  
  if ((keycode == eKeyEscape) && gRestartYN.Visible) {
    //Use ESC to cancel restart.
    gRestartYN.Visible = false; 
    gIconbar.Visible = true;
    // If the panel's not ON, then the player must have gotten here by tapping F9,
    // therefore his cursor needs restoring. If the panel IS on, then it doesn't,
    // because it's already a pointer. Get used to thinking like this!!
    if (!gPanel.Visible) mouse.UseDefaultGraphic(); 
    return;
  }
  if ((keycode == eKeyEscape) && gPanel.Visible) {
    // Use ESC to turn the panel off.
    gPanel.Visible = false; 
    mouse.UseDefaultGraphic();
    gIconbar.Visible = true;
    return;
  }
  if ((keycode == eKeyEscape) && (gSaveGame.Visible))
  {
    // Use ESC to close the save game dialog
    close_save_game_dialog();
    return;
  }
  if ((keycode == eKeyEscape) && (gRestoreGame.Visible))
  {
    // Use ESC to close the restore game dialog
    close_restore_game_dialog();
    return;
  }
  
  if (keycode == eKeyReturn) { 
    // ENTER, in this case merely confirms restart
    if (gRestartYN.Visible) RestartGame();
  }

  if (IsGamePaused() || (IsInterfaceEnabled() == 0))
  {
    // If the game is paused with a modal GUI on the
    // screen, or the player interface is disabled in
    // a cut scene, ignore any keypresses.
    return;
  }

  // FUNCTION KEYS AND SYSTEM SHORTCUTS
  if (keycode == eKeyEscape) {
    // ESC
    gPanel.Visible = true; 
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode == eKeyCtrlQ)  QuitGame(1);   // Ctrl-Q
  if (keycode == eKeyF5) show_save_game_dialog();   // F5
  if (keycode == eKeyF7) show_restore_game_dialog();  // F7
  if (keycode == eKeyF9) {
    // F9, asks the player to confirm restarting (so much better to always confirm first)
    gRestartYN.Visible = true;  
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode == eKeyF12) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode == eKeyTab)   show_inventory_window();  // Tab, show inventory

  // GAME COMMAND SHORTCUTS
  if (keycode == 'A') PlaySound(1);
  if (keycode == 'L') mouse.Mode=eModeLookat; //Note that all we do here is set modes.
  if (keycode == 'U') mouse.Mode=eModeInteract; //If you want something else to happen, such as GUI buttons highlighting,
  if (keycode == 'T') mouse.Mode=eModeTalkto; //you'll need some more scripting done.
  if (keycode == 'I') mouse.Mode=eModeUseinv; //But this will, as-is, give you some standard keyboard shortcuts your players will very much appreciate.

  // For extra cursor modes, such as pick up, feel free to add as you will.
  // Uncomment the line below if you use the "Pick Up" mode.
  //if (keycode == 'P' || keycode == 'G') mouse.Mode=eModePickup; 

  // DEBUG FUNCTIONS
  if (keycode == eKeyCtrlS)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode == eKeyCtrlV)  Debug(1,0);  // Ctrl-V, version
  if (keycode == eKeyCtrlA)  Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode == eKeyCtrlX)  Debug(3,0);  // Ctrl-X, teleport to room
  if (keycode == eKeyCtrlW && game.debug_mode) 
    player.PlaceOnWalkableArea(); //Ctrl-W, move to walkable area 
}


Alright, there it is. But all it is is just the default script. The only modification I've made so far is changing the keycode 'A' to playing a sound. The sound is an mpg in my Sounds folder titled, sound1
#5
The text in my text windows is awfully close to the edge, and I was wondering if there is a way to set the margins. Since I recently imported a font I wanted, it looks much worse, but I didn't like it even with the default font and would like to adjust it somehow. I have found many threads concerning text windows, but none seem to address the issue of margins or alignment. Thanks.
#6
I want to run an object's animation after the player interacts with a NPC. First, I have the NPC walk to another part of the room, afterwards, I want the object to animate. The problem is, the global script doesn't recognize my object. What I did then is made my code in the global just for the NPC, then in the room I wrote a code for the object to run it's animation under certain conditions. But I don't know what function to place it under. I've tried Room Load after FadeIn and Repeatedly Execute, but to no avail.

Here's my global script code:
Code: ags
function cButt_Interact()
{
cPup.Walk(479, 218, eBlock);
cButt.Walk(500, 127);
cButt.AddWaypoint(557, 303);
cButt.AddWaypoint(441, 385);
cButt.AddWaypoint(37, 353);
cButt.Clickable = false;
}

And my Room code:
Code: ags
function room_AfterFadeIn()
{
if ((cButt.Clickable == false)&&(cButt.Moving == false)) {
  oFrogEatFly.SetView(16);
  oFrogEatFly.Animate(0, 0, eOnce, eBlock);
  cButt.ChangeRoom(2, 583, 450);
  oFrogEatFly.SetView(17);
  oFrogEatFly.Animate(0, 0, eOnce, eBlock);
  }
}

After the NPC walks to his location, nothing happens unless I leave the room and then come back again. Only then does the second code run.
Would the easiest thing be to simply make my object a character and handle it all in the global script? What am I doing wrong?
#7
I get this error message when trying to run the following code...
Code: ags
function region1_Standing()
{
cPup.SpeechView = -1;
cPup.IdleView = -1;
}

Error (line 31): property 'Character::IdleView' is read-only

Just what does it mean by 'read-only'? And is there a different way to disable the IdleView on a region?
Thanks!
#8
Me again with another problem...
I have these two mouse modes that I want to animate views when clicked. The Talkto refers to the speaking view of course, and the Stare refers to the Thinking view. I only want the thinking view to show when I click on objects or characters
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 );
      if (mouse.Mode==eModeTalkto) 
  player.FaceLocation(mouse.x, mouse.y);
  if (mouse.Mode==eModeTalkto)
      cPup.Say(" "); 
        if ((mouse.Mode==eModeStare)&&(GetLocationType(mouse.x, mouse.y) == eLocationCharacter)||
      (GetLocationType(mouse.x, mouse.y) == eLocationObject)) {
  cPup.FaceLocation(mouse.x, mouse.y);
  cPup.Think("               ");
      ate -= 1;  
        if (ate == 0) {
      btnIconStare.Enabled = false;
        mouse.SelectNextMode(); 
   }
   }
        }

The problem is that every left click on an object/character seems to initiate the eModeStare View whether that mode is selected or not. I know the problem is with my code, as I'm still trying to get the hang of conditional statements and haven't quite got it yet as you can see. I've worked over this for days and days now. Also, if I condense the two ifs:
Code: ags
      if (mouse.Mode==eModeTalkto) 
  player.FaceLocation(mouse.x, mouse.y);
  if (mouse.Mode==eModeTalkto)
      cPup.Say(" "); 

into
Code: ags
if (mouse.Mode==eModeTalkto) {
player.FaceLocation(mouse.x, mouse.y);
cPup.Say(" ");

it doesn't seem to run the eModeStare script at all.

Can someone tell me what I'm doing wrong?
Thanks in advance.
#9
Hi everyone.
Okay, here's the situation...in my game when the playable character uses specific items on himself, he gains a special ability. The first time he does it, a message will pop up explaining the ability and how to use it. After that, when he uses these specific items, it will simply tell him the ability is activated. With my (probably unnecessarily long) script, I did manage to get that working. And then I added the "else" statement at the end, which would display a message for any other item he uses which would not activate his ability.

The problem is that after the activation message comes up as detailed in my "else if" statements, it follows with my "else" message display. i.e., "Scare Stare Activated" "You can't use that on yourself."

I think I understand why it's doing that, I just can't find away around it. Also, I know my scripts can be condensed in some way but mainly I just want it to work. I've tried it in a number of ways with more or less the same results.

Here's my script:

function cPup_UseInv()
{
  if ((cPup.ActiveInventory == iRadish1)&&(scarestare == 0)) {
  scarestare += 1;
  btnIconStare.Enabled = true;
  cPup.LoseInventory(iRadish1);
  Display(" New Ability Aquired: SCARE STARE!");
  Display(" Upon eating anything that's edible, Pupshaw will gain the ability to intimidate with SCARE STARE. However it may only be used once until Pupshaw finds something else to eat. The SCARE STARE ability can be found in the icon bar above."); 
}
else if ((cPup.ActiveInventory == iRadish1)&&(scarestare > 0)) {
    scarestare += 1;
    btnIconStare.Enabled = true;
    cPup.LoseInventory(iRadish1);
    Display(" SCARE STARE activated!");
  }
    if ((cPup.ActiveInventory == iRadish2)&&(scarestare == 0)) {
  scarestare += 1;
  btnIconStare.Enabled = true;
  cPup.LoseInventory(iRadish2);
  Display(" New Ability Aquired: SCARE STARE!");
  Display(" Upon eating anything that's edible, Pupshaw will gain the ability to intimidate with SCARE STARE. However it may only be used once until Pupshaw finds something else to eat. The SCARE STARE ability can be found in the icon bar above."); 
}
else if ((cPup.ActiveInventory == iRadish2)&&(scarestare > 0)) {
    scarestare += 1;
    btnIconStare.Enabled = true;
    cPup.LoseInventory(iRadish2);
    Display(" SCARE STARE activated!");
  }
      if ((cPup.ActiveInventory == iRadish3)&&(scarestare == 0)) {
  scarestare += 1;
  btnIconStare.Enabled = true;
  cPup.LoseInventory(iRadish3);
  Display(" New Ability Aquired: SCARE STARE!");
  Display(" Upon eating anything that's edible, Pupshaw will gain the ability to intimidate with SCARE STARE. However it may only be used once until Pupshaw finds something else to eat. The SCARE STARE ability can be found in the icon bar above."); 
}
else if ((cPup.ActiveInventory == iRadish3)&&(scarestare > 0)) {
    scarestare += 1;
    btnIconStare.Enabled = true;
    cPup.LoseInventory(iRadish3);
    Display(" SCARE STARE activated!");
  }
else {
  Display(" You can't use that on yourself.");
}
}
#10
The manual tells me that when a NPC changes rooms, he does so instantly. I've found this is true. Even when I code him to walk off the edge of the screen and then change rooms, in runtime he doesn't even walk, he just vanishes. I've tried using regions as well. My question is, is there any way at all to have him walk off screen and then change rooms? And even more so, I'm curious, can he be performing functions in the other room without the playable character even there to see it? I'm not married to the idea, so don't go to any trouble experimenting, if you don't already know a solution. I just made a part of my game where my playable character (who's a sort of dog) can bark at these animals which scares them off in different directions. And I was playing with the idea that perhaps he can (if he chooses) to follow one into the next room to see it continuing it's journey. If the solution is far too complex, I'll probably dump the idea, as it's uneccessary to the game and kind of frivolous. Later on, I'll have much more important problems that I'll need your help with - all you smart folks out there, you know who you are. Thanks.   
#11
Thought I could use FolllowCharacter with special values to have character move away instead of follow. Basically, as my playable character approaches the other character, I want the other character to move away. I didn't want to set coordinates though, but instead have him move a few steps away if my playable character gets too close. Is this possible? I've searched the manual and forum to no end. thanks.
#12
Basically, I want to change the "Talkto" cursor to a "Bark at" cursor, and have the player bark at things in the game, since he can't speak. Or I would instead remove the "talkto" cursor altogether and create a new one. Either way, I want a "bark at" cursor and animate the player barking when it's clicked and face in that direction. Is this even possible? I've searched the manual and forum with no luck. Any ideas? Thanks.
SMF spam blocked by CleanTalk