Jump to content

Post your Scripts Here


Smosh

Recommended Posts

I thought it might be a good idea to keep scripts and tips in one thread.

 

PLEASE DO NOT ASK FOR HELP IN THIS THREAD.

IF YOU HAVE A QUERY ABOUT SOMETHING PLEASE START A NEW THREAD.

 

I'll start it off with the only script I know.

 

Karma Effects on Items

 

scn KarmaEffect

Begin OnEquip
player.RewardKarma -650

END

Begin OnUnequip
player.RewardKarma 650

END

 

When a player equips the item they lose 650 Karma and regain it when they Unequip the item.

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

This is an autoclosing door script. It will close the door a few seconds after its opened.

 

Script type: Object

 

Scriptname AutoClosingDoor

float doorTimer
short closeDoor

Begin GameMode
if closeDoor == 1
	if doorTimer > 0
		set doorTimer to doorTimer - getSecondsPassed
	else
   ;close the door
		Activate
   ; Lock
		set closeDoor to 0
	endif
endif	
End

Begin OnActivate
Activate
if IsActionRef Player == 0  ;if it only works for NPCs remove this .....
	set doorTimer to 5
	set closeDoor to 1
endif								   ;...and this
End

 

I used it for oblivion so it should work well. (PS. I diden't actually write it, I found on a door in the SE expansion)

Link to comment
Share on other sites

This is a sample from my follower's scripts. If you leave the follower waiting for a set period of time, that will stop waiting and resume any other AI packages based on those conditions.

 

BEGIN GameMode
if ( isMillerWaiting == 1 )
	set MillerWaitTime to 1
	if ( MillerWaitTime <= GameDaysPassed )
		set isMillerWaiting to 0
		set isMillerWithPlayer to 0
		set MillerWaitTime to 0
	endif
endif
END

 

Alter the wait time to however many days you want them to wait.

 

My ai packages use the condition for isMillerWithPlayer. If he is not, they perform non-following packages. The short - isMillerWaiting is the toggle between the follow/guard package.

Link to comment
Share on other sites

I found this posted by a guy called Circuitous with help from teddybearman. I'm posting it so you can see how these things work.

 

I think it is to do with this mod http://www.fallout3nexus.com/downloads/file.php?id=121

 

Level Cap Increaser

 

scn bounceback

   Begin MenuMode

   if player.getlevel >= 21

   if bbRealLevelSet != 1
   Set bbRealLevelSet to 1
   Set bbRealLevel to Player.GetLevel
   else
   Set bbRealLevel to (bbRealLevel + 1)
   endif

   player.SetLevel 20

   ;determine and modify HP
   short hpEndurance
   short hpLevel
   short modLevel
   short realHealth

   Set hpEndurance to ((Player.GetAV Endurance) * 20)
   Set modLevel to (bbRealLevel - 1)
   Set hpLevel to (modLevel * 10)
   Set realHealth to (100 + hpEndurance + hpLevel)

   Player.SetAV health realHealth
   endif

   End

 

bbRealLevel and bbRealLevelSet are global variables that track your real level, and whether or not the script has been run before.

 

This intentionally resets your level to 20 every time you level up.

 

So, when you hit level 21, you assign your skill points, pick a Perk, and the script kicks in and sets you back to 20 before the game checks anything related to your level - preventing crashes.

Link to comment
Share on other sites

sorry i don't have any scripts to post but i wanted to bump this up cause i like the idea of this Thread. (should be stickied)
Link to comment
Share on other sites

Well if we get more than 4 scripts, then I could see that. Instead I've added this thread link to the massive link collection in the sticky post.

 

Here is a sample script from my modifiers + contract system in the merc mod. This is the detection mod and attack warning system.

 

if ( DetBoost != 0 )
set DetCurrent to Det
set Det to DetCurrent + DetBoost
set DetBoost to 0
endif 

; Calculate warning time from detection modifier.
if ( Det < 0 )
if ( Det == 100 )
	set attackWarning to 3
elseif ( Det <= 80 && Det > 100 )
	set attackWarning to 2
elseif ( Det <= 60 && Det > 80 )
	set attackWarning to 1
elseif ( Det <= 40 && Det > 60 )
	set attackWarning to 0
elseif ( Det <= 20 && Det > 40 )
	set attackWarning to -1
elseif ( Det <= 0  && Det > 20 )
	set attackWarning to -2
endif
endif

; Set the clock.
if ( attackActive == 1 )
set attackStartTime to getCurrentTime

; 0.0166 = 1 minute / 0.02 = 1.2 minutes
if ( attackWarning == 3 )
	set attackWarnTime to attackStartTime
elseif ( attackWarning == 2 )
	set attackWarnTime to attackStartTime + 0.02
elseif ( attackWarning == 1 )
	set attackWarnTime to attackStartTime + 0.04
elseif ( attackWarning == 0 )
	set attackWarnTime to attackStartTime + 0.06
elseif ( attackWarning == -1 )
	set attackWarnTime to attackStartTime + 0.08
elseif ( attackWarning == -2 )
	set attackWarnTime to attackStartTime + 0.1
endif	
endif

; Send the warning message to player.
if ( attackActive == 1 )
if ( attackMsgShown != 1 )
	if ( attackWarnTime == getCurrentTime )
		if ( attackWarning < 0 )
			ShowMessage MercMsgBaseAttack2
		else
			ShowMessage MercMsgBaseAttack1
		endif
		set attackMsgShown to 1; Only want to show message once per attack.
	endif
endif
endif

; If no attack, reset everything.
if ( attackActive == 0 )
set attackMsgShown to 0
set attackWarnTime to 0
set attackStartTime to 0
endif

 

With each modifier, in this case Detection I have

 

Det = the persistent reference for the detection modifier.

DetBoost = the value we boost it each time, e.g. 20 points.

DetCurrent = the current detection value before we boost it.

 

Any time the boost gets increased, we recalculate. We add the boost to the current and then set that to the persistent value.

 

Now we want to convert the detection value into a time frame for warning the player. We have 6 different time sets. 3 minutes before, 2 minutes before, 1 minute before, 0, 1 minute after, 2 minutes after.

 

The getCurrentTime returns the game time in say... 4.5 (4:30) so one minute is equal to 0.0166. If you added that to the 4.5 you'd get 4.5166 which would be close to 4:31. If the det value is between 80 and 100 points the player will be warned 3 minutes before the attack occurs. To get this to work correctly, every attack has to begin 3 minutes before that actual attack takes place.

 

When the attack process begins we get the game time value for that instance and add however many minutes we need for the detection warning delay. Then we check that value against the game time again and whenever it equals current game time, we send the message.

 

--------

 

A more skilled coder could probably make that a lot shorter, but in my book - If it is stupid, but works. It isn't stupid. Oh and the attactActive gets set by the attack activator and conditions outside of this script.

Link to comment
Share on other sites

since I'm using Smosh's first script to help with testing my mod I figured I should contribute something :P

finally ironed all the kinks out of this one

scn mytrackerscript

short gDoOnce

Begin Gamemode

if gDoOnce == 2
	if player.GetAV Karma >= 250

		set gDoOnce to 3
	;do something 3

	endif
elseif gDoOnce == 1
	if player.GetAV Karma >= 200

		set gDoOnce to 2
	;do something 2

	endif
elseif gDoOnce == 0
	if player.GetActorValue Karma >= 0

		set gDoOnce to 1
	;do something 1

	endif
endif

End

I'm experimenting with this as a quest code to keep track of the player's karma

you can also undo your steps when the player goes below the karma threshold e.g.

scn mytrackerscript2

short gDoOnce

Begin Gamemode

if gDoOnce == 2
	if player.GetAV Karma >= 250

		set gDoOnce to 3
		;do something 3

		elseif player.GetActorValue Karma < 200

		set gDoOnce to 1
		;undo something 2

	endif
elseif gDoOnce == 1
	if player.GetAV Karma >= 200

		set gDoOnce to 2
		;do something 2

		elseif player.GetActorValue Karma < 0

		set gDoOnce to
		;undo something 1

	endif
elseif gDoOnce == 0
	if player.GetActorValue Karma >= 0

		set gDoOnce to 1
		;do something 1

	endif
endif

End

Link to comment
Share on other sites

I'd like to contribute. :)

This is my spell effect script for a weapon that knocks people far away and creates a trail of smoke or fire along the way.

 

scn CALFPeffectSCR

ref Target

short ActorValue1
short ActorValue2
short ActorValue3
short DamageValue

Begin ScriptEffectStart

set Target to GetSelf

[b]; places initial explosion when hit, just in case there's no specified explosion effect in the weapons projectile
; also useful if you'd want a melee weapon or fist to cause explosions on hit[/b]
Target.placeatme {ExplosionType}

Player.PushActorAway Target 104

[b]; this is the part of the script in which you can specify a certain damage formula
; the formula can be added to the base damage amount set in the weapons tab 
; -or you can set the damage in the tab to zero and fully rely on the formula to calculate damage
; it can be the target NPC/creature's actor value or the player's
; it's also fine not to make a certain damage formula[/b]
set ActorValue1 to Player.GetAv {ActorValue1}
set ActorValue2 to Player.GetAv {ActorValue2}
set ActorValue3 to Player.GetAv {ActorValue3}

set Damage to -1 * ( {formula incorporating actor values} )
Target.ModAv Health DamageValue

[b]; make the effect play a certain sound-you could also use the sound of the explosion and not specify a specific sound[/b]
Playsound3D Play a certain sound
End


Begin ScriptEffectUpdate
[b]; this is the part where you place a smoke effect on every axis the NPC/Creature is located
; it makes as if the smoke is always coming out of the target while the effect is taking place[/b]
Target.placeatme {smokeeffect}

[b]; alternatively add a smoke actor effect on the character[/b]
Target.CastImmediateOnSelf {smoke actor effect}
End 


begin ScriptEffectFinish
[b];if you used the above alternative, this segment removes the smok eeffect from the character[/b]
Player.RemoveSpell {smoke actor effect}
end

Link to comment
Share on other sites

Changes the time of day on trigger activation.

 

scn timescript

short controlvar

Begin OnTriggerEnter player
if (controlvar == 0)
set GameHour to 22.5
set controlvar to 1
EndIf
End

 

The controlvar should mean that it will only activate once.

Link to comment
Share on other sites

Kudos to you for creating this Helpful and Wiki-like Thread.

Currently I have Forgotten a special script used to... Damn I Forgot that too, I'll post again when I Refresh my memory!(lol)

 

Thanks again.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...