Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: Kweepa on Mon 24/05/2004 11:57:32

Title: PLUGIN: OtherRoom plugin v0.2
Post by: Kweepa on Mon 24/05/2004 11:57:32
OtherRoom plugin for AGS v0.2 (also available as cross-platform script module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20650))

This is a simple plugin to change the state of objects/regions/hotspots/walkable areas in other rooms.
It is meant as a shortcut to the rigmarole of setting global variables and testing them in the destination room.

Download here (http://www.adventuregamestudio.co.uk/games.php?action=detail&id=425)
Mirror (http://www.2dadventure.com/ags/AGS_OtherRoom.zip) (Thanks Neole & Rui)

Here are the currently supported functions:

OtherRoomObjectOff(int room, int object);
OtherRoomObjectOn(int room, int object);
OtherRoomObjectToggle(int room, int object);
OtherRoomSetObjectPosition(int room, int object, int x, int y);
OtherRoomDisableRegion(int room, int region);
OtherRoomEnableRegion(int room, int region);
OtherRoomRemoveWalkableArea(int room, int walkableArea);
OtherRoomRestoreWalkableArea(int room, int walkableArea);
OtherRoomDisableHotspot(int room, int hotspot);
OtherRoomEnableHotspot(int room, int hotspot);

[EDIT: added region, walkable area, and hotspot functions]

Other functions will be added as needed/requested, eg AnimateObject, SetObjectTransparency...

NOTES:
IsObjectOn is not possible as the object is not loaded in memory.
Each time you call one of these functions, it goes in a list of commands that are called when the player enters the target room. So if the object is currently off, and you call toggle, off, toggle, the object will be off->on->off->on = on.
Toggle is only possible for objects as the current state of the other things is not accessible.
Saving and loading are supported. The command lists are written to and read from the savegame.

Steve

PS:
For OtherRoomSetObjectPosition, I tried this piece of code, but it crashed:

void (*func) (int, int, int) = ((void(*) (int, int, int))
    engine->GetScriptFunctionAddress("SetObjectPosition"));
func(object, x, y);

func, object, x, and y were valid. I just changed it to the following and it worked.

AGSObject *obj = engine->GetObject(object);
obj->x = x;
obj->y = y;

Any ideas?
Title: Re: New OtherRoom plugin
Post by: Vel on Mon 24/05/2004 12:49:37
That seems like an interesting idea, it will surely be very useful.
Title: Re: New OtherRoom plugin
Post by: Scorpiorus on Mon 24/05/2004 17:05:41
Nice work :)

As for the SetObjectPosition() function - it doesn't work because it's a script function - a wrapper for the MoveObject (int object, int x, int y, int speed) with the speed set to -1:

So the following should work fine:

void (*func) (int, int, int, int) = ((void(*) (int, int, int, int))
Ã,  Ã,  engine->GetScriptFunctionAddress("MoveObject"));
func(object, x, y, -1);

Title: Re: New OtherRoom plugin
Post by: Kweepa on Mon 24/05/2004 17:19:46
I think I need some clarification if that's ok.
Asking for SetObjectPosition seems to return a valid function pointer.

Is there a list of these wrapper script functions?
Are they related to the blocking functions?

Confused,
Steve
Title: Re: New OtherRoom plugin
Post by: Scorpiorus on Mon 24/05/2004 17:33:37
Yeah, it returns a valid but script address, like if you try to return the address of the repeatedly_execute. But it can't be called in a normal way.

It's declared the way like if you put in the script header:

function SetObjectPosition(int ob, int x, int y) {
MoveObject(ob, x, y, -1);
}

thus it's a script function :)


EDIT:
There are also IsSpeechVoxAvailable which is a #defined alias for IsVoxAvailable. Also GUIOn and GUIOff are actually InterfaceOn and InterfaceOff respectively.

Title: Re: New OtherRoom plugin
Post by: Dave Gilbert on Mon 24/05/2004 17:53:52
Very nice, Steve.  This addresses one of the most annoying issues I have with AGS.
Title: Re: New OtherRoom plugin
Post by: Pumaman on Mon 24/05/2004 21:00:30
Good work, Steve :)

As for the SetObjectPosition thing - ick, I'd forgotten about that. Yeah, ages ago I was trying to be efficient with the number of exported functions so I created several wrapper script functions.

When I realised what a bad idea it was, I removed most of them. I think SEtObjectPosition is the only one remaining. Scorpiorus has mentioned the other three functions that need different names to GetScriptFunctionAddress.
Title: Re: New OtherRoom plugin
Post by: Rui 'Trovatore' Pires on Tue 25/05/2004 06:33:35
Hallellujah, world without end, brother, can you give me amen! The only really annoying limitation in AGS has just been breached!

...adding it to my page, which is... ONLINE again!
Title: Re: PLUGIN: OtherRoom plugin
Post by: AnInhumer on Tue 01/03/2005 16:11:18
This probably seems like a stupid question but what do I do with the file once it's downloaded?
Title: Re: PLUGIN: OtherRoom plugin
Post by: Kweepa on Tue 01/03/2005 16:40:24
You need to unzip it into the directory that AGS is in.
Then when running AGS, use the menus to add the plugin to the loaded list.
Game -> Plugin Manager... -> [check the box next to OtherRoom]

Steve
Title: Re: PLUGIN: OtherRoom plugin v0.2
Post by: Rui 'Trovatore' Pires on Wed 01/08/2007 21:34:47
Here's a mirror:

http://www.2dadventure.com/ags/AGS_OtherRoom.zip