Raised This Month: $ Target: $400
 0% 

Using hostages


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 05-14-2006 , 02:28   Using hostages
Reply With Quote #1

I don't know if this is the right forum to ask such questions - so please don't ban me instantly.

The problem is - some CT player pressed "use" button near some hostage and the message has been sent >Player triggered "Touched_A_Hostage"<. The hostage is following him. But then the player pressed the "use' button again - so the hostage is no longer following him. But there is no message sent as Touched_A_Hostage or something. What kind of message / event is send to let me recognize - the hosatge is (or is not) free to be used by someone? What and where is the data stored I should read it to know this?
I think the question is related more to HLSDK than to scripting, but if someone will show me some AMX X natives I should use - it will be helpful for me suficient. Thanks in advance.
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-14-2006 , 12:28   Re: Using hostages
Reply With Quote #2

Quote:
I don't know if this is the right forum to ask such questions - so please don't ban me instantly.
Of course this is the place to ask for such thing. :)

Quote:
What kind of message / event is send to let me recognize - the hosatge is (or is not) free to be used by someone?
Nothing.

Quote:
What and where is the data stored I should read it to know this?
Data is stored in hostage's private data offset.

This sample code should clear up some things for you.


Code:
#include <amxmodx> #include <fakemeta> #include <cstrike> #define HOSTAGE_MAP_CHECK new USE_SOUND[] = "common/wpn_select.wav" #define IN_USE (1<<5) #define MAX_PLAYERS 32 new Float:g_use_time[MAX_PLAYERS + 1] new HOSTAGE_CLASSNAME[] = "hostage_entity" #define MAX_HOSTAGES 4 new g_foll_entid[MAX_HOSTAGES + 1] public plugin_init() {     register_plugin("Hostage Use/Unuse Detection", "0.1", "VEN") #if defined HOSTAGE_MAP_CHECK     if (!engfunc(EngFunc_FindEntityByString, -1, "classname", HOSTAGE_CLASSNAME))         return #endif     register_forward(FM_EmitSound, "forward_emit_sound")     register_forward(FM_Think, "forward_think") } public forward_emit_sound(id, channel, sound[]) {     if (equali(sound, USE_SOUND) && is_user_alive(id) && (pev(id, pev_button) & IN_USE) && get_user_team(id) == 2)         g_use_time[id] = get_gametime()     return FMRES_IGNORED } public forward_think(ent) {     new class[16]     pev(ent, pev_classname, class, 15)     if (!equal(class, HOSTAGE_CLASSNAME))         return FMRES_IGNORED     new hid = cs_get_hostage_id(ent)     new foll = cs_get_hostage_foll(ent)     if (g_foll_entid[hid] == foll)         return FMRES_IGNORED     new Float:use_time = 0.0, used_by = 0     for (new i = 1; i <= MAX_PLAYERS; ++i) {         if (g_use_time[i] > use_time) {             use_time = g_use_time[i]             used_by = i         }     }     server_print("HOSTAGE_ID[%d] FOLLOWING_ENTID[%d] %sUSED_BY[%d]", hid, foll, foll ? "" : "UN", used_by)     g_foll_entid[hid] = foll         return FMRES_IGNORED }
VEN is offline
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 05-14-2006 , 13:17  
Reply With Quote #3

Big thanks.
If I can ask more about hosatges - are there some message as Hostage Killed with entid of hostage which got killed?
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-14-2006 , 13:52  
Reply With Quote #4

Strictly: "no". But this code doing that.

Code:
#include <amxmodx> #include <fakemeta> #include <cstrike> new HOSTAGE_CLASSNAME[] = "hostage_entity" public plugin_init() {     register_plugin("Killed Hostage's EntID Detection", "0.1", "VEN")     register_event("HostageK", "hostage_kill", "bc") } public hostage_kill() {     new hid = read_data(1)     server_print("Hostage with HostageID %d is killed", hid)     server_print("Killed Hostage EntID is %d", cs_get_hostage_entid(hid)) } stock cs_get_hostage_entid(hid) {     new hent = -1, field[] = "classname"     while ((hent = engfunc(EngFunc_FindEntityByString, hent, field, HOSTAGE_CLASSNAME)) &&         cs_get_hostage_id(hent) != hid) {}         return hent }

However, one important note.
HostageK event is called only to alive CT's.
Hence, this will not work in some cases.

If you need more accurate way, let me know and i'll think about it, i'm sure it's exists. :)
VEN is offline
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 05-14-2006 , 16:51  
Reply With Quote #5

Well - to be honest I have to say I'm trying to figure out some stupid situations they happen with bots.
1. The human-player is using the hostage. But there is a lack of code to say - this hostage is alreday used - so my bots are stoling me my hosties I'm trying to rescue. It doesn't happen if any bot is already using the hostage, because the code exactly know when was triggereed this "PICKUP_THE_HOSTAGE" - so in some array the data about used hostges is stored - so other bots "know" this hostage is already used. But this doesn't work for human players, because in this case there is no code forced to PICKUP_THE_HOSATGE - so that info is not triggered.

2. Some bot is trying to rescue the hostages. But they got killed during the travel to the rescue point. But that stupid bot is trying to go to the rescue point to finish its task, because it is still remembering it got some hostages (lack of code to tell him - You don't have Your hostages - You can finish Your task.
This second problem I think I can easy fix by adding some code as - if the used hostages aren't visible for about 5s (or their healths are less or equal to 0) - the bot can finish its task RESCUE_HOSTAGE. But the first one is still difficult to solve for me.

Well - these examples You showed above are good, becase they let me understand some ways/possibility to get the info I need. Now I just need to look through AMX X sources to find how some fakemeta natives are coded. But the worst thing for me is messing around private data. They are based on some "offsets" which are different for win32, linux32, linux amd64. I aslo didn't find any good memory map about these private data to see what exactly is there and with which offsets (and what is the lenght of each data there). So - I'm just not ready to code based on some data which is a mistery for me and - if I'll try to access it badly (because of my lack of knowledge about these data) I may cause some crashes difficult for me to diagnose.
Anyway - thanks again for the help.
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-15-2006 , 05:01  
Reply With Quote #6

Ok. About hostage killing. That's true, i guess checking if oldhealth > 0 AND newhealth <= 0 in every hostage Think is enough. Oldhealth needs to be cached.
VEN is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 05-17-2006 , 14:44  
Reply With Quote #7

To detect whether a hostage is killed by either team:
Code:
   register_event("TextMsg","host_killed","b","2&#Killed_Hostage")
I believe.
__________________
Brad is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-18-2006 , 02:03  
Reply With Quote #8

Yes, but the point was a determination of the killed hostage's entity index, that's why i used HostageK event.
VEN is offline
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 05-18-2006 , 05:00  
Reply With Quote #9

I even don't need to check the old health and the new one (I don't need to check the right moment the hosatge got killed). It's sufficient if I check in code hostages parameters (as health or so) once per 5 seconds . I've precached at map start the list of hostages entities so I need to check only my table of hostages - I don't need to check every time through all map entities. It's sufficient for me if even after 5s after the hostage got killed I stop the bot to try to rescue him. But I'm still having troubles with "using" hostages detection. I wanted to try the moving (changing postion method)m but it fails in some situations, too. For example - when I go somewhere with some bots teamnates t oget the hostage. I press "use" button, but the hostage doesn't move until I'll go somewhere, so the bot-teamnate is still "thinking", the hostage is not used yet, and steals me it.
Well - to use private data I'll need more HL knowledge. Also to make the code depandant of the system (win32 and linux32 have different offset calculation than linuxAMD64). I may need to "inform" the compilator - compile it with such or such offset (because of the system it will be used with).
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 05-18-2006 , 18:22  
Reply With Quote #10

Can someone tell me what a kind of message is this "Touched_A_Hostage"? Is this a TextMsg or what?
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
Reply



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 16:25.


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