Script compile problem

Post » Fri May 27, 2011 8:28 pm

So... I'm starting to play with the Construction Set and Enchanted Editor to see how the scripting works. I thought I'd try combining two mannequin mods (Chris Janosi's original and MentalElf's version) to simplify the options while getting the enhanced weapon-handlng from the later one, and seeing if the scripts could be simplified further.

It's not exactly intuitive for new modders. :( I've now realised I have to work in TESCS rather than just trying to edit in the Editor... which is confusing. (Sure, I've edited the ESP, but the game doesn't seem to use this ESP when it starts up, using scripts and other stuff its obviously cached from previous loads). And it doesn't compile edited scripts, which I now find is necessary. But right now my progress is blocked in TESCS by a script compile error I don't understand.

To get the mannequin to show an equipped weapon, MentalElf's mannequin code forces it to attack an invisible enemy a script places right in front of it, unlike other mods which start the mannequin attacking the player, which causes companions to freak. I've assumed that the code in his mod actually worked and wasn't broken when it was uploaded... The mannequin and the enemy drone are NPCs of race Mannequin with (not sure if it's necessary, but was in MentalElf's code) opposing factions and -100 attitude modifers.

The code I've edited looks like this:
	if ( GetWeaponDrawn )		SkipAnim		SetFight, 0		StopCombat	elseif ( DronePlaced == 0 )		set DronePlaced to 1		PlaceAtMe, "IB_TargetDummy", 1, 0, 0MessageBox, "Drone activated!" ; debugging, since the drone is invisible		Disable		Enable		StartCombat, "IB_TargetDummy"		SetFight, 90		StartCombat, "IB_TargetDummy"	endif

TESCS is fine with the line PlaceAtMe, "IB_TargetDummy", 1, 0, 0 but barfs on the next reference StartCombat, "IB_TargetDummy" giving an "NPC/creature not found" error. But this NPC is clearly in the master list. How do I get this reference working?
User avatar
OnlyDumazzapplyhere
 
Posts: 3445
Joined: Wed Jan 24, 2007 12:43 am

Post » Sat May 28, 2011 7:05 am

Like most functions, I think starcombat can reference unique items placed in the editor, not spawned by script, this is probably why factions have been used by MentalElf.
Game will use modified versions of scripts at run time, as long as scripts are compiled.
Use MWEdit to indent/debug script syntax and compile MWSE extended code; use TESCS to compile normal code.
User avatar
Fiori Pra
 
Posts: 3446
Joined: Thu Mar 15, 2007 12:30 pm

Post » Sat May 28, 2011 12:45 am

Like most functions, I think starcombat can reference unique items placed in the editor, not spawned by script, this is probably why factions have been used by MentalElf.

So if I can't tell the mannequin to target a particular script-spawned drone, are you saying that having the faction mutual hate with a high SetFight will trigger combat without a specific StartCombat command? Otherwise, I'm not sure where I go from here. That section of code was pretty much cut'n paste from MentalElf's. :(

Game will use modified versions of scripts at run time, as long as scripts are compiled.

Fine, but the script won't compile as is, hence my question. LOL!

Use MWEdit to indent/debug script syntax and compile MWSE extended code; use TESCS to compile normal code.

Not really interested in MWSE right now.
User avatar
vicki kitterman
 
Posts: 3494
Joined: Mon Aug 07, 2006 11:58 am

Post » Fri May 27, 2011 9:47 pm

for starters, what's the error the CS is giving you when you try to compile?
User avatar
Darlene DIllow
 
Posts: 3403
Joined: Fri Oct 26, 2007 5:34 am

Post » Sat May 28, 2011 10:08 am

So if I can't tell the mannequin to target a particular script-spawned drone, are you saying that having the faction mutual hate with a high SetFight will trigger combat without a specific StartCombat command? Otherwise, I'm not sure where I go from here.
Never used myself, but it is the only reason I can see to give opposing factions
Fine, but the script won't compile as is, hence my question. LOL!
Just try commenting the lines with invalid
StartCombat, "IB_TargetDummy"
, it should compile (was it in MentalElf's code or did you add it yourself?). Or, place a unique IB_TargetDummy reference in TESCS near the mannequin (do not spawn it via script), so StartCombat, "IB_TargetDummy" can find the required reference
For other examples, I think similar code is also in MadMax's http://planetelderscrolls.gamespy.com/View.php?view=mods.detail&id=2734
Not really interested in MWSE right now.
Mwedit syntax checking of standard scripting code is way better than TESCS syntax checking, so you can catch much more possible errors than with TESCS. Then (when your syntax is ok for MWEdit) you copy/paste the script source in TESCS and compile a much cleaner code.
I think there are essentially 2 ways you can start combat: explicit startcombat (but this requires a reference to a unique object placed in game) or AI behavior.
Usually startcombat player is used, because player is usually safely near and unique.
Or you can try using AI: some possible ways:
- give spawned invisible cre/npc a faction opposite to mannequin (never tested, but if MentalElf used it instead of startcombat, there must be a reason)
- give mannequin 100 fight setting (should attack player on sight)
- give spawned invisible cre/npc a 100 fight setting (should attack player on sight) and give mannequin a AIEscort player package (should defend attacked player)...
User avatar
Austin England
 
Posts: 3528
Joined: Thu Oct 11, 2007 7:16 pm

Post » Sat May 28, 2011 8:07 am

I think there are essentially 2 ways you can start combat: explicit startcombat (but this requires a reference to a unique object placed in game) or AI behavior.
Usually startcombat player is used, because player is usually safely near and unique.

Well, that's exactly what mentalElf's code did. I'm flummoxed. Since it was uploaded in in a clearly well-developed state and there were no "this doesn't work" comments where I found it, I'm at a loss to know why the bare bones of his code can't be compiled in TESCS. I understand the reference problem, but the idea of a dummy the player can pick up and move at will is useless if you have to place the "drone" previously in the CS.

Or you can try using AI: some possible ways:
- give spawned invisible cre/npc a faction opposite to mannequin (never tested, but if MentalElf used it instead of startcombat, there must be a reason)
- give mannequin 100 fight setting (should attack player on sight)
- give spawned invisible cre/npc a 100 fight setting (should attack player on sight)

Well the idea is that they attack each other, very briefly, just long enough for the mannequin to draw a weapon. Both attacking the player was not really the plan... :(

Never mind. I was just trying to see what could be improved in these old scripts. Most of the scripts I've seen are very badly organised and optimised from a programing POV, even if they work. Coming from an x86 ASM background, I can see where the looping and comparisons in most can be cleaned up and reorganised to take far less processor time, which wouldn't be a bad thing for FPS if they run every frame. Even the code examples in GhanBuriGhan's guide are very inefficient.
User avatar
meg knight
 
Posts: 3463
Joined: Wed Nov 29, 2006 4:20 am

Post » Sat May 28, 2011 3:45 am

You can try placing a reference in the CS, compiling the script, then deleting the reference. Might cause errors in-game though.

Or just place a dummy reference in a dummy cell the player will never visit.
User avatar
Emerald Dreams
 
Posts: 3376
Joined: Sun Jan 07, 2007 2:52 pm

Post » Sat May 28, 2011 12:38 am

Well, that's exactly what mentalElf's code did. I'm flummoxed. Since it was uploaded in in a clearly well-developed state and there were no "this doesn't work" comments where I found it, I'm at a loss to know why the bare bones of his code can't be compiled in TESCS. I understand the reference problem, but the idea of a dummy the player can pick up and move at will is useless if you have to place the "drone" previously in the CS.
I just http://straygenius.com/index.php?title=Mannequins the mod and it compiles without errors and works in game (albeit with some quirks), so it seems startcombat zt_targetdummy works on a script placed unique reference even if the original zt_targetdummy placed in TESCS is somewhere else. Maybe your compiling error is due to a corrupted version, with no zt_targetdummy placed in TESCS ZT_MannequinsProxy cell?
User avatar
Kaylee Campbell
 
Posts: 3463
Joined: Mon Mar 05, 2007 11:17 am

Post » Sat May 28, 2011 10:46 am

I just http://straygenius.com/index.php?title=Mannequins the mod and it compiles without errors and works in game (albeit with some quirks), so it seems startcombat zt_targetdummy works on a script placed unique reference even if the original zt_targetdummy placed in TESCS is somewhere else. Maybe your compiling error is due to a corrupted version, with no zt_targetdummy placed in TESCS ZT_MannequinsProxy cell?


Ah. I was just cutting and pasting code, as I didn't understand what that odd cell was for. I didn't realise there has to be a hidden placed "instance" of the drone in a non-game cell. How odd. So there has to be one placed version of the NPC somewhere for the StartCombat code to work?
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Sat May 28, 2011 4:28 am

So there has to be one placed version of the NPC somewhere for the StartCombat code to work?
More specifically, it seems there has to be at least one TESCS placed version of the NPC somewhere before being able to compile the startcombat NPCid command.
User avatar
Claire Vaux
 
Posts: 3485
Joined: Sun Aug 06, 2006 6:56 am


Return to III - Morrowind