Best practice'd way to attach named heros to specific lords?

Users who are viewing this thread

Naur

Recruit
I need to know the best practice solution to 'attach' any named hero to a specific lord's parties as they go about their daily activities.

What I am doing:

I am generating an assortment of Knights, bannermen, lesser nobles, etc (heros) per Lord in the world predicated upon their clan ranking -- *and* their fiefs. These bannermen, knights, etc., exist in a similar capacity to, say, a Lord's spouse: in the encyclopedia, there is even a section of "bannermen" below family, enemies, etc.

I do not want these bannermen to have a form of autonomy. I want them to exist only in the context of a Lord's party. So if a battle starts I want them to generate, etc.

Moreover, this same solution (if possible) needs to be able to attach other lords to that party. For instance, having a lord's spouse follow them into battle. As of now, they just exist in a disabled capacity in a settlement -- a feature I want to keep.

I thought it would be as simple as something like Hero.AddToParty() or something, but this is apparently a little more convoluted than I had expected.

As of now looking into the code, it seems like there are a bazillion different methods relating to attaching heroes to Parties, etc, such as in MobileParty there is MemberRoster.AddToCounts(). But all this does is generate the character into a party, and those characters still manage to exist outside of the party.

Is there some form of HeroHandler that exists? Or do I have to manually set all of these bazillions different variables independentaly? I have to tell the current Hero character to despawn (or preferably move to a party's location and then despawn). I have to attach add the character to the member roster. I have to create a handler myself to allow a lord to 'drop off' the character back into a settlement -- in the case, of say a spouse -- and then re-add the character into the settlement. etc etc?
 
So you want to spawn them right before battles and then send them to the settlements they belong to?

I think you need to do that manually. But you don't need to set bazillions of different variables. I'm not 100% sure this is what you need but here we go:

Before the battle:
(1) Use
C#:
MemberRoster.AddToCounts(hero.CharacterObject, 1)
to add him/her to the party

After the battle:
(2) use
C#:
MemberRoster.RemoveTroop(character)
to remove them from the party

(3) Use
C#:
TeleportHeroAction.ApplyForCharacter(hero, settlement)
to send them back to settlement.

those characters still manage to exist outside of the party.
About this, you can try setting their state with Hero.ChangeState() between events.
Let me know if this works for you.
 
So you want to spawn them right before battles and then send them to the settlements they belong to?

I think you need to do that manually. But you don't need to set bazillions of different variables. I'm not 100% sure this is what you need but here we go:

Before the battle:
(1) Use
C#:
MemberRoster.AddToCounts(hero.CharacterObject, 1)
to add him/her to the party

After the battle:
(2) use
C#:
MemberRoster.RemoveTroop(character)
to remove them from the party

(3) Use
C#:
TeleportHeroAction.ApplyForCharacter(hero, settlement)
to send them back to settlement.


About this, you can try setting their state with Hero.ChangeState() between events.
Let me know if this works for you.
This is (for the most part) the solution I've come to.

What I've ended up doing is creating a HeroHandler which I attach to MobileParty, which centralizes and creates a single source of truth for each 'attached' hero [to a party]. With this pattern, I can then send upward data to each specific Hero to keep them from existing (such as .NotSpawned) outside in the world, or coupled to a party and not return to a settlement, etc.

If this were a larger project I'd probably create a handler on the base campaign obj, but for my purposes attaching to a mobile party works.
 
Last edited:
Back
Top Bottom