- Joined
- Feb 7, 2005
- Messages
- 409
Hey guys, I'm using an equipment system by The_Witcher and I've been editing it heavily to suit my needs. In the map every unit has it's own list of attachments, animations, etc that I save via a hashtable. When I equip a ranged weapon it replaces the unit doing the equipping with a ranged version of that same unit. This works perfectly as long as the hero is level 1, once it gains a level for some reason the unit is replaced, level is set, but the attachments and animations don't transfer over. The same problem happens when you equip a ranged weapon while wielding a ranged weapon, everything else seems to transfer except the hash data. here's an insert from the trigger.
Edit: if you have any questions or want more code just tell me, to post the whole trigger here would be ridiculously long.. since.. I'm bad at coding.
JASS:
call ShowUnit(dat.owner, false)
if GetUnitPointValue(dat.owner) == 101 then
set newUnit = CreateUnit(GetOwningPlayer(dat.owner), udg_RangedUnit[iiii], GetUnitX(dat.owner), GetUnitY(dat.owner), GetUnitFacing(dat.owner))
endif
if GetUnitPointValue(dat.owner) == 102 then
set newUnit = CreateUnit(GetOwningPlayer(dat.owner), udg_DirMRangedUnit[iiii], GetUnitX(dat.owner), GetUnitY(dat.owner), GetUnitFacing(dat.owner))
endif
if GetUnitPointValue(dat.owner) == 103 then
set newUnit = CreateUnit(GetOwningPlayer(dat.owner), udg_FemRangedUnit[iiii], GetUnitX(dat.owner), GetUnitY(dat.owner), GetUnitFacing(dat.owner))
endif
if GetUnitPointValue(dat.owner) == 104 then
set newUnit = CreateUnit(GetOwningPlayer(dat.owner), udg_DirFRangedUnit[iiii], GetUnitX(dat.owner), GetUnitY(dat.owner), GetUnitFacing(dat.owner))
endif
call InitEquipment(newUnit)
call SetUnitState(newUnit, UNIT_STATE_LIFE, GetUnitState(dat.owner, UNIT_STATE_LIFE))
call SetUnitState(newUnit, UNIT_STATE_MANA, GetUnitState(dat.owner, UNIT_STATE_MANA))
call SetHeroXP(newUnit, GetHeroXP(dat.owner), false)
set index = 0
loop
set indexItem = UnitItemInSlot(dat.owner, index)
if (indexItem != null) then
call UnitRemoveItem(dat.owner, indexItem)
call UnitAddItem(newUnit, indexItem)
endif
set index = index + 1
exitwhen index >= bj_MAX_INVENTORY
endloop
if GetUnitLevel(dat.owner) > 1 and GetOwningPlayer(dat.owner) != Player(11) then
call SetPlayerState(GetOwningPlayer(dat.owner), PLAYER_STATE_RESOURCE_LUMBER, ( GetPlayerState(GetOwningPlayer(dat.owner), PLAYER_STATE_RESOURCE_LUMBER) - 5) )
endif
call SaveEffectHandle(udg_Hash_Fashion, GetHandleId(newUnit), 8, LoadEffectHandle(udg_Hash_Fashion, udg_FashionHandle, 8) )
call SaveEffectHandle(udg_Hash_Fashion, GetHandleId(newUnit), 17, LoadEffectHandle(udg_Hash_Fashion, udg_FashionHandle, 17) )
call SaveEffectHandle(udg_Hash_Fashion, GetHandleId(newUnit), 0, LoadEffectHandle(udg_Hash_Fashion, udg_FashionHandle, 0) )
call SaveEffectHandle(udg_Hash_Fashion, GetHandleId(newUnit), 5, LoadEffectHandle(udg_Hash_Fashion, udg_FashionHandle, 5) )
call SaveEffectHandle(udg_Hash_Fashion, GetHandleId(newUnit), 40, LoadEffectHandle(udg_Hash_Fashion, udg_FashionHandle, 40) )
call SaveEffectHandle(udg_Hash_Fashion, GetHandleId(newUnit), 43, LoadEffectHandle(udg_Hash_Fashion, udg_FashionHandle, 43) )
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 1, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 1))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 2, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 2))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 3, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 3))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 4, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 4))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 6, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 6))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 7, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 7))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 9, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 9))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 10, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 10))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 11, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 11))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 12, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 12))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 13, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 13))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 14, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 14))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 15, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 15))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 16, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 16))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 18, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 18))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 19, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 19))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 20, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 20))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 21, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 21))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 41, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 41))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 42, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 42))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 44, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 44))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 45, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 45))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 46, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 46))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 48, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 48))
call SaveStr(udg_Hash_Fashion, GetHandleId(newUnit), 50, LoadStr(udg_Hash_Fashion, udg_FashionHandle, 50))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 22, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 22))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 23, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 23))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 24, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 24))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 25, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 25))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 26, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 26))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 27, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 27))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 28, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 28))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 29, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 29))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 30, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 30))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 31, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 31))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 32, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 32))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 33, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 33))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 34, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 34))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 35, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 35))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 37, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 37))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 38, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 38))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 39, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 39))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 47, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 47))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 49, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 49))
call SaveBoolean( udg_Hash_Fashion, GetHandleId(newUnit), 51, LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 51))
if ( LoadBoolean(udg_Hash_Fashion, udg_FashionHandle, 37) == true ) then
call SetUnitVertexColor( newUnit, 100, 100, 100, 50 )
endif
set udg_TempUnit = dat.owner
call TransferEquipment(dat.owner, newUnit)
call SetHeroStr(newUnit,str,true)
call SetHeroAgi(newUnit,agi,true)
call SetHeroInt(newUnit,int,true)
call FlushChildHashtable(udg_Hash_Fashion, udg_FashionHandle)
call TriggerExecute( gg_trg_HeroAbilityFix )
call ShowUnit(udg_TempUnit, true)
set udg_HeroUnit[GetConvertedPlayerId(GetOwningPlayer(dat.owner))] = newUnit
call RemoveUnit(udg_TempUnit)
set newUnit = null
set udg_TempUnit = null
call TriggerExecute( gg_trg_HeroAnimationFix )
call SelectUnitForPlayerSingle(dat.owner, GetOwningPlayer(dat.owner))
Edit: if you have any questions or want more code just tell me, to post the whole trigger here would be ridiculously long.. since.. I'm bad at coding.