Coder Social home page Coder Social logo

artvin01 / sm-tfecondata Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nosoop/sm-tfecondata

0.0 0.0 0.0 118 KB

Read TF2 item information from the game memory in SourceMod.

Home Page: https://forums.alliedmods.net/showthread.php?t=315011

License: GNU General Public License v3.0

Python 13.28% SourcePawn 86.72%

sm-tfecondata's Introduction

TF2 Econ Data

โ˜• fund my caffeine addiction โ˜•

A library to get TF2 item data from game memory, intended as a successor to TF2ItemsInfo and TF2IDB. No more parsing the schema file and maintaining your own structure for plugin support.

I got bored one day and thought about rewriting a few of my internal plugins so they didn't depend on external tooling anymore.

There's a semi-guide on porting from existing libraries to this one, as well as a WIP plugin that implements the natives from those libraries.

Installation

  1. Download all the non-source code files in the latest release.
  2. Copy tf_econ_data.smx to addons/sourcemod/plugins/.
  3. Copy tf2.econ_data.txt to addons/sourcemod/gamedata/.
  4. If you're a developer, copy tf_econ_data.inc to addons/sourcemod/scripting/include/ (or the appropriate path for your compiler toolchain / project).

Features

  • Retrieve certain properties of an item given its definition index, including entity class name, level range, and item slot.
  • Get lists of definition indices filtered with a user-defined function.
  • Translate an entity classname for the appropriate player class (making spawned multiclass weapons work correctly). Technically, this is just handled as a call to the game's function, but it saves you effort from adding / maintaining the SDKCall boilerplate yourself.
  • Get a loadout slot name by index or translate slot indices (retrieved from item definitions) to names.
  • Read attributes and attribute properties.
  • Read quality and rarity names / values.
  • Access item equip regions and their equip region overlap masks, so you can determine if two wearable items are overlapping. Also access equip region names / group indices.
  • Get lists of valid particle definitions, either as a whole or only for hats / taunts / weapons. (Internally, the game doesn't do anything special for the particles labled other_particles and killstreak_eyeglows.)
  • Get a list of all valid paintkit proto definition indices.
  • Directly get the addresses of any supported definition type, as well as the schema / protobuf schema, in case you want to do something the library doesn't support out of the box.

Note that the abstractions are intentionally low; this plugin doesn't implement higher-level functions in SourcePawn to do things like:

  • Check for equipment conflicts based on multiple definition indices.
  • Resolve paintkit protodefs to their items to determine paint rarity.
  • Provide hardcoded filters on cosmetic particles that are not obtainable from crates (map stamps, pipe smoke).
  • Determine which items can be Australium.

Example

Dump the taunt defindices for a given class:

int g_iTauntSlot = -1;

public void OnAllPluginsLoaded() {
	// you could use a hardcoded value of 11 if you want to bet on valve not changing indices
	g_iTauntSlot = TF2Econ_TranslateLoadoutSlotNameToIndex("taunt");
	if (g_iTauntSlot == -1) {
		SetFailState("Failed to determine index for slot name '%s'", "taunt");
	}
	
	ArrayList tauntList = TF2Econ_GetItemList(FilterClassTaunts, TFClass_Scout);
	
	for (int i = 0; i < tauntList.Length; i++) {
		int defindex = tauntList.Get(i);
		PrintToServer("%d", defindex);
	}
	delete tauntList;
}

/**
 * Returns true if the given item is available for the given playerClass as a taunt.
 */
public bool FilterClassTaunts(int defindex, TFClassType playerClass) {
	return TF2Econ_GetItemSlot(defindex, playerClass) == g_iTauntSlot;
}

sm-tfecondata's People

Contributors

nosoop avatar fortytwofortytwo avatar arthurdead avatar artvin01 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.