Comments (5)
Thank you.
Btw, is this related to the bots swapping weapon over and over or they just not pick the item up?
from left4bots.
Thank you. Btw, is this related to the bots swapping weapon over and over or they just not pick the item up?
Yes, this fixes "bots swapping weapon over and over".
about not pick up item, I think one reason is custom skins, my smg skins let "center pos" under ground, so bot not pick up it in c1m1, use "origin pos" can fix this.
and other reason is about "TraceLine", i guess it hit something transparent, adjust "tracemask_pickups" should be some help.
//delete some thing, need test more.
//tracemask_pickups = 16395; //CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_GRATE
::Left4Bots.CanTraceToPickup <- function (bot, item)
{
//local mask = 0x1 | 0x8 | 0x40 | 0x2000 | 0x4000 | 0x8000000; // CONTENTS_SOLID | CONTENTS_GRATE | CONTENTS_BLOCKLOS | CONTENTS_IGNORE_NODRAW_OPAQUE | CONTENTS_MOVEABLE | CONTENTS_DETAIL
local traceTable = { start = bot.EyePosition(), end = item.GetOrigin(), ignore = bot, mask = Settings.tracemask_pickups };
TraceLine(traceTable);
//printl("fraction: " + traceTable.fraction);
//DebugDrawCircle(traceTable.pos, Vector(0, 0, 255), 255, 10, true, 0.1);
return (traceTable.fraction > 0.98 || !traceTable.hit || !traceTable.enthit || traceTable.enthit == item || traceTable.enthit.GetClassname() == "prop_health_cabinet");
}
from left4bots.
Hey mate, i think i simplified your fix a little bit:
smilz0/Left4Lib@dbf18b4
Let me know if i messed up something.
About the CanTraceToPickup i don't think that using GetOrigin will fix it. Look at the comment on the ::Left4Utils.CanTraceTo function. Depending on the angle of the bot looking at the item, GetOrigin was making the trace to fall outside of the item's hitbox and so not hit it. GetCenter solved it. It shouldn't matter if the center of the item is actually under the ground because the trace is supposed to hit the part above and make this condition true: traceTable.enthit == item
.
Also, yes the default tracemask_pickups, in some maps, can make the trace hit some invisible wall and make the bots not "see" the item. It happens in c1m3 in the room with the stop alarm button with the medkit on the table next to the door. A different value of tracemask_pickups can solve but i don't know if there is a value that works every time, this is why i turned it into a setting, so people can make a settings_mapname.txt file and set a different value for these maps.
from left4bots.
Hey mate, i think i simplified your fix a little bit: smilz0/Left4Lib@dbf18b4 Let me know if i messed up something.
I tested it and works great.
About the CanTraceToPickup
bots ignore smg
green circle is center point
these screenshot shows why use "GetCenter" can not hit smg in c1m1 with this custom skins
and fix another bug about bots not pick up the last item in "cfg/weapons/*.txt".
StringToFile() : Due to a bug, string is saved with zero byte at the end.
::Left4Bots.LoadWeaponPreferences <- function (survivor, scope)
{
// WeapPref array has one sub-array for each inventory slot
// Each sub-array contains the weapons from the highest to the lowest priority one for that inventory slot
scope.WeapPref <- [[], [], [], [], []];
// WeapNoPref array contains a flag for each inventory slot
// The flag indicates whether the priority of the weapons in WeapPref for that slot must be ignored
scope.WeapNoPref <- [false, false, false, false, false];
if (!survivor || !survivor.IsValid() || !scope)
return;
//Logger.Debug("LoadWeaponPreferences - survivor: " + survivor.GetPlayerName());
// TODO: do this with the character id instead
local filename = GetCharacterDisplayName(survivor);
if (filename == null || filename == "")
filename = survivor.GetPlayerName(); // Apparently the L4D1 survivors in The Passing 3 don't have a CharacterDisplayName
filename = Settings.file_weapons_prefix + filename.tolower() + ".txt";
local lines = Left4Utils.FileToStringList(filename);
if (!lines)
return;
local c = 0;
for (local i = 0; i < lines.len(); i++)
{
local line = Left4Utils.StripComments(lines[i]);
if (line != "")
{
local weaps = split(line, ",");
for (local x = 0; x < weaps.len(); x++)
{
//delete space characters which cause bug
local wp = strip(weaps[x]);
if (x == 0 && wp == "*")
scope.WeapNoPref[i] = true;
else
{
local id = Left4Utils.GetWeaponIdByName(wp);
//Logger.Debug("LoadWeaponPreferences - i: " + i + " - w: " + wp + " - id: " + id);
if (id > Left4Utils.WeaponId.none && id != Left4Utils.MeleeWeaponId.none && id != Left4Utils.UpgradeWeaponId.none)
{
scope.WeapPref[i].append(id); // valid weapon
c++;
}
}
}
}
}
Logger.Debug("LoadWeaponPreferences - Loaded " + c + " preferences for survivor: " + survivor.GetPlayerName() + " from file: " + filename);
}
from left4bots.
Thanks!
I Added the fix to the LoadWeaponPreferences function but i still don't think that GetOrigin is the solution for CanTraceToPickup.
I tried that smg skin and indeed there is a problem with it. It seems that the trace never hits the item, it always hits the ground. Same with GetOrigin, but the difference with GetOrigin is that fraction
is enough to make this condition true: traceTable.fraction > 0.98
. You can also solve by using a different value for the trace mask. Infact if you use tracemask_others instead of tracemask_pickups, it works even with GetCenter and the bots pick that smg up no problem.
from left4bots.
Related Issues (20)
- Fix bots take more items from spawn ent HOT 2
- Improve: bots can dodge spitter's death acid pool HOT 1
- Fix vocalizer issues with "VScript Survivor Manager" again HOT 2
- Bots get stuck replenishing ammo with "t3_ammo_bots = 0" HOT 2
- Aiming function adjust HOT 1
- Automation system HOT 1
- Automation scripts for Dead Center official campaign
- Automation scripts for Dark Carnival official campaign
- u can add a new feature where in custom maps when u have to turn all generators (when commanded) and other stuff the bots will start to scavenge for the thinks HOT 1
- [Improvement] Manual Attack Adjustments HOT 3
- The full version of left 4 bots 2 works on second restart by either vote to restart or failing the chapter while the alpha version works fine with this mod HOT 1
- hey can u add a feature where when playing with friends they can also control the bots? it sucks when only 2 person can control them HOT 2
- Automation scripts for Swamp Fever official campaign
- "Dodge" pipe_bomb_projectile
- Automation scripts for Death Toll official campaign HOT 1
- Bots close saferoom door HOT 1
- Player survivors getting force-swapped away from pills/adrenaline after pickup HOT 3
- Fix bot shooting nervously sitting witch HOT 1
- When swapping your weapon with the bot, you'll find that it has no ammo. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from left4bots.