This site has been archived and made available for preservation purposes. No edits can be made.

BarrelScript Fallout: New Vegas

(Difference between revisions)
Return to current revision
  1. -
    This script uses a timer to check for the player being near a special spot. If the player is in that area and has a certain Z-angle, he will find a broken 9mm pistol.[image]barrel.jpg|thumb|right|BarrelScript in-game[/image]
  2. +
    This script uses a timer to check for the player being near a special spot. If the player is near that spot and has a certain Z-angle, he will find a broken 9mm pistol.[image]barrel.jpg|thumb|right|BarrelScript in-game[/image]
  3.  
    [h="2"] Code [/h]
    [highlight=cpp]
    #include "../vaultscript.h"
    #include <cstdio>

    using namespace std;
    using namespace vaultmp;

    Base _9mm = (Base) 0x000E3778;
    Value spot[] = {-102.76, -398.82, 3458.55};
    Value angle[] = {93.0, 134.0};
    IDSet player_barrel;

    Result VAULTSCRIPT BarrelSpot()
    {
    IDVector players = GetList(Type::ID_PLAYER);

    for (const ID& id : players)
    {
    if (!player_barrel.count(id) && IsNearPoint(id, spot[0], spot[1], spot[2], 30.0))
    {
    Value X, Y, Z;
    GetAngle(id, X, Y, Z);

    if (Z > angle[0] && Z < angle[1])
    {
    UIMessage(id, "You found a broken 9mm pistol at the bottom of the barrel!");
    AddItem(id, _9mm, 1, 0.0, False);
    player_barrel.insert(id);
    }
    }
    }

    return (Result) 0;
    }

    Void VAULTSCRIPT exec()
    {
    if (GetGameCode() != Index::NEWVEGAS)
    {
    printf("BarrelScript is for Fallout: New Vegas only!\n");
    terminate();
    }

    CreateTimer(&BarrelSpot, (Interval) 500);

    printf("BarrelScript for Fallout: New Vegas loaded\n");
    }

    Void VAULTSCRIPT OnPlayerDisconnect(ID player, Reason reason)
    {
    player_barrel.erase(player);
    }

    Void VAULTSCRIPT OnSpawn(ID object)
    {
    player_barrel.erase(object);
    }
    [/highlight]
    [h="2"] Explanation [/h]
    [category]Script examples[/category]