Dark Souls style "Bonfire"

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Dark Souls style "Bonfire"

Post by guo »

Aloha.

In Dark Souls, when you rest at a Bonfire you can save your game and restore your health + estus flasks, but all the enemies you have slain are respawned (with the exception of some boss characters). In my game, as you may have read in a previous thread, there are wandering NPCs that trigger a script - the script calls a battle then uses "delete npc (npcref)" to remove that particular NPC copy, so that I may reuse the same NPC for multiple enemies.

[s]Now my question is, if I wanted the player to use an "Inn" that also reset these enemies, how would I go about doing so? I understand that using "delete npc (npcref)" is not permanent in the sense that when the player reloads a saved game the deleted NPCs will be restored. Is there a form of trickery I could use whereby a script saves game, then immediately reloads that save game to restore these NPCs? It would fit well with my intention, as I only want to have one save slot anyway - a consequence of playing so many roguelikes. [/s]

[s]Other than that, is there another way I could achieve the same effect? [/s]

Regards.

Edit: Ok, it works great! I run it as a script used when sleeping at a particular Inn. I have another quandry, however. I want the "inn" to be free, and not display the "inn costs $x, pay $x?". Is there a script command to "use an inn"? I couldn't find anything like that anywhere. I would use plotscripting, but as I am running FF1 style mp it could be quite tricky to restore that accurately.

More regards!
Last edited by guo on Tue Apr 26, 2016 5:21 am, edited 1 time in total.
vvight.wordpress.com
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

My caveman scripting instincts say that you should give each NPC an appearance tag (e.g. tag 5 = blue goblin defeated) and set it to an OFF condition on each NPC that triggers the fight. Make a bunch of sequential tags, say 20 of them from tags 5 to 25, then do something like this for the bonfire:

Code: Select all

for (x,5,25) do (set tag (x, off))
I did the above line in Hollowkeep's script to reset all the tags that determine if a specific verb command box is highlighted, and basically reset the HUD to a normal state.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

If I remember correctly, (can't check now, posting from my phone) you can restore all HP and MP like an inn using one of the text box conditionals
Last edited by Bob the Hamster on Tue Apr 26, 2016 12:10 pm, edited 1 time in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Of course if you are using tags instead of "delete npc" then you can flip the tag.

Aside from saving and loading the game, which is certainly a good trick and the way to go, the mundane way to reload all deleted NPCs is to use "reset map state" and "delete map state". They only works for the current map, so you would have to call them in the map autorun script the first time you enter the map after when the NPCs are meant to be restored. It's quite a messy solution.

Anyway, I didn't realise there wasn't a command to get the inn effect. But you can set it as a textbox conditional, and just advance the textbox automatically with a script.

But it's easy to script a restore of level mp. You can pass 'maximum stat' as the 'type' to the "get level mp" command:

Code: Select all

script, restore level mp, who, begin
  variable(slot)
  for (slot, 0, 7) do (
    set level mp(who, slot, get level mp(who, slot, maximumstat))
  )
end
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Thanks! Brilliant. While I have you here, may I ask for an efficient way to restore levelled mp (all slots, regardless of how many spells have been used in each) by "1" spell without going over maximum ?
Last edited by guo on Tue Apr 26, 2016 10:47 pm, edited 1 time in total.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

It's nearly the same, but use a "min" function (which mysteriously isn't builtin) to cap the mp.

Code: Select all

script, min, a, b, begin
  if &#40;a < b&#41; then &#40;return &#40;a&#41;&#41; else &#40;return &#40;b&#41;&#41;
end

script, restore level mp, who, begin
  variable&#40;slot, mp&#41;
  for &#40;slot, 0, 7&#41; do &#40;
    mp &#58;= get level mp&#40;who, slot, current stat&#41; + 1
    mp &#58;= min&#40;mp, get level mp&#40;who, slot, maximum stat&#41;&#41;
    set level mp&#40;who, slot, mp&#41;
  &#41;
end
Last edited by TMC on Wed Apr 27, 2016 9:16 am, edited 1 time in total.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

That's so elegant, I wouldn't have thought of that. I have never naturally been a coder, so I always tend to think more "obtusely" when approaching these sorts of things. My thinking was along the lines of:

Code: Select all

script, level mp +1, begin
variable &#40;slot&#41;
for &#40;slot, 0, 7&#41; do &#40;
     if  &#40; &#40;level mp &#40;0, slot, currentstat&#41; < level mp &#40;0, slot, maximumstat&#41; &#41; then &#40;
           set level mp &#40;0, slot, current stat&#41; +1
      else &#40;&#41;
end
I will also have to ensure the script removes the NPC copy similar to the health pickups, and also to not remove the pickup if you are at full levelled MP.

Thankyou once again, I always find that I have learned something valuable when I ask these questions. Appreciate the patience and the help as always.
Last edited by guo on Wed Apr 27, 2016 1:16 pm, edited 3 times in total.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

That way of implementing it is just as good, actually it's probably a bit clearer. And if you want to delete the NPC only if one of the level mp stats is below maximum, then you would want to write it that way anyway.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

Would it be more efficient to make a fake array with boolean indices to store whether an NPC has been fought/destroyed already instead of using a bunch of tags?
My pronouns are they/them
Ps. I love my wife
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

I don't use a bunch of tags, I just make an NPC and paste copies of it where needed, then use the script function "delete npc (npcref)" to delete that copy. I don't even know what a fake array or boolean index is :???:
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

I was very confused as well, because I didn't realise that it was guo, not kylekrack, who posted the original question. I don't see how that would help.

Fake arrays
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

I think I severely misunderstood the original question. Ignore what I said, I'm not even sure what I meant anymore. I'm very tired.
My pronouns are they/them
Ps. I love my wife
Post Reply