.:: 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 =)

Lazy 15-02-2005 04:19

Re: Another Source SDK question ...
 
By searching around in edict_t::GetUnknown() I have found these offsets:

Quote:

health : 39 long
armor : 749 long ( sent to client as signed byte? )
money : 864 long
flashbangs : 1632 byte
scout reserve ammo : 398 long
kills : 745 long
deaths : 746 long
The only odd things are that the weapon's clip doesn't show up anywhere in memory and setting flashbangs causes it to go into the negative values after you throw your last one.

sfx1999 15-02-2005 21:46

Re: Another Source SDK question ...
 
I have a theory for the flashbang. When it is 0, it would show in the HUD, but red because it would be empty, but -1 would not show.

Lazy 15-02-2005 21:51

Re: Another Source SDK question ...
 
It actually went into -16000 or something like that and you could still throw them.
I guess if you made a mod that changes that location you'd have to work around that bug.
Still no luck finding the ammo in the clip though, I cannot figure out why its not showing up.

Lazy 15-02-2005 22:21

Re: Another Source SDK question ...
 
Hmm, you can't edit old posts?
Here is the new stuff I found, it's just all of the weapon's reserve ammo ( not the stuff in the clip since I cannot find that ).

Quote:

health : 39 long
armor : 749 long ( sent to client as signed byte? )
money : 864 long
flashbangs : 1632 byte
kills : 745 long
deaths : 746 long
9mm reserve ammo : 402 long
.45 reserve ammo : 404 long
.357 reserve ammo : 405 long
.50 reserve ammo : 397 long
12 guage reserve ammo : 403 long
.338 reserve ammo : 406 long
.223 reserve ammo : 399 long ( ALSO 5.56 )
7.62 reserve ammo : 398 long
AWP reserve ammo : 401 long ( Even though it uses .338 ammo it uses a different variable? )
5.56 reserve ammo : 400 long

Pierre-Marie Baty 16-02-2005 13:08

Re: Another Source SDK question ...
 
In my opinion this post would fit nicely in a wiki article, don't you think ? *hint* *hint* :D


All times are GMT +2. The time now is 05:55.

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