Partner Following: Difference between revisions

From PMDOWiki
Palika (talk | contribs)
No edit summary
Palika (talk | contribs)
No edit summary
Line 10: Line 10:
Open up your init script and look at the Init callback function. Here, you'll need to add several functions related to spawning in and setting up your partner.
Open up your init script and look at the Init callback function. Here, you'll need to add several functions related to spawning in and setting up your partner.


You'll need to start with calling COMMON.RespawnAllies(). This will call the spawner you made earlier. It'll also call spawners named TEAMMATE_2 or TEAMMATE_3 if they exist, if you want to have your other party members appear on the map. From here, you'll need to set up your partner's data and AI. You can do this with the following commands:
You'll need to start with calling COMMON.RespawnAllies(). This will call the spawner you made earlier. From here, you'll need to set up your partner's data and AI. You can do this with the following commands:


<pre>
<pre>
Line 18: Line 18:
</pre>
</pre>


This will
This will initialize the ground character you spawned in (known internally as 'Teammate1') with the partner following AI, targeted at following the player character. Then, it'll disable their collision, as otherwise you'll get stuck on them constantly.
 
Assuming your init script was fresh before starting, it'll look something like this afterwards:
<pre>
function YourGroundName.Init(map)
  MapStrings = COMMON.AutoLoadLocalizedStrings()
  COMMON.RespawnAllies()
  local partner = CH('Teammate1')
  AI:SetcharacterAI(partner, 'ai.ground_partner', CH('PLAYER'), partner.Position)
  partner.CollisionDisabled = true
end
</pre>
 
Now, whenever the map loads, the character in slot 2 of the party will follow you around that map! You'll need to set this up for every map you want the partner to follow you around in.
 
 
=== What if the player/partner isn't in the party, but I want them to be the overworld Pokemon? ===
To do this, you'll have to set things up a bit differently.

Revision as of 20:41, 23 December 2023

Want your partner to follow you around in the overworld? It'll take some scripting work as well as map editor work to achieve this. Let's start with the map editor.

You'll need to place down a spawner that the script will use to spawn in your partner. You can do this in the Entities tab, and choosing an object type of spawner. Let's work with the assumption that your partner will be whoever is in slot 2 of your party. In such a case, we'll call the spawner TEAMMATE_1 and the entity it spawns Teammate1, as seen below.


File:Partner Spawner.png

Place the spawner wherever in the map you want the partner to spawn in. You can also set the default direction they spawn in as by changing the direction of the spawner. Once this is done, save your map changes. It's now time to make changes to the init script for the ground so the game knows what to do with that spawner.

Open up your init script and look at the Init callback function. Here, you'll need to add several functions related to spawning in and setting up your partner.

You'll need to start with calling COMMON.RespawnAllies(). This will call the spawner you made earlier. From here, you'll need to set up your partner's data and AI. You can do this with the following commands:

local partner = CH('Teammate1')
AI:SetcharacterAI(partner, 'ai.ground_partner', CH('PLAYER'), partner.Position)
partner.CollisionDisabled = true

This will initialize the ground character you spawned in (known internally as 'Teammate1') with the partner following AI, targeted at following the player character. Then, it'll disable their collision, as otherwise you'll get stuck on them constantly.

Assuming your init script was fresh before starting, it'll look something like this afterwards:

function YourGroundName.Init(map)
  MapStrings = COMMON.AutoLoadLocalizedStrings()
  COMMON.RespawnAllies()
  local partner = CH('Teammate1')
  AI:SetcharacterAI(partner, 'ai.ground_partner', CH('PLAYER'), partner.Position)
  partner.CollisionDisabled = true
end

Now, whenever the map loads, the character in slot 2 of the party will follow you around that map! You'll need to set this up for every map you want the partner to follow you around in.


What if the player/partner isn't in the party, but I want them to be the overworld Pokemon?

To do this, you'll have to set things up a bit differently.