Basic Maniac Mansion Maniac Tutorials in English

Started by Dr Fred Rubacant Edison, Wed 15/11/2006 00:02:29

Previous topic - Next topic
MMM CODEING 1


dir = you

General functions

function FaceDirection (int CharId, int dir)
dir: DIR_UP, DIR_LEFT, DIR_DOWN, DIR_RIGHT
The figure lets look in the indicated direction. In most cases this function can replace FaceLocation. Thereby one saves a calculating of the goal.



function EnterRoom (int room, int x, int y, int dir)
dir: DIR_UP, DIR_LEFT, DIR_DOWN, DIR_RIGHT
The player figure is carried into the area and there at that Position (<x>, <y>) set up with line of sight <dir>.
The NewRoomEx instruction is extended here by FaceDirection.


function SetPlayer  (int charid)
Changes of the player figure. Is the two figures in the same area, then a scrolling becomes the new figure
<charid> accomplished


function GiveInv  (int invitem, int charid)
The player figure gives the article <invitem> to the figure <charid>.



function GiveInvEx (int invitem, int charidfrom, int charidto)
The article <invitem> becomes from figure <charidfrom> at figure <charidto>
given. None of the two figures must be the current player figure, but one of both may be the current player figure.



Functions for "before fadein"


function PlaceCharacter  (int charid, int x, int y, int dir)
dir: DIR_UP, DIR_LEFT, DIR_DOWN, DIR_RIGHT
The figure sets <charid> to the position (<x>, <y>) and it leaves toward <dir> look.


function PlacePC (int x, int y, int dir)
dir: DIR_UP, DIR_LEFT, DIR_DOWN, DIR_RIGHT
The player figure sets to the position (<x>, <y>) and it leaves toward <dir> look.

function init_object (int GI, int objects)
GI: Number of a GlobalInt
objects: Number of an object
Is GlobalInt <GI> = 1, then object becomes <objects> switched on, otherwise out.




Functions for "Any click on Hotspot" or "Any click on Object"


function any_click_move (int x, int y, int dir)
dir: DIR_UP, DIR_LEFT, DIR_DOWN, DIR_RIGHT
Return value: 0, 1
Induces the player figure to the indicated coordinates and considers thereby walkable AREAS. Subsequently, the player figure looks in indicated the direction and waits one instant. If the player clicks during itself the player figure moved on another place, then the movement is broken off and the new action can be implemented. The function adds 0 back, if the movement were broken off, 1 has the player figure the goal coordinates (<x>, <y>) reached.


function any_click_walk (int x, int y, int dir)
dir: DIR_UP, DIR_LEFT, DIR_DOWN, DIR_RIGHT
Return value: 0, 1, 2
The function examines first whether the current action "A_WALK_TO" is . If this applies, then becomes any_click_move called.
The function returns to 0, if those were not treated the current action, 1 if the execution was broken off, 2 if the goal was reached.

function any_click_walk_look (int x, int y, int dir, string lookat)
dir: DIR_UP, DIR_LEFT, DIR_DOWN, DIR_RIGHT
Return value: 0, 1, 2
extended any_click_walk (see also there) over "A_LOOK_AT". with   "A_LOOK_AT"
the player figure says that Text <lookat>, if it achieved the goal coordinates.
The function returns 0, if those was not treated the current action, 1 if the execution was broken off, 2 one reached if the goal.

function any_click_walk_look_pick (int x, int y, int dir, string lookat,
int objects, int item, int GI, int sound)
dir: DIR_UP, DIR_LEFT, DIR_DOWN, DIR_RIGHT
Return value: 0, 1, 2
extended any_click_walk_look (see also there) over "A_PICK_UP".

With "A_PICK_UP" first a clay/tone becomes after reaching the goal coordinates <sound> played, if sound = 0.
Is objects = 0, then the Object becomes <objects> switched off and is item = 0, then becomes the inventory of the player figure <item> added. or then the inventory of the player figure one adds. 

If GI = 0 is, then the GlobalInt is set to 0. The function returns to 0, if those were not treated the current action, 1 if the execution was broken off, 2 if the goal was reached. 


function any_click_use_inv (int item, int x, int y, int dir)
dir: DIR_UP, DIR_LEFT, DIR_DOWN, DIR_RIGHT
Return value: 0, 1, 2 treats only the action "A_USE_INV". If the active Inventory article is, then the player figure moves (see any_click_move). The function returns to 0, if those were not treated the current action, 1 if the execution was broken off, 2 if the goal was reached.

Alternative functions 
These functions can be used, if in an interaction several of the functions described above successively and one liked to be supposed to be called x, y and you hand over not each time.


function SetWalkTo (int x, int y, int dir)
Stores x, y and you for the following functions

function MovedTo () {calls any_click_move (description see there).

function WalkedToLookedAt (stringer lookat) {calls any_click_walk_look (description see there).

function WalkedToLookedAtPickedUp (stringer lookat, int objects, int item, int GI, int sound) {calls any_click_walk_look_pick (description see there).

function UsedInvItem (int item) {calls any_click_use_inv (description see there).



Door functions for "Any click on Hotspot" or "Any click on Object"

NORMAL ONE

function any_click_on_door (int GI, int objects, int x, int y, int dir,
int nr_room, int nr_x, int nr_y, int nr_dir)

as any_click_on_door_special (see there), where by values are reserved: The texts are empty all, opensound=2, closesound=3, key=-1, closevalue=0

LOCKED

function SetDoorStrings (string lookat, string islocked, string wrongitem)
Stores the texts for the following function.
lookat:    Text for A_LOOK_AT
islocked: Text for  A_OPEN, if door is locked
wrongitem: Text for A_USE_INV, if active Inventory article not <key> is


function any_click_on_door_special (int GI, int objects, int x, int y, int dir,
         int nr_room, int nr_x, int nr_y, int nr_dir, int opensound,
         int closesound, int key, int closevalue)


Actions: A_CLOSE, A_OPEN, A_WALK_TO, A_LOOK_AT, A_USE_INV
GI indicates the GlobalInt, in which the condition of the door is stored.
Condition: 0=closed, 1=open, 2=locked
objects the object indicates in the area, which represents the opened door (the background shows the closed door)
x, y, you are used for any_click_move (description see there).   

nr_room indicates the area, into which the Tuere leads; nr_x, nr_y, nr_dir position and line of sight indicate in the new area.
Open sound of open and CLOSE and designate the clay/tone files, when opening and/or. Latches of the door to be played are.
key >= 0: designates the Inventory article, with which the door can be unlocked.

key = -1: The door can be opened, even if it is as locked characterized.

key = -2: The door cannot be opened at all (bspw. only from the other side to open not from this side)

closevalue: That was entitled Tuere ?? oh reasoning or The Tuere was entitled after reasoning

(0=closed, 2=locked) in GlobalInt one stores. <GI> stored

With A_WALK_TO the player figure is brought to the open door after reaching into the new area nr_room to the indicated position.



Further functions for "Any click on Hotspot" or "Any click on Object"


function UsedAction (int test_action)
  test_action: A_WALK_TO, A_LOOK_AT, A_TALK_TO, A_GIVE_TO, A_PICK_UP,
               A_USE, A_OPEN, A_CLOSE, A_PUSH, A_PULL, A_USE_INV


Return value: Boolean there in MMM actually no other interactions (as bspw. "Look RK object") to be used, is made the distinction of the current action with this function. The return value is Boolean, can thus in an IF condition be used directly.

Bsp.:
if (UsedAction (A_WALK_TO)) {... Actions for "Walk to"...}
if (!UsedAction (A_WALK_TO)) {... Actions for everything except "Walk to"...}


function MovePlayer (int x, int y)

Return value: 0, 1
Induces the player figure to the indicated coordinates and considers thereby walkable AREAS. If the player clicks during itself the figure moved on another place, then the movement is broken off and the new action can be implemented.

The function returns 0, if the movement were broken off, with 1 has the player figure the goal coordinates (<x>, <y>) reached.
[identically to MovePlayerEx (int x, int y, 0)]

In film scenes, in which the player does not have influence on the happening, should be used instead of its one of the move character functions. Ex.:

A cabinet is to be away-pushed, if the player pushes "cabinet" selects. In the interaction of the cabinet first MovePlayer is used, in order to let the player figure go to the cabinet (this action can be broken off). If the player figure pushes thereupon the cabinet, then this is to be able to be broken off, but once begun up to the end not be accomplished. But bspw. MoveCharacterBlocking is then used.


function MovePlayerEx (int x, int y, int direct)
direct: 0, 1
Return value: 0, 1
behaves like MovePlayer, however it can be steered whether walkable AREAS to be considered (direct = 0) or not (direct = 1)

function Go ()
Return value: 0, 1
With this function the player figure is sent there, on which one clicked last. (further behavior such as MovePlayer) it concerns with the goal a figure, then the player figure in a distance before the figure continues. If it concerns a Hotspot, then the player figure goes to the Hotspot point. If it concerns an object, then to the object. The function returns 0, if the movement were broken off, with 1 has the player figure the goal coordinates (<x>, <y>) reached.
[ identically to GoTo (2)]

function GoTo (int blocking)
blocking: 0, 1, 2
Return value: 0, 1
Corresponds to the Go-function with the difference, corresponds to the Go-function with the difference,  that it can be selected whether the 
?? Scriptausfuehrung ?? to be blocked is or not.

blocking=0: not blocked, the return value is insignificantly, there for the end of the movement is not waited.
blocking=1: blocked, the return value is always 1, because the goal is always achieved.
blocking=2: Behavior and return value as with Go()

function GoToCharacter (int charid, int direction, int NPCfacesplayer, int blocking){
GoToCharacterEx corresponds, whereby xoffset and yoffset already given is and indicates charidwhogoes the player figure.



function NPCGoToCharacter (int charidwhogoes, int charidtogoto, int direction,  int NPCfacesplayer, int blocking) 
GoToCharacterEx corresponds, whereby xoffset and yoffset already given is

function GoToCharacterEx (int charidwhogoes, int charid, int direction,
         int xoffset, int yoffset, int NPCfacesplayer, int blocking)


direction: 1, 2, 3, 4
  NPCfacesplayer: 0, 1
  blocking: 0, 1, 2

Return value: 0, 1

The figure  <charidwhogoes>  becomes the figure <charid> sent and remains there in the distance <xoffset> or <yoffset> depending upon direction <direction>
stand

direction:  1=up ,2=right beside, 3=below, 4=left beside 
The player figure always looks at the other figure ist <NPCfacesplayer>=1, then the other figure looks at also the player figure. For the explanation of blocking and to return value see GoTo (int blocking) 


and


Example-CODE
================================================================================

**********************************************************
**********************************************************
if (MovePlayer (250, 130))
{
  FaceDirection (GetPlayerCharacter (), DIR_UP);
 
  if (UsedAction (A_PICK_UP))
  {
      Wait (5);
      UseView(DIR_UP);
      Wait (5);
      ObjectOff(2);
      ObjectOff(3);
      PlaySound(4);
      AddInventory(6);
      DisableHotspot(3);
      DisplaySpeech(GetPlayerCharacter(),"Possibly come I thereby on the attic.");
  }
else if (UsedAction (A_OPEN))
  {
      Wait (5);
      UseView(DIR_UP);
     
      if(!character[GetPlayerCharacter()].inv[15])
      ObjectOn(4);
     
      ObjectOn(1);
      PlaySound(66);
      DisplaySpeech(GetPlayerCharacter(),"Man comes up heavily, letztens had I the crash tow bar to use, around the cooling subject up wars.");
  }
else if (UsedAction (A_LOOK_AT))
  {
      Wait (5);
      DisplaySpeech (GetPlayerCharacter (), "Das alte Mistding klemmt die meiste Zeit.");
       
  }
else if(UsedAction (A_USE_INV))
  {
    if(character [GetPlayerCharacter()].activeinv == 32)
    {
      Wait(5);
      DisplaySpeech (GetPlayerCharacter (), "Nein, die Kerzen zünd ich jetzt lieber nicht an, das Haus könnte abbrennen.");
    }
  }
else Unhandled ();
}


// 777777777777777777777777777777777
CHARACTER IN RAUM Teleportieren


  SetCharacterView (GetPlayerCharacter (), 105);
  character [MARK].room = 15;
  character [MARK].x = 140;
  character [MARK].y = 122;
  character [ED].room = 15;
_________________________________________________________________________________________
___________________________________________________________________________________________


Tüare-Scripts in MMM
--------------------

In principle it is completely simple:

function any_click_on_door (int GI, int object, int x, int y, int dir, int nr_room, int nr_x, int nr_y, int nr_dir)

Int GI â€" the used GlobalInt for the door
int object â€" Number of the Objekts/Hotspots doesr
int x â€" To go coordinates over to the door
int y â€" To go coordinates over to the door
int dir â€" Direction in which it to look is
int nr_room â€" To target area "cross" the door and the remainder like the same before, only stop for the target area

Which one may not forget, the GlobalInts used in the function is to be assigned to the opening/latch functions, so that it by right-click functioned. In the global Script you find the function VariableExtensions. There lines stand like these:

if ((are == 1) && (h == 4)) OpenCloseExtension (3, location);

It means that in area 1 (are=1) a door is, those the Hotspot 4 (h=4) and the GlobalInt 3 used. And war's then already. In this way one saves ne quantity of work. That one does not make the object, which is to represent an open or closed door "clickable", so it does not pay attention the Hotspot of the door covered. One opens and quasi always closes the same Hotspot, since the object is to be seen, but not with it to be interacted can. Hope I could for something clarity provide. At first sight that may be confusing all something, but one saves as the whole A_OPEN and A_CLOSE functions as with the drawer.

NVENTORY to a NPC give:
---------------------------------

if (character [GetPlayerCharacter ()].activeinv == 1) {
  DisplaySpeech (GetPlayerCharacter (), "Bitte schön!");
  LoseInventory(1);
}

DEBUG Optionen
------------------------------------

  if (keycode == 19)  Debug (0, 0);                     // Ctrl-S, give all inventory
  if (keycode == 22)  Debug (1, 0);                     // Ctrl-V, version
  if (keycode == 1)   Debug (2, 0);                     // Ctrl-A, show walkable areas
  if (keycode == 24)  Debug (3, 0);                     // Ctrl-X, teleport to room


STANDARD Optionen
_________________________________________
SetAlternativeAction (location, 'n', A_DEFAULT);
  SetAlternativeAction (location, 'g', A_GIVE_TO);
  SetAlternativeAction (location, 'p', A_PICK_UP);
  SetAlternativeAction (location, 'u', A_USE);
  SetAlternativeAction (location, 'o', A_OPEN);
  SetAlternativeAction (location, 'l', A_LOOK_AT);
  SetAlternativeAction (location, 's', A_PUSH);
  SetAlternativeAction (location, 'c', A_CLOSE);
  SetAlternativeAction (location, 't', A_TALK_TO);
  SetAlternativeAction (location, 'y', A_PULL);
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

#1
Um .. Thanks?
I don't really know where this belongs. Have you also posted on the MMM forums, or at least contacted the MMM folks about them? Because it seems like they'd benefit from it more. You could also try adding them to the AGS Wiki.

EDIT: Unsticky-ed, due to apparent lack of interest. It'll stay in the forum, though, if it's needed in the future.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk