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

Creep Drop v1.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
It is the item drop system.


v1.0 - first upload (14.10.2011)


To add new:
[jass=system code]
call .add(creep id,chance variant 1,chance variant 2,general item,bonus item 1, bonus item 2)
[/code]

To remove
[jass=system code]
call .remove(creep id)
[/code]

+ Easy setting
+ Creep can be removed from list and items dont drop from it
+ Work :)


[jass=system code]
library CreepDrop

/**********************************************
____________________________________________________
| Creep Drop v 1.0 |
| Required: |
| JNPG and JassHelper |
|___________________________________________________|
____________________________________________________ SYSTEM
| Imporitng |
| 1. Copy folder | BY
| 2. Paste it in your map |
| 3. Write somewhere my nick | OXYGEND
|___________________________________________________|
____________________________________________________ Creep Drop v 1.0
| Information |
| 1. Easy setting |
| 2. No leak and bugs (sort of) |
| 3. Want to be approved in HiveWorkShop.com :) |
|___________________________________________________|

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

globals
/*
_________________
| Setting |
|________________|

*/

private constant boolean EnableSystem = true
private constant boolean ShowChance = true

/*
_________________
| Other |
|________________|

*/

private integer array CreepId
private real array MinChance
private real array MaxChance
private integer array DropItem
private integer array DropItemBonus1
private integer array DropItemBonus2
private integer current = 0
endglobals

struct dropData

static integer id
static unit Die
static unit Killer

static method add takes integer cid, real min, real max, integer itid, integer idbon1, integer idbon2 returns nothing
set CreepId[current] = cid
set MinChance[current] = min
set MaxChance[current] = max
set DropItem[current] = itid
set DropItemBonus1[current] = idbon1
set DropItemBonus2[current] = idbon2
set current = current + 1
endmethod

static method remove takes integer cid returns nothing
local integer index = 0

loop
exitwhen index > current
if cid == CreepId[index] then
set CreepId[index] = 0
set MinChance[index] = 0.00
set MaxChance[index] = 0.00
set DropItem[index] = 0
set DropItemBonus1[index] = 0
set DropItemBonus2[index] = 0
return
endif
set index = index + 1
endloop

endmethod

private static method GenChance takes nothing returns nothing // Generate algorithm
local integer rnd1 = 0
local real rnd2 = 0.00
local real rnd3 = 0.00
local real Bns1 = 0.00
local real Bns2 = 0.00
local real chance = 0.00
local real x = GetUnitX(.Die)
local real y = GetUnitY(.Die)

set rnd1 = GetRandomInt(0, 1)

if rnd1 == 0 then
set chance = MinChance[.id]
else
set chance = MaxChance[.id]
endif

set rnd2 = GetRandomReal(0.00, chance)
set rnd3 = GetRandomReal(0.00, 100.00)

static if ShowChance then
call DisplayTimedTextToPlayer(Player(GetPlayerId(GetOwningPlayer(.Killer))),0.00,0.00,5.00,"|cFFFF0000You get chance|r [|cFF00C000genral|r] "+R2S(rnd3)+" |cFFFF0000out|r "+R2S(rnd2))
endif

if rnd3 <= chance then

call CreateItem(DropItem[.id], x, y)
set rnd2 = GetRandomReal(0.00, chance/2)
set Bns1 = GetRandomReal(0.00, 100.00)

static if ShowChance then
call DisplayTimedTextToPlayer(Player(GetPlayerId(GetOwningPlayer(.Killer))),0.00,0.00,5.00,"|cFFFF0000You get chance|r [|cFF00C000bonus 1|r] "+R2S(Bns1)+" |cFFFF0000out|r "+R2S(rnd2))
endif

if rnd3 > Bns1 then
call CreateItem(DropItemBonus1[.id], x, y)
endif

set rnd2 = GetRandomReal(0.00, chance/4)
set Bns2 = GetRandomReal(0.00, 100.00)

static if ShowChance then
call DisplayTimedTextToPlayer(Player(GetPlayerId(GetOwningPlayer(.Killer))),0.00,0.00,5.00,"|cFFFF0000You get chance|r [|cFF00C000bonus 2|r] "+R2S(Bns2)+" |cFFFF0000out|r "+R2S(rnd2))
endif

if rnd3 > Bns2 then
call CreateItem(DropItemBonus2[.id], x, y)
endif

endif

endmethod

private static method drop takes nothing returns nothing // event action
local integer index = 0
local boolean continue = false

set .Die = GetDyingUnit()
set .Killer = GetKillingUnit()

loop
exitwhen index > current

if GetUnitTypeId(.Die) == CreepId[index] then
set .id = index
set continue = true
endif

set index = index + 1
endloop

if continue == true then
call .GenChance()
endif

endmethod

private static method InitDrop takes nothing returns nothing // death event
local integer index
local trigger trig = CreateTrigger()
static if EnableSystem then
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_DEATH , null)

set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
endif
call TriggerAddAction( trig, function thistype.drop )
endmethod

implement Init

endstruct


endlibrary
[/code]


P.S add drop module you can see into the map


item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system,item drop system


Keywords:
Drop,system,creep,die,death,vjass,jass,OxygenD
Contents

Creep Drop v1.0 (Map)

Reviews
18th Oct 2011 Bribe: This still needs a lot of work, like I said, refer to the Triggers / Scripts forum to make this better. This isn't even worth submitting in its current state.

Moderator

M

Moderator

18th Oct 2011
Bribe: This still needs a lot of work, like I said, refer to the Triggers / Scripts forum to make this better. This isn't even worth submitting in its current state.
 
More things:

- This looks more like copied Blizzard stuff with some useless variables as well.
- What happened to the indentation? It's totally wrong.
- What is this "module Init"? It is found nowhere.
- Player(GetPlayerId(GetOwningPlayer(.Killer))) find the redundancy.
- The naming convention is all screwy. "dropData" for the struct name?
- IPool would be a better choice here for handling drops, and it is more flexible.
 
Level 6
Joined
Dec 10, 2010
Messages
119
More things:

- This looks more like copied Blizzard stuff with some useless variables as well.
- What happened to the indentation? It's totally wrong.
- What is this "module Init"? It is found nowhere.
- Player(GetPlayerId(GetOwningPlayer(.Killer))) find the redundancy.
- The naming convention is all screwy. "dropData" for the struct name?
- IPool would be a better choice here for handling drops, and it is more flexible.

- This looks more like copied Blizzard stuff with some useless variables as well.

._.

- What happened to the indentation? It's totally wrong.
i am not understand

- What is this "module Init"? It is found nowhere.

second trigger

- The naming convention is all screwy. "dropData" for the struct name?
and what?
 
This needs a lot of work. You can ask for help improving it in the Triggers / Scripts forum. I simply do not have the time to go into a significant amount of detail on this one for you, only to say the general ideas of where you need to improve.

A public module in a seperate library cannot be named "Init". It needs to be a module named something relevant to the library you have yourself. And the module shouldn't be in a seperate library in the first place.

http://www.hiveworkshop.com/forums/triggers-scripts-269/

I am referring you to this forum as well because you apparently don't get what I'm saying. Maybe we should get someone to explain to you in your native language.
 
Top