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

[L4D2] Defib using Bots (Updated 09-25-2020)


Post New Thread Reply   
 
Thread Tools Display Modes
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 04-20-2015 , 09:10   Re: [L4D2] Defib using Bots (Updated 04-19-2015)
Reply With Quote #21

Quote:
Originally Posted by Marcus101RR View Post
Would you not be able to command a bot to pick up items as well with this script? I would also like to see this with the upgrade boxes?
Yes, If You look at the source, I also included CommandABot to pickup Defibs.

Of course, for some strange reason, they don't pick up normal weapon_defibrillators, so I had to make an entity scan and change them to weapon_defibrillator_spawn, I also included grenades but apparently that one isn't working too well, but it honestly doesn't matter as far as this plugin is concerned.

I had planned on using CommandABot and then forcing +Use, but for some reason it was being extremely iffy and sometimes they'd just stand there dancing around and not picking stuff up, so instead of +Use I simply had to call AcceptEntityInput(entity, "Use", SurvivorBot) and while it doesn't look as clean it works.

For Upgraded Ammo it'd actually be extremely easy, as all that actually needs to be done is force a weapon_switch and +ATTACK, no need to make and entity scan, make them move, force them to aim somewhere, etc.
__________________
DeathChaos25 is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 04-21-2015 , 00:29   Re: [L4D2] Defib using Bots (Updated 04-19-2015)
Reply With Quote #22

Quote:
Originally Posted by DeathChaos25 View Post
Yes, If You look at the source, I also included CommandABot to pickup Defibs.

Of course, for some strange reason, they don't pick up normal weapon_defibrillators, so I had to make an entity scan and change them to weapon_defibrillator_spawn, I also included grenades but apparently that one isn't working too well, but it honestly doesn't matter as far as this plugin is concerned.

I had planned on using CommandABot and then forcing +Use, but for some reason it was being extremely iffy and sometimes they'd just stand there dancing around and not picking stuff up, so instead of +Use I simply had to call AcceptEntityInput(entity, "Use", SurvivorBot) and while it doesn't look as clean it works.

For Upgraded Ammo it'd actually be extremely easy, as all that actually needs to be done is force a weapon_switch and +ATTACK, no need to make and entity scan, make them move, force them to aim somewhere, etc.
How come it is that is an issue with weapon entities? THey pick up weapons that do not have the _spawn tag on the end, so why the hell are they doing it for defibs? I mean, doesn't the commandabot actually use entity ids rather than names? Never used EMS, so, I am 0 knowledge on this.
__________________
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
bazrael
Senior Member
Join Date: Jan 2010
Location: Where Lucy became superw
Old 04-21-2015 , 11:21   Re: [L4D2] Defib using Bots (Updated 04-19-2015)
Reply With Quote #23

Could you join the ability of teleportation for bot regroupment?
PHP Code:
// 0=Off, 1=Enables the teleportation that bot survivors can fly to player's position.
l4d_dub_???? "1" 
bazrael is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 04-23-2015 , 16:26   Re: [L4D2] Defib using Bots (Updated 04-19-2015)
Reply With Quote #24

This might be a stupid suggestion:

Could you not add a check on the spawned items to see if their velocity is 0 (stationary) and then set them to the _spawn rather than have them freeze 50 miles in mid air? This happens with a mod I am using that occasional spawns items out of boxes, and they float.
__________________
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 04-23-2015 , 17:43   Re: [L4D2] Defib using Bots (Updated 04-19-2015)
Reply With Quote #25

Quote:
Originally Posted by Marcus101RR View Post
This might be a stupid suggestion:

Could you not add a check on the spawned items to see if their velocity is 0 (stationary) and then set them to the _spawn rather than have them freeze 50 miles in mid air? This happens with a mod I am using that occasional spawns items out of boxes, and they float.
Hmm, I hadn't actually thought about that, and the change should only explicitly change weapon_defibrillator into weapon_defibrillator_spawn, because for some forsaken and unknown reason weapon_defibrillator somehow fails every possible entity check for pickup (even Gear transfer has this problem, which is why I had to take this course of action).

Edit : Hmm, while VERY rare, still getting some entities stuck in the air, it's kind of a 1/100 thing but still, this is somehow firing false positives in very rare instances;
PHP Code:
            new Float:velocity[3];
            
GetEntPropVector(iProp_Data"m_vecVelocity"velocity);
            if (
velocity[0] == && velocity[1] == && velocity[2] == 0)
            {
             
            } 
__________________

Last edited by DeathChaos25; 04-23-2015 at 17:45.
DeathChaos25 is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 04-29-2015 , 18:23   Re: [L4D2] Defib using Bots (Updated 04-29-2015)
Reply With Quote #26

Updated the plugin!

Read main post for changes.
__________________
DeathChaos25 is offline
Crazygamer34894
Senior Member
Join Date: Feb 2013
Location: Cape Town Western Cape
Old 04-29-2015 , 21:15   Re: [L4D2] Defib using Bots (Updated 04-29-2015)
Reply With Quote #27

Quote:
Originally Posted by DeathChaos25 View Post
About : Ever tired of dying, when a survivor bot has a defib, and the game just goes on without you because bots won't defib you? Well, No more!

How it works :
This plugin scans the map for any survivor death models, after it finds one, if certain criterias are met, a bot with a defib will then be forced to walk up to the dead body, then he is forced to aim at the dead body, take out his defib, and use +ATTACK to successfully defib a dead survivor.

Video Demonstration here

The criterias for bots to defib survivors are as following :
1) There is distance limit, we don't want bots going halfway across the map just to defib one person
2) No survivors must need help (IE Trapped by a SI, incapacitated or hanging from a ledge)
3) There must be no visible threats to the survivor bots for them to accomplish this
Spoiler


Admin Commands (Added in Version 1.3 and 1.4, Root access required) :
sm_regroup - Orders all survivor bots to regroup and move to where the person who issued this command is located
sm_resetbots - Resets all bots and interrupts their current action.
sm_retreat - Orders all survivor bots to retreat from the special infected you are currently aiming at
sm_attack - Orders all survivor bots to focus and attack the special infected you are currently aiming at

Note that these 2 commands also have the same limitations put into place as the defib usage on bots


Code:
Version 1.0    04-15-2015 (55 views)
- Initial Release

Version 1.1   04-16-2015 (16 views)
- Improved the AI a bit
- Fixed a bug where in certain situations the bots would shoot non stop

Version 1.2   04-17-2015 (42 views)
- Fixed an oversight where bots would never stop swinging melee weapons
- Added defib tracking for bots into the plugin!

Version 1.3  04-18-2015 (33 views)
- Fixed an oversight where in certain odd conditions bots would not heal
- Added 2 new admin commands to control bots! (Root access required)

Version 1.4  04-19-2015 (99 views)
- Fixed an Invalid Client Array Issue in a timer
- Added sm_retreat and sm_attack admin commands

Version 1.5  04-29-2015
- Small Code Cleanup to make plugin more easily readble
- Completely new system is being used for defib pickup (left4dowtown2 is needed for it to work!)
- As a result, if the defib pickup function is desired, left4downtown2 is needed (Plugin will work without downtown, but bots will not pick up defibs)
To DO :
Code:
- Requests(?)
Thanks to dcx2 for suggesting "use weapon_defibrillator" !

It is suggested you run Gear Transfer!

If there is an instance where the bots go all dumb and defib people while ignoring zombies please let me know, as this shouldn't be the case.

THIS PLUGIN NOW HAS ITS VERY OWN NATURAL AI FOR DEFIB PICK UP, HOWEVER, Left4Downtown2 IS NEEDED FOR THIS SYSTEM TO WORK.

THE PLUGIN FUNCTIONS WITHOUT Downtown, BUT BOTS WILL NOT PICK UP DEFIBS IF IT IS NOT PRESENT.
So? it Is Possibble for Bots to do so !!!!!! BRILLIANT!
__________________
Crazygamer34894 is offline
Send a message via Yahoo to Crazygamer34894 Send a message via Skype™ to Crazygamer34894
Krufftys Killers
Senior Member
Join Date: Jan 2014
Old 05-09-2015 , 21:57   Re: [L4D2] Defib using Bots (Updated 04-29-2015)
Reply With Quote #28

L 05/09/2015 - 10:11:15: SourceMod error session started
L 05/09/2015 - 10:11:15: Info (map "l4d_yama_1") (file "errors_20150509.log")
L 05/09/2015 - 10:11:15: [SM] Native "GetEntPropVector" reported: Entity 1111 (1111) is invalid
L 05/09/2015 - 10:11:15: [SM] Displaying call stack trace for plugin "[L4D2] Defib using bots.smx":
L 05/09/2015 - 10:11:15: [SM] [0] Line 264, /home/forums/content/files/2/4/4/9/4/4/144630.attach::L4D2_OnFindScavengeItem()
L 05/09/2015 - 10:11:17: [SM] Native "GetEntPropVector" reported: Entity 1111 (1111) is invalid
Krufftys Killers is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 06-12-2015 , 21:06   Re: [L4D2] Defib using Bots (Updated 04-29-2015)
Reply With Quote #29

Quote:
Originally Posted by Krufftys Killers View Post
L 05/09/2015 - 10:11:15: SourceMod error session started
L 05/09/2015 - 10:11:15: Info (map "l4d_yama_1") (file "errors_20150509.log")
L 05/09/2015 - 10:11:15: [SM] Native "GetEntPropVector" reported: Entity 1111 (1111) is invalid
L 05/09/2015 - 10:11:15: [SM] Displaying call stack trace for plugin "[L4D2] Defib using bots.smx":
L 05/09/2015 - 10:11:15: [SM] [0] Line 264, /home/forums/content/files/2/4/4/9/4/4/144630.attach::L4D2_OnFindScavengeItem()
L 05/09/2015 - 10:11:17: [SM] Native "GetEntPropVector" reported: Entity 1111 (1111) is invalid
You may have had an older version, as line 264 does not contain GetEntPropVector, that line has moved down and has this line before it;
PHP Code:
if (IsValidEntity(i)) 

Meaning no invalid entity errors should happen
__________________

Last edited by DeathChaos25; 06-12-2015 at 21:06.
DeathChaos25 is offline
yurikon
Junior Member
Join Date: Jul 2013
Location: china
Old 06-23-2015 , 23:56   Re: [L4D2] Defib using Bots (Updated 04-29-2015)
Reply With Quote #30

sorry for my poor english
a bug:
because of you never removes defib from Array if someone holding it.

MedsArray{item,item,defib someone holding, defib want to pickup,...}

public Action:L4D2_OnFindScavengeItem(client, &item)
{
...
for (new i = 0; i <= GetArraySize(MedsArray) - 1; i++)
{
if(IsDefibOwned(i)) continue;
GetEntPropVector(GetArrayCell(MedsArray, i), Prop_Send, "m_vecOrigin", Origin);
GetEntPropVector(client, Prop_Send, "m_vecOrigin", TOrigin);
new Float:distance = GetVectorDistance(TOrigin, Origin);
if (distance < 300)
{
item = GetArrayCell(MedsArray, i);
return Plugin_Changed;
}
}
}

i added
"if(IsDefibOwned(i)) continue;" to fixed it

and the code,i cant't read:
stock bool:ChangePlayerWeaponSlot(Client, weaponslot)
{
if (IsValidEdict(GetEdictClassname(GetPlayerWeap onSlot(Client, 3), weapon, sizeof(weapon))))
}

Last edited by yurikon; 06-24-2015 at 03:59.
yurikon 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 06:57.


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