#include "vaultscript.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace vaultmp;
IDHash<UCount> cons;
Void VAULTSCRIPT exec() noexcept
{
std::printf("vaultmp christmas / new years eve meetup\n");
SetServerName("vaultmp christmas / new years eve meetup");
SetServerRule("website", "vaultmp.com");
switch (GetGameCode())
{
case Index::FALLOUT3:
SetServerMap("the wasteland");
break;
case Index::NEWVEGAS:
SetServerMap("mojave desert");
break;
default:
break;
}
}
Base VAULTSCRIPT OnPlayerRequestGame(ID player) noexcept
{
Player(player)
<< "Welcome to vaultmp christmas / new years eve meetup!"
<< "The goal is to create some footage for the public."
<< "Gather with other players and take screenshots / video,"
<< "and post it on the website: www.vaultmp.com"
<< "For this purpose, some animation commands are available:"
<< "type \"/anim 0\" \"/anim 1\" \"/anim 2\" etc."
<< "other commands: /players /goto [ID] /age /young /sex /bimbo /mutant /safe"
<< " $red merry christmas and a happy new year!";
cons[player] = GetConnection(player);
SetPos(player, -15444.0, 15454.0, 12007.0);
return static_cast<Base>(0x00000000);
}
Void VAULTSCRIPT OnPlayerDisconnect(ID player, Reason) noexcept
{
cons.erase(player);
}
State VAULTSCRIPT OnPlayerChat(ID player, RawString message) noexcept
{
if (*message == '/')
{
std::vector<String> tokens;
RawString cmd = std::strtok(message + 1, " ");
while (cmd)
{
tokens.emplace_back(cmd);
cmd = std::strtok(nullptr, " ");
}
if (!tokens.empty())
{
// Player object
Player pplayer(player);
if (!tokens[0].compare("anim"))
{
static std::vector<unsigned int> anims {
562248, // LooseWaveHello
550036, // DukovDrinkStand01
537880, // LooseSmokingStanding
15338, // BeerDrinkingStanding
365632, // LooseBDayCheerA
212187, // LooseCheeringOneArmUp
212188, // LooseCheeringBothArmsUp
84935, // HitBrain
};
if (tokens.size() > 1)
{
unsigned int idx = std::strtoul(tokens[1].c_str(), nullptr, 10);
if (idx < anims.size())
pplayer.PlayIdle(static_cast<Base>(anims[idx]));
}
}
else if (!tokens[0].compare("goto"))
{
if (tokens.size() > 1)
{
UCount idx = std::strtoul(tokens[1].c_str(), nullptr, 10);
auto it = std::find_if(cons.begin(), cons.end(), [idx](const std::pair<const ID, UCount>& player) { return player.second == idx; });
if (it != cons.end())
{
Player pplayer2(it->first);
Value X, Y, Z;
pplayer2.GetPos(X, Y, Z);
pplayer.SetCell(pplayer2.GetCell(), X, Y, Z);
}
else
pplayer << "Player not found!";
}
}
else if (!tokens[0].compare("players"))
{
IDVector players = Player::GetList();
for (const auto& ID : players)
{
char num[4];
std::snprintf(num, sizeof(num), "%d", GetConnection(ID));
pplayer << "(" + String(num) + ") " + GetName(ID);
}
}
else if (!tokens[0].compare("age"))
pplayer.AgeActorBaseRace(1);
else if (!tokens[0].compare("young"))
pplayer.AgeActorBaseRace(-1);
else if (!tokens[0].compare("sex"))
pplayer.SetActorBaseSex(!pplayer.GetActorBaseSex());
else if (!tokens[0].compare("bimbo"))
{
static Base talon_merc = static_cast<Base>(0x0007E948);
static Index health = static_cast<Index>(0x10);
Actor actor(Actor::Create(talon_merc, player));
actor.SetActorBaseValue(health, 100.0);
actor.SetActorValue(health, 100.0);
}
else if (!tokens[0].compare("mutant"))
{
static Base mutant = static_cast<Base>(0x0001CF95);
static Index health = static_cast<Index>(0x10);
Actor actor(Actor::Create(mutant, player));
actor.SetActorBaseValue(health, 100.0);
actor.SetActorValue(health, 100.0);
}
else if (!tokens[0].compare("safe"))
{
static Base safe = static_cast<Base>(0x000533CE);
Container::Create(safe, player);
}
else
pplayer << String("Unrecognized command: " + tokens[0]);
}
return False;
}
else
{
String msg = GetName(player) + ": " + message;
std::strncpy(message, msg.c_str(), static_cast<size_t>(Index::MAX_CHAT_LENGTH));
}
return True;
}
Void VAULTSCRIPT OnSpawn(ID object) noexcept
{
Player player(object);
if (player)
player.UIMessage("Hello, " + player.GetName() + "!");
}
Result VAULTSCRIPT RemoveActor(ID actor)
{
DestroyObject(actor);
KillTimer();
return static_cast<Result>(0);
}
Void VAULTSCRIPT OnActorDeath(ID actor, Limb limbs, Death cause) noexcept
{
if (GetType(actor) != Type::ID_PLAYER)
CreateTimerEx(RemoveActor, static_cast<Interval>(8000), actor);
}