|
Axe Software Forums
Quest Developer Forum Bug
|
Author | Topic: Bug |
Fred |
posted 10-05-2002 01:27 BST
I am having trouble implementing the code for wandering NPC's. Every time I use the movement procedure the game freezes up. I have tried to translate all the 2.x-specific code into 3.x code, but it still freezes. Any ideas? |
MaDbRiT |
posted 10-05-2002 16:21 BST
quote: Do you mean my code for the wandering cat demo as written for Q2.14 or thereabouts? If so, I haven't tried to use this with any version of Q3 and I don't recall the code off the top of my head, but I'll take a look at it sometime over the weekend. It really shouldn't be too hard to make the principle work in Q3 if my memory isn't playing tricks! Al |
Computer Whizz |
posted 10-05-2002 21:31 BST
I hope you aren't trying to make the code expandable to loads of characters! That would require you to generate ALOT of random numbers - then to move to EACH room and move the NPC's there one by one, meaning after every move/whatever then you have a great waiting time where the player can't do anything. If Quest impliments a move #object# to #room# command (I don't think it has got it) then it might be more of a possibility. Computer Whizz |
Fred |
posted 10-05-2002 22:16 BST
Well, I've only made 1 NPC so far that wanders, and I don't plan to make any more if it is going to cause a problem in the gameplay. |
MaDbRiT |
posted 10-05-2002 22:47 BST
quote: I agree CW - if there are LOADS of mobile NPC's this could be a problem, but one or two should not add an unacceptable delay.
quote: ??? Quest does have a move object to room statement! it is move <objectname; newroom> and has been in ASL for... ooh ages and ages! The problem with coding the cat that moved around was that I wanted it to move only through properly defined exits. The reason I had to move the player around out of sight, was that one could not read the available exits of any room except the one the player was in, so to find out what directions were available to the cat and where they led, I had to put the player in the room with the cat. I don't know if one can read the directional exits of other rooms from code in Q3, if it is possible I have the syntax wrong because it doesn't work for me! Al |
passerby |
posted 11-05-2002 10:29 BST
My advice would be to convert the code in small blocks. ie convert, save, and make sure that that one bit does what it should before starting on the next bit. That way, you can isolate the bits that won't work. Also, it would be best to save each version with a new bit completed to a new file, so you can go back to an old version if a bug in one bit slips through into later versions. Otherwise, maybe there's another way of implementing the wandering character(s) you want. Do you really need them to keep moving around even when the player can't see it? |
Computer Whizz |
posted 11-05-2002 16:57 BST
Well - it would be a good idea to have even the chaacters the player doesn't see moving around.... That way you could have the player running into different people in different places ect... Instead of the same place and people all the time. The trouble really beggins when you need to talk to one of these people to further the game play ; ) LOL You'd never be able to find them - or the person who is talking about the city Zolden when he's in the Evil Gentor's cave! Of course this is easily overcome with room properties - so a character walks around in a certain area..... Computer Whizz |
MaDbRiT |
posted 11-05-2002 20:20 BST
CW wrote:-
quote: Well my original code was designed for Quest 2.x - we didn't have 'properties' back then, so I had to find another way to do it. My original code also allowed the NPC to wander freely anywhere the player could go with no need for 'properties' holding the names of rooms it was possible to exit to and so was pretty simple to set up & use. Unfortunately Q3.1 seems to call the 'afterturn' script recursively if you use an 'exec <command>' statement, this prevents my old 2.1x method from working so changing the old code to 3.1 syntax won't help :-( I agree it would be possible to use a set of properties containing the names of rooms accessible from the current room for each room so that these could be read and objects moved without needing to manipulate the player character, but this could become very tiresome I fear! I think in Q3, it's better to create an array of strings to hold the names of the rooms the cat can move between and use it with the mobile npc, in my example I'd use catrooms<n>. This could be used with a randomly generated number to either 'bounce' the cat directly from room to room, move <cat;#catroom<n>#> or (better I think) use a randomly generated number to decide whether to advance / retrace the cat's movement through a predetermined path or not move it at all. As is my wont, here is a cut, paste & run example of what I mean, I am not sure if the square brackets used in the arrays will survive posting on this forum though :-)
quote: That works on my PC and I've added code to deal with the cat arrving in or leaving from the player's room this time - that was a known limitation on my V2.1x code :-) Al Al |
Fred |
posted 11-05-2002 23:16 BST
Thanks, Al. |
Computer Whizz |
posted 12-05-2002 02:15 BST
It took me a couple of minute's to work this out, but I think i've got it: quote:So you'r saying only two numbers (1 and 6) generated at random will change the cat's position - and all other random numbers won't do a thing! I did think (at the time I posted) tat you could use an array - but I didn't think about a path for the caracter to go along.... I didn't have any idea's how to use the array! I like the idea of a path the caracter can follow much more than moving at random - but I would only use this for NPC's and not NPE (non-playable enimies) in which case I personally would use the properties (and so create a game where the player DOESN'T know where the enimies are). Thanx for the code Al. Computer Whizz |
MaDbRiT |
posted 12-05-2002 09:36 BST
CW wrote
quote: Precisely that C.W. :-) Though (%catlocation% <6) ought to be (%catlocation% <5) - a simple coding oversight on my part. I chose to give the cat a 1:3 chance of moving in any turn, this is simple to vary for a more / less 'active' result. A point to note, it would be very easy to modify this code to have the cat follow the player once the two were in the same room (maybe until the player gives the cat some food).
quote: Actually you could modify the above code quite easily to allow an enemy to move around a range of available rooms in a more randomly controlled fashion rather than a linear path as I have done here, but like you I happen to prefer the idea of a 'path' for NPC's of the cat like nature. It's as well to remember that the available path is only known by the game designer, not the player and without modifying the concept you could create a quite long and twisty path that would appear very random to the player for an unfriendly NPC should you need it. Al |