Есть такой мод с шахматами (ссылка) - там есть локация с рубильником, который активирует скрипт, первым делом расставляя на маркеры клеток (ChessTiles) фигуры. Я пытаюсь сделать разнообразие внешнего вида фигур, для чего создаю npc-пешку, идентичную оригинальной, но с минимальным отличием. Но она отказывается спауниться тем же методом, что остальные фигуры.
Я плохо понимаю в скриптах, но ясно одно - скрипт шахмат обращается к скриптам NPC-фигур, а не к самим фигурам, например
ChessPieces[0] = ChessTiles[0].PlaceAtMe(Chess_Rook_White_TEST) as Chess_Piece_Master
То есть мы спауним фигуру-NPC, конвертированную в добавленный в нее скрипт (в данном случае - его родителя). Где-то здесь кроется причина, почему моя непись не добавляется... А код активатора игры такой (ниже). В чем может быть причина того, что My_Pawn_White не спавнится на этой стадии. My_Pawn_White - клон другой фигуры-NPC, наследующий и ее скрипт, дочерний к Chess_Piece_Master
Scriptname Chess_StartGame extends ObjectReference {starts a new game of chess when the player activates the object this script is in} ActorBase Property Chess_Pawn_White Auto ActorBase Property My_Pawn_White Auto ActorBase Property Chess_Pawn_Black Auto ActorBase Property Chess_Rook_White_TEST Auto ActorBase Property Chess_Rook_Black Auto ActorBase Property Chess_Knight_White Auto ActorBase Property Chess_Knight_Black Auto ActorBase Property Chess_Bishop_White Auto ActorBase Property Chess_Bishop_Black Auto ActorBase Property Chess_Queen_White Auto ActorBase Property Chess_Queen_Black Auto ActorBase Property Chess_King_White Auto ActorBase Property Chess_King_Black Auto Quest Property Chess Auto Chess_Piece_Master[] Property ChessPieces Auto Chess_Tile[] Property ChessTiles Auto Function ClearAll(Chess_Piece_Master[] refArray) Int i = 32 While i > 0 i -= 1 refArray[i].DisableNoWait() refArray[i].Delete() ;Debug.Trace("CURRENT INDEX " + refArray[i]) EndWhile i = 64 While i > 0 i -= 1 ChessTiles[i].occupyingPiece = None ChessTiles[i].setOccupied(False) EndWhile EndFunction EVENT OnActivate(ObjectReference akActionRef) GoToState("Busy") If (Chess.GetStage() != 0) ClearAll(ChessPieces) EndIf ; white pieces ChessPieces[0] = ChessTiles[0].PlaceAtMe(Chess_Rook_White_TEST) as Chess_Piece_Master ChessPieces[0].SetAngle(90,0,0) ChessPieces[0].currentTile = ChessTiles[0] ChessTiles[0].occupyingPiece = ChessPieces[0] ChessTiles[0].setOccupied(True); ChessPieces[1] = ChessTiles[1].PlaceAtMe(Chess_Knight_White) as Chess_Piece_Master ChessPieces[1].SetAngle(90,0,0) ChessPieces[1].currentTile = ChessTiles[1] ChessTiles[1].occupyingPiece = ChessPieces[1] ChessTiles[1].setOccupied(True); ChessPieces[2] = ChessTiles[2].PlaceAtMe(Chess_Bishop_White) as Chess_Piece_Bishop ChessPieces[2].SetAngle(90,0,0) ChessPieces[2].currentTile = ChessTiles[2] ChessTiles[2].occupyingPiece = ChessPieces[2] ChessTiles[2].setOccupied(True); ChessPieces[3] = ChessTiles[3].PlaceAtMe(Chess_Queen_White) as Chess_Piece_Master ChessPieces[3].SetAngle(90,0,0) ChessPieces[3].currentTile = ChessTiles[3] ChessTiles[3].occupyingPiece = ChessPieces[3] ChessTiles[3].setOccupied(True); ChessPieces[4] = ChessTiles[4].PlaceAtMe(Chess_King_White) as Chess_Piece_Master ChessPieces[4].SetAngle(90,0,0) ChessPieces[4].currentTile = ChessTiles[4] ChessTiles[4].occupyingPiece = ChessPieces[4] ChessTiles[4].setOccupied(True); ChessPieces[5] = ChessTiles[5].PlaceAtMe(Chess_Bishop_White) as Chess_Piece_Master ChessPieces[5].SetAngle(90,0,0) ChessPieces[5].currentTile = ChessTiles[5] ChessTiles[5].occupyingPiece = ChessPieces[5] ChessTiles[5].setOccupied(True); ChessPieces[6] = ChessTiles[6].PlaceAtMe(Chess_Knight_White) as Chess_Piece_Master ChessPieces[6].SetAngle(90,0,0) ChessPieces[6].currentTile = ChessTiles[6] ChessTiles[6].occupyingPiece = ChessPieces[6] ChessTiles[6].setOccupied(True); ChessPieces[7] = ChessTiles[7].PlaceAtMe(Chess_Rook_White_TEST) as Chess_Piece_Master ChessPieces[7].SetAngle(90,0,0) ChessPieces[7].currentTile = ChessTiles[7] ChessTiles[7].occupyingPiece = ChessPieces[7] ChessTiles[7].setOccupied(True); ; white pawns Game.GetPlayer().PlaceAtMe(Chess_Pawn_White_B) ChessPieces[8] = ChessTiles[8].PlaceAtMe(My_Pawn_White) as Chess_Piece_Pawn ChessPieces[8].SetAngle(90,0,0) ChessPieces[8].currentTile = ChessTiles[8] ChessTiles[8].occupyingPiece = ChessPieces[8] ChessTiles[8].setOccupied(True); ChessPieces[9] = ChessTiles[9].PlaceAtMe(Chess_Pawn_White) as Chess_Piece_Pawn ChessPieces[9].SetAngle(90,0,0) ChessPieces[9].currentTile = ChessTiles[9] ChessTiles[9].occupyingPiece = ChessPieces[9] ChessTiles[9].setOccupied(True); ChessPieces[10] = ChessTiles[10].PlaceAtMe(Chess_Pawn_White) as Chess_Piece_Pawn ChessPieces[10].SetAngle(90,0,0) ChessPieces[10].currentTile = ChessTiles[10] ChessTiles[10].occupyingPiece = ChessPieces[10] ChessTiles[10].setOccupied(True); ChessPieces[11] = ChessTiles[11].PlaceAtMe(Chess_Pawn_White) as Chess_Piece_Pawn ChessPieces[11].SetAngle(90,0,0) ChessPieces[11].currentTile = ChessTiles[11] ChessTiles[11].occupyingPiece = ChessPieces[11] ChessTiles[11].setOccupied(True); ChessPieces[12] = ChessTiles[12].PlaceAtMe(Chess_Pawn_White) as Chess_Piece_Pawn ChessPieces[12].SetAngle(90,0,0) ChessPieces[12].currentTile = ChessTiles[12] ChessTiles[12].occupyingPiece = ChessPieces[12] ChessTiles[12].setOccupied(True); ChessPieces[13] = ChessTiles[13].PlaceAtMe(Chess_Pawn_White) as Chess_Piece_Pawn ChessPieces[13].SetAngle(90,0,0) ChessPieces[13].currentTile = ChessTiles[13] ChessTiles[13].occupyingPiece = ChessPieces[13] ChessTiles[13].setOccupied(True); ChessPieces[14] = ChessTiles[14].PlaceAtMe(Chess_Pawn_White) as Chess_Piece_Pawn ChessPieces[14].SetAngle(90,0,0) ChessPieces[14].currentTile = ChessTiles[14] ChessTiles[14].occupyingPiece = ChessPieces[14] ChessTiles[14].setOccupied(True); ChessPieces[15] = ChessTiles[15].PlaceAtMe(Chess_Pawn_White) as Chess_Piece_Pawn ChessPieces[15].SetAngle(90,0,0) ChessPieces[15].currentTile = ChessTiles[15] ChessTiles[15].occupyingPiece = ChessPieces[15] ChessTiles[15].setOccupied(True); ; black pawns ChessPieces[24] = ChessTiles[48].PlaceAtMe(Chess_Pawn_Black) as Chess_Piece_Master ChessPieces[24].SetAngle(0,0,180) ChessPieces[24].currentTile = ChessTiles[48] ChessTiles[48].occupyingPiece = ChessPieces[24] ChessTiles[48].setOccupied(True); ChessPieces[25] = ChessTiles[49].PlaceAtMe(Chess_Pawn_Black) as Chess_Piece_Master ChessPieces[25].SetAngle(0,0,180) ChessPieces[25].currentTile = ChessTiles[49] ChessTiles[49].occupyingPiece = ChessPieces[25] ChessTiles[49].setOccupied(True); ChessPieces[26] = ChessTiles[50].PlaceAtMe(Chess_Pawn_Black) as Chess_Piece_Master ChessPieces[26].SetAngle(0,0,180) ChessPieces[26].currentTile = ChessTiles[50] ChessTiles[50].occupyingPiece = ChessPieces[26] ChessTiles[50].setOccupied(True); ChessPieces[27] = ChessTiles[51].PlaceAtMe(Chess_Pawn_Black) as Chess_Piece_Master ChessPieces[27].SetAngle(0,0,180) ChessPieces[27].currentTile = ChessTiles[51] ChessTiles[51].occupyingPiece = ChessPieces[27] ChessTiles[51].setOccupied(True); ChessPieces[28] = ChessTiles[52].PlaceAtMe(Chess_Pawn_Black) as Chess_Piece_Master ChessPieces[28].SetAngle(0,0,180) ChessPieces[28].currentTile = ChessTiles[52] ChessTiles[52].occupyingPiece = ChessPieces[28] ChessTiles[52].setOccupied(True); ChessPieces[29] = ChessTiles[53].PlaceAtMe(Chess_Pawn_Black) as Chess_Piece_Master ChessPieces[29].SetAngle(0,0,180) ChessPieces[29].currentTile = ChessTiles[53] ChessTiles[53].occupyingPiece = ChessPieces[29] ChessTiles[53].setOccupied(True); ChessPieces[30] = ChessTiles[54].PlaceAtMe(Chess_Pawn_Black) as Chess_Piece_Master ChessPieces[30].SetAngle(0,0,180) ChessPieces[30].currentTile = ChessTiles[54] ChessTiles[54].occupyingPiece = ChessPieces[30] ChessTiles[54].setOccupied(True); ChessPieces[31] = ChessTiles[55].PlaceAtMe(Chess_Pawn_Black) as Chess_Piece_Master ChessPieces[31].SetAngle(0,0,180) ChessPieces[31].currentTile = ChessTiles[55] ChessTiles[55].occupyingPiece = ChessPieces[31] ChessTiles[55].setOccupied(True); ; black pieces ChessPieces[16] = ChessTiles[56].PlaceAtMe(Chess_Rook_Black) as Chess_Piece_Master ChessPieces[16].SetAngle(0,0,180) ChessPieces[16].currentTile = ChessTiles[56] ChessTiles[56].occupyingPiece = ChessPieces[16] ChessTiles[56].setOccupied(True); ChessPieces[17] = ChessTiles[57].PlaceAtMe(Chess_Knight_Black) as Chess_Piece_Master ChessPieces[17].SetAngle(0,0,180) ChessPieces[17].currentTile = ChessTiles[57] ChessTiles[57].occupyingPiece = ChessPieces[17] ChessTiles[57].setOccupied(True); ChessPieces[18] = ChessTiles[58].PlaceAtMe(Chess_Bishop_Black) as Chess_Piece_Master ChessPieces[18].SetAngle(0,0,180) ChessPieces[18].currentTile = ChessTiles[58] ChessTiles[58].occupyingPiece = ChessPieces[18] ChessTiles[58].setOccupied(True); ChessPieces[19] = ChessTiles[59].PlaceAtMe(Chess_Queen_Black) as Chess_Piece_Master ChessPieces[19].SetAngle(0,0,180) ChessPieces[19].currentTile = ChessTiles[59] ChessTiles[59].occupyingPiece = ChessPieces[19] ChessTiles[59].setOccupied(True); ChessPieces[20] = ChessTiles[60].PlaceAtMe(Chess_King_Black) as Chess_Piece_Master ChessPieces[20].SetAngle(0,0,180) ChessPieces[20].currentTile = ChessTiles[60] ChessTiles[60].occupyingPiece = ChessPieces[20] ChessTiles[60].setOccupied(True); ChessPieces[21] = ChessTiles[61].PlaceAtMe(Chess_Bishop_Black) as Chess_Piece_Master ChessPieces[21].SetAngle(0,0,180) ChessPieces[21].currentTile = ChessTiles[61] ChessTiles[61].occupyingPiece = ChessPieces[21] ChessTiles[61].setOccupied(True); ChessPieces[22] = ChessTiles[62].PlaceAtMe(Chess_Knight_Black) as Chess_Piece_Master ChessPieces[22].SetAngle(0,0,180) ChessPieces[22].currentTile = ChessTiles[62] ChessTiles[62].occupyingPiece = ChessPieces[22] ChessTiles[62].setOccupied(True); ChessPieces[23] = ChessTiles[63].PlaceAtMe(Chess_Rook_Black) as Chess_Piece_Master ChessPieces[23].SetAngle(0,0,180) ChessPieces[23].currentTile = ChessTiles[63] ChessTiles[63].occupyingPiece = ChessPieces[23] ChessTiles[63].setOccupied(True); Int j = 0 While j < 16 ChessTiles[j].occupyingPiece.XrefIndex = ChessTiles[j].XrefIndex ChessTiles[j].occupyingPiece.YrefIndex = ChessTiles[j].YrefIndex ; set this tile's occupying team j += 1 EndWhile j = 48 While j < 64 ChessTiles[j].occupyingPiece.XrefIndex = ChessTiles[j].XrefIndex ChessTiles[j].occupyingPiece.YrefIndex = ChessTiles[j].YrefIndex j += 1 EndWhile Chess.Stop() Chess.Start() Chess.SetStage(20) GoToState("") EndEvent State Busy Event OnActivate(ObjectReference akActionRef) ;do nothing EndEvent EndState