Ins leere Starterpack musst du die beiden Skripte importieren um auch die neuen Türfunktionen zu haben. Was Rocco gesagt hast, ist übrigens nicht besonders Vorteilhaft, es wäre nur doppelte Arbeit.
Ich bin übrigens dafür, dass die neuen Türskripte mal jemand in das Template vom leeren Starterpack (und auch den anderen neuen) einbaut, ich musste mich damit auch rumkämpfen.
//Edit: Hier ein kleines HowTo:
1. Rechtsklick auf "Scripts" -> "Import Script..." -> Dort die heruntergeladene Datei auswählen, und zwar diese:
http://mmm.e7p.de/Doors.scm2. GlobalScript.asc bearbeiten:
Bei der Funktion "game_start" (kann oben in der Liste gewählt werden, bei mir Zeile 1491) vor Funktionsende folgendes einfügen:
(also vor dem "}" und dem nächsten "// ==========...")
DoorSetup();
Nun kommt was längeres, was du im oberen Bereich außerhalb einer Funktion einfügen musst. Bei Zeile 1239 ist bei mir ein bisschen Platz, so wurde es auch im Villa-SP gemacht.
/**********************************************************************/
/* Functions */
/**********************************************************************/
int DoorType::SetStrings(String lookat, String islocked, String wrongitem, String lookAt2)
{
this.s_LookAt = lookat;
this.s_NewLookAt = lookAt2;
this.s_IsLocked = islocked;
this.s_WrongItem = wrongitem;
}
/**********************************************************************
***********************************************************************/
int DoorType::Open()
{
this.i_GlobalInt = eDoorOpen;
if ( player.Room == this.l_Room )
{
this.o_Objekt.Visible = true;
}
else if ( player.Room == this.l_NewRoom )
{
this.o_NewObjekt.Visible = true;
}
}
/**********************************************************************
***********************************************************************/
int DoorType::Close()
{
this.i_GlobalInt = eDoorClosed;
if ( player.Room == this.l_Room )
{
this.o_Objekt.Visible = false;
}
else if ( player.Room == this.l_NewRoom )
{
this.o_NewObjekt.Visible = false;
}
}
/**********************************************************************
***********************************************************************/
int DoorType::Lock()
{
this.i_GlobalInt = eDoorLocked;
if ( player.Room == this.l_Room )
{
this.o_Objekt.Visible = false;
}
else if ( player.Room == this.l_NewRoom )
{
this.o_NewObjekt.Visible = false;
}
}
/**********************************************************************
***********************************************************************/
int DoorType::ClickSpecial(int opensound, int closesound, int key, int closevalue)
{
// key = -1: opens also locked doors without key
// key = -2: door can't be unlocked (like rusted)
InventoryItem *charInv = player.ActiveInventory;
int result = 1;
int i_XPosition;
int i_YPosition;
int i_NewXPosition;
int i_NewYPosition;
eDirection l_Direction;
eDirection l_NewDirection;
int l_NewRoom;
String s_LookAt;
Object *o_Objekt;
if ( player.Room == this.l_Room )
{
i_XPosition = this.i_XPosition;
i_YPosition = this.i_YPosition;
i_NewXPosition = this.i_NewXPosition;
i_NewYPosition = this.i_NewYPosition;
l_Direction = this.l_Direction;
l_NewDirection = this.l_NewDirection;
l_NewRoom = this.l_NewRoom;
s_LookAt = this.s_LookAt;
o_Objekt = this.o_Objekt;
if ( s_LookAt == null )
{
s_LookAt = s_LookAtStandard;
}
}
else if ( player.Room == this.l_NewRoom )
{
i_XPosition = this.i_NewXPosition;
i_YPosition = this.i_NewYPosition;
i_NewXPosition = this.i_XPosition;
i_NewYPosition = this.i_YPosition;
l_Direction = this.l_NewDirection;
l_NewDirection = this.l_Direction;
l_NewRoom = this.l_Room;
s_LookAt = this.s_NewLookAt;
o_Objekt = this.o_NewObjekt;
if ( s_LookAt == null )
{
s_LookAt = s_NewLookAtStandard;
}
l_Direction = (l_Direction+2)%4;
l_NewDirection = (l_NewDirection+2)%4;
}
else
{
result = 1;
}
if ( UsedAction (eActClose) )
{
if ( this.i_GlobalInt == 0 )
{
player.Say("Das ist schon zu.");
}
else if ( this.i_GlobalInt == 1 )
{
if ( any_click_move(i_XPosition, i_YPosition, l_Direction) )
{
PlaySound(closesound);
if ( o_Objekt )
{
o_Objekt.Visible = false;
}
this.i_GlobalInt = closevalue;
}
}
}
else if ( UsedAction(eActOpen) )
{
if ( (this.i_GlobalInt == 0) || ((this.i_GlobalInt == 2) && (key == -1)) )
{
if ( any_click_move(i_XPosition, i_YPosition, l_Direction) )
{
PlaySound(opensound);
if ( o_Objekt )
{
o_Objekt.Visible = true;
}
this.i_GlobalInt = 1;
}
}
else if ( this.i_GlobalInt == 1 )
{
player.Say("Das ist schon offen.");
}
else if ( this.i_GlobalInt == 2 )
{
if ( any_click_move(i_XPosition, i_YPosition, l_Direction) )
{
if ( this.s_IsLocked != null )
{
player.Say(this.s_IsLocked);
}
else
{
player.Say(s_IsLockedStandard);
}
}
}
}
else if ( UsedAction (eActWalkTo) )
{
if ( any_click_move(i_XPosition, i_YPosition, l_Direction) == 2 ) // == 2, korrektur Door-Script, falls sich Charakter nicht bewegen kann
{
if ( this.i_GlobalInt == 1 )
{
player.EnterRoom(l_NewRoom, i_NewXPosition, i_NewYPosition, l_NewDirection);
result = 2;
}
}
}
else if ( UsedAction(eActLookAt) && (s_LookAt.Length > 0) )
{
if ( any_click_move(i_XPosition, i_YPosition, l_Direction) )
{
player.Say(s_LookAt);
}
}
else if ( UsedAction(eActUseInventory) && (key >= 0) )
{
if (any_click_move(i_XPosition, i_YPosition, l_Direction) )
{
if ( charInv )
{
if ( charInv.ID == key )
{
if ( this.i_GlobalInt == 2 )
{
PlaySound(2);
if ( o_Objekt )
{
o_Objekt.Visible = true;
}
this.i_GlobalInt = 1;
}
}
else
{
if ( this.s_WrongItem != null )
{
player.Say(this.s_WrongItem);
}
else
{
player.Say(s_WrongItemStandard);
}
}
}
}
}
else result = 0;
return result;
// 0 = unhandled
// 1 = handled
// 2 = NewRoom
}
/**********************************************************************
***********************************************************************/
int DoorType::Click()
{
return this.ClickSpecial(2, 3, 0, 0);
}
/**********************************************************************
***********************************************************************/
int DoorType::Init(Object *o_Objekt, Hotspot *h_Hotspot)
{
if ( null != o_Objekt )
{
o_Objekt.Clickable = false; // die Türenobjekte nicht Klickbar machen
if ( this.i_GlobalInt == 1 ) o_Objekt.Visible = true;
else o_Objekt.Visible = false;
if ( this.l_Room == player.Room )
{
this.o_Objekt = o_Objekt;
}
else if ( this.l_NewRoom == player.Room )
{
this.o_NewObjekt = o_Objekt;
}
}
if ( null != h_Hotspot )
{
if ( this.l_Room == player.Room )
{
this.h_Hotspot = h_Hotspot;
}
else if ( this.l_NewRoom == player.Room )
{
this.h_NewHotspot = h_Hotspot;
}
}
}
/**********************************************************************
***********************************************************************/
Jetzt noch die Funktion "VariableExtensions" in der Auswahl oben wählen und mit folgendem ersetzen, also alles bis
exklusive der nächsten "function".
String VariableExtensions (String location)
{
int i = 0;
bool b_Ready = false;
Hotspot* hotAt = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
Object *objAt = Object.GetAtScreenXY(mouse.x, mouse.y);
while ( i < MAX_DOORS )
{
if ( ((Door[i].h_Hotspot == hotAt) && (Door[i].l_Room == player.Room)) ||
((Door[i].h_NewHotspot == hotAt) && (Door[i].l_NewRoom == player.Room)) )
{
if ( (Door[i].i_GlobalInt == eDoorClosed) || (Door[i].i_GlobalInt == eDoorLocked) )
{
location = location.AddExtension('o');
}
else
{
location = location.AddExtension('c');
}
i = MAX_DOORS; // simulates a break;
b_Ready = true;
}
i++;
}
return location;
}
3. playerExtends.ash bearbeiten und dort eigentlich nur das enum eDirection löschen, denn es gäbe sonst einen Fehler, da ich es im Türskript nochmal definieren musste.
Puh. Das war bestimmt anstrengend. Jetzt braucht man auch nur noch die Türen anpassen, Schritt 4 also beliebig oft wiederholen.
4. Türen erstellen:
Ich habe schonmal 2 Türen als Vorlage erstellt. Die erste davon mit Extrabeschreibungen. Hier schreibe ich jetzt, was du tun musst, wenn du komplett neue Türen machen willst:
1. Doors.ash:
- Gucken ob MAX_DOORS (Anzahl aller Türen) noch ausreicht. Ggf. erhöhen.
- beim enum nach Tuer2, eine neue Zeile mit eDoorNumTuer3, (Name egal, komma beachten, die ersten zwei dürfen auch verwendet werden)
2. Doors.asc:
- Schema wie Tür 2 kopieren, Werte anpassen. (oder einfach zu erst das Schema anpassen)
3. Die Räume jeweils erweitern um...
- einen Tür-Hotspot, dieser muss in der Description am Ende ">v" haben und im "any_click" Skript sowas beinhalten:
function hTuer_AnyClick()
{
if(Door[eDoorNumTuer1].Click()==0) Unhandled();
}
- ein Tür-Objekt, dieses darf nicht klickbar sein, braucht auch nicht "verskriptet" werden.
- eine Load-Funktion des Raumes:
function room_Load()
{
// Alles andere was zum Raumladen gemacht wird.
Door[eDoorNumTuer1].Init(oTuer, hTuer);
}
Im Gegensatz zu altem Skript war das doch einfach oder? (Abgesehen vom einmaligen einfügen der Skripte)
Noch eine Info: Mit Schlüsseln sieht das auch anders aus wie im alten Skript, wenn du da noch Hilfe brauchst, können wir dir gerne helfen. Und glaub mir, nicht nur dann können wir dir bei Problemen zur Seite stehen.
