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!
It’s my understanding that the player name is set for all units owned by that player. Thus you could change the name of player 12 to just 12. Or make them owned by another player and change color to brown in addition to making its name 12 too.
You could also add those units of NH you don’t want to respawn to a unit group and check if a unit is in that group before respawning it. Or give in-respawnable units a hidden ability that does nothing (and check for that ability). Or set their custom value if you’re not using that already.
I attached a map with a Drop System I threw together, it's nothing special but it seems to get the job done (hopefully bug free).
Also, I threw in a Pet System that should lead you in the right direction. It's very VERY basic and I didn't address everything you wanted but I'm all triggered out for the day. Maybe I'll work on it later.
If you have any questions on how to use something feel free to ask.
I attached a map with a Drop System I threw together, it's nothing special but it seems to get the job done (hopefully bug free).
Also, I threw in a Pet System that should lead you in the right direction. It's very VERY basic and I didn't address everything you wanted but I'm all triggered out for the day. Maybe I'll work on it later.
If you have any questions on how to use something feel free to ask.
the item drop system, is it possible to set different drops per unit type, and can it set to unit type, as the bosses dont spawn in till you enter the dungeon, so cant select unit specifically
and pet one, nice, the pet wouldnt follow me, half the time, and how i make it so it pet u buy from a shop not a unit already on the map.
the item drop system, is it possible to set different drops per unit type, and can it set to unit type, as the bosses dont spawn in till you enter the dungeon, so cant select unit specifically
I like how Uncles system is, and for use itempools, i would if i know what i was doing, i can edit a made system add items, units ect, but i have no clue what i am doing putting one together from snippets
Alright, I got excited about making this work easily and I came up with a simple system (will clean up with more comments and a demo map and submit later). AFAIK currently the unit-specific drop tables can bug out if you try to use it on a handle ID higher than 8191, but that should be resolved soon.
JASS:
library ItemPoolsEx initializer init requires Table
globals
private TableArray DropData
private constant boolean CLEAR_ON_UNIT_DEATH = true //when true, unit-specific drop table associations will be cleared for non-heroes when they die (since regular units can't be revived this should probably always be true)
private constant boolean CLEAR_ON_HERO_DEATH = false //when true, unit-specific drop table associations will be cleared for heroes when they die (you might want this to be false if heroes can be revived and you want to keep their drop table associations)
private constant boolean CLEAR_ON_UNIT_REMOVE = true //when true, unit-specific drop table associations will be cleared when a unit is removed via RemoveUnit()
constant integer NULL_ITEM = 'ZZZZ' //this item corresponds to an 'empty' drop slot. it should be an item id that NO item in your map has, or if you feel maniacal make it a junk item
//just system config variables, don't need to touch these
private constant integer KEY_COUNT = -1
private constant integer KEY_MIN = 1
private constant integer KEY_MAX = 2
private constant integer SIZE = 3
public trigger DropOnDeath = null //you can disable this to disable dropping temporarily
endglobals
struct DropTable
private itempool p = null
private group ex = null
//======
method add takes integer itemID, real weight returns nothing
call ItemPoolAddItemType(.p, itemID, weight)
endmethod
method remove takes integer itemID returns nothing
call ItemPoolRemoveItemType(.p, itemID)
endmethod
method place takes real x, real y returns item
return PlaceRandomItem(.p, x, y)
endmethod
method placeN takes real x, real y, integer count returns nothing
loop
exitwhen count <= 0
call .place(x, y)
set count = count-1
endloop
endmethod
//======
method excludeUnit takes unit u, boolean flag returns nothing
if flag then
call GroupAddUnit(.ex, u)
else
call GroupRemoveUnit(.ex, u)
endif
endmethod
method excludes takes unit u returns boolean
return IsUnitInGroup(u, .ex)
endmethod
method clearExclusions takes nothing returns nothing
local unit u
loop
set u = FirstOfGroup(.ex)
exitwhen u == null
call GroupRemoveUnit(.ex, u)
endloop
set u = null
endmethod
//======
method typeDrop takes integer unitID, integer minDrops, integer maxDrops returns nothing
local integer dcount = DropData[unitID].integer[KEY_COUNT]
set DropData[unitID].integer[dcount*SIZE] = this
set DropData[unitID].integer[dcount*SIZE + KEY_MIN] = minDrops
set DropData[unitID].integer[dcount*SIZE + KEY_MAX] = maxDrops
set DropData[unitID].integer[KEY_COUNT] = dcount+1
endmethod
method unitDrop takes unit whichUnit, integer minDrops, integer maxDrops returns nothing
call .typeDrop(GetHandleId(whichUnit), minDrops, maxDrops)
endmethod
method stopTypeDrop takes integer unitID, boolean all returns nothing
local integer dcount = DropData[unitID].integer[KEY_COUNT]
local integer i = 0
loop
exitwhen i >= dcount
if DropData[unitID].integer[i*SIZE] == this then
set DropData[unitID].integer[i*SIZE] = DropData[unitID].integer[dcount*SIZE]
set DropData[unitID].integer[i*SIZE + KEY_MIN] = DropData[unitID].integer[dcount*SIZE + KEY_MIN]
set DropData[unitID].integer[i*SIZE + KEY_MAX] = DropData[unitID].integer[dcount*SIZE + KEY_MAX]
set i = i-1
set dcount = dcount-1
set DropData[unitID].integer[KEY_COUNT] = dcount
exitwhen not all
endif
set i = i+1
endloop
endmethod
method stopUnitDrop takes unit whichUnit, boolean all returns nothing
call .stopTypeDrop(GetHandleId(whichUnit), all)
endmethod
//======
static method create takes nothing returns thistype
local thistype t = thistype.allocate()
set t.p = CreateItemPool()
set t.ex = CreateGroup()
return t
endmethod
method onDestroy takes nothing returns nothing
call DestroyItemPool(.p)
call DestroyGroup(.ex)
endmethod
endstruct
private function onRemove takes unit u returns nothing
local integer unitID
static if CLEAR_ON_UNIT_REMOVE then
set unitID = GetHandleId(u)
call DropData[unitID].flush()
call DropData[unitID].destroy()
endif
endfunction
hook RemoveUnit onRemove
private function onDeath takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer unitID
local integer dcount
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local integer i = 0
local boolean h
set unitID = GetUnitTypeId(u)
set dcount = DropData[unitID].integer[KEY_COUNT]
loop
exitwhen i >= dcount
if not DropTable(DropData[unitID].integer[i*SIZE]).excludes(u) then
call DropTable(DropData[unitID].integer[i*SIZE]).placeN(x, y, GetRandomInt(DropData[unitID].integer[i*SIZE + KEY_MIN], DropData[unitID].integer[i*SIZE + KEY_MAX]))
endif
set i = i+1
endloop
set h = IsHeroUnitId(unitID)
set unitID = GetHandleId(u)
set dcount = DropData[unitID].integer[KEY_COUNT]
loop
exitwhen i >= dcount
call DropTable(DropData[unitID].integer[i*SIZE]).placeN(x, y, GetRandomInt(DropData[unitID].integer[i*SIZE + KEY_MIN], DropData[unitID].integer[i*SIZE + KEY_MAX]))
set i = i+1
endloop
if (dcount > 0) and ((h and CLEAR_ON_HERO_DEATH) or (not h and CLEAR_ON_UNIT_DEATH)) then
call DropData[unitID].flush()
call DropData[unitID].destroy()
endif
set u = null
return false
endfunction
private function init takes nothing returns nothing
set DropData = TableArray[0x2000]
set DropOnDeath = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(DropOnDeath, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(DropOnDeath, Condition(function onDeath))
endfunction
endlibrary
Here's an example of how to use it:
JASS:
library DropTableExample initializer init requires ItemPoolsEx
globals
DropTable OrbTable
DropTable PendantTable
DropTable GemTable
DropTable GenericTable
endglobals
private function init takes nothing returns nothing
set PendantTable = DropTable.create() //Create a new droptable, this one is different types of pendants
call PendantTable.add('prvt', 1) //Add periapt of vitality with weight 1
call PendantTable.add('penr', 1) //Add pendant of energy with weight 1
call PendantTable.add('pmna', 4) //Add pendant of mana with weight 4
//on average every 6 drops there will be:
// 1 vitality
// 1 energy
// 4 mana
//now we associate the table with various unit types:
call PendantTable.typeDrop('nmrl', 0, 1) //tiderunners drop 0 or 1 of these pendants
call PendantTable.typeDrop('nmmr', 1, 3) //huntsmen drop 1-3 of them
call PendantTable.typeDrop('nmmm', 4, 4) //nightcrawlers always drop 4
set OrbTable = DropTable.create() //Create a new drop table, this one has orbs on it
call OrbTable.add('odef', 1) //Add orb of darkness with weight 1
call OrbTable.add('ofro', 1) //Add orb of frost with weight 1
call OrbTable.add('ocor', 1) //Add orb of corruption with weight 1
call OrbTable.add('ofir', 0.1) //Add orb of fire with weight 0.1
//on average every 31 drops there will be:
// 10 darkness
// 10 frost
// 10 corruption
// 1 fire
//now associate with a unit type
call OrbTable.typeDrop('hpea', 0, 3) //peasants drop between 0 and 3 orbs
set GemTable = DropTable.create() //Create a new droptable, this one has gems and null items (null items are a 'ghost' drop that doesn't exist)
call GemTable.add('gemt', 1) //Add gem of true sight with weight 1
call GemTable.add(NULL_ITEM, 2) //Add null item with weight 2
//on average every 3 drops there will be:
// 1 gem of true sight
// 2 null/ghost items that don't exist
//now associate with a unit type:
call GemTable.unitDrop(gg_unit_hdhw_0057, 5, 5) //this particular unit will always drop 5 items from the gem table
call OrbTable.unitDrop(gg_unit_hdhw_0057, 1, 3) //it also drops between 1 and 3 items from the orb table
set GenericTable = DropTable.create() //create a new table
call GenericTable.add('phea', 5) //healing potion (very common)
call GenericTable.add('pinv', 1) //invisibility potion (rare)
call GenericTable.add('shas', 3.5) //scroll of haste (pretty common)
call GenericTable.add('rat6', 1) //claws +6 (rare)
call GenericTable.add('clfm', 0.25) //cloak of flames (very rare)
call GenericTable.typeDrop('ncea', 0, 1) //these centaurs all have a chance to drop 0 or 1 items from the generic table
call GenericTable.typeDrop('ncer', 0, 1)
call GenericTable.typeDrop('ncim', 0, 1)
call GenericTable.typeDrop('ncen', 0, 1)
call GenericTable.excludeUnit(gg_unit_ncen_0013, true) //but these two particular centaurs will never drop anything
call GenericTable.excludeUnit(gg_unit_ncim_0029, true) //excluded as above
call GenericTable.clearExclusions() //jk those two units aren't excluded after all!
endfunction
endlibrary
the item drop system, is it possible to set different drops per unit type, and can it set to unit type, as the bosses dont spawn in till you enter the dungeon, so cant select unit specifically
and pet one, nice, the pet wouldnt follow me, half the time, and how i make it so it pet u buy from a shop not a unit already on the map.
Instead of selecting the unit from the map, just use "Last created unit" to reference the boss after creating it. You can also Pick every Unit of Type and add them to the system.
Or you could even do something like "A unit Enters the Entire Map -> Unit Type of Entering Unit equal to Footman -> Add (Entering Unit) to ds_UnitGroup, etc..."
Boss Example
Events
Conditions
Actions
Unit - Create 1 DUNGEON BOSS for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
Unit Group - Add (Last created unit) to ds_UnitGroup
-------- - --------
-------- - --------
-------- Item Settings --------
-------- Set the total number of Items in this Item Table --------
Set ds_TotalItems = 3
-------- MultiDropOn = More than 1 Item can drop. This overrides AlwaysDropOn when set to True. --------
Set ds_MultiDropOn = False
-------- AlwaysDropOn = This guarantees that 1 of the Items will always drop. The % Chances of the Items need to add up to exactly 100%. --------
Set ds_AlwaysDropOn = False
-------- - --------
Set ds_Item[1] = Boots of Speed
Set ds_Chance[1] = 25.00
Set ds_Charges[1] = 0
-------- - --------
Set ds_Item[2] = Gloves of Haste
Set ds_Chance[2] = 25.00
Set ds_Charges[2] = 5
-------- - --------
Set ds_Item[3] = Claws of Attack +6
Set ds_Chance[3] = 50.00
Set ds_Charges[3] = 10
-------- - --------
Custom script: call ds_CreateItemTable()
Units of Type
Events
Conditions
Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units of type Footman) and do (Actions)
Loop - Actions
Unit Group - Add (Picked unit) to ds_UnitGroup
-------- - --------
-------- - --------
-------- Item Settings --------
-------- Set the total number of Items in this Item Table --------
Set ds_TotalItems = 3
-------- MultiDropOn = More than 1 Item can drop. This overrides AlwaysDropOn when set to True. --------
Set ds_MultiDropOn = False
-------- AlwaysDropOn = This guarantees that 1 of the Items will always drop. The % Chances of the Items need to add up to exactly 100%. --------
Set ds_AlwaysDropOn = False
-------- - --------
Set ds_Item[1] = Boots of Speed
Set ds_Chance[1] = 25.00
Set ds_Charges[1] = 0
-------- - --------
Set ds_Item[2] = Gloves of Haste
Set ds_Chance[2] = 25.00
Set ds_Charges[2] = 5
-------- - --------
Set ds_Item[3] = Claws of Attack +6
Set ds_Chance[3] = 50.00
Set ds_Charges[3] = 10
-------- - --------
Custom script: call ds_CreateItemTable()
I attached a new version with some Pet System changes. I also changed how the Item Drop System works slightly. I added a new Boolean called "AlwaysDropOn" and changed the name of "MultiItemsOn" to MultiDropOn. I also fixed some bugs so I recommend replacing the old system with this new one IF you don't plan on using Pyrogasm's system. Another note, in order for your Gold/Lumber to be properly Refunded when you try to buy a second Pet, I had to use the Gold Bounty Base and Lumber Bounty Base values. So you need to set your Pet's Gold Bounty Base and Lumber Bounty Base to match it's Gold Cost and Lumber Cost.
So Gold Bounty Awarded - Base = Gold Cost, and Lumber Bounty Awarded - Base = Lumber Cost. This is a workaround fix until Blizzard adds a way to get a unit's Gold Cost/Lumber Cost.
Anyway, I'm mostly doing this for fun/learning, so with that being said I think you should try to get Pyrogasm's suggested system to work. It looks a lot better and a lot more versatile than mine. @Pyrogasm It would be nice if the items drop with X number of Charges. 0 = none, 1+ = that many charges. Probably wouldn't be too difficult to add it to that system.
Edit: Uploaded v.3. Small tweaks. Fixed a minor bug.
@Uncle - Thanks for the help, and i did try pyrogasm drop system, but gets errors.
@Pyrogasm - when i copied code to map it pasted 5 chinese smybols instead, however, copying bit at a time and that worked, However when compiling i get this error
Line 2430: ItemPoolsEx__DropData[unitID] is not of type that allows . syntax
fair enough, thing is if I disable Table and put in NewTable wont half my triggers stop working? As they use original table
EDIT: As i thought, if i put both on, it gets error, if i disable original table, and onyl use the new table then it gets 3 errors
i got this table
JASS:
//TESH.scrollpos=74
//TESH.alwaysfold=0
library Table
//***************************************************************
//* Table object 3.0
//* ------------
//*
//* set t=Table.create() - instanceates a new table object
//* call t.destroy() - destroys it
//* t[1234567] - Get value for key 1234567
//* (zero if not assigned previously)
//* set t[12341]=32 - Assigning it.
//* call t.flush(12341) - Flushes the stored value, so it
//* doesn't use any more memory
//* t.exists(32) - Was key 32 assigned? Notice
//* that flush() unassigns values.
//* call t.reset() - Flushes the whole contents of the
//* Table.
//*
//* call t.destroy() - Does reset() and also recycles the id.
//*
//* If you use HandleTable instead of Table, it is the same
//* but it uses handles as keys, the same with StringTable.
//*
//* You can use Table on structs' onInit if the struct is
//* placed in a library that requires Table or outside a library.
//*
//* You can also do 2D array syntax if you want to touch
//* mission keys directly, however, since this is shared space
//* you may want to prefix your mission keys accordingly:
//*
//* set Table["thisstring"][ 7 ] = 2
//* set Table["thisstring"][ 5 ] = Table["thisstring"][7]
//*
//***************************************************************
//=============================================================
globals
private constant integer MAX_INSTANCES=8100 //400000
//Feel free to change max instances if necessary, it will only affect allocation
//speed which shouldn't matter that much.
//=========================================================
private hashtable ht
endglobals
private struct GTable[MAX_INSTANCES]
method reset takes nothing returns nothing
call FlushChildHashtable(ht, integer(this) )
endmethod
private method onDestroy takes nothing returns nothing
call this.reset()
endmethod
//=============================================================
// initialize it all.
//
private static method onInit takes nothing returns nothing
set ht = InitHashtable()
endmethod
endstruct
//Hey: Don't instanciate other people's textmacros that you are not supposed to, thanks.
//! textmacro Table__make takes name, type, key
struct $name$ extends GTable
method operator [] takes $type$ key returns integer
return LoadInteger(ht, integer(this), $key$)
endmethod
method operator []= takes $type$ key, integer value returns nothing
call SaveInteger(ht, integer(this) ,$key$, value)
endmethod
method flush takes $type$ key returns nothing
call RemoveSavedInteger(ht, integer(this), $key$)
endmethod
method exists takes $type$ key returns boolean
return HaveSavedInteger( ht, integer(this) ,$key$)
endmethod
static method flush2D takes string firstkey returns nothing
call $name$(- StringHash(firstkey)).reset()
endmethod
static method operator [] takes string firstkey returns $name$
return $name$(- StringHash(firstkey) )
endmethod
endstruct
//! endtextmacro
//! runtextmacro Table__make("Table","integer","key" )
//! runtextmacro Table__make("StringTable","string", "StringHash(key)" )
//! runtextmacro Table__make("HandleTable","handle","GetHandleId(key)" )
endlibrary
So cant use only original, as itempool doesnt work, cant use table you use, as 3 of my triggers dont work
so i to figure out what it is table i use is missing from table you use, and put it on the one i use.
EDIT2: must be something wrong with my map, as i have tried all 3 DropPools by Adiktus Item Drop System 1.20
And all 3 of them save without errors so thats nice, but units dont drop anything in game, i even placed the original units on the trigger on the map to test, non of them drop anything
i also tested the drop map, and they work perfectly, so must be something wrong with my map.
EDIT3: @Uncle so as Jass Tables are not working for me, your drop system to try now, however, how do i set multiple tables one of each boss, and for pet system, is nice, but only works for player 1 not all ingame players. and one thing i will try at some point, is so only 2 specific heros can get pets. but for now jsut having pet system workign for all 5 players would be nice
EDIT4: Yup something wrong with my map, Even Uncle's Drop Table doesnt work, it saves with no issue, but again the units drop nothing
EDIT5: i cant even get the pet system working either, you can buy a pet but ti doesnt follow you and it is controllable
I would say issue is as i use Reforged WE, however all the original triggers and stuff from old W3 work perfectly still in W3
also i loaded the maps in Reforged WE, and clicked test there, and they still work do original test maps
only issue in Reforged WE, is the druid forms dont work, they dont turn into what is set on the trigger.
This is a bug with Reforged right now and will eventually be fixed. If you are trying things to see if they work with Reforged you need to open the map and save it before testing it so it’s actually recompiled using Reforged. That being said the NewTable snippet includes backwards compatibility for old Vex Table code so it should be easy to replace. You likely can’t just copy some of the code over from one system to another and hope it will work.
This is a bug with Reforged right now and will eventually be fixed. If you are trying things to see if they work with Reforged you need to open the map and save it before testing it so it’s actually recompiled using Reforged. That being said the NewTable snippet includes backwards compatibility for old Vex Table code so it should be easy to replace. You likely can’t just copy some of the code over from one system to another and hope it will work.
yeah i know druid forms is a bug with Refogred, but i was just saying everything else works in it, so the drop table not working has nothing to do with reforged. so any ideas how to fix?
EDIT: Sorted, got system working, and given Credit on map, Thanx for The Help Pyrogasm
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.