Running 2 scripts at the same time on a single NPC

Post » Wed Dec 07, 2011 8:56 pm

Hello,
Can I make the TES4 runing 2 scripts on npc at the same time?

My custom script (packages, class restrictions, classgen, birthsign gen etc) all the time
Companion scripts when required...

Thanks
User avatar
Red Sauce
 
Posts: 3431
Joined: Fri Aug 04, 2006 1:35 pm

Post » Wed Dec 07, 2011 10:15 pm

regardless if what you want is possible or not, I think the best solution would be to create a function for the shorter script and add some checks to determine when to run it.
http://obse.silverlock.org/obse_command_doc.html#User_Defined_Functions

e.g
if ( required )      call CompanionFunctionendif

User avatar
SiLa
 
Posts: 3447
Joined: Tue Jun 13, 2006 7:52 am

Post » Thu Dec 08, 2011 9:09 am

regardless if what you want is possible or not, I think the best solution would be to create a function for the shorter script and add some checks to determine when to run it.
http://obse.silverlock.org/obse_command_doc.html#User_Defined_Functions

e.g
if ( required )      call CompanionFunctionendif



Ye that worked for me... but I still facing some problems with 1 of my linked scripts.
The main script is not executing...

ref NPC
ref NPCClass
.....
.....

Set NPC to GetSelf
Set NPCClass to NPC.GetClass

If (NPCClass == Warrior)
call NPCClassWarrior
endif
If (NPCClass == Warlock)
call NPCClassWarlock
endif
If (NPCClass == Thief)
call NPCClassThief
endif
If (NPCClass == Sorcerer)
call NPCClassSorcerer
Endif
If (NPCClass == Rogue)
call NPCClassRogue
Endif
If (NPCClass == Priest)
call NPCClassPriest
endif
If (NPCClass == Nightblade)
call NPCClassNightblade
endif
If (NPCClass == Mage)
MessageEX "I'm a mage"
call NPCClassMage
endif
If (NPCClass == Knight)
call NPCClassKnight
endif
If (NPCClass == Acrobat)
call NPCClassAcrobat
endif
If (NPCClass == Assassin)
call NPCClassAssassin
endif
If (NPCClass == Barbarian)
call NPCClassBarbarian
Endif
If (NPCClass == Bard)
call NPCClassBard
Endif
If (NPCClass == Monk)
call NPCClassMonk
endif
.......
......


dunno where is the prob...
I just want the program to check the NPC's class and run the propraite script.
User avatar
Jerry Jr. Ortiz
 
Posts: 3457
Joined: Fri Nov 23, 2007 12:39 pm

Post » Thu Dec 08, 2011 6:53 am

oh my.. your script. Is this a quest script?
And more.. show us one of your funtions that are called, I have I guess they are simmilar so one will suffice.

Advice how I use the call function...
first I set the ref
set MyRef to ................ GetSelf /// if the script is attached on a NPC or is attached to a SPELL that effects player or npc. /// ... in your example this is the case.
Then I call my user-defined functions ON my REFS
MyRef.Call MyFunction

------ NOW .. function content is like this


begin function {}
set hp to ( getav health + 100 )
modav health hp
return
end

.... Make sure your function are OBJECT type script that are NOT attached to ANY object... in this case the "modav health hp" runs ON MyRef because I called the function like that ... -> MyRef.Call MyFunction.
And don't forget the RETURN in the end of the function
User avatar
Kirsty Wood
 
Posts: 3461
Joined: Tue Aug 15, 2006 10:41 am

Post » Thu Dec 08, 2011 3:45 am

Use tabs. This site should sort out a lot of your problems, neatness is key. If you can easily read your work you are more likely to understand where your problem is. Also, you should use ";comment". Making comments helps you understand what you were doing with your script segments in the future (trust me you will run into that problem more often then you think).

Also, we need the whole script. Besides that why not use elseif's instead of a TON of if/endifs. This makes the script way faster and is a lot more clean.

Site: http://webpages.charter.net/manauser/morrowind/indenter.htm (or just learn it second nature like I did.)

ref NPCref NPCClass..........Set NPC to GetSelfSet NPCClass to NPC.GetClassIf (NPCClass == Warrior)	call NPCClassWarriorendifIf (NPCClass == Warlock)	call NPCClassWarlockendifIf (NPCClass == Thief)	call NPCClassThiefendifIf (NPCClass == Sorcerer)	call NPCClassSorcererEndifIf (NPCClass == Rogue)	call NPCClassRogueEndifIf (NPCClass == Priest)	call NPCClassPriestendifIf (NPCClass == Nightblade)	call NPCClassNightbladeendifIf (NPCClass == Mage)	MessageEX "I'm a mage"	call NPCClassMageendifIf (NPCClass == Knight)	call NPCClassKnightendifIf (NPCClass == Acrobat)	call NPCClassAcrobatendifIf (NPCClass == Assassin)	call NPCClassAssassinendifIf (NPCClass == Barbarian)	call NPCClassBarbarianEndifIf (NPCClass == Bard)	call NPCClassBardEndifIf (NPCClass == Monk)	call NPCClassMonkendif.............

User avatar
Rachie Stout
 
Posts: 3480
Joined: Sun Jun 25, 2006 2:19 pm


Return to IV - Oblivion