Перейти к содержанию

Скрипт под MWSE


Рекомендуемые сообщения

Вообщем хотел сделать скрипт, вешающийся на сундук для размножения вещей. Но при заходе в локацию с сундуком, игра вылетает.

Begin _NmLs_ChestOfCloningScript

short sState
long sItemName
long sItemCount
long sItemRef
long sItemNext
float LDay
short sDoOnce

if ( MenuMode == 1 )
Return
endif

if ( OnActivate == 1 )
if ( sState != 0 )
	MessageBox "Сундук закрыт"
	Return
else
	Activate
	Set sState to 1
	set Lday to Day
endif
endif

if ( sState == 1 )
setx sItemName,sItemCount,sItemRef to xInventory
if ( sItemName != 0 )
	Set sState to 2
	MessageBox "Вокруг сундука вспыхнул магический свет, и сундук закрылся."
else
	Set sState to 0
endif
endif

if ( sState == 2 )
if ( LDay != Day )
	set sState to 3
endif
endif

if ( sState == 3 )
if ( sDoOnce == 0 ) 
	setx sItemName,sItemCount,sItemRef to xInventory
	set sDoOnce to 1
endif
if ( sItemName != 0 )
	xAddItem sItemName sItemCount
	set sItemNext to sItemRef
	setx sItemName,sItemCount,sItemRef to xNextStack sItemNext
else
	set sState to 0
	set sDoOnce to 0
endif
endif

End _NmLs_ChestOfCloningScript

Изменено пользователем NmLs
Ссылка на комментарий
Поделиться на другие сайты

  • 3 недели спустя...
  Цитата
The standard Morrowind script if and while commands do not work when the body of the block contains extended commands, instead use ifx and whilex. The ifx and whilex do not currently support a full syntax, I would just use a single value or function for now. The ifx/whilex will be performed if the value is not zero. You can use 'else' with 'ifx' but not 'elseif' and there isn't an 'elseifx'.

 

то есть в блоках где есть команды из MWSE используется ifx вместо if.

Попробуй так:

Begin _NmLs_ChestOfCloningScript

short sState
long sItemName
long sItemCount
long sItemRef
long sItemNext
short LDay
short sDoOnce
short tmp

if ( OnActivate == 1 )
if ( sState != 0 )
	MessageBox "Сундук закрыт"
	Return
else
	Activate
	Set sState to 1
	set Lday to Day
endif
endif

set tmp to ( sState - 1 )
ifx ( tmp ); выполняется при != 0
else; а это чтобы было при == 0
setx sItemName,sItemCount,sItemRef to xInventory
ifx ( sItemName )
	Set sState to 2
	MessageBox "Вокруг сундука вспыхнул магический свет, и сундук закрылся."
else
	Set sState to 0
endif
endif

if ( sState == 2 )
if ( LDay != Day )
	set sState to 3
	set tmp to ( sState - 3 )
set LDay to Day
endif
endif

ifx ( tmp )
else
ifx ( sDoOnce )  
else
	setx sItemName,sItemCount,sItemRef to xInventory
	set sDoOnce to 1
endif
ifx ( sItemName )
	xAddItem sItemName sItemCount
	set sItemNext to sItemRef
	setx sItemRef to xNextStack sItemNext  ;sItemName,sItemCount, закомментил
else
	set sState to 0
	set sDoOnce to 0
endif
endif

End _NmLs_ChestOfCloningScript

Изменено пользователем Smokingbird
Ссылка на комментарий
Поделиться на другие сайты

Прогресс налицо хех: теперь игра вылетает при активации сундука,а не при заходе в локацию )))

Видать с циклом чегойто не то я намутил (((

Изменено пользователем NmLs
Ссылка на комментарий
Поделиться на другие сайты

так... ну во-первых LDay будет short, как и Day, хоть это и несущественно. Во-вторых, менюмод здесь абсолютно не к месту, так как при активации мы все-таки попадаем в меню. в-третьих, а как это так вспыхнул свет и он сам закрылся? если игрок вручную не закрывает меню, он так и останется открытым. в общем не знаю, сейчас отредактирую пост выше и попробуй опять.

 

Вот кстати нашел скрипт, забирающий все вещи у игрока. Может тебе оказаться полезен:

begin take_player_items

short trapdisabled
long invitem   ; name of the item (i.e. gold_001, ingred_ruby_01, etc.)
long invcount  ; amount of the item (i.e. 327 gold_001, etc.)
long invref	; pointer to next item (unused in this script)
long pcref

if ( OnActivate == 0 )   ; Nothing to do until player tries to open it.
return
endif

if ( trapdisabled == 1 ) ; This would be changed by some external script
Activate			 ; to allow the player to retrieve the items.
endif

; If we get here, the trap is active, take everything the player carries.
setx pcref to xGetRef "player"

setx invitem,invcount,invref to pcref->xInventory	 ; get first item
whilex ( invcount )
xAddItem invitem invcount						 ; add to container
pcref->xRemoveItem invitem invcount			   ; take from player
setx invitem,invcount,invref to pcref->xInventory ; get another item
endwhile

end

Изменено пользователем Smokingbird
Ссылка на комментарий
Поделиться на другие сайты

Просто из интереса решил написать с нуля свой скрипт. Чуть не умер пока отлаживал, но все-таки добился эффекта. Вот. Проверено - работает как часы.

Begin SmB_item_double

short activated
short button
short action
long x_item
long x_count
long x_ref
short once
short once_mess
short my_day

if ( menumode )
return
endif

if ( OnActivate )
if ( once_mess == 1 )
	MessageBox "Сундук закрыт."
	return
endif
if ( activated == 0 )
	MessageBox "Что вы хотите?" "Добавить/взять вещи" "Удвоить кол-во"
	Set activated to 1
endif
endif

if ( activated == 1 )
Set button to GetButtonPressed
if ( button == -1 )
	return
elseif ( button == 0 )
	Activate
else
	Set action to 1
	Set my_day to Day
endif
Set activated to 0
endif

if ( action < 1 )
return
endif

if ( my_day == Day )
if ( once_mess == 0 )
	MessageBox "Подождите до завтра." "Ok"
	Set once_mess to 1
endif
return
else
Set my_day to 0
endif

ifx ( once )
else
setx x_item,x_count,x_ref to xInventory
set once to 1
endif

ifx ( x_ref )   
xAddItem x_item x_count
setx x_item,x_count,x_ref to xNextStack x_ref
return
else
xAddItem x_item x_count
endif


Set action to 0
set once to 0
Set once_mess to 0

End

зы. Да, к слову, я был неправ насчет menumode :)

Изменено пользователем Smokingbird
Ссылка на комментарий
Поделиться на другие сайты

Благодарю :hatoff: . Небудешь против если слегка изменю и засуну в свой плагин ? Твое имя будет в списке авторов ;-)
Ссылка на комментарий
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!

Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.

Войти
  • Последние посетители   0 пользователей онлайн

    • Ни одного зарегистрированного пользователя не просматривает данную страницу
×
×
  • Создать...