Navigating through and understanding the AGS Source: Part 2: Interaction Modes

Started by Joseph DiPerla, Fri 27/07/2012 16:14:58

Previous topic - Next topic

Joseph DiPerla

I had a question... I wanted to add more user mode's for better verbcoin functionality. I suppose the first place I should be concerned with this is in the Engine itself. As I have mentioned numerous times, I am not expert at c++, I am still learning and the adventure game engine scene in C++ is still a bit out of reach for me. However, that does not mean I cant practice and mingle :)

Anyway, I wanted to add the following cursor modes to the engine itself:
Give, Pull, Push, Take Off, Put On, Use with, read, Open, Close, Turn on, Turn Off, Kiss, Kick, Punch, Lick, Slap, instigate.

So, correct me if I am wrong, but, would I do this as far as the engine goes:

in rundefines.h, on lines 72 of the refactored code I would add:

Code: AGS
#define MODE_GIVE 10

Code: AGS
#define MODE_PULL 11

Code: AGS
#define MODE_PUSH 12

Code: AGS
#define MODE_TAKEOFF 13

Code: AGS
#define MODE_PUTON 14

Code: AGS
#define MODE_USEWITH 15

Code: AGS
#define MODE_READ 16

Code: AGS
#define MODE_OPEN 17

Code: AGS
#define MODE_CLOSE 18

Code: AGS
#define MODE_TURNON 19

Code: AGS
#define MODE_TURNOFF 20

Code: AGS
#define MODE_KISS 21

Code: AGS
#define MODE_KICK 22

Code: AGS
#define MODE_PUNCH 23

Code: AGS
#define MODE_SLAP 24

Code: AGS
#define MODE_LICK 25

Code: AGS
#define MODE_INSTIGATE 26

-----------------------------

In global_character.cpp on lines 381 I would add:
Code: AGS
else if (mood==MODE_GIVE) passon = 10;

Code: AGS
else if (mood==MODE_PULL) passon =  11;

Code: AGS
else if (mood== MODE_PUSH) passon =  12;

Code: AGS
else if (mood== MODE_TAKEOFF) passon =  13;

Code: AGS
else if (mood==MODE_PUTON) passon =  14;

Code: AGS
else if (mood==MODE_USEWITH) passon =  15;

Code: AGS
else if (mood== MODE_READ) passon =  16;

Code: AGS
else if (mood==MODE_OPEN) passon =  17;

Code: AGS
else if (mood== MODE_CLOSE) passon =  18;

Code: AGS
else if (mood== MODE_TURNON) passon =  19;

Code: AGS
else if (mood== MODE_TURNOFF) passon =  20;

Code: AGS
else if (mood== MODE_KISS) passon =  21;

Code: AGS
else if (mood== MODE_KICK) passon =  22;

Code: AGS
else if (mood==MODE_PUNCH) passon =  23;

Code: AGS
else if (mood==MODE_SLAP) passon =  24;

Code: AGS
else if (mood==MODE_LICK) passon =  25;

Code: AGS
else if (mood== MODE_INSTIGATE) passon =  26;

--------------------------

In Global_Object.cpp on line 374 I would add:
Code: AGS
else if (mood==MODE_GIVE) passon = 10;

Code: AGS
else if (mood==MODE_PULL) passon =  11;

Code: AGS
else if (mood== MODE_PUSH) passon =  12;

Code: AGS
else if (mood== MODE_TAKEOFF) passon =  13;

Code: AGS
else if (mood==MODE_PUTON) passon =  14;

Code: AGS
else if (mood==MODE_USEWITH) passon =  15;

Code: AGS
else if (mood== MODE_READ) passon =  16;

Code: AGS
else if (mood==MODE_OPEN) passon =  17;

Code: AGS
else if (mood== MODE_CLOSE) passon =  18;

Code: AGS
else if (mood== MODE_TURNON) passon =  19;

Code: AGS
else if (mood== MODE_TURNOFF) passon =  20;

Code: AGS
else if (mood== MODE_KISS) passon =  21;

Code: AGS
else if (mood== MODE_KICK) passon =  22;

Code: AGS
else if (mood==MODE_PUNCH) passon =  23;

Code: AGS
else if (mood==MODE_SLAP) passon =  24;

Code: AGS
else if (mood==MODE_LICK) passon =  25;

Code: AGS
else if (mood== MODE_INSTIGATE) passon =  26;

---------

In Global_hotspot.cpp on line 88 add:
Code: AGS
else if (mood==MODE_GIVE) passon = 10;

Code: AGS
else if (mood==MODE_PULL) passon =  11;

Code: AGS
else if (mood== MODE_PUSH) passon =  12;

Code: AGS
else if (mood== MODE_TAKEOFF) passon =  13;

Code: AGS
else if (mood==MODE_PUTON) passon =  14;

Code: AGS
else if (mood==MODE_USEWITH) passon =  15;

Code: AGS
else if (mood== MODE_READ) passon =  16;

Code: AGS
else if (mood==MODE_OPEN) passon =  17;

Code: AGS
else if (mood== MODE_CLOSE) passon =  18;

Code: AGS
else if (mood== MODE_TURNON) passon =  19;

Code: AGS
else if (mood== MODE_TURNOFF) passon =  20;

Code: AGS
else if (mood== MODE_KISS) passon =  21;

Code: AGS
else if (mood== MODE_KICK) passon =  22;

Code: AGS
else if (mood==MODE_PUNCH) passon =  23;

Code: AGS
else if (mood==MODE_SLAP) passon =  24;

Code: AGS
else if (mood==MODE_LICK) passon =  25;

Code: AGS
else if (mood== MODE_INSTIGATE) passon =  26;


In Global_inventoryitem.cpp on lines 104 and on
Code: AGS

Code: AGS
else if (modd == MODE_GIVE)

Code: AGS
        run_event_block_inv(iit, 10);

Code: AGS
else if (modd == MODE_PULL)

Code: AGS
        run_event_block_inv(iit,11);

Code: AGS
else if (modd == MODE_PUSH)

Code: AGS
        run_event_block_inv(iit, 12);

Code: AGS
else if (modd == MODE_TAKEOFF)

Code: AGS
        run_event_block_inv(iit, 13);

Code: AGS
else if (modd == MODE_PUTON)

Code: AGS
        run_event_block_inv(iit, 14);

Code: AGS
else if (modd == MODE_USEWITH)

Code: AGS
        run_event_block_inv(iit, 15);

Code: AGS
else if (modd == MODE_READ)

Code: AGS
        run_event_block_inv(iit, 16);

Code: AGS
else if (modd == MODE_OPEN)

Code: AGS
        run_event_block_inv(iit, 17);

Code: AGS
else if (modd == MODE_CLOSE)

Code: AGS
        run_event_block_inv(iit, 18);

Code: AGS
else if (modd == MODE_TURNON)

Code: AGS
        run_event_block_inv(iit, 19);

Code: AGS
else if (modd == MODE_TURNOFF)

Code: AGS
        run_event_block_inv(iit, 20);

Code: AGS
else if (modd == MODE_KISS)

Code: AGS
        run_event_block_inv(iit, 21);

Code: AGS
else if (modd == MODE_KICK)

Code: AGS
        run_event_block_inv(iit, 22);

Code: AGS
else if (modd == MODE_PUNCH)

Code: AGS
        run_event_block_inv(iit, 23);

Code: AGS
else if (modd == MODE_SLAP)

Code: AGS
        run_event_block_inv(iit, 24);

Code: AGS
else if (modd == MODE_LICK)

Code: AGS
        run_event_block_inv(iit, 25);

Code: AGS
else if (modd == MODE_INSTIGATE)

Code: AGS
        run_event_block_inv(iit, 26);

Code: AGS


Now the next few parts of code are for the editor itself. I get most of it, however, I can not seem to be able to add these to the mouse cursors section on the pane. Any idea’s? Anyway, here goes:

On line 23 in Roomhotspot.cs, change the following to:
Code: AGS
_interactionSchema = new InteractionSchema(new string[] {"Stands on hotspot",

Code: AGS
                "$$01 hotspot","$$02 hotspot","Use inventory on hotspot",

Code: AGS
                "$$03 hotspot", "Any click on hotspot","Mouse moves over hotspot",

Code: AGS
                "$$05 hotspot", "$$08 hotspot", "$$09 hotspot", “Give”, “Pull”, “Push”, “Take Off”, “Put on”, “Use with”, “Read”, “Open”, “Close”, “Turn on”, “Turn off”, “Kiss”, “Kick”, “Punch”, “Slap”, “Lick”, “Instigate”},

Code: AGS
                new string[] { "WalkOn", "Look", "Interact", "UseInv", "Talk", "AnyClick", "MouseMove", "PickUp", "Mode8", "Mode9", “Give”, “Pull”, “Push”, “TakeOff”, “PutOn”, “UseWith”, “Read”, “Open”, “Close”, “TurnOn”, “TurnOff”, “Kiss”, “Kick”, “Punch”, “Slap”, “Lick”, “Instigate” });

Code: AGS
        }


On line 40 on Character.cs:

Code: AGS
  _interactionSchema = new InteractionSchema(new string[] {"$$01 character",

Code: AGS
                "$$02 character","$$03 character","Use inventory on character",

Code: AGS
                "Any click on character", "$$05 character","$$08 character",

Code: AGS
                "$$09 character", “Give”, “Pull”, “Push”, “Take Off”, “Put on”, “Use with”, “Read”, “Open”, “Close”, “Turn on”, “Turn off”, “Kiss”, “Kick”, “Punch”, “Slap”, “Lick”, “Instigate”},

Code: AGS
                new string[] { "Look", "Interact", "Talk", "UseInv", "AnyClick", "PickUp", "Mode8", "Mode9", “Give”, “Pull”, “Push”, “TakeOff”, “PutOn”, “UseWith”, “Read”, “Open”, “Close”, “TurnOn”, “TurnOff”, “Kiss”, “Kick”, “Punch”, “Slap”, “Lick”, “Instigate”  });

Code: AGS
        }


Line 27 in InventoryItem.cs:

Code: AGS
_interactionSchema = new InteractionSchema(new string[] { "$$01 inventory item",

Code: AGS
                "$$02 inventory item", "$$03 inventory item", "Use inventory on this item",

Code: AGS
                "Other click on inventory item", “Give”, “Pull”, “Push”, “Take Off”, “Put on”, “Use with”, “Read”, “Open”, “Close”, “Turn on”, “Turn off”, “Kiss”, “Kick”, “Punch”, “Slap”, “Lick”, “Instigate” },

Code: AGS
                new string[] { "Look", "Interact", "Talk", "UseInv", "OtherClick", “Give”, “Pull”, “Push”, “TakeOff”, “PutOn”, “UseWith”, “Read”, “Open”, “Close”, “TurnOn”, “TurnOff”, “Kiss”, “Kick”, “Punch”, “Slap”, “Lick”, “Instigate”   });

Code: AGS
        }


On line 33 in RoomObject.cs

Code: AGS
_interactionSchema = new InteractionSchema(new string[] {"$$01 object",

Code: AGS
                "$$02 object", "$$03 object",  "Use inventory on object",

Code: AGS
                "Any click on object",

Code: AGS
                "$$05 object", "$$08 object", "$$09 object", “Give”, “Pull”, “Push”, “Take Off”, “Put on”, “Use with”, “Read”, “Open”, “Close”, “Turn on”, “Turn off”, “Kiss”, “Kick”, “Punch”, “Slap”, “Lick”, “Instigate”},

Code: AGS
                new string[] { "Look", "Interact", "Talk", "UseInv", "AnyClick", "PickUp", "Mode8", "Mode9", “Give”, “Pull”, “Push”, “TakeOff”, “PutOn”, “UseWith”, “Read”, “Open”, “Close”, “TurnOn”, “TurnOff”, “Kiss”, “Kick”, “Punch”, “Slap”, “Lick”, “Instigate”  });

Code: AGS
        }



Am I missing anything, besides the mouse cursors pane issue?
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

Crimson Wizard

I am sorry to say this, but I believe hard-coding interaction modes in the engine is one of the worst ideas I've heard.
Even the fact that few are hard-coded in the current AGS is bad enough already.

Joseph DiPerla

Why do you say that? I always liked the idea that there were hard-coded interactions in AGS as it made programming for people like me easier to do.
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

Crimson Wizard

Quote from: Joseph DiPerla on Fri 27/07/2012 17:18:16
Why do you say that? I always liked the idea that there were hard-coded interactions in AGS as it made programming for people like me easier to do.

I'll try to elaborate.
The question here is not how those interactions look in the editor and script. The question is how they look in the engine.
Better idea would be to allow creating interaction types right in the editor, similar to how you create custom properties. That would allow ultimate flexibility.
Newbies could use templates that define some simple default interaction schemas, while hardcore game devs could create their own schemas with custom itneraction types.
Now what you do is making a bunch of interactions that will be in game regardless if game dev wants them to be there or not. And if the engine development will follow this logic, we would have to add more and more hard-coded interactions for every interaction type users would like to have (I dunno, Shoot, Eat, Drink, Dance...).

So, to be frank, I do not see any benefit from this, unless you are doing this for learning purposes only.

On your code.
Why are you using constant values (11,12,13 etc) when you just declared macros for those types? That makes no sense.
More than that, you do realize that you set a "passon" variable to the same value as the mood? Why writing all those "else if" lines when you could just write
Code: cpp

passon = mood;

only once.
Same for inventory:
Code: cpp

run_event_block_inv(iit, mode);


I hadn't paid much attention to how that works, so I'll have too look more to give any further opinion.

Joseph DiPerla

Well, yes, I am definitely doing this for learning purposes. :) Also, I always thought that there should be a way to add more interactions in the editor as you mentioned. Sorry, I didn't understand why you were opposed to the hard-coded interactions. But again, I think the next best thing if we do not have the ability to add interactions to the editor is to hard code it. I think adding mouse cursor modes is heading in the right direction, but not streamlined enough.
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

Crimson Wizard

Quote from: Joseph DiPerla on Fri 27/07/2012 17:27:34
Sorry, I didn't understand why you were opposed to the hard-coded interactions. But again, I think the next best thing if we do not have the ability to add interactions to the editor is to hard code it. I think adding mouse cursor modes is heading in the right direction, but not streamlined enough.

Well, you see, problem with AGS, as being mentioned by Chris Jones himself, is that it was written in not a very best way. Ah, well, why to be so tender... it is coded just terribly :D.
In fact I am pretty much amazed by stoicism CJ had to have to maintain this program for nearly 13 or 14 years.

So, what I meant to say is that many things there were coded the way they are because that did have sense back then, 10 years ago, when everyone wanted to make games with Sierra-like interface. As more time passed more customizable features were added. But it would require lots of rewriting to change it all.

So now when we have this opportunity (at least in theory) I feel a bit strange when I see someone attempts to extend the thing that should not be extended but rather replaced.

Joseph DiPerla

QuoteWell, you see, problem with AGS, as being mentioned by Chris Jones himself, is that it was written in not a very best way. Ah, well, why to be so tender... it is coded just terribly .

TRAITOR!!!! HOW DARE YOU!!!!!! :D

No, I see what your saying. Unfortunately, my C++/C# Coding experience only allows me to do it the way I am doing it. Eventually I will be good enough to make cool enhancements in AGS. :)
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

SMF spam blocked by CleanTalk