some noob questions TESCS and MWSE

Post » Wed Sep 24, 2014 1:14 am

I've cobbled two scripts from abot's and qqqbbb's help. One moves my player to an NPC.

Spoiler
Begin JH_sendmethere

;script to move my character to where another NPC is
;adapted from working script by abot
;uses a unique NPC to identify spot where player goes to
;uses xMyCellID, xPositionCell, GetPos
;concept - get x,y,z, cellname coordinates of the other NPC
;GetPos does not return useable X, Y, Z coordinates until player is in its cell
;therefore movement to the NPC is a two step process
;first get the cell name where the NPC is now and move player to the cell
;once in NPC's cell, run GetPos to get actual X, Y, Z for use in xPositionCell
;plug the X, Y, Z values into xPositionCell parameters and run xPositionCell again for final move
;MWSE manual gave one suggestion - use xGetRef, getPos and xMyCellID
;Scripting for Dummies describes two functions GetPos and GetAngle
;for script testing, will choose the NPC Ajira
;later in testing replace Ajira with the custom NPC object ID name



Long NPCRef ;variable for pointer to NPC uses xGetRef
float NPCx ;x axis coordinate of the NPC (Ajira atm)
float NPCy ;y axis coordinate of the NPC (Ajira atm)
float NPCz ;z axis coordinate of the NPC (Ajira atm)
float NPCangle ;unclear to me how works, will set as 0
Long WhereNPC ;name of cell object is in - uses xMyCellID


Setx NPCRef to xGetRef "Ajira" ;no commas!, pointer to the NPC, in this case Ajira

setx WhereNPC to NPCRef->xMyCellID ;identifies the cell where the NPC is

player->xPositionCell 0 0 0 0 WhereNPC ;move player to NPC's cell

;step two of movement, get NPC coordinates using GetPos


XSetRef NPCRef ; the NPC is now the default implicit reference to be applied to next command
set NPCx to GetPos X ;stores value of X

XSetRef NPCRef
set NPCy to GetPos Y

XSetRef NPCRef
set NPCz to GetPos Z

;XSetRef NPCRef ;not used atm
;set NPCangle to GetAngle Z ;not used atm

player->xPositionCell NPCx NPCy NPCz 0 WhereNPC

stopscript JH_sendmethere ;seems needed to not bog down

End
The other moves an NPC to my player.
Spoiler
Begin JH_bringNPChere

;script to move an NPC marker to where I am
;uses xPositionCell, xPCCellID, GetPos
;concept - get x,y,z, cellname coordinates of my player
;use xPCCellID to identify cell where player is
;plug cellname into cellname parameter in xPositionCell
;run it to bring the NPC marker to cell where my char is
;for script testing, will choose the NPC Ajira
;test move Ajira to my position


Long NPCRef ;variable for pointer to NPC, necessary to load for use
float myx ;x axis coordinate of the player
float myy ;y axis coordinate of the player
float myz ;z axis coordinate of the player
;float myangle ;not sure if makes sense so will set as 0
Long IamHere ;name of cell player is in - uses xPCCellID
Long WhereNPC ;name of cell NPC is currently in (for testing)


setx Iamhere to xPCCellID Player ;stores name of cell where player is

;geographical position code
setx NPCRef to xGetRef Ajira ;get pointer to Ajira
setx WhereNPC to NPCRef->xMyCellID ;store name of cell where NPC is, used for testing

set myx to player->GetPos X ;variable for player's X coordinate
set myy to player->GetPos Y ;variable for player's Y coordinate
set myz to player->GetPos Z ;variable for player's Z coordinate
;set myangle to 0 ;chose to not declare

NPCRef->xPositionCell 0, 0, 0, 0, IamHere ;put NPC on top of me

stopscript JH_bringNPCHere

End

My testing has been restricted to running them from the console using startscript and stopscript choosing an arbitrary game NPC as a guinea pig :smile: The scripts use some MWSE functions and work, which is what counts although even I think they can use more tweaking (for one thing, the scripts drop the NPC on top of the player and vice versa which looks 'ugly' to me although because the NPC will be disabled, may not matter).

I'm now where I want to create two unique objects in the TESCS - a creature with a unique object ID and an amulet with a unique object ID. I'll use the code for the amulet, but I don't know how to proceed in the TESCS from here.

Because the code uses MWSE commands, it has to be compiled in MWEdit, which lets you make an esp. The objects that I'll tap for this are in the TESCS - I'm thinking a scrib and a common amulet for grins, which of course I'll make sure I give each one a unique Object ID and rename. But how do I get an MWSE script into the TESCS to use with an object and in order to continue testing on those objects?

Because MWSE scripts won't compile in TESCS, how do I recover if I accidentally hit the compile button in TESCS when I've also got MWSE scripts in the esp? For that matter, can one compile one script at a time in TESCS? It looks like its button is an all or nothing option.

Another question I have. Because it's for myself, my plan is just to place the NPC (scrib) somewhere on the ground outside the door where the player steps into Seyda Neen for the first time and to do the same for the amulet. How do I go about making sure that my mod puts them in the world but doesn't mess up the other mods that I load which affect Seyda Neen. I don't think my stuff would conflict after I get started, but I am concerned about the first time. I could add the amulet to my inventory using the console, which may still be the most practical for me, but that still leaves the NPC/creature. I'm sure I could always load it first so that it'd be obvious if there was a conflict, but I'd like the warm and fuzzy feeling that I was doing things right in the first case.

Thanks

User avatar
chloe hampson
 
Posts: 3493
Joined: Sun Jun 25, 2006 12:15 pm

Post » Tue Sep 23, 2014 6:55 pm

I usually use MWEdit for navigating/searching objects info and testing (all) script syntax, but compiling only final MWSE scripts. This is mainly because certain parts of MWEdit beta are not finished and anything else is best done using the CS. So, for normal scripting, after testing scripts syntax in MWEdit I copy/paste them to the CS and finally compile/save them from the CS

So, for your project, this is what I'd do:

1. Open Morrowind.esm (and other Bethesda .esms if you need their objects) and look for a amulet /creature you like
2. click and open it, change what property you need (e.g. scale), change the ID to your new unique ID before saving, save the new object

3. create the 2 scripts in the CS, they can be empty apart the

begin scriptname

end

, save the mod, exit CS

4. load the mod in MWEdit, add code, edit/syntax check/compile the scripts. When there are no errors, save the mod

Mod should be ready to test in game. Notice that you only edited the MWSE scripts in MWEdit

5- optional - try understanding in MSFD the differences/when to use local scripts attached to a object/creature from the object properties windows in CS compared to global scripts (started using startscript, stopped using stopscript command).

Probably you can do everything from a local script attached to the amulet, but knowing the differences between local/global scripts would be nice.

[EDIT]re- accidental compile from CS: if you try compiling the MWSE script in CS, I think compiled script is not saved if errors are found. In any case, just recompiling the source script from MWEdit would fix the compiled script

User avatar
Brian LeHury
 
Posts: 3416
Joined: Tue May 22, 2007 6:54 am


Return to III - Morrowind