SKELETON WARRIORS death/inn script

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

Moderators: marionline, SDHawk

Post Reply
User avatar
Nathan Karr
Liquid Metal Slime
Posts: 1215
Joined: Fri Jan 25, 2008 3:51 am
Contact:

SKELETON WARRIORS death/inn script

Post by Nathan Karr »

For my hotOHR game, Bonecrush the Demolisher, I want to use a semi-harsh player character death system I've had in mind for a while.

Hero 0 (Find Hero(Hero:Bonecrush)) is the wielder of the blursed sword Dethbane, which prevents him from truly dying. He will always be revived fully at an inn.

Hero 6 is a skeleton (Find Hero(Hero:Skeleton), rising up to continue fighting the good fight through determination. If at 0 HP after battle, this character's equipped items should all be dumped into the party inventory and he be removed from the game.

All other heroes, if dead when the party heals at the inn, should transform into Hero 6, transferring their currently equipped items and customized name.

For simplicity's sake, a full party wipe is a game over as normal - presumably the enemies capture Bonecrush and indefinitely imprison him.
Remeber: God made you special and he loves you very much. Bye!
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6461
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

neat

are you asking for help coding that?
User avatar
Nathan Karr
Liquid Metal Slime
Posts: 1215
Joined: Fri Jan 25, 2008 3:51 am
Contact:

Post by Nathan Karr »

Spoonweaver wrote:neat

are you asking for help coding that?
Yes. I forgot to include the question, didn't I?

Find Hero and Force Equip are basically the only relevant commands I know here. I know they'll be involved, just not how they'll be involved.
Remeber: God made you special and he loves you very much. Bye!
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6461
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

Well, you'll need to store what they have on first in some variables you'll need to define
then, you can unequip it
then delete the hero or remove him or bench him, up to you
then add the new guy, or skeleton
and then equip him
no big deal

Code: Select all

script , skeletonize, iwhichhero, begin

variable(ihead,iarmor,iweapon,ishield)

iweapon:=check equipment (iwhichhero, slot:weapon)

unequip (iwhichhero, slot:weapon)

delete hero (iwhichhero)

add hero (hero:skeleton)

force equip (hero:skeleton, slot:weapon, iweapon)

end

hope this helps
clearly it's not a finished product as you'll need to add a line for all of the equipment pieces
I assume you want to do something about the hero names and levels too
Last edited by Spoonweaver on Wed Jun 17, 2020 7:14 pm, edited 1 time in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

i tried this, but i made some mistakes, and it doesnt work quite right?
i am not familiar with hero changing commands.

Code: Select all

plotscript, make skelly, begin
variable(who)
for(who,0,40,1)do( # heroes in party
variable(skelly, hero)

hero:= hero by slot(who) # since who is the slot, get the hero name

IF&#40;hero<>-1&#41;THEN&#40; # not an invalid &#40;empty&#41; hero
IF&#40;hero<>6&#41;THEN&#40; # not already a skeleton

# IF HERO IS DEAD. INSERT A CHECK HERE #

    skelly &#58;= add hero &#40;6&#41; # returns a party slot

variable&#40;slot&#41;
for&#40;slot, 1,5,1&#41;do&#40;
IF&#40;check equipment&#40;hero,slot&#41;<>-1&#41;THEN&#40;
force equip&#40;skelly, slot, check equipment&#40;hero, slot&#41;&#41;
&#41;   # if valid item in slot
&#41;   # for each slot

# you could also carry across other info, like name, exp/lvl etc.,
    
    swap by position &#40;hero, skelly&#41;
    delete hero&#40;hero&#41; # bye bye

    # IF HERO IS DEAD OR OTHER CHECK #
&#41; # not a skeleton already
&#41; # a valid hero in this slot
&#41; # for active party
end 
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6461
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

that script is a little messy
and you should avoid keyterms like hero for variables
but what exactly happens with your script that you dont want to happen and what doesnt it do right
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Sword's script is close to correct and complete. Tomorrow when I have time I'll post a completed version of it if not beaten to it. "check equipment(hero, slot)" should be "check equipment(who, slot)". You use "get hero stat" to check HP.

Unfortunately, a lot of hero/party plotscripting commands behave badly when you have multiple copies of a hero in the party, they just act on the first copy because they use a hero ID instead of a party slot. "delete hero" is one of them. If you need to act on other copies you need to temporarily change the party ordering, yuck. Is it possible for heroes other than the Skeleton to be duplicated?

There's nothing wrong with giving variables names like "hero" and "item". That's just so common that I wouldn't add any builtin meaning that clashes and breaks scripts (I would actually like to add Hero and Item as 'types').
Last edited by TMC on Fri Jun 19, 2020 3:43 pm, edited 3 times in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

right. multiple heroes of the same definition are kinda a pain to manage.
oh! excuse me.

(screams internally)
"Imagination. Life is your creation."
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Here you go. Unlike Sword, I didn't test it.

Code: Select all

plotscript, inn revive, begin
  variable &#40;slot, skelly, hero&#41;
  for &#40;slot, 0, 40&#41; do&#40;  # For each party slot

    hero &#58;= hero by slot&#40;slot&#41;  # Get the hero ID
    if &#40;hero == -1&#41; then &#40;continue&#41;  # Empty party slot? Skip  to next 'for' iteration

    if &#40;get hero stat&#40;slot, stat&#58;hp&#41; <= 0&#41; then &#40;
      # This hero is dead

      if &#40;hero == hero&#58;Bonecrush&#41; then&#40;
        # Revive
        set hero stat&#40;slot, stat&#58;hp, get hero stat&#40;slot, stat&#58;hp, maximum stat&#41;&#41;

      &#41; else if &#40;hero == hero&#58;Skeleton&#41; then&#40;
        # Drop equipment
        variable &#40;eqslot, item&#41;
        for &#40;eqslot, 1, 5&#41; do&#40;
          item &#58;= check equipment&#40;slot, eqslot&#41;
          if &#40;item <> -1&#41; then&#40;get item&#40;item&#41;&#41;  # Not empty?
        &#41;

        # Delete hero &#40;because of possible duplicates, temporarily swap to slot 0&#41;
        swap by position&#40;0, slot&#41;
        delete hero&#40;hero&#41;
        swap by position&#40;0, slot&#41;

      &#41; else &#40;
        # Turn into skeleton

        skelly &#58;= add hero &#40;hero&#58;Skeleton&#41;  # Returns a party slot

        # Transfer equipment
        for &#40;eqslot, 1, 5&#41; do&#40;
          item &#58;= check equipment&#40;slot, eqslot&#41;
          if &#40;item <> -1&#41; then&#40;  # Not empty?
            add item&#40;item&#41;  # Add to inventory
            force equip&#40;skelly, eqslot, item&#41;  # Removes from inventory again
          &#41;
        &#41;

        # Copy name
        get hero name&#40;0, slot&#41;
        set hero name&#40;0, skelly&#41;

        swap by position &#40;slot, skelly&#41;
        # &#40;Assume non-skeleton heroes are never duplicate, otherwise need same trick as before&#41;
        delete hero&#40;hero&#41;  # bye bye
      &#41;
    &#41;
  &#41;
end
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

TMC wrote:Here you go. Unlike Sword, I didn't test it.
:kamina:
"Imagination. Life is your creation."
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6461
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

Nate... did it work for you?
Post Reply