.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > SDK Programming discussions > Half-Life 2 SDK
Half-Life 2 SDK For developments focused around the Half-Life 2 engine Half-Life 2

Reply
 
Thread Tools
Another Source SDK question ...
Old
  (#1)
BotUser
Member
 
Status: Offline
Posts: 39
Join Date: Jun 2004
Default Another Source SDK question ... - 30-01-2005

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.

  
Reply With Quote
Re: Another Source SDK question ...
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Another Source SDK question ... - 31-01-2005

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



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Another Source SDK question ...
Old
  (#3)
BotUser
Member
 
Status: Offline
Posts: 39
Join Date: Jun 2004
Default Re: Another Source SDK question ... - 31-01-2005

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 >
  
Reply With Quote
Re: Another Source SDK question ...
Old
  (#4)
botman
Super Moderator
 
Status: Offline
Posts: 280
Join Date: Jan 2004
Location: Plano, TX
Default Re: Another Source SDK question ... - 31-01-2005

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
  
Reply With Quote
Re: Another Source SDK question ...
Old
  (#5)
BotUser
Member
 
Status: Offline
Posts: 39
Join Date: Jun 2004
Default Re: Another Source SDK question ... - 31-01-2005

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
  
Reply With Quote
Re: Another Source SDK question ...
Old
  (#6)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Another Source SDK question ... - 31-01-2005

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

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



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Another Source SDK question ...
Old
  (#7)
BotUser
Member
 
Status: Offline
Posts: 39
Join Date: Jun 2004
Default Re: Another Source SDK question ... - 31-01-2005

PMB, let's hope you'll turn out right and they'll give us some nice SDK update
  
Reply With Quote
Re: Another Source SDK question ...
Old
  (#8)
XAD
Member
 
Status: Offline
Posts: 4
Join Date: Jan 2005
Default Re: Another Source SDK question ... - 13-02-2005

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
  
Reply With Quote
Re: Another Source SDK question ...
Old
  (#9)
Akz
Creator of GrogBot
 
Akz's Avatar
 
Status: Offline
Posts: 91
Join Date: Jan 2004
Default Re: Another Source SDK question ... - 13-02-2005

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.


GrogBot - A bot for Pirates, Vikings and Knights HL modification.

http://grogbot.bots-united.com
  
Reply With Quote
Re: Another Source SDK question ...
Old
  (#10)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Another Source SDK question ... - 13-02-2005

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



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 13-02-2005 at 14:23..
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com