• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Morale system

Status
Not open for further replies.
Level 12
Joined
Jun 1, 2010
Messages
748
I want to base morale system on mana. When the general (hero) is alive, all units have full morale, but when the general dies all units will not have full mana. When units fight without general, when example Player 4 units are killed, units will lose 5 mana per kill, when they kill Player 5 units, the enemy will also lose mana and Player 4 gains mana.

I do not know how to make the mana gradually lose when a unit is killed, also when the general is alive the mana should get regeneration and when general dies there is no mana regeneration.

Finally when there is 0 mana I need the units to flee. Simply by fleeing the units will lose hitpoints and are prone to defeat. When the mana is 0 (or maybe unit's mana is less than 1) I would want to have a surrender buff on units to signify that they are routing. When the general is revived mana is back to 100% and can be decreased if own's units are killed.
 
Level 12
Joined
Jun 1, 2010
Messages
748
1.There is no mana loss when the general is alive, when general is dead all units lose 5 mana per player 4 kill and gain 5 mana per enemy kill.
2.They should get a buff surrender flag, but not lose hp because they would already lose hitpoints by fleeing and not striking back, they just flee and when their mana is more than 0 they will stop fleeing.
3.Of course and the killed loses mana.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,220
note that it only works for player red in the loop trigger you need to modify it

  • setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Array=player number --------
      • Set MS_general[1] = Your_unit
      • Set MS_mana_gain = 10.00
      • Set MS_mana_lost = 1.00
  • modify
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to MS_general[(Player number of (Triggering player))]
        • Then - Actions
          • Set MS_constant_loss[(Player number of (Triggering player))] = True
        • Else - Actions
      • Unit - Set mana of (Killing unit) to ((Mana of (Picked unit)) + MS_mana_gain)
  • loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MS_constant_loss[1] Equal to True
            • Then - Actions
              • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - MS_mana_lost)
            • Else - Actions
 
Level 12
Joined
Jun 1, 2010
Messages
748
Are you sure about Your_unit? When I set MS_general [1] = Value, it does not show the variable Your_unit, because MS_general is a unit variable and Your_unit is a boolean. How to fix this?

Should Your_unit variable be a unit variable type because it signifies a unit?

I think the morale system does not function well. The MS_mana_gain and lost are set to 10. But to flee the unit should have 0 mana. Instead of losing mana when owned units are killed the mana of one is set to 10. So this is a mistake, there should be something that decreases 10 mana per owned units are being killed. I think you missed the main point of the system, to make units flee. I have seen no trigger that does that.
It should be, if a unit's mana is 0, then order all unit controlled by Player 1 who have 0 mana to flee.
 
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
Are you sure about Your_unit? When I set MS_general [1] = Value, it does not show the variable Your_unit, because MS_general is a unit variable and Your_unit is a boolean. How to fix this?

Should Your_unit variable be a unit variable type because it signifies a unit?

I think the morale system does not function well. The MS_mana_gain and lost are set to 10. But to flee the unit should have 0 mana. Instead of losing mana when owned units are killed the mana of one is set to 10. So this is a mistake, there should be something that decreases 10 mana per owned units are being killed. I think you missed the main point of the system, to make units flee. I have seen no trigger that does that.

Your_unit was meant to be an example, he meant that you can have any unit variable or specified unit in there.

It should be, if a unit's mana is 0, then order all unit controlled by Player 1 who have 0 mana to flee.

If this is what you want then it's as simple as:
  • Check Mana
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_loc = (Random point in (Playable map area))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Equal to (==) 0.00
            • Then - Actions
              • Unit - Order (Picked unit) to Move To Temp_loc
              • Custom script: call RemoveLocation(udg_Temp_loc)
            • Else - Actions
This will check every 1 seconds if player 1 has any units with 0 mana. If he/she does that unit will move to a random location within the map.
You can alter this to your likings ofcourse, and you can probably use a custom unit group in order to not make the units constantly move to different locations every second.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
No error, just trigger Hashjie posted does not work.

That's odd, because for me it does work...
You might be doing something wrong.

By saying it does not work, could you be more specific?
Are the units not walking towards random locations every 1 second when they have 0 mana and are owned by player 1?

I changed that and it is not working.

I do not understand why
MS mana gain= 10
MS mana lost = 10
is setted to 10 and when mine units die, one unit has 10 mana, but it should lose 10 mana per one of mine units is killed!

Eerm well that's completely different then my trigger :S
All my trigger is doing is randomly move a unit if it is owned by player 1 and if it has 0 mana...
Are you refferencing this trigger perhaps?

  • modify
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to MS_general[(Player number of (Triggering player))]
        • Then - Actions
          • Set MS_constant_loss[(Player number of (Triggering player))] = True
        • Else - Actions
          • Unit - Set mana of (Killing unit) to ((Mana of (Picked unit)) + MS_mana_gain)
If so then you might want to closely look what this part does:
  • Unit - Set mana of (Killing unit) to ((Mana of (Picked unit)) + MS_mana_gain)
This sets the mana of the unit who killed the dying unit to be the mana of picked unit (there is no picked unit) + 10.

Could you please explain what exactly you mean with:
is setted to 10 and when mine units die, one unit has 10 mana, but it should lose 10 mana per one of mine units is killed!
I really, really can't make sense of what you're trying to say here.

Which units should have how much mana lost?

Who is one unit?

Explain this more thoroughly and I would be abled to help you out.

You might also want to use completely different triggers then Darkgrom's suggested.
No offense, but they have a few mistakes and can be done more efficiently.

EDIT: I didn't read this post:

1.There is no mana loss when the general is alive, when general is dead all units lose 5 mana per player 4 kill and gain 5 mana per enemy kill.
2.They should get a buff surrender flag, but not lose hp because they would already lose hitpoints by fleeing and not striking back, they just flee and when their mana is more than 0 they will stop fleeing.
3.Of course and the killed loses mana.

There are a few questions I would like to ask:

when general is dead all units lose 5 mana per player 4 kill and gain 5 mana per enemy kill.

Are you trying to say that whenever the general is dead all units will loose 5 mana for each missing (killed) units inside the unit group of that player?
An example would be: A unit gets killed and is owned by a player, if the general is dead at that moment. All units of the player who owned the killed unit should loose 5 mana, is that it?
And they all gain back 5 mana for killing other units?

They should get a buff surrender flag
Don't you mean a special effect? What is the point of having a buff if it doesn't do anything?

and the killed loses mana
How can a killed unit loose mana? It's dead...
 
Last edited:
Level 12
Joined
Jun 1, 2010
Messages
748
I really, really can't make sense of what you're trying to say here.

The mana of one alive mine controlled unit is setted to 10 when one one of mine unit dies in the trigger, but it should lose 10 mana (unit has 100 mana example) not to have 10 mana, but lose like 90 then 80 if another mine unit dies.

Which units should have how much mana lost?

The unit which is alive and controlled by me (it loses mana if some mine united is killed) it should lose 10 mana (mine unit killed 100-10=90 another one 80-10=70 till it reaches 0 and starts to flee)

Are you trying to say that whenever the general is dead all units will loose 5 mana for each missing (killed) units inside the unit group of that player?
An example would be: A unit gets killed and is owned by a player, if the general is dead at that moment. All units of the player who owned the killed unit should loose 5 mana, is that it?
And they all gain back 5 mana for killing other units?

Actually ignore that, I have a different idea now. It does not have to do with depending on general. A 1 alive mine controlled units lose 10 mana if one of mine unit is killed. No matter if the general is alive or dead.

Don't you mean a special effect? What is the point of having a buff if it doesn't do anything?

Yes, attached to the fleeing unit.

How can a killed unit loose mana? It's dead...

It is a mistake, the alive unit which is mine loses mana if a mine unit is killed.

---

I have a new idea about the role of the general. The role of General would be to heal units who lost mana (like a moon well). If it is near those units. The ability is auto heal. Thus totally preventing unit flee.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
The mana of one alive mine controlled unit is setted to 10 when one one of mine unit dies in the trigger, but it should lose 10 mana (unit has 100 mana example) not to have 10 mana, but lose like 90 then 80 if another mine unit dies.

What is a mine unit? Or do you mean a unit controlled by you?
So basically what you're saying is: Every unit you controll has 100 mana and whenever one of your controlled units dies 10 mana needs to be extracted from all of your controlled units who are still alive?

I can't seem to understand your english, it's like a big riddle :S


The unit which is alive and controlled by me (it loses mana if some mine united is killed) it should lose 10 mana (mine unit killed 100-10=90 another one 80-10=70 till it reaches 0 and starts to flee)

Does this count for all units controlled by you or just one specific unit?

Actually ignore that, I have a different idea now. It does not have to do with depending on general. A 1 alive mine controlled units lose 10 mana if one of mine unit is killed. No matter if the general is alive or dead.

So whenever 1 of your controlled units die all your other controlled units who are still alive will loose 10 mana. Right?

Then you could do something like this:

  • Unit mana
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to (==) (Player((Integer A)))
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Player((Integer A)))) and do (Actions)
                • Loop - Actions
                  • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - 10.00)
            • Else - Actions
Whenever a unit dies it checks if the owner of that unit equals player 1-12
if it does, all units of the player who owned the unit that died will loose 10 mana.

And of course you can add whatever conditions you need...

Also: my triggers might look slightly different then that of others since I'm using JNGP.
But I'm sure that you can find the actions corresponding to mine. It looks almost exactly the same.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Erm yeah I did, a few posts back...

  • Check Mana
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_loc = (Random point in (Playable map area))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Equal to (==) 0.00
            • Then - Actions
              • Unit - Order (Picked unit) to Move To Temp_loc
              • Custom script: call RemoveLocation(udg_Temp_loc)
            • Else - Actions
But what do you mean with flee?
Because right now only the units of player 1 who have 0 mana will walk to a random point every 1 second, causing them all to wonder around to the same point instead of fleeing.
If you want a good flee system you might want to make sure that the units walk away from the attacking units to at least a specific range. This would make it look more natural...

If you want I can create something like that for you, but you have to specify what you mean with flee.
(Yes I know that you want them to run away, but in what direction? How far? When should they stop running? There are a lot of questions to ask here...)
First figure out how you want it to behave and then ask me on how to do it.
 
Level 12
Joined
Jun 1, 2010
Messages
748
Mysteriously, this completely does not work. I just get unit's mana 0 instead of making it decrease.

Four things that the trigger needs:
1.To make a alive mine unit lose 10 mana per mine unit killed
2.To make one mine unit gain 10 mana per enemy unit killed
3.Make unit that has 0 mana to flee or random point
4.Stop fleeing (random point) if mana is more than 0
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Okay, here is an example map:

See if you like it or not.

Note:
Code:
Random point is a bit messy still, but it does what it's supposed to do. 
I guess a better way would be calculating the fastest route of the distance between enemy units and allied units. 
This way the units will look more intelligent as they will try to stay out of combat instead of walk to a random point.
You would have to use some math here ^.^

This is how it works: Units will regenerate their mana by 0.10 every 1 second.
This means that after 11 seconds the units will have 1.10 mana. Which means the unit is not in the unit group anymore:
  • Set Units_Without_Mana = (Units in (Playable map area) matching (((Mana of (Matching unit)) Less than or equal to (<=) 1.00) and ((Custom value of (Matching unit)) Equal to (==) 0)))
You can change this value to whatever you want ofcourse....

The custom value of a unit will be set to 5 whenever it does have less then 1.00 mana.
This way another trigger removes 1 custom value of each unit that has more then 0 custom value every second.
Meaning that the unit will walk to a random location and after 5 seconds it's ordered to walk to a random location again.
Since it meets the requirements of the group.

Remember: after 11 seconds the unit will not randomly move to a location anymore since it has more then 1.00 mana.

The other triggers also work fine. All the units of a player will loose 10 mana when one unit of that player is killed.
And if a unit kills another unit, the killing unit will recieve 10 mana.

EDIT: I know I could've used timers instead, but I don't really care that I'm using custom values at this moment... Timers would be better though.

EDIT2: You where right my flee trigger didn't seem to work.
But now it does in the example map ;)

EDIT3:
  • Unit decrease Mana
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to (==) (Player((Integer A)))
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Player((Integer A)))) and do (Actions)
                • Loop - Actions
                  • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - 10.00)
            • Else - Actions
  • Unit Increase Mana
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Unit - Set mana of (Killing unit) to ((Mana of (Killing unit)) + 10.00)
  • Flee
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Set Units_Without_Mana = (Units in (Playable map area) matching (((Mana of (Matching unit)) Less than or equal to (<=) 1.00) and ((Custom value of (Matching unit)) Equal to (==) 0)))
      • Unit Group - Pick every unit in Units_Without_Mana and do (Actions)
        • Loop - Actions
          • Unit - Set the custom value of (Picked unit) to 5
          • Unit - Order (Picked unit) to Stop
          • Set TempLoc = (Random point in (Playable map area))
          • Unit - Order (Picked unit) to Move To TempLoc
          • Custom script: call RemoveLocation(udg_TempLoc)
  • Unit Timer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked unit)) Not equal to (!=) 0
            • Then - Actions
              • Unit - Set the custom value of (Picked unit) to ((Custom value of (Picked unit)) - 1)
            • Else - Actions
 

Attachments

  • Example Map.w3x
    20.5 KB · Views: 60
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
Erm, yes there is...
That is a fact!

You do know what mana is don't you?
It's displayed underneath the health of a unit when you select it?
And it decreases when units get killed? Or increases for a unit that kills another unit?
I've seen this with my own eyes.
There is no way you can tell me that this system is not doing what it's supposed to, for there is no doubt that this is not working.
If you wait for at least 50 seconds you'll see that the units start fleeing...


EDIT: I just downloaded the map again myself and tested it about 10 times. It does what it is supposed to.
Tell me how you come to the conclusion that it's not decreasing the mana of the footmans...

Just download the map and play it!
Don't import it into your own map and afterwards tell me that it's not working.
It might be that your map is having issues, which is not my mistake.

Sorry for getting a bit frustrated but I clearly see it working -,-"
 
Status
Not open for further replies.
Top