Demo Map GetBounty

Hellohihi

New Member
Reaction score
42
GetBounty
v1.2

Requires VJASS

What is GetBounty?
GetBounty enables you to get the bounty value of a specific unit


Why did i make this?

I made this because I badly needed a GetBounty script for my Vampirism Speed map, and i could not find one anywhere at all.
I needed it to display the amount of gold that was fed to the opposing team.
And furthermore, all the bounty value in my map does not have dices.

Alternative 1 (Best):
Requires:
Damage
Credits: Jesus4Lyf
JASS:
library DyingBounty initializer OnInit uses Damage
    globals
        private integer array LastGold
        private player TempPlayer
    endglobals
    private function OnDamage takes nothing returns boolean
        set TempPlayer=GetOwningPlayer(GetEventDamageSource())
        set LastGold[GetPlayerId(TempPlayer)]=GetPlayerState(TempPlayer,PLAYER_STATE_RESOURCE_GOLD)
        return false
    endfunction
    private function OnInit takes nothing returns nothing
        local trigger t=CreateTrigger()
        call TriggerAddCondition(t,Filter(function OnDamage))
        call Damage_RegisterEvent(t)
    endfunction
    function GetDyingBounty takes nothing returns integer
        set TempPlayer=GetOwningPlayer(GetKillingUnit())
        return GetPlayerState(TempPlayer,PLAYER_STATE_RESOURCE_GOLD)-LastGold[GetPlayerId(TempPlayer)]
    endfunction
endlibrary

Example use:
Trigger:
  • Untitled Trigger 002
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Custom script: call BJDebugMsg("Bounty on death: "+I2S(GetDyingBounty()))


Alternative 2:
Requires:
Damage
Credits: Jesus4Lyf
JASS:
library DyingBounty initializer OnInit uses Damage, AIDS
    private struct GoldStore extends array
        integer gold
        
        static method init takes nothing returns nothing
            local trigger t=CreateTrigger()
            call TriggerAddCondition(t,Filter(function thistype.onDamage))
            call Damage_RegisterEvent(t)
            set t=null // Personal habit. Aaand a good one.
        endmethod
        //! runtextmacro AIDS()
        private static method onDamage takes nothing returns boolean
            set GoldStore[GetTriggerUnit()].gold=GetPlayerState(GetOwningPlayer(GetEventDamageSource()),PLAYER_STATE_RESOURCE_GOLD)
            return false
        endmethod
    endstruct
    private function OnInit takes nothing returns nothing
        // Because those init functions on structs fire way too early.
        call GoldStore.init()
    endfunction
    
    globals
        private unit TempUnit
    endglobals
    function GetDyingBounty takes nothing returns integer
        set TempUnit=GetKillingUnit()
        
        if TempUnit==null then
            // Killed with triggers or whatever.
            return 0
        endif
        
        return GetPlayerState(GetOwningPlayer(TempUnit),PLAYER_STATE_RESOURCE_GOLD)-GoldStore[GetDyingUnit()].gold
    endfunction
endlibrary



Alternative 3:
Requires no other system

Example usage:
JASS:
call DisplayTimedTextToPlayer(player, 0. , 0., 5. , "The bounty of the last killed unit is " + I2S(GetBounty(GetUnitTypeId(GetDyingUnit() ))) )


Trigger:
JASS:

//////////////////////Get BOUNTY v2///////////////////////////////////////////////////////////////////////////////////
// How to use:
// 1. Copy and paste this trigger into your map
// 2. set the integer variable DUMMY_ID to a dummy unit ID in your map
// 3. (Optional) Set real X and Y to the coordinates that you desire
//// For real X and Y, they determined where the dummy units will be created, this does not really matters because the dummy units cannot be seen in game.
// 4. (Optional) Set BOUNTY_ACCURACY to an integer number that you desire.
//// For BOUNTY_ACCURACY, a higher number will produce a more accurate average result but will be slower, vice versa.
//// For BOUNTY_ACCURACY, you can set it to 1 if your map uses non-diced bounty.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Pros:
// 1. Does not leak, as far as i can tell
// 2. Easy implementation
// 3. Does NOT mess up the alliance between neutral hostile and victim
// 4. Does NOT mess up the gold of neutral hostile
// 5. The entire operation of the script is -Hidden- in game, the players in game will NOT see anything being created at all.
// 6. 100% accurate for non-diced bounty
// 7. You can set the BOUNTY_ACCURACY, so that it will give a rough average of diced bounty in your map.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Cons:
// 1. Inaccurate for diced bounty
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


library GetBounty
/////////////////////////////////////////////////////////
//You may edit the values below//////////////////////////
globals
private constant integer DUMMY_ID = 'n000'
private constant real X = 0.
private constant real Y = 0.
private constant integer BOUNTY_ACCURACY = 3
endglobals
//////////////////////////////////////////////////////////
//Editing of options ends here, all that is below here is the script
/////////////////////////////////////////////////////////

function GetBounty takes integer unit_id returns integer
local integer loops = 0
local integer bounty = 0
local integer originalgold = GetPlayerState(Player(PLAYER_NEUTRAL_AGGRESSIVE), PLAYER_STATE_RESOURCE_GOLD)
local unit dummyattacker = CreateUnit( Player(PLAYER_NEUTRAL_AGGRESSIVE) , DUMMY_ID, X, Y , 0. )
local unit dummyattacked

    call SetPlayerState(Player(bj_PLAYER_NEUTRAL_VICTIM) , PLAYER_STATE_GIVES_BOUNTY , 1)
        call SetPlayerAllianceStateBJ( Player(PLAYER_NEUTRAL_AGGRESSIVE), Player(bj_PLAYER_NEUTRAL_VICTIM), bj_ALLIANCE_UNALLIED )

loop
    exitwhen loops == BOUNTY_ACCURACY
    set dummyattacked = CreateUnit( Player(bj_PLAYER_NEUTRAL_VICTIM) , unit_id , X, Y , 0. ) 
    call ShowUnit(dummyattacked, false)
    call UnitDamageTarget(dummyattacker,dummyattacked,1000000000.,false,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_ENHANCED,null)
    call RemoveUnit(dummyattacked)
    set bounty = bounty + GetPlayerState(Player(PLAYER_NEUTRAL_AGGRESSIVE), PLAYER_STATE_RESOURCE_GOLD) - originalgold
    call SetPlayerState( Player(PLAYER_NEUTRAL_AGGRESSIVE), PLAYER_STATE_RESOURCE_GOLD, originalgold  )
        set loops = loops + 1
endloop

    call SetPlayerAllianceStateBJ( Player(PLAYER_NEUTRAL_AGGRESSIVE), Player(bj_PLAYER_NEUTRAL_VICTIM), bj_ALLIANCE_ALLIED )
        call SetPlayerState(Player(bj_PLAYER_NEUTRAL_VICTIM) , PLAYER_STATE_GIVES_BOUNTY , 0)
        
call RemoveUnit(dummyattacker)
set dummyattacker = null
set dummyattacked = null

set bounty = bounty / BOUNTY_ACCURACY
return bounty
endfunction
endlibrary


Changelog:
v1.2
1. No longer shows gold coin animation
2. Options to easily set for users
3. Average diced bounty
4. Neutral hostile gold no longer need to be at a constant 0
5. Neutral hostile and neutral victim does not need to be permanent enemies
 

Attachments

  • GetBounty_v1.w3x
    16.6 KB · Views: 272
  • GetBounty_v1.2.w3x
    18.9 KB · Views: 288

Jesus4Lyf

Good Idea™
Reaction score
397
How's this better than Gcsn?
It doesn't have a useless name, and this documents its cons.
Gosh, if that system had a good name...
2. Requires you to set neutral hostile and neutral victim to be enemies, and turn on bounty for neutral victim.
3. Requires neutral hostile's gold to be at a constant 0.
4. At the location where your dummy units is created, there will be the bounty gold coins animation shown. You can avoid this by setting it in custom game interface - Model - Bounty Art - Gold Credit.
All these can be removed. Try harder. :thup:
 

Sevion

The DIY Ninja
Reaction score
413
I fail to see how the name degrades it.

And I can't think of a con off the top of my head.

My statement stands.

How is this system better than Gcsn.
 

Hellohihi

New Member
Reaction score
42
How's this better than Gcsn?

Gcsn does more and is more accuate.

I never knew Gcsn existed.

Gcsn does more of other stuffs like item cost, unit cost and such.
Mine is a single solo function.

So, its up to people to take their pick.

Also, Gcsn getbounty is also not 100% accurate for the diced bounty.
It just gives an average.

I will improve mine tomorrow when i wake up, so that average bounty is more accurate.
And i will also add a GUI version of it, so that it will also be GUI friendly.

Thanks for your reply.
 

Sevion

The DIY Ninja
Reaction score
413
I said more accurate ;)

Getting an average is much better than just any random integer from a kill.
 

Hellohihi

New Member
Reaction score
42
I said more accurate ;)

Getting an average is much better than just any random integer from a kill.

I skimmed through the Gscn system.

I suppose it uses 3 results to get an average, so i'll maybe use more?
And i'll also add an option so that people can choose how many results they want to average from.
 

Sevion

The DIY Ninja
Reaction score
413
Yeh, but remember, more results == more time unless you do them simultaneously.
 

Jesus4Lyf

Good Idea™
Reaction score
397
What's this madness about taking an average?

>And I can't think of a con off the top of my head.
It returns an average, so it's useless for giving a bounty on kill?

If you call GetBounty on a unit that has a bounty involving dice, in my opinion the result had better be random! If I want to find how much bounty I should assign for a unit kill, it must take into account the random factors of the dice. As in, the result must be generated in real-time, at the moment, not be precached and it must not be some average.
And i'll also add an option so that people can choose how many results they want to average from.
Spend your time on what I said first. But this is a good idea for people who -want- an average, maybe.

Over engineering does not constitute accuracy.
And if you doubted that the name takes away from it, here's your proof:
I made this because I badly needed a GetBounty script for my Vampirism Speed map, and i could not find one anywhere at all.
>Yeh, but remember, more results == more time unless you do them simultaneously.
You can't do anything actually "simultaneously" in JASS.

@Sevion:
Gcsn also has most of the cons this has, but fails to document them. :)
 

Nestharus

o-o
Reaction score
84
Nice job Hellohihi : ).

I've been seeing a lot of systems being made for getting unit and item costs and getting bounty : O. Mine was actually the second to be made. Before mine, there was another, but it leaked : ).

Oh well, interesting stuff. The one made by MapperMalte takes up more memory and has more of a performance hit, but it can return a unit's cost + upgrades (not sure about items ^_^)

So I guess it's really up to people on what they want. There are lots of dif styles to do things, and they merit different results, so : o. However, this one is 99% the exact same as the one in Gcsn : ), and Gcsn has all of it merged because it does it all in one fell swoop for faster speeds.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Yep. I'm also happy to approve yours instead because it was submitted first and all, I guess...

And I expect you to breeze through fixing the cons. :thup:
(Store the player's gold and compare, turn bounty on for the duration of the func if it isn't, etc.)

But further Gcsn discussion belongs in Gcsn's thread. :)

As for this, I think this will probably be graveyarded (so long as Gcsn is updated appropriately).
 

Hellohihi

New Member
Reaction score
42
Updated.

All major cons are removed.

Does not show gold bounty animation at all for the dummy. (Good thing)

Added in easily customizable options for users.

Added in average result for diced bounty.

I fail to see how the name degrades it.

And I can't think of a con off the top of my head.

My statement stands.

How is this system better than Gcsn.

As for now, Gcsn get bounty shows the gold coin animation.

Mine does not.

And, mine sets the alliance and gold back to the original.
 

BloodyMary

New Member
Reaction score
0
You could use this.

OR

you can trigger bounty yourself. then call upon it when required.
which can easily be done in GUI if need be.

Edit: although this might be the quicker options for maps which aren't new. still i fail to see how this could be useful

i would like a scenario were this would come in handy.
 

Hellohihi

New Member
Reaction score
42
By the way, thanks for registering a brand new account, and replying with your first post here.

You could use this.

OR

you can trigger bounty yourself. then call upon it when required.
which can easily be done in GUI if need be.

Yes it can be easily done, but it can be very tedious if your map contains many different units and structures that has specific bounty values.

An example would be my map. It has many units and towers.
I did thought of making a table with all the bounty values, but it would end being very tedious to set up each and every single bounty value of the units and structures.

Edit: although this might be the quicker options for maps which aren't new. still i fail to see how this could be useful

i would like a scenario were this would come in handy.

A scenario where this would come in handy?

Take for example one of the very famous and widely hosted maps, vampirism fire.

In the map vampirism fire, they have a multiboard that shows how much a human has fed to the vampire in terms of unit bounty.

There you go, an example on a very famous map.
 

Jesus4Lyf

Good Idea™
Reaction score
397
In the map vampirism fire, they have a multiboard that shows how much a human has fed to the vampire in terms of unit bounty.

There you go, an example on a very famous map.
!!

This is a terrible way to trigger that! You could have a global OnDamage trigger which saves the damage source's gold before the damage is dealt, and a trigger for on death which compares it against the player's new gold value...

Way better. And accurate.

Maybe this isn't useful. o.o
 

Nestharus

o-o
Reaction score
84
Balancing a game with unbalanced teams. Based on your team size, you'd get bonus bounty : ).
 

Jesus4Lyf

Good Idea™
Reaction score
397
And in reply to Nestharus' statement, I say...
!!

This is a terrible way to trigger that! You could have a global OnDamage trigger which saves the damage source's gold before the damage is dealt, and a trigger for on death which compares it against the player's new gold value...

Way better. And accurate.
What the hell? These snippets are STILL a horrible way to do this.

I was thinking this was useful if the units DON'T give bounty (for that player) and you want to get the bounty they would give if the player gave bounty. So you can manually add it, or make the bounty give mana instead or something.

And that's it.

Question: Is this completely useless?
 

Nestharus

o-o
Reaction score
84
I dunno.. u just named an interesting use : )
I was thinking this was useful if the units DON'T give bounty (for that player) and you want to get the bounty they would give if the player gave bounty. So you can manually add it, or make the bounty give mana instead or something.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Actually, no. The only use of this is to modify the given bounty by disabling the bounty and using this to assign it - there's probably no other way to get the yellow +gold text to display correctly.

(Things like that mana suggestion should just be done with JASS and hashing the amount onto the unit type, really.)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top