Raised This Month: $32 Target: $400
 8% 

[TFC] Teleporter arrows


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Team Fortress Classic        Category:   General Purpose       
pizzahut
Senior Member
Join Date: Oct 2004
Old 03-16-2015 , 20:51   [TFC] Teleporter arrows
Reply With Quote #1

One problem with TFC's teleporters is that you don't know where they lead to. There's a Metamod plugin running on Drippy's 2fort which works great, however it's private AFAIK. I decided to write my own. It sorta works, however it has some flaws.

To get hold of the necessary info, I'm tracking players as they teleport, and make a correlation between teleporters this way. Disadvantage with this method is that when the teleporters are originally built, there is no arrow yet as no one has used the teleporter yet.

I made two versions. The first one draws arrows from the entrance all the way to the exit, across the whole map if necessary. These teleporter routes are only visible by the corresponding team and by spectators.

The 2nd version is the standard approach, that is drawing a single arrow above the tele entrance.

Difficulty with AMXX is that it doesn't give access to certain private entity data of buildings, such as owner of a teleporter and whether it's entrance or exit.

EDIT: What I meant was that reading this thread I was under the impression that dealing with entity pointers inside the private entity data (e.g. owner of a building) wasn't possible without using a modified TFCX module which is available in the linked thread, but probably outdated. Perhaps this was actually the case at the time of writing (2007). However with the info from Arkshine I now managed to access such data, but haven't integrated this into the plugin yet.

v1



v2



There was a bug in the original release, the entity numbers can on some maps be higher than the entity limit (512), e.g. coolfort2. I ran an entity test plugin and it said the maximum allowed entities were 1565. I raised the maximum number to 2048, hopefully this will do!
Attached Files
File Type: sma Get Plugin or Get Source (tele_arrows.sma - 794 views - 2.7 KB)
File Type: sma Get Plugin or Get Source (tele_arrows2.sma - 788 views - 3.1 KB)
__________________
My AMXX plugins (content date 2007-03-29, link check 2017-04-26)

Plugins for the Royston Vasey TFC server - These are UNSUPPORTED, except those which have been published at AMX Mod X.

Last edited by pizzahut; 04-15-2016 at 06:33. Reason: Updated images which I had deleted.
pizzahut is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-17-2015 , 05:42   Re: [TFC] Teleporter arrows
Reply With Quote #2

Quote:
Difficulty with AMXX is that it doesn't give access to certain private entity data of buildings, such as owner of a teleporter and whether it's entrance or exit.
You can access player's private data with fakemeta module and get/set_pdata_*. Just a matter to find the right offset you need.

Well I can help you a bit.

Looking at IDA, when you create a teleporter, it uses real_owner from CBaseEntity to store the player who is building the teleporter, and m_iType from CTFTeleporter to specify entry/exit, and it seems to be 4 for entry and 5 for exit.

Here a dump from linux binary:

CTFTeleporter

CBaseEntity


To use these char-based offsets, you need to calculate first the value windows-based.

Generally, for classes derived from CBaseMonster, it's +20 for linux, otherwise +16.

Here CTFTeleporter, should be +20 and +16 for CBaseEntity.

So:

real_owner = 348 - 16 = 332 ; can be used I think with get_pdata_ent (but this native is int-based, so you need to do 332 / 4). In 1.8.3-dev, you can use 332 with get_pdata_ehandle
m_iType = 1728 - 20 = 1708 ; can be used with get_pdata_int (careful too, this is unfortunately int-based too, so you need to do 708 / 4).

Member with type starting with CBase, like m_pPLayer can be retrieved with get_pdata_cbase (hamsandwich module)

Tell if you don't understand something.
__________________

Last edited by Arkshine; 03-17-2015 at 06:45.
Arkshine is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 03-17-2015 , 16:14   Re: [TFC] Teleporter arrows
Reply With Quote #3

Thanks for the info Arkshine. I read about offsets in the thread I linked, just wasn't aware that the newer version of AMXX can deal better with this private data.

Due to Valve's mess up with the SteamCMD version of TFC (double rockets, sporadically broken spy disguise, game description not updating, custom sprays not up- or downloading) we're still running a 2012 build of the HLDS and AMXX. Would the SteamCMD compatible version of AMXX work fine with the old HLDS?

Code:
version
Protocol version 48
Exe version 1.1.2.2/Stdio (tfc)
Exe build: 11:30:00 Aug 28 2012 (5787)

meta version
Metamod v1.20p36  2013/02/18 (5:13)
by Will Day
   http://www.metamod.org/
 Patch: Metamod-P (mm-p) v36
 by Jussi Kivilinna
    http://metamod-p.sourceforge.net/
compiled: Feb 19 2013, 00:06:29 EET (optimized)

amxx version
AMX Mod X 1.8.2-dev (http://www.amxmodx.org)
Authors:
<TAB>David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
<TAB>Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
<TAB>Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
<TAB>Borja "faluco" Ferrer, Scott "Damaged Soul" Ehlert
Compiled: Jul 27 2012, 12:58:57
Build ID: 1.8.2-dev 26:81ff4ff3da92
Core mode: JIT+ASM32
pizzahut is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-17-2015 , 17:26   Re: [TFC] Teleporter arrows
Reply With Quote #4

AMXX 1.8.2+, likely. The only thing I see is hamdata.ini, you should probably not update this file, values have been changed after the steam update. But it's manually fixable. If you want to use 1.8.2/3 for example, because of some fixes or many missing virtual functions have been added, you can fix file like this: you keep "pev" and "base" and for tfc linux only you add +2 to all values.

By the way, If you want I can see for integrating schnitzelmaker's changes for 1.8.3-dev.
__________________

Last edited by Arkshine; 03-17-2015 at 17:30.
Arkshine is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 03-18-2015 , 16:11   Re: [TFC] Teleporter arrows
Reply With Quote #5

Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

// old tfc_i386.so (2012): 12
// new tfc.so (2013): 16
#define linux_diff 12

public plugin_init()
{
	register_plugin("pdata test", "1.4", "pizzahut")
	register_clcmd("say test", "say_test")
}

public say_test(id)
{
	static tele_id, tele_owner, tele_type
	client_print(id, print_chat, "Check console")
	tele_id = -1
	while (tele_id = find_ent_by_class(tele_id, "building_teleporter"))
	{
		client_print(id, print_console, "tele id: %d", tele_id)
		tele_owner = get_pdata_ent(tele_id, 332, linux_diff)
		if (is_valid_ent(tele_owner))
			client_print(id, print_console, "owner id: %d", tele_owner)
		tele_type = get_pdata_int(tele_id, 427)
		switch (tele_type)
		{
			case 4: client_print(id, print_console, "type: entrance")
			case 5: client_print(id, print_console, "type: exit")
		}
	}
	return PLUGIN_HANDLED
}

Last edited by pizzahut; 03-20-2015 at 20:15. Reason: .
pizzahut is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-18-2015 , 18:56   Re: [TFC] Teleporter arrows
Reply With Quote #6

get_pdata_ent is int-based too. Only _string and the new natives introduced in 1.8.3 are char-based.
And yeah, the linux extra offset you provide in the native, you should / 4 as well (so either 5, which is the default, or 4).
__________________

Last edited by Arkshine; 03-18-2015 at 18:59.
Arkshine is offline
SpannerSpammer
Member
Join Date: Mar 2006
Old 03-20-2015 , 23:17   Re: [TFC] Teleporter arrows
Reply With Quote #7

Like Pizzahut, I too have been spoiled by Drippy's teleporter arrows, so I made my own MetaMod based version
a while back. It was a little laggy and the code was not optimized, but it worked. I had never even considered
porting it to AMX because I thought there wasn't any way to manipulate entity edict offsets, I guess I was
wrong. This helped a LOT guys, Thanks. With this I can port my Teleporter Exit Camera function to AMX.


Here's a little something for you Pizzahut, the attached SMA file is some old MM building offset code I just ported.
Note: I don't currently have a Linux box to test it out on so you will need to adjust the linux offset, just let me
know what the value should be. This code works on amx 1.8.2 on Windows, I don't know about later versions.

NOTE: For teleporters use this offset for TYPE
Code:
//                       raw windows offset / 4
#define PD_TELE_STATE 		124 / 4
These are the teleporter state values associated with this offet
Code:
#define TELE_NOT_PAIRED 		0	// Entry or Exit is idle
#define TELE_ENTRY_CHARGE		4	// Entry ONLY (charging)
#define TELE_EXIT_PAIRED 		8	// Exit ONLY (paired with Entry)
#define TELE_ENTRY_READY 		516	// Entry ONLY (fully charged, ready to use)
I can give you some steps on how to optimize your code if you want.
Attached Files
File Type: sma Get Plugin or Get Source (tele_info.sma - 723 views - 10.1 KB)
__________________
[NeoTF|DEV]SpannerSpammer-[AoE]-
NeoTF Development Team.
http://steamcommunity.com/groups/neotf
SpannerSpammer is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode