Custom commands for objects

dennis
18 Feb 2005, 21:10
Woulnt it be a good idea to have a "Custom commands" for objects, much the same as foor rooms?

Eg. custom commands that would work only when the player has the object or is in the same room as the object.

Or is there allready a better way to do It that I've yet to discover??

007bond
18 Feb 2005, 21:45
You know what, that isn't a bad idea. To have a custom command attached to an object, not a room. That way, it will save you making a global command, or a command in every room that it can go to. That's an alright idea.

dennis
19 Feb 2005, 00:36
It would make having NPC's moving about possible. (For me)

I could just give an actor a string of movement "player commands"
N, N, W, S etc. with a timer to have them move in paths..

Of course I'm only waving this flag because I can't see how else I could figuire out moving actors about. (Unless having a script in each room waiting for the actor to arrive from another room and the local room script then shutteling the actor on to the next room after a time.)

I say you asking about moving NPC's in an earlier post 007bond.
What trick did you end up using??

007bond
19 Feb 2005, 19:32
That wasn't me, that was steve the gaming guy. If you just reply to the post, that'll bring it up to the top, and we can discuss it further.

paul_one
20 Feb 2005, 02:46
Ugh...

Al has made a start with the NPC's... I may do my own little NPC thingy, but it ain't gonna be pretty!

Anonymous
20 Feb 2005, 09:11
I've posted elsewhere on this forum examples of how to have an NPC move about randomly (but obeying the real exits of a room) and have an NPC follow the player about - both using my versatile 'cat' NPC as an example. My (obsolete) Quest 2.1 tutorial actually featured a following actor - which is much easier to do now!

I also have working code for a basic ask about/tell about construct with the ability for NPC's to learn from what they are told :shock: This is part of my next iteration of Typelib which, if I ever get the time and health to progress it, is close to release. I'm also hoping Alex is going to improve the library interfacing - currently the new typelib has to add WAY too many extra tabs and is getting very confusing.

I've had moving actors on a pre-arranged path (which I call a script - an idea borrowed from the ALAN system) working quite nicely since Quest 2.1x - but no one has ever seemed interested in this (except me!)

That being so - the code is currently Quest 2.1 based, but I could easily modernise it for Quest 3.5, though making it a library would be quite messy as it requires a string of locactions etc to work..

Actually, I could plug it onto the forthcoming new version of typelib - that might be a good idea...

Al (MaDbRiT)

Anonymous
20 Feb 2005, 14:28
This is all great news. Except your ailing health that is. Are there any remedies that I can send you from Sweden to help you get back to form? I dont know powdered moosehorn or salt licroriche or something?
As recompensation for all the help with getting into Quest.

I would by extremely interested in the secret of NPC's moving in pre determined paths. I think that is a lot more useful than random movement.

I'm going to dig through the old posts about It. I've just been so incredibly carried away with learning the basics and sorting out than ruddy lantern of mine.

Since my mail is not getting yo you, could I ask you to mail me the latest Typlib? I'm in no hurry - If it is about to be modernised I can wait - I've got plenty of stuff to try and wrap my brain around as it is.

paul_one
20 Feb 2005, 16:06
Personally I'd prefer a seperate NPC library, since I don't necissarily want the synonym's etc from the typelib interfering with anything else in my game, while still liking the idea of a plug-in-and-go NPC stuff.

BUT I do understand that it could use some functions etc from typelib - so it's a give/take thing.

I personally love the idea of a path - for me that's the only way any game would work (well... With full 3D games you'd implement a degree of variance etc - but that's out of this field)...

I can't imagine it being a list of object properties (far too many locations on just a 10-room wander), so perhaps it would be an action-list? Having a list of actions to move the NPC to the certain room, and then just going through and using an object property ("roomnum=#") to move them around the circuit.
At least - that would be my idea - much easier than bounds checking, arrays, etc.
How did you go about your 2.1 NPC path Al?

dennis
20 Feb 2005, 16:41
I think It would be nice if actors could be programmed to do "player commands"

Go north, Go west, Drop puppy dropping, go east etc.

That way drones like me could easily understand how to make behaviour for NPC's.

In fact there are probably ways to do just that allready, but I've got a long way to go before I learn how to do it.

Anyway - I really don't care at the moment - I've got a lamp that works :)

Insigma
07 Mar 2005, 02:14
dennis wrote:Woulnt it be a good idea to have a "Custom commands" for objects, much the same as foor rooms?

Eg. custom commands that would work only when the player has the object or is in the same room as the object.

Or is there allready a better way to do It that I've yet to discover??


Alternatively, perhaps it might be possible to assign custom commands to particular types of objects. That way you could specifically 'wear' a 'clothing' object, 'eat' a 'food' object and so on. Especially if it was combined with the customisable right-click menu suggested in another thread... :D

Cryophile
10 Mar 2005, 22:43
I wrote a NPC movement code about a year ago with less than 2kb of code :shock: If someone wants it I can paste it here by monday.

francisstokes
10 Mar 2005, 23:27
i wouldn't mind that code.It could come in useful for my new game! :D

paul_one
11 Mar 2005, 09:43
Along these lines - wasn't it possible to get the exit's of 'a' room without having to move the player into that room? I keep forgetting that part.

Cryophile
17 Mar 2005, 20:56
I forgot about this topic. Yes, the names of the rooms that each room exits to are properties.
Say you had a room called room1 that exited to room2 going north.
room1's north property is room2.

Simple, eh?
The code is in The Shadow Project under the procedure npc_move
All it needs to run is:

do <npc_move;objectname>


The code could easily be trimmed but I needed it the way it was since I'm adding to it for enemies (objects with the property enemy can't enter a room that doesn't have the property dungeon unless it also has the property city

Cryophile
18 Mar 2005, 18:27
Here's my npc_move script. I know it could be simpler but I'm modifying it and I don't want to have to completely rewrite portions and stuff.


define procedure <npc_move>
set numeric <temp2; 0>
set numeric <rand; $rand(1;10)$>
set string <temp; $parameter(1)$>
set string <locob; $locationof(#temp#)$>
if ( %rand% = 1 ) then {
if property <#locob#; north> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;north)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;north)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;north)$>
set numeric <temp2; 1>
}
}
}
if ( %rand% = 2 ) then {
if property <#locob#; south> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;south)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;south)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;south)$>
set numeric <temp2; 1>
}
}
}
if ( %rand% = 3 ) then {
if property <#locob#; east> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;east)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;east)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;east)$>
set numeric <temp2; 1>
}
}
}
if ( %rand% = 4 ) then {
if property <#locob#; west> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;west)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;west)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;west)$>
set numeric <temp2; 1>
}
}
}
if ( %rand% = 5 ) then {
if property <#locob#; northeast> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;northeast)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;northeast)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;northeast)$>
set numeric <temp2; 1>
}
}
}
if ( %rand% = 6 ) then {
if property <#locob#; northwest> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;northwest)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;northwest)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;northwest)$>
set numeric <temp2; 1>
}
}
}
if ( %rand% = 7 ) then {
if property <#locob#; southeast> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;southeast)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;southeast)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;southeast)$>
set numeric <temp2; 1>
}
}
}
if ( %rand% = 8 ) then {
if property <#locob#; southwest> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;southwest)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;southwest)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;southwest)$>
set numeric <temp2; 1>
}
}
}
if ( %rand% = 9 ) then {
if property <#locob#; up> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;up)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;up)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;up)$>
set numeric <temp2; 1>
}
}
}
if ( %rand% = 10 ) then {
if property <#locob#; down> then {
if property <#temp#; enemy> and not property <$objectproperty(#locob#;down)$; dungeon> then {
if property <#temp#; city> then {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;down)$>
set numeric <temp2; 1>
}
else do <npc_move(#temp#)>
}
else {
if ( $locationof(#temp#)$ = #quest.currentroom# ) then doaction <#temp#; move>
move <#temp#; $objectproperty(#locob#;down)$>
set numeric <temp2; 1>
}
}
}
if ( %temp2% = 0 ) then do <npc_move($parameter(1)$)>
end define


Each of the characters that can randomly move have a "move" action script that gives a description like "The dog runs away."

paul_one
19 Mar 2005, 21:27
That is one big-ass code!

All that is chenging is a number, which you should put into an array and use that way..

Although I still don't like the fact it's totally random - since the characters can end up anywhere.

I also have a thing against those variables, especially the "temp" ones.... What are they? What are they for?
Temp variables should mainly be used for testing stuff, that either get replaced or discarded.

With this line:
if property <#temp#; city>
Are you assigning the CITY property to objects (enemies)?
What's even more questionable is this:
if property <#temp#; enemy> and not property <$objectproperty(#locob#;north)$; dungeon> then
So if it IS an enemy and the room north ISN'T a dungeon then move it there.... While if it isn't an enemy then move it there or if it's a dungeon north move it there.

Cryophile
27 Mar 2005, 01:23
The city property is applied to enemies that can enter non-dungeon areas. The second piece you found questionable simply said that if the object was an enemy and the room it tried to move into was not a dungeon then run that script. It will eventually be simplified when I'm finished since there's much more to come that requires heavy modifications. I'm not even 10% done the game. The game is based in a magic environment and I haven't even coded that aspect. Or a ton of others.
Also I find the temp variable highly useful. Since it's only used during that script and is scrapped afterward, why not reuse it? It saves space so I don't have to sort through 500 variables that will only be used occasionally.