What makes thing targetable?

Started by Darker, March 11, 2014, 05:57:03 PM

Previous topic - Next topic

Darker

Some things can be shot by gun. Others can't. Why? (I'm asking about the XML and how to arrange things to be targetable or not)
Please... Throw human readable errors on savefile parsing failure!!!
Rim world editor Editor on GIT

JackQW

Excluding direct orders to attack and psychosis...

Other than line of sight and distance, looks like GenHostility.HostileTo is the primary decider, which leans on Faction.IsEnemyOf...

So if something is marked as being of an enemy faction, it's a target.


Darker

I think I'm asking for a way simpler thing. I wanna know, how to allow a player to order a colonist to shoot a thing I've added to the game.

Pick a colonist. Draft him. Click the gun icon. Click rock or wall.
Do the same and try to target debris. You'll fail.

Now I have a thing that can't be targeted and I want to allow the targeting.
Please... Throw human readable errors on savefile parsing failure!!!
Rim world editor Editor on GIT

JackQW

#3
Guess that'd be TargetingParameters.CanTarget... ?

A 'TargetPack' must be valid according to the TargetingParameter's validator, then there's a bunch of hard coded scenarios...
If it's not a thing, the TargetingParameters must specify canTargetLocations, etc..
It's used by the FloatMenuMaker.ChoicesAtFor (the choice menu)...
If all the checks pass, it eventually gives a choice for "Fire at blah..."

Then the resulting action actually issues the attack order, which appears to issue a new AI.Job...

If you create your own action, maybe you can issue a Job of JobDefOf.AttackMelee or JobDefOf.AttackStatic ...

Things implicitly cast to a TargetPack, so... If you want to force a pawn to attack;
`YourPawn`.MindHumanoid.TakeOrderedJob(new AI.Job(JobDefOf.AttackStatic, `SomeThing`))

There appears to be several ways to allow or force something to get attacked by a pawn...
I don't see a way to add your own FloatMenuOption though...