武器持ち替え ■機能説明 config.txtで設定したモンスターが来たときに設定した武器に持ち替えます。 属性剣なんかを使い分けるときに有用かも ■使い方 changeWeaponを1にすると武器を持ち替えるようにする、0で解除。 changeWeapon_defaultには普段装備している武器の名前を設定 changeWeapon_#_monsterにはモンスター名を設定する。(#は数字。0,1,2・・・ changeWeapon_#_weaponにはchangeWeapon_#_monsterに攻撃するときに持ち替える武器を設定 例)ポリンにはカッター、ウィローにはマインゴージュで攻撃する。(普段はナイフ) changeWeapon 1 changeWeapon_default ナイフ changeWeapon_0_monster ポリン changeWeapon_0_weapon カッター changeWeapon_1_monster ウィロー changeWeapon_1_weapon マインゴージュ ----- [kore.pl] sub attack { my $ID = shift; my %args; + useWeaponsChange($ID); ----- [kore.pl] +sub useWeaponsChange { + my $monsterID = shift; + return if (!$config{'changeWeapon'}); + my $weaponName = $config{'changeWeapon_default'}; + for ($i=0; ; $i++) { + my $monsterName = $config{"changeWeapon_$i"."_monster"}; + last if ($monsterName eq ""); + if ($monsterName =~ /\Q$monsters{$monsterID}{'name'}\E/) { + $weaponName = $config{"changeWeapon_$i"."_weapon"}; + last; + } + } + return if ($weaponName eq ""); #設定ミス? + if ($weaponName =~ /\Q素手\E/) { + #@equipment初期化(バグ防止) + undef @equipment; + for ($i = 0; $i < @{$chars[$config{'char'}]{'inventory'}};$i++) { + next if (!%{$chars[$config{'char'}]{'inventory'}[$i]}); + if ($chars[$config{'char'}]{'inventory'}[$i]{'type_equip'} != 0) { + push @equipment, $i; + } + } + for ($i=0; $i<@equipment; $i++) { + if ($chars[$config{'char'}]{'inventory'}[$equipment[$i]]{'equipped'} & + $chars[$config{'char'}]{'inventory'}[$equipment[$i]]{'type_equip'} == 2 || + $chars[$config{'char'}]{'inventory'}[$equipment[$i]]{'type_equip'} == 34) { + print "Now Unequip Weapon: $chars[$config{'char'}]{'inventory'}[$equipment[$i]]{'name'}\n" if ($config{'debug'}); + sendUnequip(\$remote_socket, $chars[$config{'char'}]{'inventory'}[$equipment[$i]]{'index'}); + last; + } + } + } else { + my $index = findIndexString(\@{$chars[$config{'char'}]{'inventory'}}, 'name', $weaponName); + if ($index ne "" && !$chars[$config{'char'}]{'inventory'}[$index]{'equipped'}){ + print "Now Equip Weapon: $chars[$config{'char'}]{'inventory'}[$index]{'name'}\n" if ($config{'debug'}); + sendEquip(\$remote_socket, $chars[$config{'char'}]{'inventory'}[$index]{'index'}, $chars[$config{'char'}]{'inventory'}[$index]{'type_equip'}, 0); + } + } +} ----- [config.txt] +changeWeapon 1 +changeWeapon_default hoge +changeWeapon_#_weapon hoge +changeWeapon_#_monster