System Shared Bounty System

Andrewgosu

The Silent Pandaren Helper
Reaction score
715
Have you ever played a rpg in Warcraft? Surely, you have. A lot of them have "imba" heroes, heroes which get money fast and ones which don't.

The problem lies in the Warcraft bounty system: the player that kills a unit, gets the money, no matter how much damage others did to it. That's unfair if you have been killing a boss, for example, for the last 10 minutes and then comes someone else and snatches the bounty in front of your nose, isn't it?

Well, that's history! I made a system, which gives bounty to all nearby allied players. For example, player red kills a unit and his allies, teal and blue are nearby, they also receive bounty for the killed unit.

Shared Bounty System requires JASS NewGen Package.

screen-1.jpg


CHANGE LOG

ver. 1.2a
- Minor code optimizing.

ver. 1.2
- Got rid of useless BJ functions.
- Replaced constant functions with constant globals. Makes things easier to modify and to read.
- Minor code optimizing.
- Made a decent Read Me.

ver. 1.1a
- Added a handicap function in order to give more options to configure the system.
- Made sure that +0 bounty is never awarded.

ver 1.1
- Bounty art appears only overhead the victim, instead of the "killer".
- Every player sees only his personal bounty text.
- The recieved total bounty is shared amongst the players in the area equally.

ver 1.0
- First release.

Anyway, check the map, and you'll understand what I meant with this blurry description.

And here's the code for the gullible, who do not wish to download the map.

JASS:
// SHARED BOUNTY SYSTEM by ANDREWGOSU.
// ver. 1.2.

// Requires JASS NewGen Pack.

globals
    //LEAVE THESE UNCHANGED
    boolexpr ALLIE_INDICATOR
    boolean array PLAYER_INDICATOR

    //CONFIGURATION

    //SYSTEM
    constant real    RADIUS   = 756. //The radius where the gold is distributed.
    constant integer HANDICAP = 100  //The bounty handicap. E.g 50 is half the normal bounty, 200 double the normal.

    //APPEREANCE
    constant string TEXTTAG_COLOUR  = "|cffffcc00"                                //Colour code of the texttag.
    constant string BOUNTY_ART      = "UI\\Feedback\\GoldCredit\\GoldCredit.mdl"  //Model path of the bounty art.
    constant string ATTACHMENTPOINT = "overhead"                                  //Attachmentpoint of the bounty art.
    
    //TEXTTAG CONFIGURATION
    constant integer TEXTTAG_TEXTSIZE  = 11  //The size of the texttag text.
    constant real    TEXTTAG_VELOCITY  = 64. //Texttag's velocity.
    constant real    TEXTTAG_ANGLE     = 90. //Texttag's angle.
    constant real    TEXTTAG_LIFESPAN  = 5.  //Texttag's lifespan.
    constant real    TEXTTAG_FADEPOINT = 4.  //Texttag's fading point.
endglobals

// SYSTEM
function SharedBounty_Allied takes nothing returns boolean
    return (IsUnitAlly( GetKillingUnit(), GetOwningPlayer(GetFilterUnit()) ) == true)
endfunction

function SharedBounty_Gold takes integer level returns integer
    if     ( level == 1 ) then
        return GetRandomInt( 4, 6 )
    elseif ( level == 2 ) then
        return GetRandomInt( 6, 8 )
    elseif ( level == 3 ) then
        return GetRandomInt( 8, 10 )
    elseif ( level == 4 ) then
        return GetRandomInt( 11, 15 )
    elseif ( level == 5 ) then
        return GetRandomInt( 20, 26 )
    elseif ( level == 6 ) then
        return GetRandomInt( 44, 52 )
    elseif ( level == 7 ) then
        return GetRandomInt( 55, 65 )
    elseif ( level == 8 ) then
        return GetRandomInt( 76, 88 )
    elseif ( level == 9 ) then
        return GetRandomInt( 107, 121 )
    elseif ( level == 10 ) then
        return GetRandomInt( 158, 174 )
    endif
    return 0
endfunction

function SharedBounty_TextTag takes integer bounty, unit receiver returns nothing
    local texttag t          = CreateTextTag()
    local real    textHeight = TextTagSize2Height(TEXTTAG_TEXTSIZE)
    local real    vel        = TextTagSpeed2Velocity(TEXTTAG_VELOCITY)
    local real    xvel       = vel * Cos(TEXTTAG_ANGLE * bj_DEGTORAD)
    local real    yvel       = vel * Sin(TEXTTAG_ANGLE * bj_DEGTORAD)
    
    if ( GetLocalPlayer() == GetOwningPlayer(receiver) ) then
        call SetTextTagText(t, TEXTTAG_COLOUR + "+" + I2S(bounty) + "|r", textHeight)
        call SetTextTagPos( t, GetUnitX(receiver), GetUnitY(receiver), 0 )
        call SetTextTagColor( t, 0, 0, 0, 255 )
        call SetTextTagPermanent( t, false )
        call SetTextTagVelocity(t, xvel, yvel)
        call SetTextTagLifespan( t, TEXTTAG_LIFESPAN )
        call SetTextTagFadepoint( t, TEXTTAG_FADEPOINT )
        call SetTextTagVisibility( t, true )
    endif
    
    set t = null
endfunction

function SharedBounty_CreateBounty takes nothing returns nothing
    local group   g     = CreateGroup()
    local unit    a     = GetTriggerUnit()
    local integer level = GetUnitLevel(a)
    local integer i     = 0
    local integer id
    local unit    receiver
    local player  owner
    local integer amount
    local unit array receivers
    
    call DestroyEffect(AddSpecialEffectTarget(BOUNTY_ART, a, ATTACHMENTPOINT))
    loop
        exitwhen ( i == bj_MAX_PLAYERS )
        set PLAYER_INDICATOR<i> = true
        set i = i + 1
    endloop
    set i = 0
    call GroupEnumUnitsInRange( g, GetUnitX(a), GetUnitY(a), RADIUS, ALLIE_INDICATOR )
    loop
        set receiver = FirstOfGroup(g)
        exitwhen ( receiver == null )
        set owner = GetOwningPlayer(receiver)
        set id    = GetPlayerId(owner)
        if ( IsUnitType( receiver, UNIT_TYPE_HERO ) == true ) then
            if ( PLAYER_INDICATOR[id] == true ) then
                set PLAYER_INDICATOR[id] = false
                set i = i + 1
                set receivers<i> = receiver
            endif
        endif
        call GroupRemoveUnit( g, receiver )
    endloop
    call DestroyGroup(g)
    set amount = SharedBounty_Gold(level) / i * (HANDICAP / 100)
    if ( amount &lt; 1 ) then
       set amount = 1
    endif   
    loop
        exitwhen ( i == 0 )
        set owner = GetOwningPlayer(receivers<i>)
        call SetPlayerState( owner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD) + amount )
        call SharedBounty_TextTag( amount, receivers<i> )
        set receivers<i> = null
        set i = i - 1
    endloop
    
    set a        = null
    set g        = null
    set receiver = null
    set owner    = null
endfunction

function InitTrig_SharedBounty takes nothing returns nothing
    set gg_trg_SharedBounty = CreateTrigger()
    set ALLIE_INDICATOR = Condition(function SharedBounty_Allied)
    call TriggerRegisterPlayerUnitEvent( gg_trg_SharedBounty, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH, null )
    call TriggerAddAction( gg_trg_SharedBounty, function SharedBounty_CreateBounty )   
    call SetPlayerState( Player(PLAYER_NEUTRAL_AGGRESSIVE), PLAYER_STATE_GIVES_BOUNTY, IntegerTertiaryOp( false, 1, 0 ) )
endfunction</i></i></i></i></i>
 

Attachments

  • Shared Bounty System_byAndrewgosu_ver.1.2a.w3m
    18.4 KB · Views: 518

martix

There is no spoon
Reaction score
49
Seeing those globals up there perhaps its worth mentioning that you'd need JassNewGen to compile this...
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
715
Right, that was the thing I forgot. I'll upload a "regular" version, too.

Edit:

Uploaded the regular version, also.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
715
Updated the system, some minor and major changes were made (Read changelog, to find in detail).
 

emjlr3

Change can be a good thing
Reaction score
395
neat, though the idea of giving gold to allies in the area may not be the best method at attempting a shared bounty system, its still a good one at that

seeing as u use jass new gen, why have functions to get values? why not make them all globals, to make it even faster?

im not sure why you have two created triggers either, and there is currently no way for a noob to change the gold given

and there are some bjs in your text tag function :(
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
715
neat, though the idea of giving gold to allies in the area may not be the best method at attempting a shared bounty system, its still a good one at that

seeing as u use jass new gen, why have functions to get values? why not make them all globals, to make it even faster?

im not sure why you have two created triggers either, and there is currently no way for a noob to change the gold given

and there are some bjs in your text tag function :(

- Removed the useless local trigger.
- Replaced constant functions with constant globals.
- Removed the useless BJ functions.
- Optimized coding.

Thanks for feedback.
 

J3LADE

New Member
Reaction score
7
In the picture it shows 2 units of the same player getting shared gold can it be modified so that allies of the player get the gold?
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
715
Sorry, the picture is quite distracting, I'll soon change it to a better one.

This is what the system does:

When a unit is killed, which bounty is 80, and there is 3 allied heroes plus you in the defined radius from the killed unit, you and your allies get a 80/4 = 20 gold for the kill, meaning, every allie in the radius gets equal bounty. That makes training in a party more efficient.

Now, the bounty text is shown for every player individually, so everyone sees their own "+20", so, on the screenshot, only player red bounty text is shown, though his allies got money, too.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
715
3 allied heroes + yourself, too. That makes 4 players, who get an equal share.

You can try to make this is GUI, however, I'm certain you'll need custom script from that.
 

emjlr3

Change can be a good thing
Reaction score
395
looks good, sry it took so long, moved
 

waaaks!

Zinctified
Reaction score
255
is the bounty sharing can only be affected to neutrals that dies?

or every player that dies?
 

Hatebreeder

So many apples
Reaction score
381
Heeeeeeeeeeeeey, Andrew :p
A few things I'd want to point out...
First of all, this System realy brings pro-team play into a new Dimension.
But, like the Blizz System, there is a leak in the System (I'm not taking about the Code):
Say, your ally, which is much weaker, and a noob, which is realy going on your nerves, walks nearby, whilst you kill creeps, and doesn't care about your propose of hunting for Gold...
So, he gets gold for doing nothing...
Well, how about setting a constant amount of Gold * the Level of the Creep your killing.
Then, divide that constant, by the HP of the Creep, and keep it in a Variable.
It's like a piece of Cake. If you take 1/2 of the creeps HP, you gain 1/2 of the Maximum Gold, which the Creep gives.
So, your ally can't exploit you, and is forced to help you kill the Creep. You get more Gold than him, but he doesn't leave combat with empty Hands.
 
M

marcotjuhhhh

Guest
nice idea to create a system like that, you can improof your system to change the experience constant to zero, and add a code, every hero in eara, add XXX exp depending on wich unit is killed, your system is great, but can be simplyfied., no need for jass, but this is very good if you want to learn jass better, otherwise, i suggest do GUI share bounty and experience.
 

wraithseeker

Tired.
Reaction score
122
you can do the share bounty system like the one in AOM, and you can add experience too, like getting 0.xxxx exp per hit,i will like your bounty system if it was a one hit add gold system
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top