Space Engineers

Space Engineers

Froid's WeaponCore Rotor Turret Script
 此主题已被置顶,因此可能具有重要性
Sigmund Froid  [开发者] 2020 年 8 月 23 日 上午 5:38
Bugs and Issues Discussion
Post your bugs and issues here.

Bugs not to report:
  • The script says x Vanilla Weapons installed, but I only have x WC Weapons on the turret
    ->Seems like the script sometimes has problems aquiring the WC weapons and then lists some of them as Vanilla Weapons. Reload usually fixes the issue. Feel free to post bugged grids with modlist here for me to investigate.
最后由 Sigmund Froid 编辑于; 2020 年 10 月 4 日 上午 5:59
< >
正在显示第 1 - 15 条,共 52 条留言
Natomic 2020 年 12 月 15 日 上午 11:24 
So I have the issue of it showing x vanilla when I only have WC weapons (it shows 1 vanilla and 4 WC, I only have 4 WC). Interestingly it also seems to mess with the firing code, looking through `AimAtTarget(Vector3D)` I guess it goes down the wrong path somewhere. I managed to fix it and get it firing by adding `StaticVanilla.Clear()` at the top of `AimAtTarget(Vector3D)`. I would love to know if there is a cleaner way around this or a better place to put that call. Its on a DS that I can't easily restart :).

Also currently it will only actually target something if I set it as the WC main target, it isn't picking up stuff from the WC turrets.
最后由 Natomic 编辑于; 2020 年 12 月 15 日 上午 11:59
Sigmund Froid  [开发者] 2020 年 12 月 15 日 上午 11:36 
Thanks for your report. I'll look into it. Might be a bug left from the merge to the new API.
Natomic 2020 年 12 月 15 日 下午 12:48 
Ok I did some debugging and I _think_ the issue is its picking the wrong designator. I got it to print the name of the designator (with `CustomName`) and it was selecting a weapon which was both off and out of range. Moving into range and turning it on has fixed it. Perhaps changing `Designator = WC_DIRECTORS[0];` to `Designator = WC_DIRECTORS.First(<test if it can hit its target>)` would fix it? (I think api.IsTargetAligned can be used but not sure how to get the weaponId).

Also the extra vanilla weapon has now vanished after deleting the group and recreating so I may have set that up wrong or something (or thats what a reload does ?).
Natomic 2020 年 12 月 15 日 下午 2:08 
I've managed to get it selecting a working designator by
modifying the code in `getDesignators` as follows:
引用自 TheGoldKnight23
Designator = null;
distance2Turret = Single.MaxValue;
temp.Clear();
bGroup.GetBlocksOfType<IMyLargeTurretBase>(temp,b=>b.CustomName.Contains(DesignatorNameTag));
if(temp.Count!=0){
this.Designator = temp[0];
distance2Turret = (Designator.Position - Azimuth.Position).Length();
foreach(IMyTerminalBlock t in temp){
if((t.Position - Azimuth.Position).Length()<distance2Turret){
Designator = t;
distance2Turret = (t.Position - Azimuth.Position).Length();
}
}
}
var designatorCandidates = WC_DIRECTORS.Where(d => {
long? id = api.GetWeaponTarget(d, 0)?.EntityId;
if (id != null) {
return api.IsTargetAligned(d, (long)id, 0) && ((IMyFunctionalBlock)d).Enabled;
} else {
return false;
}
}
).ToList();
designatorCandidates.Sort((lhs, rhs) => ((lhs.Position - Azimuth.Position).Length() - (rhs.Position - Azimuth.Position).Length()));

Designator = designatorCandidates.Any() ? designatorCandidates[0] : null;
It is working for me, switching to an in range designator when the current one goes out of range or is turned off and selects the closest when it has to rechoose (the designator does not update if a closer one is made valid unless the current one is invalidated).

Edit:
Getting a null exception here so I guess setting designator to null _after_ it has been not null messes stuff up... not sure I know how to fix that, but hopefully its helpful to you anyway.

Cannot reproduce that exception, it seems fine when losing the target and switching targets.
最后由 Natomic 编辑于; 2020 年 12 月 15 日 下午 2:32
Sigmund Froid  [开发者] 2021 年 1 月 8 日 上午 11:11 
I'll apply your changes in the next days, I haven't had the time last month. Thanks for your help. I'm still relatively new to C# so I was unaware of the Where function for Lists.
Natomic 2021 年 1 月 9 日 上午 10:26 
Just a heads up, I'm still getting an exception while using that code. I can't get it to consistently repro but I have to recompile it every few minutes or so while in combat so theres _something_ up there. I'm not sure if it's caused by my changes or a problem in my setup but I suspect the former.
Sigmund Froid  [开发者] 2021 年 2 月 6 日 上午 3:11 
引用自 Sigmund Froid
I'll apply your changes in the next days
Well that aged well. The problem with your code was mostly that getDesignators was designed to avoid that the designator is ever null so I didn't check for that anymore afterwards. the update is out now
Kaito  [开发者] 2021 年 4 月 26 日 下午 7:45 
Can't get it to work. It throws an exception the moment it finds my group, or if it finds a vanilla designator. I'm not sure how I could copy paste the stack trace, but you'll have to excuse me for not typing it all out. Abbreviated stack trace transcript below:

Object reference not set to an instance of an object, at isTargetAligned, PbIsTargetAligned, isTargetAligned, getDesignators.

Anything I can do to help debug this?
Kaito  [开发者] 2021 年 4 月 26 日 下午 8:11 
Line 272, you need to check that id is not 0 in addition to not being null.
Kaito  [开发者] 2021 年 4 月 26 日 下午 8:25 
The conditional on line 400 does not consider DIRECTOR, and getDesignators does not consider DIRECTORS, so it will never use vanilla designators for targets.
Kaito  [开发者] 2021 年 4 月 26 日 下午 9:01 
Fixed it by passing DIRECTOR down frorm AttemptVanillaTargetting.

Do you have a git repo or something?
Sigmund Froid  [开发者] 2021 年 4 月 27 日 上午 2:09 
1. No I don'T have a git (yet). 2. I'll implement it, thanks for your effort. It seems I haven't tested it with vanilla designators in the last updates as it isn't the main purpose of this script.
Kaito  [开发者] 2021 年 4 月 27 日 上午 4:49 
My entire reason is using the MA Designator Turret, as there is no dedicated WC designator, and that one is apparently used in StarCore.... Somehow.

I've got some more work I'd like to do on the script now that I'm mildly familiar. Let me know if you get it on GitHub or whatever repo hosting you prefer.

Also, where did you hear that DDS would add WC support? I saw no mention of it. I figure you don't want to put too much effort into this, since you expect it to he deprecated soon.
最后由 Kaito 编辑于; 2021 年 4 月 27 日 上午 5:10
Sigmund Froid  [开发者] 2021 年 4 月 27 日 上午 6:43 
Well when I wrote that this script was new and I'd been contacted if I could write a similiar add on like my whip's turret ai slaving script wc addon. When I contacted the author of DDS on his setup guide about the matter he told me he's working on it. From there my script was mostly for personal use but as DDS yet has to push a update supporting WC (I suspect the vast amount of edge cases and setup would bloat the script), I kept updating this as issues arised. On the note of your issue: I haven't been able to fix it yet; maybe I'm just missing the point. I assume you set DIRECTORS static and run the code used to find the best WC turret again over DIRECTORS or are you just replacing null as value for Designator with DIRECTORS[0]?
Sigmund Froid  [开发者] 2021 年 4 月 27 日 上午 7:04 
ok nevermind it works now. I guess my old testing world just got borked by the update.
< >
正在显示第 1 - 15 条,共 52 条留言
每页显示数: 1530 50