(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Resources > Submissions

Submissions Submit JASS resources! If approved, they will be moved to their proper section.
Please read me first.

Reply
 
LinkBack Thread Tools Display Modes
Old 09-14-2008, 11:08 PM   #1 (permalink)
 
SerraAvenger's Avatar

How may I serve you?
 
Join Date: Apr 2007
Posts: 100

SerraAvenger has little to show at this moment (3)


Bounty System

The Bounty System

Replaces the Blizzard bounty.
Features:
  1. Bounty can be changed during gameplay
  2. Players are able to give/recieve only a certain percentage of the original bounty
  3. You are able to react to the bounty event with some nice functions
  4. Absolutely efficient due to Hashtable implementation

Functions:
// set a unittype's bounty to min-max
SetUnitTypeBounty( integer unittypeid, integer min, integer max )
// set a player's received and gived bounty to gain% and give%
 // 1 = 100%, 0.5 = 50% and 0 = 0%
SetPlayerBounty( integer playerid, real give, real gain )
// The trigger toregister will fire whenever a unit gives bounty:
TriggerRegisterBountyEvent( trigger toregister )
// Functions that can be used with the TriggerRegisterBountyEvent:
 // NOTE: They are not wait resistant!
// The unit that died and gave the bounty - unit
GetBountyUnit()
 // The amount of bounty, with player gain and give allready comuted - integer
 GetTriggerBounty()
// The player that got the bounty - player
GetBountyPlayer()
// The owner of BountyUnit - player
GetBountyGiver()

REQUIREMENTS:
JassPack NewGen
My Utilities Library
My Hashtable Library
My UnitAttacher Library

ToDo:
Upload my hashtable here, too :P

Code

// SPECIAL THANKS: Tom_Kazansky for his incredible wisdom concerning the creation of texttags ; )
/////// VER 00
globals
    // Set To false if you want to add bounty on your own way.
    constant boolean AUTO_ADD_BOUNTY = true
endglobals


 //! runtextmacro AddUnitValue( "BountyMax", "integer", "0" )
 //! runtextmacro AddUnitValue( "BountyMin", "integer", "0" )


library BountySystem initializer InitBountySystem needs Hash, Utilities, BountyMinAttacherUnit, BountyMaxAttacherUnit
 globals
      private constant real DefaultGainValue = 1.0 // 1 = 100%; 0.5 = 50%
      private constant real DefaultGiveValue = 1.0

      private real array PlayerBountyGive
      private real array PlayerBountyGain

      private integer Bounty = 0
      private unit BountyGiver = null
private player BountyGetter = null
      private player BountyGiverOwner = null
      private constant trigger BountyTrigger = CreateTrigger()

private trigger array AttachedTrigger
      private integer AttachedTriggerNum = -1
      private constant trigger TriggerHandler = CreateTrigger()
              constant integer PLAYER_BOUNTY_GIVE = -1
constant integer PLAYER_BOUNTY_GAIN = 1
 endglobals


function GetBountyUnit takes nothing returns unit
     return BountyGiver
 endfunction

function GetTriggerBounty takes nothing returns integer
     return Bounty
 endfunction

 function GetBountyPlayer takes nothing returns player
return BountyGetter
 endfunction

 function GetBountyGiver takes nothing returns player
     return BountyGiver
endfunction

 function TriggerRegisterBountyEvent takes trigger toregister returns nothing
     set AttachedTriggerNum = AttachedTriggerNum + 1
     set AttachedTrigger [ AttachedTriggerNum ] = toregister
 endfunction

 function SetPlayerBounty takes integer playerid, real give, real gain returns nothing
     set PlayerBountyGive[ playerid ] = give
     set PlayerBountyGain[ playerid ] = gain
 endfunction

 function GetPlayerBounty takes integer playerid, integer bountytype returns real
if bountytype == PLAYER_BOUNTY_GIVE then
         return PlayerBountyGive[ playerid ]
     elseif bountytype == PLAYER_BOUNTY_GAIN then
         return PlayerBountyGain[ playerid ]
     endif
     return 0.0
 endfunction

 private function GetUnitTypeBounty takes integer unittypeid returns integer
     return GetRandomInt( GetUnitTypeBountyMin( unittypeid ), GetUnitTypeBountyMax( unittypeid ) )
 endfunction

 function SetUnitTypeBounty takes integer unittypeid, integer min, integer max returns nothing
     call SetUnitTypeBountyMin( unittypeid, min )
     call SetUnitTypeBountyMax( unittypeid, max )
 endfunction

 private function TriggerHandler_Actions takes nothing returns nothing
             local integer loopIndicator = 0
             local unit trigUnit = GetTriggerUnit ( )
             local integer trigUnitID = GetUnitTypeId ( trigUnit )
             local integer bounty = GetUnitTypeBounty( trigUnitID )
             local player bountyPlayer = GetOwningPlayer ( GetKillingUnit() )
             local player bountyGiver = GetOwningPlayer ( trigUnit )

             set Bounty = bounty
             set BountyGetter = bountyPlayer
             set BountyGiver = trigUnit
             set BountyGiverOwner = bountyGiver

             if IsPlayerEnemy( BountyGiverOwner, BountyGetter ) then
                 loop
                     exitwhen loopIndicator > AttachedTriggerNum
                     if TriggerEvaluate( AttachedTrigger[ loopIndicator ] ) then
                        call TriggerExecute( AttachedTrigger[ loopIndicator ] )
                     endif
                     set loopIndicator = loopIndicator + 1
                 endloop

            endif
            set trigUnit = null
         endfunction







 private function BountyTrigger_Actions takes nothing returns nothing
             local integer bountyAmount = GetTriggerBounty( )
             local unit bountyUnit = GetBountyUnit ( )
             local player bountyPlayer = GetBountyPlayer ( )


             local player bountyGiver = BountyGiverOwner
             local integer bountyPlayerId = GetPlayerId ( bountyPlayer )
             local integer bountyGiverId = GetPlayerId ( bountyGiver )



             set bountyAmount = R2I( bountyAmount * PlayerBountyGive[ bountyGiverId ] * PlayerBountyGain[ bountyPlayerId ] )

             call CreateBountyText( bountyAmount, bountyUnit, bountyPlayer )


             call SetPlayerState ( bountyPlayer, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState( bountyPlayer, PLAYER_STATE_RESOURCE_GOLD ) + bountyAmount )
             call SetPlayerState ( bountyPlayer, PLAYER_STATE_GOLD_GATHERED, GetPlayerState( bountyPlayer, PLAYER_STATE_GOLD_GATHERED ) + bountyAmount )


             set bountyUnit = null
         endfunction

 private function InitBountySystem takes nothing returns nothing
             local integer playerIndex = 0
             call TriggerRegisterAnyUnitEventBJ( TriggerHandler, EVENT_PLAYER_UNIT_DEATH )
             call TriggerAddAction ( TriggerHandler, function TriggerHandler_Actions )

             loop
                 exitwhen playerIndex > NUMPLAYERS
                 set PlayerBountyGive[ playerIndex ] = DefaultGiveValue
                 set PlayerBountyGain[ playerIndex ] = DefaultGainValue
                 set playerIndex = playerIndex + 1
             endloop

             // Please outcomment the following two lines if you do not want to distribute bounty as usually!
             if AUTO_ADD_BOUNTY then
                call TriggerRegisterBountyEvent ( BountyTrigger )
                call TriggerAddAction ( BountyTrigger, function BountyTrigger_Actions )
             endif

         endfunction
endlibrary

__________________
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Last edited by SerraAvenger; 09-20-2008 at 03:54 PM..
SerraAvenger is offline   Reply With Quote
Old 09-16-2008, 11:10 AM   #2 (permalink)
 
scorpion182's Avatar

It's Show Time!
 
Join Date: Jun 2008
Posts: 225

scorpion182 has little to show at this moment (33)scorpion182 has little to show at this moment (33)scorpion182 has little to show at this moment (33)scorpion182 has little to show at this moment (33)


any example map?
__________________
scorpion182 is offline   Reply With Quote
Old 09-20-2008, 03:53 PM   #3 (permalink)
 
SerraAvenger's Avatar

How may I serve you?
 
Join Date: Apr 2007
Posts: 100

SerraAvenger has little to show at this moment (3)


Quote:
Originally Posted by scorpion182 View Post
any example map?
Here:
With -toggle, you can toggle how the bounty for heroes will be computed:
Either 100, or 100 + 20 * Herolevel.
( AUTO_ADD_BOUNTY has been set to false for this purpose. If you set it to true, it will automatically compute and add bounty, which might end in adding bounty twice. )

This is just to show what the system can do. If you just want to use the normal system, only 1 line is needed per unit you want to spawn bounty.

Greetings, Davey
Attached Files
File Type: w3x TEstmap.w3x (42.8 KB, 5 views)
__________________
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
SerraAvenger is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bounty System underscore "Graveyard" 9 07-02-2008 03:55 AM
[Solved] Bounty Help El_Suave World Editor Help Zone 8 03-25-2008 02:34 PM
Need some Bounty Help Ardnived World Editor Help Zone 9 10-26-2007 12:00 AM
bounty x-Metal-x Map Development 2 04-11-2006 11:40 PM
Bounty help ADemonWarlord Map Development 2 08-22-2004 01:33 AM

All times are GMT. The time now is 09:20 AM.






Your link here 
Problem Mortgage | Debt Consolidation | Loans | Loans | Mortgage Calculator
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle