• 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 System Pack

Status
Not open for further replies.
Level 11
Joined
Jul 12, 2005
Messages
764
I'd like to advertise what I've been working on this week:

Creep System Pack
A useful collection of systems in connetion with creeps (Neutral Hostile units). These systems can be useful both in melee maps, or in custom maps that has hostile creeps (like RPGs).

1. Creep Respawn System
There were many threads about creep respawnig, so I created (I think) the best creep respawn system that can be ever made.

The advantages:
-Needs one trigger only
-Respawns creeps at their initial location with their initial facing
-Leakless
Additional/optional functions:
-The system can check if the creep respawn point is visible to a player. Creeps will respawn
if the respawn point is invisible for all players. This is useful, for example when creating
new bases near gold mines, we don't want creeps to respawn, do we?
-It can increase the number of respawned creeps exponentially.
-It can respawn random creeps chosen from the same level creeps.
-Removes corpses after spawning the new breed.

2. Creep Item Drop System
With this system, not only the initially placed, but respawned creeps will also drop items. Blizzard's item drop table does not allows this.
However, you have to assign the items manually (with one line of custom script per unit-type) at map initialization. You can set two item drop options:
-Drop a random item from the given level and class
-Drop a specific item

3. Custom Bounty System
This "powerful" bounty system works exactly how the normal one works, but it has a few useful extras:
-You can set a chance value for every unit-type to drop bounty
-You can change bounty in-game anytime
-You can disable/enable bounty gain for a specific player


Please read the instructions that I wrote for each system!
A credit would be appreciated if you use a system.
Enjoy!

If you have an idea that you want to share, an idea of a system that would fit in the pack, or you have a suggestion or a problem, don't be afraid to post it.

*UPDATED:
-Used global variables to prevent gamecache leaks.
 

Attachments

  • CreepSystemPack.w3x
    93.4 KB · Views: 412
Last edited:
Level 21
Joined
Aug 3, 2004
Messages
710
Lovely system. But might i suggest that you found a way to use globals instead of gamecache, since globals are faster, and there's a limit to Game Caches. Just a suggestion tho.

EDIT: Forgot to suggest that you could use itempool's for item drops, they're already native to wc3, and works just like normal item drops on units. Again, just a suggestion.
 
Level 21
Joined
Aug 3, 2004
Messages
710
JASS:
native CreateItemPool           takes nothing returns itempool
native DestroyItemPool          takes itempool whichItemPool returns nothing
native ItemPoolAddItemType      takes itempool whichItemPool, integer itemId, real weight returns nothing
native ItemPoolRemoveItemType   takes itempool whichItemPool, integer itemId returns nothing
native PlaceRandomItem          takes itempool whichItemPool, real x, real y returns item
Those are the itempool natives, here's a short guide to use them:

This creates an item pool, with 1/2(50%) chance of dropping item I001 and 1/2(50%) chance of dropping item I002.
JASS:
 local itempool ip = CreateItemPool()
    call ItemPoolAddItemType(ip, 'I001', 1)
    call ItemPoolAddItemType(ip, 'I002', 1)

This creates an item pool, with 1/3(33%) chance of dropping item I001 and 2/3(66%) chance of dropping item I002.
JASS:
 local itempool ip = CreateItemPool()
    call ItemPoolAddItemType(ip, 'I001', 1)
    call ItemPoolAddItemType(ip, 'I002', 2)

This creates an item pool, with 1/5(20%) chance of dropping item I001, 2/5(40%) chance of dropping item I002 and 2/5(40%) chance of dropping item I003.
JASS:
 local itempool ip = CreateItemPool()
    call ItemPoolAddItemType(ip, 'I001', 1)
    call ItemPoolAddItemType(ip, 'I002', 2)
    call ItemPoolAddItemType(ip, 'I003', 2)

As you can see it's pretty simple actually, the "weight" determines the chance of how often an item will drop. The easiest way to get the drop chance of an itempool, is to add the weight's together and divide the individual weight. Like the last example there's 1+2+2 which is 5, then 'I001' has 1 as weight, then you just do 1/5 which is 0.20, then you multiply by 100, and you have 20%.

To create an item using an itempool, you just use the PlaceRandomItem native, like this:
JASS:
 local itempool ip = CreateItemPool()
    call ItemPoolAddItemType(ip, 'I001', 1)
    call ItemPoolAddItemType(ip, 'I002', 2)
    call ItemPoolAddItemType(ip, 'I003', 2)
    call PlaceRandomItem(ip,x,y)
This will place a random item from the itempool created, and return the item created, incase you want to do something with it.

And example of using the returned item would be the following function i use in hero rewards:
JASS:
function GiveUnitRandomItem takes unit u, itempool ip returns nothing
 local item i = PlaceRandomItem(ip,0,0)
    call UnitAddItem(u,ip)
    set i = null
endfunction

Hope that helps, you seem intelligent enough to understand something like this, i just made the guide a little newbie friendly for other people reading this thread.
 
Level 11
Joined
Jul 12, 2005
Messages
764
Ok, i understand the whole itempool thing. Thx for the long explanation (+rep).
BUT, somehow, I have to attach the itempool to the unit-type! And I could only use GC for that. This way, it would be the same as my version. Also, I couldn't assign random item-types to units.
The only addition in itempools with itempools would be that you could add more items to the unit.
So, I don't think I'll change to itempools.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
BUT, somehow, I have to attach the itempool to the unit-type! And I could only use GC for that. This way, it would be the same as my version. Also, I couldn't assign random item-types to units.
Support both, then? And you use GCs anyways ><

Also, I heard somewhere (KaTTaNa I think) that just calling InitGameCache every time, and not setting it to a variable, leaks.
 
Level 21
Joined
Aug 3, 2004
Messages
710
Support both, then? And you use GCs anyways ><

Also, I heard somewhere (KaTTaNa I think) that just calling InitGameCache every time, and not setting it to a variable, leaks.

That is indeed true yes, you have to keep atleast the GameCache global, since as you said, the init everytime will cause leaks.

EDIT:
Oh, and btw, the itempool thing was just a suggestion, i know that itempool's are limited in some ways too.
 
Level 2
Joined
Aug 12, 2007
Messages
13
sorry for replying to an older topic, but i have a little question about the script.

I am working on a map with a friend, its much like dota.. just doing it for fun and we are using the creep-respawn system in our tests atm and we got a little problem.

When the creeps respawn, they act very different. You can walk near the trees where they are hidden behind and they will attack you, even if you dont see them. This doenst happen at first, only after the creeps died once..

Can you help me pleasee?

(Everything else is fine and i really love the system.. its so easy to use (especially for me, because i can do everything in gui, but the simples jass things really are to hard for me..)
 
Level 4
Joined
Aug 14, 2007
Messages
66
The system looks great but I have a question..

I am using player 12 and neutral hostile as creeps, and I have a computer thats allied to all of the players (player 11). Will the systems visibility thing be effected by players set to computers and is there a way to get it to work for player 12 as well?
 
Level 11
Joined
Jul 12, 2005
Messages
764
I don't really understand what you were saying. So you use player 12 AND neutral hostile for creeps? With some modification, it is possible to respawn other players' units, yes. To tell the truth I don't remember how I wrote the script, I have to check it. But I don't have too much time for modding nowadays... :S

To your other question about the visibility check, I'm not sure. If a computer player is near a respawn location, I don't think creeps will respawn - if this is what you're asking..
 
Level 1
Joined
Sep 30, 2007
Messages
2
Hiya

I see you havent been working on this system for awhile, but I am using it on a map im developing and for awhile all 3 systems seemed to work fine.
However when developing heroes I noticed that some (spawning) abilities prevent your system from respawning creeps on my map.

For example turning on black arrows to spawn skeletons from creeps. Not one creep on whole map will respawn after being killed by a black arrow. And I can not understand why that would be.

Your system has "EVENT_PLAYER_UNIT_DEATH" as trigger event, so I think it should trigger no matter how creeps are killed. I was thinking maybe it has something to do with number of units, since your code seems to count them:

"call GroupEnumUnitsOfPlayer(g,Player(PLAYER_NEUTRAL_AGGRESSIVE),null)"

Though its only counting neutral creeps, so the skeletons wont affect it?

Any help would be appreciated Paskovich or anyone who has a clue whats going on.....
 
Level 1
Joined
Sep 30, 2007
Messages
2
Well if you ever get around to it, try your map with a dark ranger hero. Use black arrows and no creeps will spawn. I´ve got through a few respawn systems now and they had this same problem.
Seems we cant use any monster spawning abilities with these systems=(
 
Level 4
Joined
Dec 28, 2007
Messages
9
hello)
i'm not very good in English..so excuse me for my mistakes..
---The system is very nice.. but i have some problems with it..
On clear map it works very good.But in my map it's smth incomprehensible.
I placed some creeps and heroes for test.. and spawn only heroes!
what it can be?...
Beforehand thank you.
 
Level 1
Joined
Jan 11, 2008
Messages
4
Wow! This is great! Thank you so much for this! I was working with a creep system so much more difficult then this where I would have to make 1 trigger per region with creep-group, THANK YOU!!
 
Status
Not open for further replies.
Top