Help for WHAM - All solved

Started by WHAM, Sun 18/03/2007 09:44:41

Previous topic - Next topic

Khris

Yes. Call "cRadio.ChangeRoom(player.Room, player.x, player.y);" before starting the dialog / calling the Say commands.

Just use cEgo's view(s) for the char, then put "cRadio.Transparency=100;" in game_start.

It will. This is only an issue if chars walk into each other and even that can be made work by setting the Solid property of one of the chars to false.

WHAM

WORKS!!! Thank Khris!
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

WHAM

Just going to throw a quick question here.

Is there a way to give an inventory item a default message, that would be said by the cEgo every time that item was used on something that has not been set to react to that item. For example: I have a gun, that when used on a certain hotspot, triggers a cutscene. If it is used on a pair of boot lying on the floor, or anything else for that matter, the character says "No use".

The way I see it now, is to give each and every hotspot a way of reacting to that item, by making cEgo say this message. Troublesome...
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

GarageGothic

Sure just look up unhandled_event in the manual. You see that you want to use type 3, but you may also want to distinguish at least between characters and objects/hotspots in the responses ("I see no reason to shoot at that.", "No, I'm not a killer!").

Check the player.ActiveInventory property to distinguish between different items.

Khris

This can be done by using unhandled_event.

Add it to the global script:
Code: ags
function unhandled_event (int what, int type) {
  if (type==3) { // use inv on
    InventoryItem*i=player.ActiveInventory;
    player.Say(i.GetPropertyText("unhandled");
  }
}


In the Custom properties editor, add a new string property with name "unhandled" and a default value of, say, "That doesn't work."
Now enter an appropriate message for every inv item.

This will work for every hotspot/char/object... with a blank "use inv on ..." interaction.

If there are actions in "use inv on ..." defined:
Code: ags
  if (player.ActiveInventory==iKey) {  // intended item(s)
    ...
  }
  else unhandled_event(1, 3);


If this doesn't work, try I'm- and exporting unhandled_event.
If it still doesn't work, add this below the declaration of unhandled_event:
Code: ags
function unhandled() {
  unhandled_event(1, 3);
}
export unhandled;

and import it in the script header, then call unhandled(); at the end of the interaction.

WHAM

Hey guys! I'm back! AGAIN!!!

The following code is my shooting script for the game, but it has one tiny problem. Apparently due to the "cEgo.ChangeView(1);" at the end, the cEgo's shooting animation is not run properly, as only the first frame of it is run. Any ideas on how to solve this? I recon that having the animation be a blocking one would help, but can I even have two animation running at the same time, that are both blocking?

Code: ags

if (player.ActiveInventory == igun40 ||  player.ActiveInventory == igun30 ||  player.ActiveInventory == igun20 ||  player.ActiveInventory == igun10) { 

if (player.x < cAi3.x) {
cEgo.Animate(8, 5, eOnce, eNoBlock);
cAi3.Animate(8, 5, eOnce, eNoBlock);
}

else if (player.x > cAi3.x) {
cEgo.Animate(9, 5, eOnce, eNoBlock);
cAi3.Animate(9, 5, eOnce, eNoBlock);

}

}
cEgo.ChangeView(1);


Thanks...
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Khris

Change both Ai3's anims to blocking.

You can't run two blocking anims at the same time, but if you run the first non-blocking and the second one blocking, they will run blocking simultaneously.

With your current code, AGS only gets to the first frame, because Ego's view is changed immediately afterwards.

WHAM

Ahhh... Thanks!

I've never been that good with figuring out how these things work, but this helped alot. I thought that having the animation block would cause the earlier activated animations to also cease.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

WHAM

Quote from: KhrisMUC on Fri 04/05/2007 22:13:03
This can be done by using unhandled_event.

Add it to the global script:
Code: ags
function unhandled_event (int what, int type) {
  if (type==3) { // use inv on
    InventoryItem*i=player.ActiveInventory;
    player.Say(i.GetPropertyText("unhandled");
  }
}


In the Custom properties editor, add a new string property with name "unhandled" and a default value of, say, "That doesn't work."
Now enter an appropriate message for every inv item.

This will work for every hotspot/char/object... with a blank "use inv on ..." interaction.

If there are actions in "use inv on ..." defined:
Code: ags
  if (player.ActiveInventory==iKey) {  // intended item(s)
    ...
  }
  else unhandled_event(1, 3);


If this doesn't work, try I'm- and exporting unhandled_event.
If it still doesn't work, add this below the declaration of unhandled_event:
Code: ags
function unhandled() {
  unhandled_event(1, 3);
}
export unhandled;

and import it in the script header, then call unhandled(); at the end of the interaction.

I've tried this quite a few times now, altering it and trying to get it to work, and keep getting an error:
"We're sorry, the AGS editor has encountered a serious error and must shut down...

(Exception 0.0000000 at EIP=0x0000000,
AGSEDIT v2.72.652, SIP=26)

Ideas on the reason? This happen when I put KhrisMUC's code into the global script and test the game. Something about is either wrong or then there's a problemn with something else.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Gilbert

I'm not quite sure, but maybe declaration of pointer variable in a function is not supported.

Try moving the Inventory* declaration line of unhandled_event() out of the function to the top of the script, or try:
Code: ags

function unhandled_event (int what, int type) {
  if (type==3) { // use inv on
    player.Say(player.ActiveInventory.GetPropertyText("unhandled");
  }
}

WHAM

Ok... I dont know what I've changed, but at the moment, both:

Code: ags
// main global script file

function unhandled_event (int what, int type) {
  if (type==3) { // use inv on
    InventoryItem*i=player.ActiveInventory;
    player.Say(i.GetPropertyText("unhandled");
  }
}

/*************************************************************\
 GLOBAL VARIABLES
\*************************************************************/


and:
Code: ags
// main global script file

function unhandled_event (int what, int type) {
  if (type==3) { // use inv on
    player.Say(player.ActiveInventory.GetPropertyText("unhandled");
  }
}
/*************************************************************\
 GLOBAL VARIABLES
\*************************************************************/


Return a "Runtime error: Umexpected eof". I'm not even sure if it matters if I put this script in a certain area of the global script or not? Does it? I've been trying to put it at the very beginning or the very end.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Pumaman

    player.Say(i.GetPropertyText("unhandled") );

You're missing that closing bracket.

However, it's quite bad that this causes the editor to crash.

Ashen

AFAIK, declaring pointers in functions works fine - it always has for me, anyway.

In addition to the missing ')' Pumaman noticed, everyone in this thread apparently needs to read the manual  ;) - the function is called GetTextProperty, not GetPropertyText. (At least, after V2.7 it is.)

However, even with the wrong command and the missing ')' I don't get the original crash, just 'unexpected eof' and 'undefined token'. Either there was something else that you've fixed without realising, or AGS was just having a bad day when it threw that one out.
I know what you're thinking ... Don't think that.

WHAM

Well... fcuk!!! FCUK!!!

The closing bracket and the wrong order of words in GetTextProperty have been causing the problem! I'm just too friggin BLIND to spot these things. *bangs head to the wall in frustration*

Thanks for pointing this out people, I'll be trying this out today but it seems to be working. Ill modify the results here in an hour or two.

EDIT: Works like a charm now! WOOHOOO!!!
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

WHAM

I seem to be unable to find a following anywhere:

How do I remove an inventory item from the player? I can find a dozen tips on adding and using the items but nothing on removing them. Perhaps I just use the wrong words for the search but... blargh...
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Ashen

#75
Character.LoseInventory, or even directly modifying Character.InventoryQuantity (e.g. player.InventoryQuantitiy[iKey.ID] --;), though player.LoseInventory is best unless you need to remove multiple instances of an item. How did you not see them in the manual? It seems like a lot of your recent questions here could've been solved by checking the manual, or (as with the missing '(') double checking your code.

EDIT:
As is the case with most related commands, LoseInventory is cross-linked with AddInventory. No need for searching.
I know what you're thinking ... Don't think that.

WHAM

"Lose"...

I was dilligently looking for something along the lines of "RemoveInventory" as opposed to the "AddInventry"... Thanks Ashen... And sorry. I did look at the manual but as I used ctrl+f to scan through it with any search words I could come up with, I failed to spot this.

The good news is that I wont be asking the same thing twice, ever! Promise!
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

WHAM

Project again underway. New question has arisen.

My game is being quite heavy on different actions taking place as the main character walk onto a certain region (doors opening etc) but this has caused a veeery annoying problem.

If I anter a room and click on a hotspot that has a walk to point, and the character goes to this walk to point, he doesn't trigger any regions. This causes doors animating opening twice as they never closed and such. Is there a way to fix this?

Thanks again.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Recluse

It seems like the walk-to point may be calling a blocking function, which would definately cause some problems with walking on the region.

I have 2 Possible solutions (not sure which is best):

  • Add something in the Always_Executes function that checks to see if the player is standing on a region  in the rooms which give you trouble.
  • Remove the walk-to points and use character.Walk() instead with eNoBlock on (you may need to code around some things so that the eNoBlock doesn't screw up your list of actions.
I'm not sure if either of those would work. I'm inclined to think that using the Always_executes function like this would cause some serious lag on slower machines, and I'm not sure if using eNoBlock would be feasible. But that's what I've got, someone please correct me if I'm wrong.
All your verbcoin are belong to us.

WHAM

Yeah... I was thinking about abandoning walk to points and using cEgo.Walk...

I just asked if anyone knew a better way so I wouldn't have to remove them all and replace them with the walking commands.

Thanks anyway.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

SMF spam blocked by CleanTalk