Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

General Script Questions #2


WillieSea
 Share

Recommended Posts

What is the best way to determine how much of the PC's health has been lost by taking melee damage?  Only way I can figure is to take the base health and subtract from the modified health.  Is there a better way?

 

I am using "(GetBaseAV Health - GetAV Health)"

 

Is there a more eloquent way?

Link to comment
Share on other sites

  • 1 month later...

Problem.  I'm trying to increase the speed of a bow via a script (with ModWeaponSpeed or SetWeaponSpeed - OBSE I know, but it's not hard to figure out what it does).  But it doesn't work.  The script does change the speed in practice, but the speed change is not reflected in the animation of drawing and firing the bow.  Plus, the speed is not changed in the stats of the bow.  Is there some kind of trick to actually get the bow speed to change?  I want an actual quicker animation.  I've tried "Update3D", but doesn't make a difference.

 

Help would be greatly appreciated.

Link to comment
Share on other sites

Interesting, WillieSea, the ever-helpful.  I did not even think about that.

 

Just for sh*ts and giggles, any idea why the Mod/Set-WeaponSpeed doesn't work?

 

EDIT

 

I'm dense.  Where can I find this perk?  Not one of the standard archer perks awarded in-game...

Edited by Malonn
Link to comment
Share on other sites

WillieSea,

 

You're thinking of Skyrim.  I checked, and one of the perks for Marksman in that game is a 30% quicker bow draw.  This script I'm working on is for Oblivion.

Anyone have any other ideas?

 

EDIT:

 

On the off chance anyone is interested, I just thought of something having looked at a couple of mods.  What I could do is create a bow with the speed set high.  Then I could add the bow to the inventory and have the PC equip it when the conditions are met for a quick draw.

 

Will that work?

Edited by Malonn
Link to comment
Share on other sites

Okaay.  The above works.  I created a bow, then I call it and equip when the conditions are met.  The problem is that equipping the "rapid shot" bow goes through the whole drawing of the weapon again.  I don't want that.  Is there a way to circumvent the animation of drawing a bow??

 

Help me, WillieSea.  Thou hast bountiful knowledge.

Link to comment
Share on other sites

  • 2 weeks later...

I have a question regarding door naming.

 

Is there a way to eliminate the "to *destination cell" part of a door's text?

 

For instance, I have a door named "East Wing".  In game it displays as "East Wing to Hideout" if the doors are linked.

 

The connected doors are in the same cell.  So, it looks rather silly if the doors are linked in the conventional way (displaying that they are going "to" the same location).  As of now, I have the doors scripted to simply move the player to a directional marker.  This does take care of the text.  However, I would like to make the doors operate as other doors in Oblivion and be more NPC/partner-friendly.

 

I have a northeast, southeast, and west wing in one cell.  I know this is not optimal.  However, separating these areas into different cells would mean a total rewrite.  It is a rather large mod that I have been working on and expanding for quite a while.  Separating the areas would also effectively keep NPCs & partners from utilizing the entire hideout at one time.

 

I have been beating my head against the wall over this for some time.  Any help would be greatly appreciated.

Link to comment
Share on other sites

Its not really a scripting question.

 

But for Oblivion, there is no way you can remove the destination cell from the door. (You can in skyrim.)

 

You could copy your cell a few times, then remove the other parts of the cell objects, so each cell has its own wing. You would not have to totally rewrite the whole mod when you do this.

Link to comment
Share on other sites

Removing the in game name from the door ("East Wing" in this case) is the only way to prevent the destination from showing up. There is a workaround for this, but I'm not sure how "companion friendly" it is.

 

1. Place two normal doors in the door frames and link them as normal. Position your teleport markers where you want them.

 

2. Move the doors (but NOT the teleport markers) below the floor so the meshes can't be seen.

 

3. Make sure both doors are set as Persistent references and give both doors unique Ref IDs. I'll use "ToEastWingRef" and "FromEastWingRef" for scripting purposes.

 

4. Create two activators that use the same mesh as the door you wish to use (this may require unpacking the mesh from the .bsa). I'll use ToEastWingAct and FromEastWingAct for their editor IDs. Give them in game names appropriate to their function. (i.e., name the ToEastWingAct "East Wing" and the FromEastWingAct "Main Hall", or wherever it is that you'll be teleporting).

 

5. Attach the following script to the ToEastWingAct activator:

scn EastWingActScript

 

Begin OnActivate Player

ToEastWingRef.Activate Player, 1

 

End

 

6. Attach the following script to the FromEastWingAct activator:

scn EastWingActScript

 

Begin OnActivate Player

FromEastWingRef.Activate Player, 1

 

End

 

7. Place the ToEastWingAct activator where the door to the east wing goes, then place the FromEastWingAct activator where the return door goes.

 

That should give the appearance of teleporting while also keeping the destination from showing. As long as you have a SubSpace around the East Wing area, NPCs will know they need to use a door to get there. With the actual teleport doors placed just below the floor, NPCs may be able to activate them and teleport. It might help to rotate the doors so they are parallel to the floor.

Link to comment
Share on other sites

Thank you so much, Vyper!

 

My doors finally work as I have always wanted them to.  Now, the NPCs/partners/followers travel through the hideout properly and pathing is greatly improved.

 

What I did was left the original doors as they were and added very scaled down doors, hiding them just behind the original doors, and linking them as you specified (close anyway ;) ).  I was close.  You helped me get the rest of the way.

 

Thank you again!

 

Would you mind doing me a favor and test out my mod for me?  I would love to have an experienced eye walk through it. :)

 

http://oblivion.nexusmods.com/mods/43162

Edited by cross1492
Link to comment
Share on other sites

  • 5 months later...

I had an idea that may be usefull to some modders, but I don't know enough about scripting to make it happen.  I'll give a few examples.

 

Let's start with the basics:   A room furnished with 3 choices of furniture a)Red b)Green c)Blue  each set with their own enable-parent.

3 corresponding color coded "items"  that the player can either purchase or find in a barrel outside the house etc.

 

If the player enters the house for the first time with none of the 3 items, then there is no furniture.

If the player enters the house with the blue item, then the blue furniture is enabled, and stays blue until changed.

If the player enters the house with the red item, the existing furniture is disabled, and red is enabled. and so on...

(I know this can be done with switches but.... can having an item in inventory do the job)

 

Example 2 (similar script)  One Training room instead of many:

player selects (1) object from display case outside the training room.   i.e. Sword enables Blade training partner in the training room. bow enables marksman trainer, etc.

I've seen several mods that have multiple training rooms, where one room could serve multiple purposes.

 

Example 3 (same script)  Training room creatures.  player carrying items (b)(i) and (m) enters room to face a bear, imp, and minotaur.

 

Example 4 (same old same)   Player carrying item x enters store y.   Item x enables Merchant container z -  making (n) items available for sale.

 

Example 5 ...  player finds item(k) in wilderness:  entering a nearby tavern carrying item (k) brings up rumor topic, adventurer seeking to purchase (k) etc.

 

as you can see there are many posibilities for this cell script.   How to?   Thanks for any input, good or bad.

Link to comment
Share on other sites

  • 3 weeks later...

Ex1

You setup a 'trigger zone' surrounding the entrance door marker.

The script you put on the trigger zone could then check the players inventory for the required items, and enable or disable the correct color xmarker based on the results.

 

Ex2

The 'object' the player selects could be an activator, which makes the changes to the training room.

 

Ex3

Same as Ex1

 

Ex4

Same as Ex1, but you can 'add' or 'remove' items from the merchants chest using a script.

 

Ex5

Same as Ex1. But I don't work with 'dialog' but would guess you can add conditions to the dialog that can be set in the script if the player has the item.

Link to comment
Share on other sites

  • 3 months later...

I'm try to create an amulet that will add somebody (Player or NPC) to a faction when equipped, then remove them from the faction when unequipped, but I can't seem to get it to work. My current script is:





scn BlarneyInfiltrationAmuletObjectScript



Ref Wearer



Begin OnEquip

Set Wearer to GetActionRef

Wearer.SetFactionRank BlarneyFaction, 0 ;BlarneyFaction is a custom faction unique to this mod

End



Begin OnUnEquip

Wearer.SetFactionRank BlarneyFaction, -1

End

I get no errors when I save this script, but see no results in game. What do I need to do to get this to work on NPCs as well as the Player?

Link to comment
Share on other sites

Its probably not working because GetActionRef does have issues outside of 'onactivate' or 'ontrigger' events.

 

http://cs.elderscrolls.com/index.php?title=GetActionRef

 

So your GetActionRef probably is NULL when you attempt to use it.

 

There are probably ways around it, setting a variable, then in an update event, check if the variable is set, then do the commands. That would get you to the next frame.

Link to comment
Share on other sites

Its probably not working because GetActionRef does have issues outside of 'onactivate' or 'ontrigger' events.

 

http://cs.elderscrolls.com/index.php?title=GetActionRef

 

So your GetActionRef probably is NULL when you attempt to use it.

 

There are probably ways around it, setting a variable, then in an update event, check if the variable is set, then do the commands. That would get you to the next frame.

Ahh, I forgot about the GetActionRef issue. Well, that complicates issues a bit. I just tried using a GameMode block in the script also to no avail:





scn BlarneyInfiltrationAmuletObjectScript



Short AAWearing

Ref Wearer



Begin OnEquip

  Set Wearer to GetSelf

  Set AAWearing to 1

End



Begin GameMode

  If AAWearing == 1

    Wearer.SetFactionRank BlarneyFaction, 0

  ElseIf AAWearing == 0

    Wearer.SetFactionRank BlarneyFaction, -1

  EndIf

End



Begin OnUnEquip

  Set AAWearing to 0

End

Again, I get no error messages when saving the script, but I also get no results in game. Is there any way to actually set this up so it's non actor-specific?

Link to comment
Share on other sites

  • 2 months later...

I've got a question that's really baking my brain.  Probably simple to an experienced scripter.  Well, here it is:  How can I track how many times I hit an NPC with a bash?  I wrote a simple push/shield bash script, and I want to track how many times I hit any given NPC with the bash/push.  If they are pushed 3 times within a certain time frame, they attack.  I'm really having trouble tracking the NPC's because I could push one NPC twice, then go to another NPC and push him/her once, then go to another NPC and push him/her three times.  The script needs to track those individuals and the number of times they've been pushed/bashed.  The script should only track 10 or so NPC's so it doesn't get out of control.  Anything over 10 resets the thing.

 

Can this be done simply?  I can't figure out how to do it.

 

EDIT:

 

Okay.  I buckled down and strapped on my thinking cap and figured out a way to do what I was asking for help to do.  It strikes me as rough and clumsy.  Just not elegant.  Here's the script:

ScriptName MalonnPushScript

Short sNPCReset
Short sKeyVar
Short sStaggerVar
Short sCountReset
Short sCounter1
Short sCounter2
Short sCounter3
Short sCounter4
Short sCounter5
Float fQuestDelayTime
Float fAnimDelay
Ref rCrossRef
Ref rShield
Ref rNPC
Ref rNPC2
Ref rNPC3
Ref rNPC4
Ref rNPC5

Begin GameMode

	If fQuestDelayTime != 0.10
		Let fQuestDelayTime := 0.10
	Endif

	Let rCrossRef := GetCrosshairRef
	Let rShield := Player.GetEquippedObject 13
	If rCrossRef.GetObjectType == 35
		If sNPCReset == 0
			Let rNPC := rCrossRef
			Let sNPCReset := 1
			If sCountReset == 1
				Let sCounter1 := 0
				Let sCountReset := 2
			Endif
		Endif
		If rNPC != rCrossRef
			If sNPCReset == 1
				Let rNPC2 := rCrossRef
				Let sNPCReset := 2
				If sCountReset == 2
					Let sCounter2 := 0
					Let sCountReset := 3
				Endif
			Endif
		Endif
		If rNPC != rCrossRef && rNPC2 != rCrossRef 
			If sNPCReset == 2
				Let rNPC3 := rCrossRef
				Let sNPCReset := 3
				If sCountReset == 3
					Let sCounter3 := 0
					Let sCountReset := 4
				Endif
			Endif
		Endif
		If rNPC != rCrossRef && rNPC2 != rCrossRef && rNPC3 != rCrossRef
			If sNPCReset == 3
				Let rNPC4 := rCrossRef
				Let sNPCReset := 4
				If sCountReset == 4
					Let sCounter4 := 0
					Let sCountReset := 5
				Endif
			Endif
		Endif
		If rNPC != rCrossRef && rNPC2 != rCrossRef && rNPC3 != rCrossRef && rNPC4 != rCrossRef
			If sNPCReset == 4
				Let rNPC5 := rCrossRef
				Let sNPCReset := 5
				If sCountReset == 5
					Let sCounter5 := 0
					Let sCountReset := 6
				Endif
			Endif
		Endif
		If rNPC != rCrossRef && rNPC2 != rCrossRef && rNPC3 != rCrossRef && rNPC4 != rCrossRef && rNPC5 != rCrossRef
			Let sNPCReset := 0
			Let sCountReset := 1
		Endif
	Endif

	If IsKeyPressed3 33 == 1 && sKeyVar == 0
		Let sKeyVar := 1
		If Player.IsWeaponOut == 1
			If Player.IsShieldOut == 1
				Player.PlayGroup BlockAttack 1
				Player.PlayGroup Idle 0
				Let sStaggerVar := 1
				If Player.GetActorValue Fatigue >= 10
					Player.ModActorValue2 Fatigue -10
				Endif
			Else
				Player.PlayGroup CastTouch 1
				Player.PlayGroup Idle 0
				Let sStaggerVar := 1
				PlaySound WPNSwishHand
				If Player.GetActorValue Fatigue >= 10
					Player.ModActorValue2 Fatigue -10
				Endif
			Endif
		Elseif Player.GetEquipped rShield == 1 && Player.IsWeaponOut == 0 && Player.GetWeaponAnimType <= 1
			Player.PlayGroup BlockAttack 1
			Player.PlayGroup Idle 0
			Let sStaggerVar := 1
			If Player.GetActorValue Fatigue >= 10
				Player.ModActorValue2 Fatigue -10
			Endif
		Else
			Player.PlayGroup CastTouchAlt 1
			Player.PlayGroup Idle 0
			Let sStaggerVar := 1
			PlaySound WPNSwishHand
			If Player.GetActorValue Fatigue >= 10
				Player.ModActorValue2 Fatigue -10
			Endif
		Endif
	Elseif IsKeyPressed3 33 == 0 && sKeyVar == 1
		Let sKeyVar := 0
	Endif

	If rCrossRef.IsActor == 1
		If sStaggerVar == 1
		Let fAnimDelay += GetSecondsPassed
			If fAnimDelay >= 0.6
				rCrossRef.PlayGroup Stagger 1
				Let sStaggerVar := 0
				Let fAnimDelay := 0
				rCrossRef.ModDisposition Player -10
				If rCrossRef.IsGuard == 1
					Player.ModCrimeGold 1000 
				Endif
				If rCrossRef == rNPC
					Let sCounter1 += 1
				Elseif rCrossRef == rNPC2
					Let sCounter2 += 1
				Elseif rCrossRef == rNPC3
					Let sCounter3 += 1
				Elseif rCrossRef == rNPC4
					Let sCounter4 += 1
				Elseif rCrossRef == rNPC5
					Let sCounter5 += 1
				Endif
			Endif
		Endif
	Else
		Let sStaggerVar := 0
		Let fAnimDelay := 0
	Endif

	If sCounter1 >= 3
		rNPC.StartCombat Player
		Let sCounter1 := 0
	Elseif sCounter2 >= 3
		rNPC2.StartCombat Player
		Let sCounter2 := 0
	Elseif sCounter3 >= 3
		rNPC3.StartCombat Player
		Let sCounter3 := 0
	Elseif sCounter4 >= 3
		rNPC4.StartCombat Player
		Let sCounter4 := 0
	Elseif sCounter5 >= 3
		rNPC5.StartCombat Player
		Let sCounter5 := 0
	Endif

End

That's the full script that does what I want.  Is there a more efficient way?  I'm satisfied enough, I suppose.  But insight is always welcome.

Edited by Malonn
Link to comment
Share on other sites

  • 1 year later...

I would have three questions:

 

- Is there a way to make the player temporarily immune to fall damage? I know that Super Marioblivion did it, but I can't figure out how.

 

- Is there a way to make the player temporarily unable to jump? As in, making it so that pressing the jump key gives no input at all.

 

- When moving the player somewhere within the same cell using player.moveto, the player is instantly brought to the nearest standing ground directly below the XMarkerHeading. Is there a way around this, so that the player starts floating in the air and subsequently falls to the ground?

Edited by ZuTheSkunk
Link to comment
Share on other sites

Maybe using ResetFallDamageTimer could help? With a trigger zone right before player hits the ground, maybe? Or something to set some fall damage multiplier to 0 for a while, maybe, if there is such a command - or variable. I do not know.

Player.ResetFallDamageTimer
Jumping thing probably works with DisableControl from OBSE. And EnableControl afterwards.

DisableControl 13
...
EnableControl 13
And could the falling thing be made by moving the player to the target, but with supplying offsets? Or does it still move him/her on the ground?

Player.MoveTo TargetRef 0,0,300
Maybe moving player up in the next frame? With a trigger zone (again)? If, despite the supplied z-axis offset, player is still moved on the ground?

short DoOnce
float Height

Begin OnTrigger Player

    If ( DoOnce )
        Return
    EndIf

    let DoOnce := 1
    let Height := ( Player.GetPos Z ) + 300
    Player.SetPos Z Height

End
If SetPos can be used on player. I have never done it. :P Or perhaps a collision box in the air, the XMarkerHeading on top of that one and then disable the collision box when player has been placed on top of it (by a trigger zone, maybe)? If a collision box counts as 'ground' so that the game places player on top of it. I have never done that either... Edited by PhilippePetain
Link to comment
Share on other sites

  • 3 months later...

Greetings,

First time on the forum as a poster, has read plenty of your tutorials earlier though, very helpful! Please do correct me if I post this in the wrong section.

I've been trying to make a Katana with a script which would add a random magic damage effect on the opponent on strike, e.g various elemental damages and weakness to magic and so on. I havent found much on the net for it, and the one I tried myself using Rand among others has no effect. Does anyone have any idea if this could even be possible to do, and if it is, how I can do it. Which commands would be suitable for this?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...