Actors & enemies without Morale
#1
It has been a while since I last posted here. I’ve been using Kitsune's Extra Statistics combined with health/sp bars and such, and all works well.

I added a stat called Morale which also uses its own bar. When a battler for example has less than 25% morale this will give him/her a state with negative effects (low morale), but if a battler has more than 75% of the morale bar filled it will give a state with positive effects (high morale). A battler can lose morale by missing an enemy or losing a partymember, or can increase morale by defeating enemies and winning a battle. 

But there is a problem.


.png   1.png (Size: 727.04 KB / Downloads: 7)

There will be friends and enemies which shouldnt have a mental state, for example,  elementals, robots, zombies etc. (see where the red arrows point to in the picture). This means their state shouldnt change depending on their morale and their morale bar shouldnt show either. In fact, they shouldnt have it at all.

I tried working around it with a permanent state for those without morale called “no morale”. It sort of worked, but it quickly became a mess when I also tried removing the stat from showing for said friends/enemies inbattle.

Does anyone know what to do?
Reply }
#2
Well, the removal of the Morale bar itself could be as simple as wrapping the bar-drawing code in an if...endif block, or just adding some code before the stat is even drawn:

Examples:

First, let's assume we're dealing with a list of 'actors' and/or enemies with no Morale to work with
Code:
IGNORE_ACTOR = [2,4,6,8]
IGNORE_ENEMY = [1,5,6,12]

We can refer to these battlers at the very 'beginning' of a method like so:
Code:
  def draw_actor_morale(actor, x, y, width = 144)

    # Just exit if the battler is in an excluded list
    # (Added Enemies into the method for kicks)
    if actor.is_a?(Game_Actor)
      return if IGNORE_ACTOR.include?(actor.id)
    else
      return if IGNORE_ENEMY.include?(actor.id)
    end

    # Draw "Morale" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, "Morale")
    # Calculate if there is draw space for MaxMorale
    if width - 32 >= 108
      morale_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      morale_x = x + width - 48
      flag = false
    end
    # Draw Morale
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.morale <= actor.maxmorale / 4 ? crisis_color : normal_color
    self.contents.draw_text(morale_x, y, 48, 32, actor.morale.to_s, 2)
    # Draw MaxMorale
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(morale_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(morale_x + 60, y, 48, 32, actor.maxmorale.to_s)
    end
  end

This example merely revents the 'text' of the Morale statistic from showing when the 'draw_actor_morale' is showing, just by exiting when an inappropriate battler is detected.  I don't know if your method to draw the morale stat and the morale bar are combined in one... though that would make it SO convenient.

An increase or decrease of the morale stat could be just as simple:
Code:
# Assume morale change is permitted
    allow_morale = true

    # Test if the actor or enemy doesn't change morale
    if target.is_a?(Game_Actor)
      allow_morale = false if IGNORE_ACTOR.include?(target.id)
    else
      allow_morale = false if IGNORE_ENEMY.include?(target.id)
    end

    # Change the morale if permitted
    if allow_morale == true
      target.morale += morale_change_value
    end

Of course, this is conjecture as I don't see your code and the above clode assumes you (the developer) may pick and choose what actors and/or enemies have morale.

Winking It would be entertaining if an enemy's morale drops so badly he ESCAPES from combat!
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
#3
Just a minor correction here...

Code:
if actor.is_a?(Game_Actor)
      return if IGNORE_ACTOR.include?(actor.id)
    else
      return if IGNORE_ENEMY.include?(actor.id)
    end

You don't conjugate the verb in Ruby. Happy with a sweat
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#4
Updated. Been dealing with other coding recently.

And neglected to include a minor consideration in the second example.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
#5
Finally had time to work on the issue (wish I had more time for this).
Works properly now. Thanks!
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   A Skill that throws enemies? Bennerdeben 10 1,202 10-08-2024, 05:12 PM
Last Post: Bennerdeben
   Lycan abs - Making enemies flee on sight ChickenFetus 1 4,482 06-07-2016, 04:39 AM
Last Post: DerVVulfman
   Jumping Enemies? Bounty Hunter Lani 2 5,321 01-17-2015, 06:58 AM
Last Post: Bounty Hunter Lani
   Help with Computer controlled actors and AIBC ZeroSum 12 14,428 08-14-2013, 06:36 AM
Last Post: Ryaryu
   Possible to move battle actors when escaping? NewHope 8 13,943 07-27-2012, 06:14 AM
Last Post: NewHope
   2 or more drops from enemies -Luke- 12 14,397 03-12-2010, 02:57 AM
Last Post: fgsfds
   Getting actors name? PK8 0 4,041 07-13-2009, 06:35 PM
Last Post: PK8



Users browsing this thread: 2 Guest(s)