GenAI.BestShootTargetFromCurrentPosition

Started by skullywag, October 15, 2014, 11:03:49 AM

Previous topic - Next topic

skullywag

Anyone know how i can make this muther work for non hostiles:

return GenAI.BestShootTargetFromCurrentPosition(base.Position, searcher, new Predicate<Thing>(this.IsValidTarget), this.gun.PrimaryVerb.verbProps.range, this.gun.PrimaryVerb.verbProps.minRange, !this.gun.PrimaryVerb.verbProps.projectileDef.projectile.flyOverhead, !this.gun.PrimaryVerb.verbProps.ai_IsIncendiary);

The this.isVallidTarget only fires when the pawn its targetting is a hostile, but I dont seem to be able to find where it wants a hostile before firing that. (its in the turretgun code btw).

Anyone have any clues?

or alternatively anyone know a good way to scan for targets using another way?
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Rikiki

You could use something like:
IEnumerable<Thing> potentialTargets = Find.ListerThings.ThingsOfDef(ThingDef.Named("Human")).Where(testedThing => testedThing.HostileTo(Faction.OfColony));

Not tested though...

skullywag

I was looking at something like that earlier but the GenAI stuff handles picking a target so much nicer and now I just want to know where in the code it implicitly states it has to be hostile....its bugging me now lol!
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

skullywag

Im banging my head against a brick wall here, this just doesnt seem possible but I cannot find where it states it has to be hostile target....
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Matthiasagreen

If you find it, you could essentially create an auto hunter turret that targets any animals in ints area.
Hi, my name is Matthias and I am a Rimworld Addict. It has been five seconds since my last fix...

skullywag

Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

mrofa

Bullet_Sponge PSpark = (Bullet_Sponge)GenSpawn.Spawn(ThingDef.Named("PlasmaSpark"), base.Position); // Creating a bullet

PSpark.Launch(this, fire.Position); //Launching that bullet


Did use that in afs device in clutter for auto fire fighting
All i do is clutter all around.

Rikiki

Isn't it a little bit cheated? ::)
Okay you can spawn bullets and tell them where to go but getting the AI to do it autonomously would be great.

mrofa

Well i didnt find any other way that dont require to make alot of pawns classes rewriting
All i do is clutter all around.