.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 2 SDK (http://forums.bots-united.com/forumdisplay.php?f=62)
-   -   Another Source SDK question ... (http://forums.bots-united.com/showthread.php?t=3501)

BotUser 30-01-2005 22:40

Another Source SDK question ...
 
Hi, it's me again :|

after the hint to the wiki, I was finally able to get my dev environment set up for plugin development. Thanks again.

Now, next question. I studied some of the emtpy-plugin source code and it seems to me that Valve wants me to use the IPlayerInfo interface to interact with the players in the game, creating an instance to it from the entity (edict_t*) passed to the plugin callbacks. Like:

IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo( pEntity );

OK. So far so good. But having a look at the interface's methods, it seems there are only some getters and status vars, but no setter methods !!

In HL1, there was the nice v-structure accessible in the edict_t* where I could manipulate some properties of the entity directly, like:

pEdict->v.takedamage = DAMAGE_NO; for a given player entity.

So, I poked around a bit further and found, in class CBaseCombatCharacter, some methods that deal with taking damage, using m_takedamage to determine if damage is caused or not.

However, in the plugin, I cannot access this member that easy.
I think I need to create a CBaseCombatCharacter instance from pEntity, but how ?

What is the correct way to set m_takedamage ? Or is there a totally different way to achieve the same ?

Thanks

BotUser


P.S.:
Why is there no class diagram to show the design of the source SDK classes in the SDK documentation ? This would help greatly.


Pierre-Marie Baty 31-01-2005 01:30

Re: Another Source SDK question ...
 
Yes, we have the same problems here. Valve's interfaces are nice, but either they don't want us to mess around with the entities, or they thought people would only need to *read* stuff and not write it (so as to write only stats plugins...) :(

I'm moving this thread to the HL2 SDK coding forum btw

BotUser 31-01-2005 09:40

Re: Another Source SDK question ...
 
Thanks for your reply, PMB.

This doesn't sound very encouraging 8o
Having only read access to player entites will make a lot of plugins
just impossible.
Either Valve will fix that or we might have to find some ugly hack around it
without using their interfaces >:(

botman 31-01-2005 15:08

Re: Another Source SDK question ...
 
Browse around the SourceMod forums and look at some of the things they are doing there...

http://www.sourcemod.net/

...some people would consider modifying C++ vtables kind of "hackish" and you might not want to do things that way, but for now, that's about the only way to modify CBaseEntity or CBasePlayer member variables.

botman

BotUser 31-01-2005 15:36

Re: Another Source SDK question ...
 
Thx for the link, botman.

I read the tutorial at http://www.sourcemod.net/forums/viewtopic.php?t=273

Man, that's some hack !
CBaseEntity_CreateFunc CBaseEntity_Create = (CBaseEntity_CreateFunc)0x22227F00;

LOL !o_O

Valve should definitely provide a way to access the entities legally. Cmon. This is ridiculous.

Gonna try it anyway ;)

Pierre-Marie Baty 31-01-2005 20:51

Re: Another Source SDK question ...
 
LOL!

I was about to try the same memory scan thingy to find the address of the CGlobalVars instance in the game DLL, because HL2DM doesn't export it yet!

But yeah... this is ridiculous :D

Things going at the pace they are going, I believe there will be a *MAJOR* SDK update in a few months.

BotUser 31-01-2005 22:16

Re: Another Source SDK question ...
 
PMB, let's hope you'll turn out right and they'll give us some nice SDK update 8)

XAD 13-02-2005 01:41

Re: Another Source SDK question ...
 
Quote:

Originally Posted by botman
...some people would consider modifying C++ vtables kind of "hackish" and you might not want to do things that way, but for now, that's about the only way to modify CBaseEntity or CBasePlayer member variables.

FYI: Changing vtables does not give you access to class variables directly but a way to hook function calls...

CBaseEntity and CBasePlayer vars can often be accessed by changing from private to public in the ".h" files, but you better of accessing the functions reading and setting them (which often are private but can be changed to public). But you might more often be interrested in hooking the functions calls than actually read the vars as they get updated in some complex ways (f.ex the player damage stuff)... Also some local function variables are possible to access by hooking other appropriate functions...

/X

Akz 13-02-2005 08:04

Re: Another Source SDK question ...
 
I contacted Valve yesterday asking if they are planning to update the server plugin interface soon.

Quote:

Subject:
RE: Limited server plugin interface
From:
"Yahn Bernier" <YahnBernier@valvesoftware.com>
Date:
Sat, 12 Feb 2005 10:16:14 -0800
To:
"Akz" <akz@bots-united.com>
CC:
"Alfred Reynolds" <alfred@valvesoftware.com>

I think the plan is to extend the plugin's to allow more access to the
entities. Alfred would know for sure.

Yahn

-----Original Message-----
From: Akz [mailto:akz@bots-united.com]
Sent: Saturday, February 12, 2005 9:25 AM
To: Yahn Bernier
Subject: Limited server plugin interface

Hi,

I used to code MetaMod plugins and such for the Half-Life 1 engine. Now
as I'm moving to Source, I've noticed that the HL2 server plugin
interface seems to lack a lot of useful functionality. For example,
plugins should be able to get and set things such as origin, angle,
velocity and flags for EVERY entity there is. I'm developing a bot
plugin for HL2, but it's going to lack a lot of features if the
interface is not going to be updated. For example, my bots wouldn't be
able to shoot at npc:s, because I don't have an access to the entity's
flags variable, therefore I'm not able to check if FL_NPC is set. Oh, I
could check the classname as well, but that was just an example. So, I'd
like to know, are you going to extend the plugin interface's
functionality somewhere in the future?

Thanks in advance,
Alfred contacted me later with this:

Quote:

Subject:
RE: Limited server plugin interface
From:
"Alfred Reynolds" <alfred@valvesoftware.com>
Date:
Sat, 12 Feb 2005 20:47:46 -0800
To:
"Yahn Bernier" <YahnBernier@valvesoftware.com>, "Akz" <akz@bots-united.com>

As Yahn said, we plan to update the interface as we find a need for it.
The last release of the SDK extended the IPlayerInfo structure to return
player origins and angles, I will look into adding flags to that
interface. For your particular problem I would recommend using the
CBaseEntity shipped in the HL2 code portion of the SDK (as this layout
should be constant for HL2, it won't be for other mods however).

- Alfred
That's not quite the answer I was waiting for. If I understood right, they are going to add flags into the IPlayerInfo structure, which still isn't much.

Pierre-Marie Baty 13-02-2005 13:20

Re: Another Source SDK question ...
 
I believe they want to limit the mess there was in HL1 with all these "fun" plugins doing weird things to players all the time.

*edit*

Steam news tell me that the HL2DM interface update is planned for this thursday =)


All times are GMT +2. The time now is 04:07.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.