• 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.

How to build Morale System in VJass with Tactical Retreat Ability

Status
Not open for further replies.
Level 12
Joined
Dec 25, 2010
Messages
972
Morale is how the mind of a soldier is being affected by the battlefield around him/her, In Dawn of War that is represented by a blue number below the squad's health points once it is depleted they lose effectiveness, that is how i envision the system
 
Level 4
Joined
Apr 14, 2014
Messages
98
First "Help" Post

This is my first "help" post, ever. So don't get upset that I have no idea what I'm talking about. Actually, I just wanted to do this because it seemed like fun and a challenge that no one else wanted to do.

This script will make Red's units run to a random point on the map when their morale goes below 10. All you need to do is kill one unit to test this.

This is the first thing I've ever made, so don't be mad that it's no good. Test it out and see if you like it.

It's super newbie, I know. :goblin_cry:

JASS:
function Trig_MoraleDownRed_Func002C takes nothing returns boolean
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return true
    endif
    return false
endfunction

function Trig_MoraleDownRed_Conditions takes nothing returns boolean
    if ( not Trig_MoraleDownRed_Func002C() ) then
        return false
    endif
    return true
endfunction

function Trig_MoraleDownRed_Func001C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return false
    endif
    return true
endfunction

function Trig_MoraleDownRed_Actions takes nothing returns nothing
    if ( Trig_MoraleDownRed_Func001C() ) then
        set udg_RedPlayerMorale = ( udg_RedPlayerMorale - 1 )
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_MoraleDownRed takes nothing returns nothing
    set gg_trg_MoraleDownRed = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_MoraleDownRed, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_MoraleDownRed, Condition( function Trig_MoraleDownRed_Conditions ) )
    call TriggerAddAction( gg_trg_MoraleDownRed, function Trig_MoraleDownRed_Actions )
endfunction

JASS:
function Trig_MoraleUpRed_Func002C takes nothing returns boolean
    if ( ( GetOwningPlayer(GetKillingUnitBJ()) == Player(0) ) ) then
        return true
    endif
    return false
endfunction

function Trig_MoraleUpRed_Conditions takes nothing returns boolean
    if ( not Trig_MoraleUpRed_Func002C() ) then
        return false
    endif
    return true
endfunction

function Trig_MoraleUpRed_Func001C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(1) ) ) then
        return false
    endif
    return true
endfunction

function Trig_MoraleUpRed_Actions takes nothing returns nothing
    if ( Trig_MoraleUpRed_Func001C() ) then
        set udg_RedPlayerMorale = ( udg_RedPlayerMorale + 1 )
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_MoraleUpRed takes nothing returns nothing
    set gg_trg_MoraleUpRed = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_MoraleUpRed, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_MoraleUpRed, Condition( function Trig_MoraleUpRed_Conditions ) )
    call TriggerAddAction( gg_trg_MoraleUpRed, function Trig_MoraleUpRed_Actions )
endfunction

JASS:
function Trig_RetreatRed_Conditions takes nothing returns boolean
    if ( not ( udg_RedPlayerMorale < 10 ) ) then
        return false
    endif
    return true
endfunction

function Trig_RetreatRed_Func001A takes nothing returns nothing
    call IssuePointOrderLocBJ( GetEnumUnit(), "move", GetRandomLocInRect(GetPlayableMapRect()) )
endfunction

function Trig_RetreatRed_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(0)), function Trig_RetreatRed_Func001A )
endfunction

//===========================================================================
function InitTrig_RetreatRed takes nothing returns nothing
    set gg_trg_RetreatRed = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_RetreatRed, Player(0), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_RetreatRed, Condition( function Trig_RetreatRed_Conditions ) )
    call TriggerAddAction( gg_trg_RetreatRed, function Trig_RetreatRed_Actions )
endfunction
 

Attachments

  • morale.w3x
    18.8 KB · Views: 32
  • moralesystem.w3x
    18.1 KB · Views: 32
Level 28
Joined
Sep 26, 2009
Messages
2,520
Morale is how the mind of a soldier is being affected by the battlefield around him/her, In Dawn of War that is represented by a blue number below the squad's health points once it is depleted they lose effectiveness, that is how i envision the system
I know what morale is, but again, you don't give us any info about how it should work, except that in the game you saw it in it was represented by blue number.

I've seen "morale" systems in various games and they each worked differently.
You can't expect people to point you in the right direction or help you, if you provide nothing but vague informations.
You should have some basic concept on how it should work - how does it increase? Or decrease? Does it only do the one or the other? Or both? If I have low morale, what does it mean to me? If I have none, what happens? etc.


Based on all you said, you can increase morale of units nearby enemy unit that is killed; or decrease morale of nearby units if their allied unit dies. You can simply catch the event "unit dies" and pick all nearby units with it. You can save morale of each unit in hashtable. When you decrease/increase morale, you can check the amount and do things which should happen when you reach this "morale amount".


---

As a side note, I'm not too sure it will be possible to represent it with numbers. In WCIII, these would be "floating text", but I think floating text is limited that there can be a maximum of 100 floating texts in the game at once (unless this can increased by using GetLocalPlayer() function, but someone more experienced would have to confirm it)
 
Level 12
Joined
Dec 25, 2010
Messages
972
Thanks for the help guys

@loxie: thanks for your time to try to help me
@IcemanBo: I want to build this script but I need help
@Nichilus: It increases over time slowly (+1 per 3 or 4 seconds) or at a little faster rate at the Presence of a Hero (+1 Per 2 seconds), It Decreases when the unit takes damage (-3 per damage) and when a unit dies near the unit under attack, it suffers a medium level morale drop (-25 points per death), if it is at low morale, then the unit can still fight, if it is at zero, Massive Debuff to the Unit (-9 points to all Atributes
 
Status
Not open for further replies.
Top