Author Topic: Surrendering  (Read 396 times)

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Surrendering
« on: January 19, 2016, 08:08:01 am »


               This is a response to mlshuford14, who wrote "Is there a way during encounters to have my enemies top fighting once they reach a certain hit point? Almost like a surrender?".

First, flag the creature as Immortal, so that their HP never falls below 1, regardless of damage taken, and put them in a local faction (one with the Global box unchecked).

There are various ways of managing surrender. I find the following to be robust, for Single Player.

In the OnDamaged event
 
if (GetCurrentHitPoints() < 10)  // or whatever arbitrary value you like          
  {
    bhCeaseFire(GetFirstPC());
  }
The function definition is

   Spoiler
   



You may want to set the plot flag on the creature, to prevent renewed attacks by the player.

If you then want the creature to talk to the player, use ClearAllActions(TRUE) on the player before ActionStartConversation, otherwise the combat state will cause the conversation to fail. Alternatively, a floating string "I surrender" or whatever will do.

Stopping battles with multiple enemies is more tricky. In theory, have each of them call bhCeaseFire. In practice, it may be necessary to repeat after 1 second or so. I suspect this is because there are combat actions and shouts in the pipeline that don't always get cancelled by the first attempt.
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Surrendering
« Reply #1 on: January 19, 2016, 01:35:17 pm »


               

@proleric something seems to have eaten the newlines from you code snippets. As they are they won't do much '<img'>



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Surrendering
« Reply #2 on: January 19, 2016, 04:54:00 pm »


               

@proleric something seems to have eaten the newlines from you code snippets. As they are they won't do much '<img'>

Thanks. Should be OK now.