Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --InitGameMode() requires
- --Hook
- --ListenToGameEvent( "entity_killed", Dynamic_Wrap( CAddonTemplateGameMode, 'OnEntityKilled' ), self )
- --RANDOM ITEM DROPS
- -- Read and assign configurable keyvalues if applicable
- function CAddonTemplateGameMode:_ReadGameConfiguration()
- local kv = LoadKeyValues( "scripts/maps/" .. GetMapName() .. ".txt" )
- kv = kv or {} -- Handle the case where there is not keyvalues file
- self:_ReadLootItemDropsConfiguration( kv["ItemDrops"] )
- end
- -- If random drops are defined read in that data
- function CAddonTemplateGameMode:_ReadLootItemDropsConfiguration( kvLootDrops )
- self._vLootItemDropsList = {}
- --[[if type( kvLootDrops ) ~= "table" then
- return
- end
- for _,lootItem in pairs( kvLootDrops ) do
- table.insert( self._vLootItemDropsList, {
- szItemName = lootItem.Item or "",
- nChance = tonumber( lootItem.Chance or 0 )
- })
- end]]
- table.insert ( self._vLootItemDropsList, {szItemName = "item_cloak_of_flames", nChance = })
- print("Drop Table:")
- DeepPrintTable( self._vLootItemDropsList, nil, true )
- print("----")
- end
- function CAddonTemplateGameMode:OnEntityKilled( event )
- local killedUnit = EntIndexToHScript( event.entindex_killed )
- print("1 mob dead")
- self:CheckForLootItemDrop( killedUnit )
- end
- function CAddonTemplateGameMode:CheckForLootItemDrop( killedUnit )
- print("Drop")
- for _,itemDropInfo in pairs( self._vLootItemDropsList ) do
- print("Calculating Drops")
- if RollPercentage( itemDropInfo.nChance ) then
- print("Giving Drop")
- local newItem = CreateItem( "item_cloak_of_flames", nil, nil )
- newItem:SetPurchaseTime( 0 )
- if newItem:IsPermanent() and newItem:GetShareability() == ITEM_FULLY_SHAREABLE then
- item:SetStacksWithOtherOwners( true )
- end
- local drop = CreateItemOnPositionSync( killedUnit:GetAbsOrigin(), newItem )
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement