Jump to content

Need a script that affects both player AND npcs


crazedinmate

Recommended Posts

Hello,

 

I am looking for a way to have a script affect the player and all npc characters automatically and all of the time so that they all experience the same effect equally. I know that there must be a simple way to script this, but I am new to modding, and I only understand some scripting. Would anyone be willing to show me a sample of code that would accomplish this? Any help would be appreciated.

 

Thanks.

Link to comment
Share on other sites

Hello,

 

I am looking for a way to have a script affect the player and all npc characters automatically and all of the time so that they all experience the same effect equally. I know that there must be a simple way to script this, but I am new to modding, and I only understand some scripting. Would anyone be willing to show me a sample of code that would accomplish this? Any help would be appreciated.

 

Thanks.

 

You are going to have to provide a lot more information. As it stands, your question looks like (as unlikely as it sounds) you want to put a script effect on every NPC -- yeah, right! I am guessing that you mean all NPCs in the same cell as the player at a specific time or trigger. But you are going to have to confirm or contradict that. Spell out your proposition.

Link to comment
Share on other sites

Affecting everyone in the same cell as the player would be fine. What I want to do is have a script that prevents anyone wearing heavy armor from being able to swim. I am familiar with the mod "no encumbered swimming," which attempts to address this idea. However, it only seems to affect the player character. Also, it is based on encumbrance, rather than what a character is wearing. It doesn't seem right to be swimming away from a guard who has heavy armor equipped and is still keeping pace with you. What I would like to have is a mod that affects anyone and everyone who has armor equipped.

 

So, how would I compose a script(s) that would affect everyone in a cell that is swimming? I am most curious as to what type of script it should be, how to get the script to run , and how to have it work on everyone.

 

Any help would be appreciated. Thanks.

Link to comment
Share on other sites

I can think of a script that would kill someone trying to swim with heavy armor on.

 

 

scriptname ExampleQuestScript


array_var temparr
ref tempref
ref tempref2
short tempshort


Begin GameMode

let tempref := GetFirstRef 69
while (tempref)
	if (tempref.IsSwimming == 1)
		let temparr := tempref.GetEquippedItems
		while (tempshort < ar_size temparr)
			let tempref2 := temparr[tempshort]
			if (tempref2.GetArmorType == 1)
				tempref.Kill
				MessageEX "%n tried to swim while wearing heavy armor.  What an idiot!" tempref
				Break
			endif
			let tempshort := (tempshort + 1)
		loop
	endif
	let tempshort := 0
	ar_Erase temparr
	let tempref := GetNextRef
loop

End

 

 

But I'm not sure how to stop them from swimming... You could try making an AI package that doesn't allow swimming and force it onto any NPC that swims with heavy armor on. I think that should make it so the NPC gets out of the water. But that would interrupt whatever they were doing in the first place. And if you just remove it as soon as they get out of the water, then when they continue what they were doing before, they'd just get into the water again.

Edited by fg109
Link to comment
Share on other sites

What's the difference between a subject carrying 90% of his max encumbrance swimming, and a subject carrying 30% of his max enc, but wearing heavy armor? Basing it on enc makes more sense to me.

I would image that NPCs dont ever have 90% encumbrance, unless they get place under a burden spell. (right? dose encumbrance even effect NPCs?)

Link to comment
Share on other sites

Encumbrance and the weight of worn armour are mutually inclusive, so rather than kill anybody who's swimming with heavy armour, you could modify their swimspeedmultiplier via the OBSE command ModActorValueC, so using fg109's script, you could do:

 

 

scriptname ExampleQuestScript


array_var temparr
ref tempref
ref tempref2
short tempshort
long modifier


Begin GameMode

   	let tempref := GetFirstRef 69
   	let modifier := -25
   	while (tempref)
           	if (tempref.IsSwimming == 1)
                   	let temparr := tempref.GetEquippedItems
                   	while (tempshort < ar_size temparr)
                           	let tempref2 := temparr[tempshort]
                           	if (tempref2.GetArmorType == 1)
                                   	tempref.ModActorValueC 54 modifier
                                   	MessageEX "%n is trying to swim in heavy armour" tempref
                                   	Break
                           	endif
                           	let tempshort := (tempshort + 1)
                   	loop
           	endif
           	let tempshort := 0
           	ar_Erase temparr
           	let tempref := GetNextRef
   	loop

End

 

Link to comment
Share on other sites

I would image that NPCs dont ever have 90% encumbrance, unless they get place under a burden spell. (right? dose encumbrance even effect NPCs?)

You are correct in your assessment regarding NPC encumbrance, they are rarely even remotely close to their limit (few are more than a couple of percent of their limit). That's why without proper stacking Burden spells are a waste of time against anyone but the player.

Link to comment
Share on other sites

Thanks for the script examples, everyone. However, I haven't been able to get either of the examples given to function properly. I must be doing something wrong, since there is no change in my game. I have tried using them as stand-alone scripts and as parts of simple quests, and still I have had no luck. One thing that I have noticed is that the construction set is telling me that I have an "invalid parameter range" for the "ar_Erase temparr"

line towards the end of the script, or some similar sounding error message. I have been adding information at the end of that line, such as "0:1000" so that the script can be saved. I am running OBSE 18.0 with the Construction Set. Could that be the problem? Perhaps I simply have not properly set the script within a quest.

 

I am more of a noob than I thought. How embarrassing.

 

If you were to set up the script in your game, would it run as a standalone script, one that runs with "Begin Gamemode?"

 

Or, would it be incorporated into a quest? If so, how would you set up that quest? Just assume that I don't know what I'm doing with the Construction Set, because apparently that is the case.

 

I would appreciate any input and help.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...