PLUGIN: OtherRoom plugin v0.2

Started by Kweepa, Mon 24/05/2004 11:57:32

Previous topic - Next topic

Kweepa

OtherRoom plugin for AGS v0.2 (also available as cross-platform script module)

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
Mirror (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?
Still waiting for Purity of the Surf II

Vel

That seems like an interesting idea, it will surely be very useful.

Scorpiorus

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);


Kweepa

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
Still waiting for Purity of the Surf II

Scorpiorus

#4
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.


Dave Gilbert

Very nice, Steve.  This addresses one of the most annoying issues I have with AGS.

Pumaman

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.

Rui 'Trovatore' Pires

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!
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

AnInhumer

This probably seems like a stupid question but what do I do with the file once it's downloaded?

Kweepa

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
Still waiting for Purity of the Surf II

Rui 'Trovatore' Pires

Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SMF spam blocked by CleanTalk