| 10-11-2006, 04:47 AM | #1 |
Ok, so I know how to create an item table, name it, and select the unit(s) i want to have it for, but here's the problem. How do I get it to when a unit of the same type has a chance to drop certain items after it respawns. Example: I click the Unit and set it so it has the desired loot table. Unit dies and a new unit of the same type respawns, but it doesn't drop anything. |
| 10-17-2006, 10:15 AM | #2 |
This way you modify items droped by concrete unit, not unit type. If you want all units of same type drop certain item, you must create trigger such: E - Generic Unit dies C - unit type of dying unit = unit A - create item at position of dying unit |
| 10-18-2006, 02:19 PM | #3 |
The problem with that is, it drops it all the time using that trigger, yea? I just want the unit to have a chance to drop an item. |
| 10-18-2006, 02:28 PM | #4 |
hmm i suggest you save your item drop list in a game cache and then call it when a unit die, I'll share my drop system with you, not to say that you can just copy and paste the thing, but hope that you can learn from it setup the game cache, store the item into it JASS:function DropList takes integer i, string e, integer lvla, integer lvlb returns nothing local string a if lvla ==lvlb then set a=I2S(lvla) call StoreInteger(udg_gc,e,"creeplvl"+a,i) else loop exitwhen lvla > lvlb set a=I2S(lvla) call StoreInteger(udg_gc,e,"creeplvl"+a,i) set lvla = lvla + 1 endloop endif set e=null set a=null endfunction function SetupInventorySystem takes nothing returns nothing //================================================================== //setup gamecache //================================================================== call InitGameCacheBJ("GameCache.w3v") set udg_gc = GetLastCreatedGameCacheBJ() //=================================================================== //setup drop list //=================================================================== //DropList takes : itemtype, itemclass (pot,eq,etc), creeplevel a to b call DropList('phea',"pot1",1,3) //potion of minor heal call DropList('pman',"pot2",1,3) //potion of minor mana call DropList('pinv',"pot1",4,5) //potion of heal call DropList('pclr',"pot2",4,5) //potion of mana call DropList('rat9',"eq1",2,5) //claw of attack +9 call DropList('rat6',"eq2",2,5) //claw of attack +6 call DropList('bspd',"eq3",2,5) //boots of speed endfunction //=========================================================================== function InitTrig_Setup_Inventory_System takes nothing returns nothing call ExecuteFunc("SetupInventorySystem") endfunction now this trigger run whenever there is an enemy of player(0) [which is player1, red] died JASS:function CreepDropCondition takes nothing returns boolean return IsUnitEnemy(GetDyingUnit(), Player(0)) endfunction function CreepDrop takes nothing returns nothing local gamecache g = udg_gc local unit u = GetDyingUnit() local real x = GetUnitX(u) local real y = GetUnitY(u) local integer lvl = GetUnitLevel(u) local integer i local integer id local string slvl = I2S(lvl) //pot dropping, 15% set i = GetRandomInt(1,100) if i<=15 then set i = GetRandomInt(1,2) set id = GetStoredInteger(g,"pot"+I2S(i),"creeplvl"+slvl) if id != 0 then call CreateItem(id,x,y) endif endif //eq dropping, 4% set i = GetRandomInt(1,100) if i<=4 then set i = GetRandomInt(1,3) set id = GetStoredInteger(g,"eq"+I2S(i),"creeplvl"+slvl) if id != 0 then call CreateItem(id,x,y) endif endif set g=null set u=null set slvl=null endfunction //=========================================================================== function InitTrig_Creep_Drops takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH ) call TriggerAddCondition( t, Condition(function CreepDropCondition)) call TriggerAddAction( t, function CreepDrop ) endfunction hope it helps ![]() |
| 10-20-2006, 01:53 AM | #5 |
Well, it looks like it would help. Just 1 little problem, I am JASS impared. I have no knowledge on how to use it at all. And i suppose that wouldnt be a problem if this is copy/pastable...is it? |
