Help for WHAM - All solved

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

Previous topic - Next topic

WHAM

Ok, I'll take some time to read the manuals.

I'll admit it, I get bored reading manuals, and I just want to get creating and learn as I go, thats why I keep asking this stuff.

Thanks again for all the help.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Creator

Quote
No, WHAM is right - ints are set to 0 at declaration unless you say otherwise, so while cutscene ++; will set it to 1, it'll be 'destroyed' when the interaction finishes and re-declared as 0 next time the player steps onto the Region. Placing the declaration (int cutscene;) at the top of the room script (or just anywhere before you need to use it, provided it's outside of any functions) should work for cases like this, where it only has to affect things in the one room.

Woops, sorry, I was thinking wrong, the variable should be put at the start of the room script shouldn't it (now I know why my game wasn't working  :P)?

WHAM

Ok, call me an asshole for not getting this, but I just dont get the manual on this part at all.

I'm using the BASS base on my game, so I have an inventory already made. When I click on an item in the inventory, the cursor begomes the item, check.

How do I define how the same hotspots react to the use of this item on them?

As in: when I pick a gun from the inventory, and then click on another character, how do I get the shooting to actually happen? (No, I'm not asking about how to assign the views and loops here. Just to be clear.)

UseInventory on character/hotspot? Probably, but what kind of scripts do I define there, and how do I define which inventory item the hotspot reacts to?
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Ashen

BFAQ

So:
Code: ags

// script for Character 2 (NPC): Use inventory on character
  if (player.ActiveInventory == iGun) { // Or whatever the gun's Script-o-name is
    //Do shooting stuff
    cNpc.Say("You shot me, you git.");
  }
I know what you're thinking ... Don't think that.

WHAM

Hahaha!

Thanks for the perfect readymade code! I owe you one big time!
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

WHAM

This is no question, but I wanted those interested to see what they've helped me create here.

http://protoni.huittinen.fi/~tkahkone/Compiled.rar

The version behind the link is, as you probably guessed, far from complete, as it lacks voice acting, most sounds, most music, most rooms, and most of everything.

A friend of mine (a great drawer) has promised to help create better animations, that will be used as base for the final characters.

A proper intro will be added too, when I get there.

Thank you all, for helping me out.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Candle

Like what you have so far. good luck with the game.

Pumaman

Just as a side note, I'd strongly recommend against using numbered objects and characters like you've been doing:

object[0].SetView()
character[2].Walk()
etc

It's very difficult to read the code, since you don't know what object 0 is or which character 2 is. Give the objects and characters a script name in the editor, then you can do:

oDoor.SetView()
cDavid.Walk()
etc

which is much easier to read.

WHAM

Quote from: Pumaman on Sat 24/03/2007 17:45:41
Just as a side note, I'd strongly recommend against using numbered objects and characters like you've been doing:

object[0].SetView()
character[2].Walk()
etc

It's very difficult to read the code, since you don't know what object 0 is or which character 2 is. Give the objects and characters a script name in the editor, then you can do:

oDoor.SetView()
cDavid.Walk()
etc

which is much easier to read.



This may be easier to read by someone else, but I'm used to using short abbreviations and numbers in the codem and having their meanings written down in a separate .txt file.

Thanks for the tip though, and I might give it a try in the next part, but this first part will be made as it has been started.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

WHAM

No biggie, but this is annoying me:

If you download the version I linked earlier, you'll see whats happening to the doors when you enter them. As you enter the next room, the door animates, and opens again behind you, even though you opened it earlier on the other side.

Any tips on how to get rid of this?

I simply have the doors animate when player steps into a region set in front of the door:

object[0].SetView(3);
object[0].Animate(1, 3);

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

Ashen

Only moderators can delete posts, so I got rid of that one for you. In the future, if it's less that 24 hours since your last post edit it rather than double posting.

Variables will probably help here. Declare a bool in the Global Script, and make it Global (BFAQ).

Then you can do something like:
Code: ags

object[0].SetView(3);
if (CloseDoor == false) {
  object[0].Animate(1, 3);
  CloseDoor = true;
}


From the test game you uploaded, it looks like you've got something that closes the door when the player steps off the region. Make that:
Code: ags

object[0].Animate(1, 3, eOnce, eBlock, eBackwards); // Or whatever you're using now
CloseDoor = false;


Because the bool is being set and reset for every door, one variable should be OK to use for all of them (i.e. you don't need to make a new bool for every single door).
I know what you're thinking ... Don't think that.

WHAM

#31
I've tried working on the advise you gave me, Ashen, but I keep getting a parse error. This is the firs global variable I've created, so I put the whole script here, in case you can find out what it keeps complaining about. I've been changing bits and pieces of this for the last hour and something, and am gettin a little bit frustrated. ^^ This might, again, be just something I missed 'cause I lack experience, but heck!


//This is the room script for the door
#sectionstart region1_a  // DO NOT EDIT OR REMOVE THIS LINE
function region1_a() {
  // script for Region 1: Player walks onto region

if (doorsopen == false) {
SetObjectView(0, 3);
AnimateObject(0, 1, 3, false);
// this opens the door
//the next line has an error(?)
doorsopen == true;
}
}
#sectionend region1_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart region1_b  // DO NOT EDIT OR REMOVE THIS LINE
function region1_b() {
  // script for Region 1: Player walks off region
if (doorsopen == true) {
SetObjectView(0, 4);
AnimateObject(0, 1, 3, false);
// this closes the door
doorsopen == false;

}

//This is the global script used to create the bool
bool doorsopen;
export doorsopen;

Elsewhere in the game I have door that are opened bu pushing a switch, and I have the doors remain open as you enter/exit the door, but now the script is on a region near the door, as you can see. This poses a totally different challenge, as in the current situation, when the player enters the next room, he is already standing on the region that opens the door, and triggering the door opening animation. I cant disable the region and activate it later, because it would not close the door then, as the player get further away from the door.

Hope you're still following me here.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Khris

Did you put
import bool doorsopen;
in the script header?
And remember that the == is only for comparing stuff, setting a variable to a certain value is done with a single =.

And you might want to indent your code to increase readability:
Code: ags
#sectionstart region1_a  // DO NOT EDIT OR REMOVE THIS LINE
function region1_a() {
  // script for Region 1: Player walks onto region
  if (doorsopen == false) {
    SetObjectView(0, 3);
    AnimateObject(0, 1, 3, false);
    // this opens the door
    //the next line has an error(?)
    doorsopen = true;
  }
}
#sectionend region1_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart region1_b  // DO NOT EDIT OR REMOVE THIS LINE
function region1_b() {
  // script for Region 1: Player walks off region
  if (doorsopen == true) {
    SetObjectView(0, 4);
    AnimateObject(0, 1, 3, false);
    // this closes the door
    doorsopen = false;
  }  
}

WHAM

I just realized another problem. In the current situation, the variable changes as the player steps OFF the region, but this also happen as he neters the door (there is another region behind the door, which causes the room change), so as the player is moved to the next room, the variable is again set so that the door opens itself, taking me back to square one.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Ashen

#34
From before the last two posts:
Also, what is the exact wording of the error message? Giving that information is a good habit to get into - but fortunately it's pretty obvious in this case, as Khris has shown.

On to new stuff:
Have the 'Room Change' region set the bool as well. That way, it'll 'reset' to closed when you step off the first region, but still run OK when you enter the next room. (You might want to include a Object.StopAnimating(); command, so the animation isn't run before you leave the room. Alternatively, let it finish before the room change, and you don't need to run the closing animation in the next room.)

EDIT:
You could also modify the 'Walks off Region' interaction to only run if the player isn't stepping onto another Region, e.g.:
Code: ags

function region1_b() {
  // script for Region 1: Player walks off region
  if (Region.GetAtRoomXY(player.x,  player.y) == region[0]) {
    object[0].Animate(3,3,eOnce,eNoBlock);
    CloseDoor = false;
  }
}


For the switch operated door, just set doorsopen in the switch interaction, when you animate the door open. It should work exactly the same on the other side (door stays open until you walk off the Region).
I know what you're thinking ... Don't think that.

WHAM

HAAA!!!

Thank you!!!

*Bows down to the ground and sings in joy*

You people have, once again, saved my day AND my game!
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

WHAM

ok, this problem I cannot even describe properly. I've updated the game at http://protoni.huittinen.fi/~tkahkone/Compiled.rar and the problem can be seen in the second room you can access. If I use the elevator control there, the character walks onto the elevator, and the elevator should take him down to the lower level, BUT as you can see, tha animation is off.

the script used for interacting with the elevator control is the following, and seems to need some kind of way to define a new location for the player, that is a bit lower so that the animation gets to the right place, before running the animation.

Code: ags
character[0].Walk(166, 130, eBlock);
SetCharacterView(0, 16);
AnimateCharacter(0, 0, 2, false);


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

Ashen

1. Unless you're using an AGS version earlier then 2.7 (which you're not): Stop using the old style commands (SetCharacterView, AnimateCharacter). This is nothing to do with your problem, it just bugs me :)

2. Read the manual. Character.LockViewOffset should do what you want, just set the y offset.
I know what you're thinking ... Don't think that.

WHAM

The "old style commands" as you called them...

I've learned most of my scripting by using the ready commands you can create through clicking 'em, and it always shows you how the same thing can be made in scripting, so I've copied that.

You're asking me to relearn this stuff AGAIN in the same month ive learned the once! This equals: sorry, but no can do, at least yet. I'll keep learning as I go, so what I find is what I learn. ^^

And the offset thing worked out nicely. Lets hope that I run out of new ideas soon, so that I wont have to ask you how to get them to work any more.

Thank you, again.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Khris

Quote from: WHAM on Mon 02/04/2007 15:42:02I've learned most of my scripting by using the ready commands you can create through clicking 'em, and it always shows you how the same thing can be made in scripting, so I've copied that.
The has the effect part of Character - Quick animation indeed still contains three old style commands. CJ probably focused on the Text script equivalent code part and forgot to change it to new code.
Apart from that one single spot, every action will show proper new style commands, and you did use character[0].Walk, so you absolutely won't have to relearn everything.

SMF spam blocked by CleanTalk