耐性チェック

Last-modified: 2015-05-03 (日) 21:30:41

耐性チェック †
02AB: set_actor $PLAYER_ACTOR immunities BP 1 FP 1 EP 1 CP 1 MP 1
等で耐性を付けることは可能ですが、どの耐性が付いているかをチェックするOpcodeはありません。
ですのでメモリからフラグを直接調べることが必要になります。
車や物の耐性を調べたい場合は、0A96を適当なものに書き換えてください。

コード

0A96: 0@ = actor $PLAYER_ACTOR struct
000A: 0@ += 0x42
0A8D: 0@ = read_memory 0@ size 1 virtual_protect 0
if
08B7: test 0@ bit 2 //銃撃耐性が付いているか
then

   真処理

end
if
08B7: test 0@ bit 3 //炎耐性が付いているか
then

   真処理

end
if
08B7: test 0@ bit 4 //衝突耐性が付いているか
then

   真処理

end
if
08B7: test 0@ bit 5 //打撃耐性が付いているか
then

   真処理

end
if
08B7: test 0@ bit 6 //プレイヤーからの攻撃のみ有効
then

   真処理

end
if
08B7: test 0@ bit 7 //爆発耐性が付いているか
then

   真処理

end
08B7は指定されたビットが1なら真、0なら偽を返します。
SA SCMでは32ビット変数が使用されていますが、耐性などの
フラグが格納されている変数は8ビットなので使用できるのは0~7です。
0番はPEDのcollision。1にすると壁抜けなど出来ます。
1番は動けるか動けないか。1にすると動けない。
2~7番は耐性。上記の通り。


耐性を記憶し、後で元に戻す †
0A96: 0@ = actor $PLAYER_ACTOR struct
000A: 0@ += 0x42
0A8D: 1@ = read_memory 0@ size 1 virtual_protect 0
  :
  処理
  :
0A96: 0@ = actor $PLAYER_ACTOR struct
000A: 0@ += 0x42
0A8C: write_memory 0@ size 1 value 1@ virtual_protect 0