// Function to log debug messages (includes player and system information) void LogDebug(string sLogMessage, string sPrefix = "cas") { // Construct the final log message string sFinalMessage = sPrefix + ": " + sLogMessage; // Log to the server console (or wherever logging is handled) SendMessageToPC(GetFirstPC(), sFinalMessage); // Example logging method to PC, change as needed } // Function to log pizza orders with character, username, and pizza type void LogPizzaOrder(object oPC, int nPizzaID) { // Get the character name and player username string sCharacterName = GetName(oPC); string sUserName = GetPCPlayerName(oPC); // Determine the pizza type based on the pizza ID string sPizzaType; switch (nPizzaID) { case 0: sPizzaType = "Iago's Special Pizza"; break; case 1: sPizzaType = "Pizza a la Nat"; break; case 2: sPizzaType = "Circe's Delight Pizza"; break; case 3: sPizzaType = "Meb's Monster Pizza"; break; case 4: sPizzaType = "Amarie's Sweet Pie"; break; case 5: sPizzaType = "Pepperoni Pizza"; break; case 6: sPizzaType = "Cheese Pizza"; break; default: sPizzaType = "Unknown Pizza"; break; } // Construct the log message string sLogMessage = "Pizza ordered by character: " + sCharacterName + ", username: " + sUserName + ", pizza: " + sPizzaType; // Log the message LogDebug(sLogMessage); } // Function to get an offset location (spawn further away, e.g., 15 units) location GetLocationOffsetFromLocation(location lOriginal, float fX, float fY) { vector vOriginal = GetPositionFromLocation(lOriginal); vector vOffset = Vector(fX, fY, 0.0); // fX and fY will control the distance and direction vector vNew = vOriginal + vOffset; return Location(GetAreaFromLocation(lOriginal), vNew, GetFacingFromLocation(lOriginal)); } // Helper function: Imp delivers pizza void ImpDeliverPizza(object oImp, object oPC, int nPizzaID) { // Delay the imp's speech action by 1 second DelayCommand(1.0, AssignCommand(oImp, ActionSpeakString("Pizza Delivery!"))); string sPizza; switch (nPizzaID) { case 0: sPizza = "cas_iagopizza"; break; case 1: sPizza = "cas_pizzanat"; break; case 2: sPizza = "cas_circepizza"; break; case 3: sPizza = "cas_mebpizza"; break; case 4: sPizza = "cas_amariepie"; break; case 5: sPizza = "cas_pizzapep"; break; case 6: sPizza = "cas_pizzacheese"; break; default: sPizza = "cas_pizzapep"; break; } // Create the pizza item in the player's inventory CreateItemOnObject(sPizza, oPC); // Make the imp move away after delivery AssignCommand(oImp, ActionMoveAwayFromObject(oPC, TRUE)); // Destroy the imp after a short delay DelayCommand(6.0, DestroyObject(oImp)); } // Helper function: Imp moves to the player (simulate flying by changing movement speed) void ImpMoveToPlayerAndDeliver(object oPC, object oImp, int nPizzaID) { // Make the imp move to the player AssignCommand(oImp, ActionForceMoveToObject(oPC, TRUE)); // After reaching the player, deliver the pizza AssignCommand(oImp, ImpDeliverPizza(oImp, oPC, nPizzaID)); } // This function will be called after the delay to spawn the imp void SpawnPizzaImpAfterDelay(object oPC, location lSpawnLocation, int nPizzaID) { // Spawn the pizza imp 15 units away from the player object oPizzaImp = CreateObject(OBJECT_TYPE_CREATURE, "cas_pizzaimp", lSpawnLocation); // Move the imp to the player and deliver the pizza ImpMoveToPlayerAndDeliver(oPC, oPizzaImp, nPizzaID); } // Main function to order the pizza, spawn the imp, and deliver the pizza void OrderAndDeliverPizza(object oPC) { int nGold = GetGold(oPC); int nPizzaID = GetSelectedNodeID(); // Get the ID of the selected dialogue node if (nGold < 10000) { SpeakString("You don't have enough gold for this highly expensive pizza!"); return; } // Log the pizza order LogPizzaOrder(oPC, nPizzaID); // Deduct the gold from the player TakeGoldFromCreature(10000, oPC, TRUE); // Notify the player SendMessageToPC(oPC, "Thank you for ordering the pizza! Please stay in this area until the pizza arrives."); location lPC = GetLocation(oPC); // Offset the spawn location by 15 units to simulate flying from further away location lSpawnLocation = GetLocationOffsetFromLocation(lPC, 1.0, 1.0); // Shortened spawn delay for testing purposes (adjust based on gameplay) DelayCommand(30.0, SpawnPizzaImpAfterDelay(oPC, lSpawnLocation, nPizzaID)); } void main() { object oPC = GetLastSpeaker(); if (GetIsPC(oPC)) { OrderAndDeliverPizza(oPC); } }