scripting woes

Post » Tue Dec 29, 2009 10:19 am

EDIT: Seems after placing more messageboxes, it may not be that. I'll check back here and update it if i find something closer.

You can ignore this post
User avatar
Kahli St Dennis
 
Posts: 3517
Joined: Tue Jun 13, 2006 1:57 am

Post » Tue Dec 29, 2009 2:46 pm

i missed the unedited post, what are you testing with messageboxes?

currently, i've gotten everything i've done working as intended and bug free (lol, yeah right) well aside from the journal giving repeat messages. i havent tested gaining an entry in another index between my index updates, but as it stands now, it seems random on if it outputs to the player's journal. the player gets the update message, and untill someone complains, that's good enough for me.

if you would like a reference, i can post up my current scripts, as my last posted ones are several internal revisions out of date.
User avatar
Jodie Bardgett
 
Posts: 3491
Joined: Sat Jul 29, 2006 9:38 pm

Post » Tue Dec 29, 2009 6:00 pm

I don't think many did. The idea of the mod i was working on involved making a ring that burned your skills and stats, and gave instead magical (curses) bonuses that never leave you. Using those you'd be able to break the 100 limits imposed in the game.

The issue was the script kept erroring with, complaining from a syntax error that was from the set command. This was kinda new to me. The line i ended up putting up was rather silly since it wasn't even the one in question.

Anyways, i have the framework (all the spells/curses needed, about 40) and it's just a matter of making the script happy and not cause it to die.

EDIT: Well, the scripts (5) are happy. Haven't had a real problem yet, however originally i planned on a 5:1 conversion, but after serious thought and a year to get some stats to 100 (could take you a lifetime unless your gaining skills like crazy) it seemed a bit much. Maybe 5:3?

I've seen scripts that break up the bonuses by decimal, ( 1-9's, and by 10's from 10-90, giving you a 99 bonus) with 19-20 curses/bonus spells. I took a binary approach and only made 8 per group. This can get you up to an additional 255 bonuses on all stats & skills. That gives you 355 if you max the bonus and your stats/skills; And at that point boots of blinding speed is nearly useless, unless you walk everywhere.
User avatar
no_excuse
 
Posts: 3380
Joined: Sun Jul 16, 2006 3:56 am

Post » Tue Dec 29, 2009 9:07 am

allright, here's my issue now...

how do i go about having an NPC return to the place he was placed in the CS if he is not in the same cell anymore?

i've skirted the issue before, as i was using my own NPCs and could hardcode the respawn. this time, i'm using targeted scripts and dialog to manipulate existing NPCs, so that's not really an option.
User avatar
mishionary
 
Posts: 3414
Joined: Tue Feb 20, 2007 6:19 am

Post » Tue Dec 29, 2009 6:48 pm

Does SetAtStart not work if you are in a different cell? If it doesn't maybe you could try this.
When the NPC needs to return to its original position, could you set a global variable to 1, and attach a script to an object in the NPC's original cell?

BeginIf ( myglobal == 1 )	set myglobal to 0	"NPCname"->SetAtStartendifend


So when you enter that cell this script will load and run.
User avatar
Sierra Ritsuka
 
Posts: 3506
Joined: Mon Dec 11, 2006 7:56 am

Post » Tue Dec 29, 2009 7:28 pm

Does SetAtStart not work if you are in a different cell? If it doesn't maybe you could try this.
When the NPC needs to return to its original position, could you set a global variable to 1, and attach a script to an object in the NPC's original cell?

BeginIf ( myglobal == 1 )	set myglobal to 0	"NPCname"->SetAtStartendifend


So when you enter that cell this script will load and run.

last time i tried setatstart, it did not work. was when i was just starting out, though, so i may have had the usage wrong. for some odd reason, i got the impression that setatstart did not function for NPCs. i'll give it another shot.

i cannot set a fix however. this is a targeted script, crafted so that i dont have to make redundant scripts for a mass of vanilla NPCs. any NPC of class "noble" to be exact.

i wonder.... i just read today that if you position an NPC in aiwander outside of his range, he will return to the range of the aiwander. so perhaps i can set the NPC to wander initially, and somehow trick the NPC into following the PC without changing AI packages. not sure how i'd go about doing this though, or if it would function as intended.

thanks for the help though, i appreciate it.
User avatar
Laurenn Doylee
 
Posts: 3427
Joined: Sun Dec 03, 2006 11:48 am

Post » Tue Dec 29, 2009 8:31 am

this is the script so far. havent been able to test setatstart because i'm getting a left eval that i cant seem to track down.

Spoiler
begin RAK_tg_kidnappingshort chanceshort oppositionshort initialshort doonceshort currentdayshort varcleanshort oncedoshort threedayshort didonceshort pspeeshort pstrfloat nfightfloat nfleefloat nalarmif ( initial == 0 )	set nfight to ( getfight )	set nflee to ( getflee )	set nalarm to ( getalarm )	set doonce to 0	set varclean to 0	set oncedo to 0	set threeday to 0	set didonce to 0	set opposition to ( ( GetSpeechcraft ) + random100 )	set pspee to ( "player"->GetSpeechcraft )	set pstr to ( "player"->GetStrength )	set chance to ( pspee + pstr )	set initial to 1	returnendifif ( gethealth < 1 )	setfight nfight	setflee nflee	setalarm nalarm	set varclean to 1endifif ( ( getpccell "Balmora, South Wall Cornerclub" ) == 1 )	if ( ( "player"->getdistance ) <= 200 )		set RAK_kidnap to 4		set RAK_ba_ransom to 1	endifelseif ( ( getpccell "Ald-ruhn, The Rat In The Pot" ) == 1 )	if ( ( "player"->getdistance ) <= 200 )		set RAK_kidnap to 4		set RAK_ar_ransom to 1	endifelseif ( ( getpccell "Sadrith Mora, Dirty Muriel's Cornerclub" ) == 1 )	if ( ( "player"->getdistance ) <= 200 )		set RAK_kidnap to 4		set RAK_sm_ransom to 1	endifelseif ( ( getpccell "Vivec, Simine Fralinie: Bookseller" ) == 1 )	if ( ( "player"->getdistance ) <= 200 )		set RAK_kidnap to 4		set RAK_vc_ransom to 1	endifendifif ( RAK_kidnap == 0 )	if ( opposition < chance )		set RAK_kidnap to 1		return	endifelseif ( RAK_kidnap == 1 )	if ( doonce == 0 )		aifollow "player" 0, 0, 0, 0		setfight 0		setflee 80		set doonce to 1		return	elseif ( doonce == 1 )		if ( ( "player"->getdistance ) >= 500 )			set currentday to day			set RAK_kidnap to 2			return		else			return		endif	endifelseif ( RAK_kidnap == 2 ) 	if ( currentday =! day )		set currentday to day		setfight nfight		setflee nflee		setalarm nalarm		setatstart		set varclean to 1		return	endif	setfight 70	setflee 40		if ( oncedo == 0 )			AIWander 5000, 0, 0, 60, 30, 10, 0, 0, 0, 0, 0, 0			set oncedo to 1			return		endifelseif ( RAK_kidnap == 3 )	if ( opposition < chance )		set doonce to 0		set RAK_kidnap to 1		return	else		moddisposition -30		set RAK_kidnap to 2		return	endifelseif ( RAK_kidnap == 4 )	if ( didonce == 0 )		forcegreeting 		AIWander 200, 0, 0, 60, 30, 10, 0, 0, 0, 0, 0, 0		set didonce to 1	endif		if ( currentday != day )		set currentday to day		set threeday to ( threeday + 1 )	endifendifif ( threeday > 2 )	set RAK_ransom to ( ( getlevel ) * 10 )	setfight nfight	setflee nflee	setalarm nalarm	setatstart	set varclean to 1else 	returnendifif ( varclean == 1 )	set RAK_kidnap to 0	set doonce to 0	set varclean to 0	set oncedo to 0	set threeday to 0	set didonce to 0	set initial to 0	stopscript "RAK_tg_kidnapping"endifend


the error seems to be popping up after doonce is set to 1, but before the dialog is closed. i'm quite baffled here, anyone see any obvious mistakes?
User avatar
Elea Rossi
 
Posts: 3554
Joined: Tue Mar 27, 2007 1:39 am

Post » Tue Dec 29, 2009 8:21 am

If I'm understanding your previous reply to my post correctly this is a global script right?
If this script isn't attached to an npc, I don't think this will work:

elseif ( RAK_kidnap == 1 )        if ( doonce == 0 )                aifollow "player" 0, 0, 0, 0     ;<--------this has to be defined (i think) if the script isn't attached to an NPC ex: "myNPC"->aiflollow "player" 0, 0, 0, 0                 setfight 0                setflee 80                set doonce to 1                return


And I believe you are right about the setatstart, I looked it up on the uesp. Frome the UESP: Setatstart-This resets the object to the original position and orientation it was given in the editor, before any movement or rotation occurred. Be warned that this function doesn't always seem to do exactly as it should. Objects are not nessecarily reset to its editor defined position.

It says objects not npcs, I should have looked it up before I suggested it :facepalm:
User avatar
Teghan Harris
 
Posts: 3370
Joined: Mon Mar 05, 2007 1:31 pm

Post » Tue Dec 29, 2009 4:21 pm

tis a targeted script. functions like a mishmash of global and local scripts. from MWSFD -

It is possible to use the StartScript function to run global scripts that are tied to an object or
Actor. These are called "targeted scripts".
"Object_ID"->StartScript "Script_ ID"
These scripts resemble both local scripts (in that the functions called always default to the
object or Actor the script targets) and global scripts (in that they are always running and can
be terminated with StopScript).

It is possible to use the StartScript function to run global scripts that are tied to an object or
Actor. These scripts resemble both local scripts (in that the functions called always default to
the object or Actor the script targets) and global scripts (in that they are always running).
Objects may have several different targeted scripts running on them at one time, and may also
have a local script.
To start a script as a targeted script:
? Object_ID->StartScript Script_ID (may be used from script, but does not work from
dialogue results).
? Start the script from the intended target's local script or another targeted script on the
object (it will inherit the target).
? Start the script from dialogue results (this will only work to target the actor the player
is in dialogue with: it is not possible to specify a different target in dialogue results). "*this is the method i am using"
This method is particularly useful as you don't need access to scripts running on the
actor, nor do you need an ID.
Uses of targeted scripts:
As a general rule: If a function requires a fix in a global script but the fix can be omitted in a
local script, that function may be used without a fix in a targeted script as well. Examples of
popular functions for targeted scripts include:
AddItem, RemoveItem, GetItemCount
AIFollow, AIWander, AIEscort
GetPos, SetPos, PositionCell
Get/Set/ModStat
StartCombat, StopCombat
Targeted scripts can be powerful tools, especially in combination with dialogue: you can
create generic dialogue (e.g. filtered for class only) and start your script from the resultbox.
CDCooley's "Companion Teleportation" is a good example of use with dialogue. Voice
dialogue can also be used this way: for example, many companions have a targeted "pacifist"
script that is started from Attack voice results if the player tells the companion to avoid
combat.
Cautions and limitations:
? Variables defined in a targeted script are not considered local to the object from the point
of view of dialogue and other scripts. For example, they cannot be used as dialogue
conditions. The special variable "companion" also cannot be used, i.e. declaring a short
variable "companion" in a targeted script and setting it to 1 will not enable companion
share on the target actor. I assume this applies to other special locals as well, but I haven't
tested any others.
? You cannot have more than one instance of a targeted script running at one time (same as
global scripts). The obvious workaround is to have several different scripts that all do the
same thing.

? If OnActivate is used in a targeted script, the object will not be able to be activated by
normal means after the script is stopped, unless a targeted script with an OnActivate is
again added to the object.
? If an object is deleted while a targeted script is running on it, the game will CTD. If the
target is not necessary but is merely a consequence of the way the script was started, you
can usually target the script on the player instead to avoid this: "player->StartScript
ScriptName". Otherwise, the script must be stopped before deleting the object.
? Scripts will detach from non-persistent targets when the game is saved and reloaded. This
may give errors on load ("Unable to locate reference for global script…"), or may not;
either way it may also give odd effects in some circumstances.
? When a targeted script is started on an object that was not placed into the gameworld in
the editor (i.e. an object that was placed or generated during the game), the script will lose
its targeting when a savegame is reloaded. Note that this applies to the player character as
well.
? Load list changes may also cause targeted scripts to lose their targeting when the game is
reloaded, whether or not the target is persistent and whether or not it was placed in the
editor. This doesn't always happen, but it can (adding several mods higher in the load list
will usually do it).
If a script becomes detached from its target, some functions that manipulate data about the
previously targeted object (e.g. getHealthGetRatio) may cause CTD if used without a fix.
As a workaround to avoid untargeted scripts running, you may be able to use a startscript to
stop the targeted script if it is running, then restart it if necessary. As a safety check for
targeted scripts on actors, GetHealth may be used before any functions that may cause
problems (returns 0 in an untargeted script)


as i said before, doonce completes normally, along with the aifollow command. i THINK the problem might be the "player"->getdistance. on second thought, i'm pretty sure this is the issue. it should be
if ( ( getdistance "player" ) <= 500 )

User avatar
Sammie LM
 
Posts: 3424
Joined: Thu Nov 30, 2006 1:59 pm

Post » Tue Dec 29, 2009 9:35 pm

Thanks for posting that, i really need to read all of mwsfd.

I'm not sure how picky the compiler is, but I saw one instance of < =! > in lieu of < != > in your script. I don't know if this could cause issues or not.
User avatar
Nice one
 
Posts: 3473
Joined: Thu Jun 21, 2007 5:30 am

Post » Tue Dec 29, 2009 9:26 pm

arg, i do that a bunch, thanks for picking it out.

and setatstart is not functioning.
User avatar
Sunnii Bebiieh
 
Posts: 3454
Joined: Wed Apr 11, 2007 7:57 pm

Post » Tue Dec 29, 2009 9:39 pm

arg, i do that a bunch, thanks for picking it out.

and setatstart is not functioning.


Yea, that's unfortunate. Is your aiwander trick not working?
User avatar
Arrogant SId
 
Posts: 3366
Joined: Sat May 19, 2007 11:39 am

Post » Tue Dec 29, 2009 7:38 pm

to be honest, i havent thought that all the way through. im kind of stumped on how to execute an aiwander and get the NPC to follow the player without interrupting that package.

i've managed to get everything else functional. the only problem now is that thief guildhalls hold the potential to get very crowded.

i wonder if there is something i can do with the 72-hour bug and the disable command....

eh, it's just a bit irritating, this is the last bit of functionality i'm adding before my mod's next version release.
User avatar
Matthew Warren
 
Posts: 3463
Joined: Fri Oct 19, 2007 11:37 pm

Post » Tue Dec 29, 2009 9:05 pm

This could probably be done with MWSE.

Using:
xMyCellID
xPositionCell

When the script is initialized set xyz POS and xMyCellID to variables, and when the NPC needs to return to his position call xPositionCell, MyX, MyY, MyZ, MyCell.
User avatar
ZzZz
 
Posts: 3396
Joined: Sat Jul 08, 2006 9:56 pm

Post » Tue Dec 29, 2009 6:45 am

i kind of figured i could do it in mwse, just have been trying to avoid that because of the extra work involved, and for people who dont use MGE/MWSE
User avatar
stacy hamilton
 
Posts: 3354
Joined: Fri Aug 25, 2006 10:03 am

Post » Tue Dec 29, 2009 3:42 pm

i kind of figured i could do it in mwse, just have been trying to avoid that because of the extra work involved, and for people who dont use MGE/MWSE


I can understand your point there, not everybody has mwse in some form or another. I added the functions to your script. If i'm understanding the script right If it gets to the cleanvar part then it's safe to say the NPC needs to return to his position right?

Spoiler
begin RAK_tg_kidnappingshort GatherInfo;;;;;;;;;;;;;;;;;;;;;;;;;;;;short chanceshort oppositionshort initialshort doonceshort currentdayshort varcleanshort oncedoshort threedayshort didonceshort pspeeshort pstrfloat nfightfloat nfleefloat nalarm;;;;;;;;;;;;;;;;;;;;;;;;;;float NXFloat NYFloat NZLong MyCell;;;;;;;;;;;;;;;;;;;;;;;;if ( initial == 0 )        set nfight to ( getfight )        set nflee to ( getflee )        set nalarm to ( getalarm )        set doonce to 0        set varclean to 0        set oncedo to 0        set threeday to 0        set didonce to 0        set opposition to ( ( GetSpeechcraft ) + random, 100 )        set pspee to ( "player"->GetSpeechcraft )        set pstr to ( "player"->GetStrength )        set chance to ( pspee + pstr )        set initial to 1        returnendif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Ifx ( GatherInfo )		  Set Nx to GetPos, X		  Set Ny to GetPos, Y		  Set Nz to GetPos, Z		  Setx MyCell to xMyCellId                  set gatherinfo to 0EndIf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;if ( gethealth < 1 )        setfight nfight        setflee nflee        setalarm nalarm        set varclean to 1endifif ( ( getpccell "Balmora, South Wall Cornerclub" ) == 1 )        if ( ( getdistance, player ) <= 200 )                set RAK_kidnap to 4                set RAK_ba_ransom to 1        endifelseif ( ( getpccell "Ald-ruhn, The Rat In The Pot" ) == 1 )        if ( ( getdistance, Player ) <= 200 )                set RAK_kidnap to 4                set RAK_ar_ransom to 1        endifelseif ( ( getpccell "Sadrith Mora, Dirty Muriel's Cornerclub" ) == 1 )        if ( ( getdistance, Player ) <= 200 )                set RAK_kidnap to 4                set RAK_sm_ransom to 1        endifelseif ( ( getpccell "Vivec, Simine Fralinie: Bookseller" ) == 1 )        if ( ( getdistance, player ) <= 200 )                set RAK_kidnap to 4                set RAK_vc_ransom to 1        endifendifif ( RAK_kidnap == 0 )        if ( opposition < chance )                set RAK_kidnap to 1                return        endifelseif ( RAK_kidnap == 1 )        if ( doonce == 0 );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	 set GatherInfo to 1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                aifollow "player" 0, 0, 0, 0                setfight 0                setflee 80                set doonce to 1                return        elseif ( doonce == 1 )                if ( ( getdistance, player ) >= 500 )                        set currentday to day                        set RAK_kidnap to 2                        return                else                        return                endif        endifelseif ( RAK_kidnap == 2 )         if ( currentday != day )                set currentday to day                setfight nfight                setflee nflee                setalarm nalarm                setatstart                set varclean to 1                return        endif        setfight 70        setflee 40                if ( oncedo == 0 )                        AIWander 5000, 0, 0, 60, 30, 10, 0, 0, 0, 0, 0, 0                        set oncedo to 1                        return                endifelseif ( RAK_kidnap == 3 )        if ( opposition < chance )                set doonce to 0                set RAK_kidnap to 1                return        else                moddisposition -30                set RAK_kidnap to 2                return        endifelseif ( RAK_kidnap == 4 )        if ( didonce == 0 )                forcegreeting                 AIWander 200, 0, 0, 60, 30, 10, 0, 0, 0, 0, 0, 0                set didonce to 1        endif            if ( currentday != day )                set currentday to day                set threeday to ( threeday + 1 )        endifendifif ( threeday > 2 )        set RAK_ransom to ( ( getlevel ) * 10 )        setfight nfight        setflee nflee        setalarm nalarm        setatstart        set varclean to 1else         returnendififx ( varclean );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;        xPositionCell, NX, NY, NZ, 0, MyCell;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;        set RAK_kidnap to 0        set doonce to 0        set varclean to 0        set oncedo to 0        set threeday to 0        set didonce to 0        set initial to 0        stopscript "RAK_tg_kidnapping"endifend


EDIT: Bleh, my tab spacing is off on my MWEdit
I haven't tested this script, It compiles fine but that doesn't mean anything.

EDIT2: now that I think about it should probably be under the stopscript
User avatar
Trevor Bostwick
 
Posts: 3393
Joined: Tue Sep 25, 2007 10:51 am

Post » Tue Dec 29, 2009 11:58 am

nope, it should be under the
if ( threeday > 2 )


i really dont want teleporting corpses after all.

i'll take a little time and mull it over, to decide if i do want to make use of MWSE. i'd really rather avoid it if at all possible, but every time i check my options, it seems i have little choice if i want this to function as i intend.

if i do decide to go with MWSE, i'll credit you for the help.
User avatar
Sabrina Schwarz
 
Posts: 3538
Joined: Fri Jul 14, 2006 10:02 am

Post » Tue Dec 29, 2009 5:59 pm

I appreciate the thought, but you would have easily figured out the MWSE stuff. I feel like I forced my additions of the script on you, and I don't want to take any credit from you. So, again thank you for the thought, but mentioning me isn't necessary If you go the MWSE route.
User avatar
Project
 
Posts: 3490
Joined: Fri May 04, 2007 7:58 am

Post » Tue Dec 29, 2009 2:27 pm

so i'm trying an edited version of the script metalfiend posted (differences include a few refinements to the basic script (forgot to reset opposition for RAK_kidnap = 3, and placed the position functions where the setatstart functions were) and i get the error on game load

Need more room for zero pointers in script::ReplaceGlobalsInData


i do not user more than one operator per set statement in this script, so i'm assuming that something with the extended functions is not working. any ideas?
User avatar
lolli
 
Posts: 3485
Joined: Mon Jan 01, 2007 10:42 am

Post » Tue Dec 29, 2009 7:07 am

Can you post the new script?
User avatar
Jessica Stokes
 
Posts: 3315
Joined: Fri Jul 28, 2006 11:01 am

Post » Tue Dec 29, 2009 10:03 am

silly me, i knew i should have....

Spoiler
begin RAK_tg_kidnappingshort chanceshort oppositionshort initialshort doonceshort currentdayshort varcleanshort oncedoshort threedayshort didonceshort pspeeshort pstrshort GatherInfofloat nfightfloat nfleefloat nalarmfloat NXFloat NYFloat NZLong MyCellif ( initial == 0 )	set nfight to ( getfight )	set nflee to ( getflee )	set nalarm to ( getalarm )	set doonce to 0	set varclean to 0	set oncedo to 0	set threeday to 0	set didonce to 0	set Gatherinfo to 1	set opposition to ( ( GetSpeechcraft ) + random100 )	set pspee to ( "player"->GetSpeechcraft )	set pstr to ( "player"->GetStrength )	set chance to ( pspee + pstr )	set initial to 1	returnendifIfx ( GatherInfo )	Set Nx to GetPos, X	Set Ny to GetPos, Y	Set Nz to GetPos, Z	Setx MyCell to xMyCellId	set gatherinfo to 0EndIfif ( gethealth < 1 )	setfight nfight	setflee nflee	setalarm nalarm	set varclean to 1endifif ( ( getpccell "Balmora, South Wall Cornerclub" ) == 1 )	if ( ( getdistance "player" ) <= 200 )		set RAK_kidnap to 4		set RAK_ba_ransom to 1	endifelseif ( ( getpccell "Ald-ruhn, The Rat In The Pot" ) == 1 )	if ( ( getdistance "player" ) <= 200 )		set RAK_kidnap to 4		set RAK_ar_ransom to 1	endifelseif ( ( getpccell "Sadrith Mora, Dirty Muriel's Cornerclub" ) == 1 )	if ( ( getdistance "player" ) <= 200 )		set RAK_kidnap to 4		set RAK_sm_ransom to 1	endifelseif ( ( getpccell "Vivec, Simine Fralinie: Bookseller" ) == 1 )	if ( ( getdistance "player" ) <= 200 )		set RAK_kidnap to 4		set RAK_vc_ransom to 1	endifendifif ( RAK_kidnap == 0 )	if ( opposition < chance )		set RAK_kidnap to 1	endifelseif ( RAK_kidnap == 1 )	if ( doonce == 0 )		aifollow "player" 0, 0, 0, 0		setfight 0		setflee 80		set doonce to 1		return	elseif ( doonce == 1 )		if ( ( getdistance "player" ) >= 500 )			set currentday to day			set RAK_kidnap to 2			return		endif	endifelseif ( RAK_kidnap == 2 ) 	if ( oncedo == 0 )		AIWander 5000, 0, 0, 60, 30, 10, 0, 0, 0, 0, 0, 0		set oncedo to 1		return	endif	if ( currentday != day )		set currentday to day		setfight nfight		setflee nflee		setalarm nalarm		xPositionCell, NX, NY, NZ, 0, MyCell		set varclean to 1		return	endif	setfight 70	setflee 40elseif ( RAK_kidnap == 3 )	set opposition to ( ( GetSpeechcraft ) + random100 )	if ( opposition < chance )		set doonce to 0		set RAK_kidnap to 1		return	else		moddisposition -30		set RAK_kidnap to 2		return	endifelseif ( RAK_kidnap == 4 )	if ( didonce == 0 )		forcegreeting 		AIWander 500, 0, 0, 60, 30, 10, 0, 0, 0, 0, 0, 0		set didonce to 1	endif	if ( currentday != day )		set currentday to day		set threeday to ( threeday + 1 )	endifendifif ( threeday > 2 )	set RAK_ransom to ( ( getlevel ) * 100 )	setfight nfight	setflee nflee	setalarm nalarm	set RAK_kidnap to 5	xPositionCell, NX, NY, NZ, 0, MyCell	set varclean to 1endifif ( varclean == 1 )	set RAK_kidnap to 0	set doonce to 0	set varclean to 0	set oncedo to 0	set threeday to 0	set didonce to 0	set initial to 0	stopscript "RAK_tg_kidnapping"endifend


edit, readability

edit again, noticed an error and corrected it.... gatherinfo should be in the "initializing" if block, otherwise, if you get to far away and have to retry ( rak_kidnapping == 3 ) than the position info would get reset as well.
User avatar
jeremey wisor
 
Posts: 3458
Joined: Mon Oct 22, 2007 5:30 pm

Post » Tue Dec 29, 2009 12:17 pm

silly me, i knew i should have....

Spoiler
begin RAK_tg_kidnappingshort chanceshort oppositionshort initialshort doonceshort currentdayshort varcleanshort oncedoshort threedayshort didonceshort pspeeshort pstrshort GatherInfofloat nfightfloat nfleefloat nalarmfloat NXFloat NYFloat NZLong MyCellif ( initial == 0 )	set nfight to ( getfight )	set nflee to ( getflee )	set nalarm to ( getalarm )	set doonce to 0	set varclean to 0	set oncedo to 0	set threeday to 0	set didonce to 0	set opposition to ( ( GetSpeechcraft ) + random100 )	set pspee to ( "player"->GetSpeechcraft )	set pstr to ( "player"->GetStrength )	set chance to ( pspee + pstr )	set initial to 1	returnendifIfx ( GatherInfo )	Set Nx to GetPos, X	Set Ny to GetPos, Y	Set Nz to GetPos, Z	Setx MyCell to xMyCellId	set gatherinfo to 0EndIfif ( gethealth < 1 )	setfight nfight	setflee nflee	setalarm nalarm	set varclean to 1endifif ( ( getpccell "Balmora, South Wall Cornerclub" ) == 1 )	if ( ( getdistance "player" ) <= 200 )		set RAK_kidnap to 4		set RAK_ba_ransom to 1	endifelseif ( ( getpccell "Ald-ruhn, The Rat In The Pot" ) == 1 )	if ( ( getdistance "player" ) <= 200 )		set RAK_kidnap to 4		set RAK_ar_ransom to 1	endifelseif ( ( getpccell "Sadrith Mora, Dirty Muriel's Cornerclub" ) == 1 )	if ( ( getdistance "player" ) <= 200 )		set RAK_kidnap to 4		set RAK_sm_ransom to 1	endifelseif ( ( getpccell "Vivec, Simine Fralinie: Bookseller" ) == 1 )	if ( ( getdistance "player" ) <= 200 )		set RAK_kidnap to 4		set RAK_vc_ransom to 1	endifendifif ( RAK_kidnap == 0 )	if ( opposition < chance )		set RAK_kidnap to 1	endifelseif ( RAK_kidnap == 1 )	if ( doonce == 0 )		aifollow "player" 0, 0, 0, 0		setfight 0		setflee 80		set Gatherinfo to 1		set doonce to 1		return	elseif ( doonce == 1 )		if ( ( getdistance "player" ) >= 500 )			set currentday to day			set RAK_kidnap to 2			return		endif	endifelseif ( RAK_kidnap == 2 ) 	if ( oncedo == 0 )		AIWander 5000, 0, 0, 60, 30, 10, 0, 0, 0, 0, 0, 0		set oncedo to 1		return	endif	if ( currentday != day )		set currentday to day		setfight nfight		setflee nflee		setalarm nalarm		xPositionCell, NX, NY, NZ, 0, MyCell		set varclean to 1		return	endif	setfight 70	setflee 40elseif ( RAK_kidnap == 3 )	set opposition to ( ( GetSpeechcraft ) + random100 )	if ( opposition < chance )		set doonce to 0		set RAK_kidnap to 1		return	else		moddisposition -30		set RAK_kidnap to 2		return	endifelseif ( RAK_kidnap == 4 )	if ( didonce == 0 )		forcegreeting 		AIWander 500, 0, 0, 60, 30, 10, 0, 0, 0, 0, 0, 0		set didonce to 1	endif	if ( currentday != day )		set currentday to day		set threeday to ( threeday + 1 )	endifendifif ( threeday > 2 )	set RAK_ransom to ( ( getlevel ) * 100 )	setfight nfight	setflee nflee	setalarm nalarm	set RAK_kidnap to 5	xPositionCell, NX, NY, NZ, 0, MyCell	set varclean to 1endifif ( varclean == 1 )	set RAK_kidnap to 0	set doonce to 0	set varclean to 0	set oncedo to 0	set threeday to 0	set didonce to 0	set initial to 0	stopscript "RAK_tg_kidnapping"endifend


edit, readability





When ever you use an extended funtion (xPositionCell in this case), it has to be within an Ifx block. Another problem is MWSE functions doesn't have full syntax support in an IFx statement.

An Ifx statement has to be written like this:

Ifx ( MyVariable )

Ifx ( MyVariable == 5 ) Doesnt work

Here is another example of an Ifx block thats from the readme that comes with mwse;

set temp to ( MyVariable - 5 )ifx ( temp )    ; section for not 5else    section for 5endif


Now I'm not sure how you are supposed to this for a > 2 condition. So I would just set a new variable to 1 in the 2 )> block and create a new IFx block that contains the xpositioncell function.

I hope this makes sense, I'm terrible at explaining things.
User avatar
Michelle Chau
 
Posts: 3308
Joined: Sat Aug 26, 2006 4:24 am

Post » Tue Dec 29, 2009 11:14 am

how about setting a new control variable for the xpositioncell?

so that

if ( threeday > 2 )        set respawn to 1endififx ( respawn )    xPositionCell, NX, NY, NZ, 0, MyCellendif


edit, nope, same error.
User avatar
XPidgex Jefferson
 
Posts: 3398
Joined: Fri Sep 08, 2006 4:39 pm

Post » Tue Dec 29, 2009 12:37 pm

how about setting a new control variable for the xpositioncell?

so that

if ( threeday > 2 )        set respawn to 1endififx ( respawn )    xPositionCell, NX, NY, NZ, 0, MyCellendif



Yep, that should work.
User avatar
W E I R D
 
Posts: 3496
Joined: Tue Mar 20, 2007 10:08 am

Post » Tue Dec 29, 2009 1:51 pm

hrm, could it be that i am using the MGE MWSE, and not the "standalone"?

or could this have something to do with it?

Note that both string and reference variables are recorded as long in the scripts but they are not interchangable. In addition, if you use an invalid string or reference value, Morrowind will crash; this is especially something you need to watch out for when games are loaded, as string and reference variables are not saved with the game.

User avatar
Lucy
 
Posts: 3362
Joined: Sun Sep 10, 2006 4:55 am

PreviousNext

Return to III - Morrowind