Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: [how-to] How to init a dialogue with a custom entity?  (Read 1730 times)

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
[how-to] How to init a dialogue with a custom entity?
« on: November 14, 2014, 12:06:14 AM »

Hi.

I have a custom entity with tag "wrecks". I have a set of rules that 'should' run whenever a player is interacting with an entity with "wrecks" tag. Everything looks ok so far, right? In game I can click on an entity, so it is possible to interact with it. But there is no dialog pop up or anything - my fleet just floats over the entity.

If I set the entity tag to those that are used by stations or relays - everything works fine.

The question is simple - do I need to overwrite some interactionDialogue files and if yes - which ones and most importantly - HOW?


Entity settings:

Spoiler
   "rsf_wrecks":{
      "defaultName":"Station Wrecks", # used if name=null in addCustomEntity()
      "defaultRadius":50, # used if radius<0 in addCustomEntity()
      "customDescriptionId":"orbital_station_default",
      "interactionImage":"graphics/illustrations/space_wreckage.jpg",
      "icon":"graphics/icons/station0.png",
      "iconWidth":24,
      "iconHeight":24,
      "sprite":"graphics/stations/station-rsf-wreck-1.png",
      "spriteWidth":128,
      "spriteHeight":128,
      "renderShadow":true,
      "useLightColor":false,
      "showInCampaign":true,
      "showIconOnMap":false,
      "showNameOnMap":false,
      "scaleNameWithZoom":false,
      "tags":["wrecks"],
      "layers":[STATIONS], # what layer(s) to render in. See CampaignEngineLayers.java for possible values
   },
[close]

Rules for interaction dialogue:

Spoiler
# swrecks interactions,,,,,,
swrecksOpen,OpenInteractionDialog,$tag:wrecks,"ShowDefaultVisual
FireBest InitSWrecksDialog",,,
swrecksInit,InitSWrecksDialog,$tag:wrecks,"$menuState = main 0
#SetTextHighlightColors buttonText ""255,0,0,255""
#SetTextHighlights $shipOrFleet
FireAll PopulateOptions",Your $shipOrFleet approaches the massive field of debris. Apparently it once was an orbital station that was destroyed by someone or something. You can`t do anything with it in current version.,,
swrecksOptionLeave,PopulateOptions,$tag:wrecks,"SetShortcut crLeave ""ESCAPE""",,100:crLeave:Leave the wrecks alone,
swrecksLeave,DialogOptionSelected,$tag:wrecks,DismissDialog,,,
[close]
« Last Edit: November 17, 2014, 11:54:06 AM by Okim »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24125
    • View Profile
Re: [interaction dialogues] How to init a dialogue with a custom entity?
« Reply #1 on: November 14, 2014, 09:21:49 AM »

I think this is missing just the final step - telling the game what interaction dialog plugin to use when interacting with this entity. Since the interaction is driven by rules, you want the default RuleBasedInteractionDialogPluginImpl.

To do that, in your ModPlugin implementation:

public PluginPick<InteractionDialogPlugin> pickInteractionDialogPlugin(SectorEntityToken interactionTarget) {
   if (interactionTarget.hasTag("wrecks")) {
      return new PluginPick<InteractionDialogPlugin>(new RuleBasedInteractionDialogPluginImpl(), PickPriority.MOD_GENERAL);
   }
}
Logged

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: [interaction dialogues] How to init a dialogue with a custom entity?
« Reply #2 on: November 14, 2014, 10:18:02 AM »

Thanks, it is working now.