Name | Type | is_array | initial_value |
i | integer | No | |
IdentifyTable | hashtable | No |
//TESH.scrollpos=43
//TESH.alwaysfold=0
library EquipmentSystem initializer Init
// Scythy Dervish's Identify System
//
// you just need to set up the item which can be used to identify items
// and the ability used to identify items.
//
// Additional you can configure the Errormessage to be shown when the item
// you want to identify is already identified (or cant be identified)
//
// have fun :D
// Here you can Set Up Item, Ability and Errormessage
globals
private hashtable IdentifyTable //Just ignore this one ^^
private constant integer IdentifyAbility = 'A000'
private constant integer IdentifyItem = 'I002'
private constant string ErrorMessage = "Item is already identified!"
endglobals
private function AddItemToIdentify takes integer ParentType, integer Amount returns nothing
call SaveIntegerBJ( Amount, 0, ParentType, IdentifyTable )
endfunction
private function AddIdentifiedItem takes integer ParentType, integer ChildType returns nothing
local integer index = 1
local integer maxIndex = LoadIntegerBJ(0, ParentType, IdentifyTable)
loop
if ( LoadIntegerBJ(index, ParentType, IdentifyTable) == 0 ) then
call SaveIntegerBJ( ChildType, index, ParentType, IdentifyTable )
set index = maxIndex
endif
exitwhen ( index >= maxIndex )
set index = index + 1
endloop
endfunction
// Here you can Set Up your Items
private function InitItems takes nothing returns nothing
// First you must Set up the item you want to identify. To do that use:
// call AddItemToIdentify(<RAWCODE>, <AMOUNT>)
// RAWCODE = Rawcode of the Item to identify
// AMOUNT = Amount of "subitems" you want to register (is just a checksum)
//
// Then you can register items to the ParentItem
// call AddItemToIdentify(<PARENTRAW>, <RAWCODE>)
// PARENTRAW = Rawcode of the Item to identify
// RAWCODE = Rawcode of the Item which should be created after identifying
//Claws of attack
call AddItemToIdentify('I000', 5)
call AddIdentifiedItem('I000', 'rat3')
call AddIdentifiedItem('I000', 'rat6')
call AddIdentifiedItem('I000', 'rat9')
call AddIdentifiedItem('I000', 'ratc')
call AddIdentifiedItem('I000', 'ratf')
//Ring of Protection
call AddItemToIdentify('I001', 5)
call AddIdentifiedItem('I001', 'rde0')
call AddIdentifiedItem('I001', 'rde1')
call AddIdentifiedItem('I001', 'rde2')
call AddIdentifiedItem('I001', 'rde3')
call AddIdentifiedItem('I001', 'rde4')
//No more items from here
endfunction
private function check takes nothing returns boolean
if ( GetSpellAbilityId() == IdentifyAbility ) then
return true
else
return false
endif
endfunction
private function Identify takes nothing returns nothing
local real xOffset = -I2R(StringLength(ErrorMessage))*6
local integer i = GetItemTypeId(GetSpellTargetItem())
local texttag tt = CreateTextTag()
if (LoadIntegerBJ(0, i, IdentifyTable) != 0 ) then
call RemoveItem( GetSpellTargetItem() )
call UnitAddItemById(GetTriggerUnit(), LoadIntegerBJ(GetRandomInt(1, LoadIntegerBJ(0, i, IdentifyTable) ), i , IdentifyTable ) )
else
call SetTextTagText(tt,ErrorMessage,0.024)
call SetTextTagPos(tt,xOffset+GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit())-16,0)
call SetTextTagColor(tt,255,204,0,255)
call SetTextTagPermanent(tt, false )
call SetTextTagLifespan( tt, 5.00 )
call SetTextTagFadepoint( tt, 2.00 )
call SetTextTagVelocity(tt, 0,0.04)
if (GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit())) then
call SetTextTagVisibility(tt, true)
endif
call SetItemCharges( GetItemOfTypeFromUnitBJ(GetTriggerUnit(), IdentifyItem), ( GetItemCharges(GetItemOfTypeFromUnitBJ(GetTriggerUnit(), IdentifyItem)) + 1 ) )
endif
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call InitHashtableBJ( )
set IdentifyTable = GetLastCreatedHashtableBJ()
call TriggerAddAction( t, function Identify )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function check ) )
call InitItems()
endfunction
endlibrary
function Trig_Unbezeichneter_Ausl__ser_001_Actions takes nothing returns nothing
call SaveRealBJ( 13.37, 1, 2, GetLastCreatedHashtableBJ() )
endfunction
//===========================================================================
function InitTrig_Unbezeichneter_Ausl__ser_001 takes nothing returns nothing
set gg_trg_Unbezeichneter_Ausl__ser_001 = CreateTrigger( )
call TriggerAddAction( gg_trg_Unbezeichneter_Ausl__ser_001, function Trig_Unbezeichneter_Ausl__ser_001_Actions )
endfunction