Jump to content

Scripting Aid Needed


axussriddare

Recommended Posts

Ok, here's the deal. I made a nice little mod that was supposed to give the player some extra skills. I created a riding skill and a trap lore skill. Then I added the enchanting skill that opaj had created. It should work fine, but it doesn't. So I need someone to find my little scripting mistakes for me. It's a lot easier for someone else than for the maker, right? Anyone who offers any help of value will be given proper credit. The file can be found here. Well, here you go:

 

This first one is the quest script. Do note that the spellmaking skill is not finished yet. Also note that there are a couple of globals that are used to easily switch the different skills on or off.

scn MSKQuestScript

;Init the skill variables

float MSKEnchantingXP
float MSKRidingXP
float MSKSpellmakingXP
float MSKTrapLoreXP

short MSKEnchanting
short MSKRiding
short MSKSpellmaking
short MSKTrapLore

;And then the rest of the variables

short DisplaySpellActive
short MSKMaxSkillLevel
short setuponce
short temp
short Updatetimer

Begin GameMode
if setuponce != 1;Here we make sure we only setup once
 set setuponce to 1
 set MSKEnchanting to 0
 set MSKEnchantingXP to 0
 set MSKRiding to 20;We assume the player has some experience riding
 set MSKRidingXP to 0
 set MSKSpellmaking to 0
 set MSKSpellmakingXP to 0
 set MSKTrapLore to 0
 set MSKTrapLoreXP to 0
 set MSKMaxSkillLevel to getGS iSkillMasterMin;Here we fetch the game setting for master skill level
 set Updatetimer to 0
 set DisplaySpellActive to 0
endif
if Updatetimer == 10;We don't want to run this every time the quest script runs, so we have a timer
 set Updatetimer to 0
 set MSKMaxSkillLevel to getGS iSkillMasterMin
 if DisplaySpellActive == 0
	 if getspellschool MSKSkillDisplaySpell == 4
		 set DisplaySpellActive to 1
		 player.addspell MSKSkillDisplaySpell
	 endif
 elseif getspellschool MSKSkillDisplaySpell != 4
	 set DisplaySpellActive to 0
	 player.removespell MSKSkillDisplaySpell
 endif
 if MSKTrapLore < 20 && MSKTrapLoreActive == 1
	 set temp to player.getav security
	 set temp to temp / 2.0 + 0.5
	 if temp > MSKTrapLore
		 set MSKTrapLore to temp
		 message "Your trap lore skill has been increased!"
	 endif
 endif
 set temp to player.getav mysticism / 2.0 + 0.5
 if temp > MSKEnchanting && temp > MSKSpellmaking && MSKSpellmakingActive == 1 && MSKEnchantingActive == 1
	 set MSKEnchanting to temp
	 message "Your enchanting and spellmaking skills have been increased!"
 elseif temp > MSKEnchanting && MSKEnchantingActive == 1
	 set MSKEnchanting to temp
	 message "Your enchanting skill has been increased!"
 elseif temp > MSKSpellmaking && MSKSpellmakingActive == 1
	 set MSKSpellmaking to temp
	 message "Your spellmaking skill has been increased!"
 endif
else
 set Updatetimer to Updatetimer + 1
endif
if MSKEnchantingXP >= 1 && MSKEnchanting < MSKMaxSkillLevel && MSKEnchantingActive == 1
 set MSKEnchantingXP to 0
 set MSKEnchanting to MSKEnchanting +1
 message "Your enchanting skill has been increased!"
endif
if MSKRidingXP >= 1 && MSKRiding < MSKMaxSkillLevel
 set MSKRidingXP to 0
 set MSKRiding to MSKRiding +1
 message "Your riding skill has been increased!"
endif
if MSKSpellmakingXP >= 1 && MSKSpellmaking < MSKMaxSkillLevel && MSKSpellmakingActive == 1
 set MSKSpellmakingXP to 0
 set MSKSpellmaking to MSKSpellmaking +1
 message "Your spellmaking skill has been increased!"
endif
if MSKTrapLoreXP >= 1 && MSKTrapLore < MSKMaxSkillLevel && MSKTrapLoreActive == 1
 set MSKTrapLoreXP to 0
 set MSKTrapLore to MSKTrapLore +1
 message "Your trap lore skill has been increased!"
endif
if MSKEnchanting > MSKMaxSkillLevel
 set MSKEnchanting to MSKMaxSkillLevel
endif
if MSKRiding > MSKMaxSkillLevel
 set MSKRiding to MSKMaxSkillLevel
endif
if MSKSpellmaking > MSKMaxSkillLevel
 set MSKSpellmaking to MSKMaxSkillLevel
endif
if MSKTrapLore > MSKMaxSkillLevel
 set MSKTrapLore to MSKMaxSkillLevel
endif
End

Then we take the enchanting quest script, made mainly by opaj

scn EXEnchantQuestScript

float fQuestDelayTime
short Control
short Apprentice
short Journeyman
short Expert
short Master

begin GameMode
 if GetGameLoaded
	 set fQuestDelayTime to 30
	 set Apprentice to GetGS iSkillApprenticeMin
	 set Journeyman to GetGS iSkillJourneymanMin
	 set Expert to GetGS iSkillExpertMin
	 set Master to GetGS iSkillMasterMin
 endif

 if control == 0
	 if MSKQuest.MSKEnchanting >= Apprentice
		 Player.AddSpell EXEnchantSpell
		 MessageBox "As an apprentice of Enchanting, I am now able to enchant my own weapons and armor.  It's free for me to do myself, but the quality of my enchantments depends solely upon my skill level."
		 set control to 1
	 endif
 elseif control == 1
	 if MSKQuest.MSKEnchanting < Apprentice
		 Player.RemoveSpell EXEnchantSpell
		 MessageBox "I've lost the ability to create my own enchantments."
		 set control to 0
	 elseif MSKQuest.MSKEnchanting >= Journeyman
		 player.addspell MSKCreateRechargeGem
		 MessageBox "As a Journeyman of Enchanting, I can now create recharge gems to recharge or enchant items."
		 set control to 2
	 endif
 elseif control == 2
	 if MSKQuest.MSKEnchanting < Journeyman
		 Player.RemoveSpell MSKCreateRechargeGem
		 MessageBox "I've lost the ability to create recharge gems."
		 set control to 1
	 elseif MSKQuest.MSKEnchanting >= Expert
		 Player.AddSpell EXEnchantMultiple
		 MessageBox "As an Expert of Enchanting, I can now create an 'essence of enchantment.'  I can combine a single enchanted essence with another constant enchantment, allowing me to have multiple effects on one piece of armor or clothing."
		 set control to 3
	 endif
 elseif control == 3
	 if MSKQuest.MSKEnchanting < Expert
		 Player.RemoveSpell EXEnchantMultiple
		 MessageBox "I've lost the ability to combine constant enchantments."
		 set control to 2
	 endif
 endif
end

Here is the basic riding script, used on horses that didn't have any script before.

scn MSKBasicRidingScript

float ftemp

ref me
ref rider

short doonce
short hassetup
short horsedifficulty;The mean of all the factors affecting the horse's mood and difficulty
short horseslowed;A variable to check if the horse has decided to slow down.
short introuble;A variable to check if the player and the horse aren't getting along
short oldspeed;The horse's old speed, before the slowing
short setuptimer
short stemp
short troubletesttimer

Begin OnActivate
;this shouldn't be needed here, but I'll run it anyway
if doonce != 1
 set me to getself
 set doonce to 1
 set troubletesttimer to 0
 set introuble to 0
endif
;Now these things are needed
set rider to getactionref
if getdead == 1
 activate rider
 EvaluatePackage
 return
endif
if rider != player
 activate rider
 EvaluatePackage
 return
else
;run setup and make sure the player can do this
;I split the set line into several lines to avoid possible crashes
 set horsedifficulty to getav speed + getav aggression
 set horsedifficulty to horsedifficulty + getav confidence + getav agility
 set horsedifficulty to horsedifficulty + getav strength + getav endurance
 set horsedifficulty to horsedifficulty - getdisposition player
 set horsedifficulty to horsedifficulty / 7.0 +0.5
 if horsedifficulty > 100
	 set horsedifficulty to 100
 endif
 if MSKQuest.MSKRiding - 10 < horsedifficulty
;The player can't ride the horse.
	 message "The horse refuses to allow you to get on. You need to improve your riding skill."
;Give the player some experience, just for good measure
	 set ftemp to rand 0.0001 0.001
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
 elseif MSKQuest.MSKRiding - 10 >= horsedifficulty && MSKQuest.MSKRiding <= horsedifficulty
;Player can ride the horse, but barely. We give the player a warning and then activate. Here I have some problems. Apparently the player can get on a horse without warning
	 message "This horse doesn't like you. You should train your riding skill."
	 set ftemp to rand 0.001 0.005
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
	 activate player
	 EvaluatePackage
 elseif MSKQuest.MSKRiding > horsedifficulty
;The player can ride the horse. Just give the player some XP and then activate
	 set ftemp to rand 0.001 0.005
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
	 activate player
	 EvaluatePackage
 endif
 if MSKQuest.MSKRidingXP >= 1 && MSKQuest.MSKRiding < MSKQuest.MSKMaxSkillLevel
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP - 1
	 set MSKQuest.MSKRiding to MSKQuest.MSKRiding + 1
	 message "Your riding skill has been increased!"
 endif
endif
End

Begin GameMode
;We have a lot of return blocks here. Why? Well, the GameMode block runs every frame the player is near the horse and out of the menu. Thus the script should run as few times as possible
if doonce != 1
 set me to getself
 set doonce to 1
 set troubletesttimer to 0
 set introuble to 0
endif
if getdead == 1
 return
endif
if getrider == 0
 if horseslowed == 1
	 setav speed oldspeed
	 set horseslowed to 0
 endif
 return
elseif getrider == player
 if hassetup != 1 || setuptimer == 50
;I split the set line into several lines to avoid possible crashes
	 set horsedifficulty to getav speed + getav aggression
	 set horsedifficulty to horsedifficulty + getav confidence + getav agility
	 set horsedifficulty to horsedifficulty + getav strength + getav endurance
	 set horsedifficulty to horsedifficulty - getdisposition player
	 set horsedifficulty to horsedifficulty / 7.0 +0.5
	 if horsedifficulty > 100
		 set horsedifficulty to 100
	 endif
	 set hassetup to 1
	 set setuptimer to 0
 else
 set setuptimer to setuptimer + 1
 set troubletesttimer to troubletesttimer + 1
 endif
 if MSKQuest.MSKRiding - 10 < horsedifficulty && introuble != 1 || troubletesttimer == 120
;The player just got into trouble
	 set stemp to rand 1 4
	 set introuble to 1
	 set troubletesttimer to 0
	 if stemp <= 2
		 if horseslowed != 1
		;The horse slows
			 message "Your horse is trying to get you off. It won't move very quickly untill you dismount."
			 set ftemp to rand 0.001 0.1
			 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
			 set oldspeed to getav speed
			 setav speed 1
			 set horseslowed to 1
		 else
		;The horse is already slowed.
			 set stemp to stemp + 2
		 endif
	 elseif stemp == 3
	;The horse bites the player
		 if player.getav health < 6
			 message "Your horse is trying to get you off. It bit you to death!"
			 player.kill me
		 else
			 message"Your horse is trying to get you off. It bit you!"
			 set ftemp to rand 0.001 0.1
			 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
			 player.modav2 health -5
		 endif
	 elseif stemp == 4
	;decrease fatigue
		 if player.getav fatigue < 26
			 if player.getav health < 6
				 message "Your horse is trying to get you off. You hurt yourself and died trying to stop it."
				 player.kill me
			 else
				 message "Your horse is trying to get you off. You hurt yourself trying to stop it."
				 set ftemp to rand 0.001 0.1
				 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
				 player.modav2 health -5
			 endif
		 else
			 message "Your horse is trying to get you off. You start getting tired."
			 set ftemp to rand 0.001 0.1
			 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
			 player.modav2 fatigue -25
		 endif
	 endif
 elseif MSKQuest.MSKRiding - 10 >= horsedifficulty && MSKQuest.MSKRiding <= horsedifficulty && troubletesttimer == 120
	 message "Your horse doesn't like you. You should train your riding skill."
	 set ftemp to rand 0.001 0.05
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
	 set troubletesttimer to 0
 elseif MSKQuest.MSKRiding > horsedifficulty && troubletesttimer == 120
	 set ftemp to rand 0.001 0.01
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
	 set troubletesttimer to 0
 endif
 if MSKQuest.MSKRidingXP >= 1 && MSKQuest.MSKRiding < MSKQuest.MSKMaxSkillLevel
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP - 1
	 set MSKQuest.MSKRiding to MSKQuest.MSKRiding + 1
	 message "Your riding skill has been increased!"
 endif
Endif
End

Here is the script for a buyable horse (this one is a black horse).

ScriptName MSKHorsePCBlackCheydinhalRidingScript

float ftemp

ref me
ref rider

short doonce
short hassetup
short horsedifficulty
short horseslowed
short introuble
short oldspeed
short setuptimer
short stemp
short troubletesttimer

Short RespawnHorse
Short TellPC
Short Mounted

Begin OnDeath
 Set RespawnHorse to 1
 Set Horses.OwnCheydinhalBlack to 0
 Set Mounted to 0
 HorseSaleBlackCheydinhalRef.Enable
 ModPCMiscStat 14 -1
End

Begin OnPackageEnd HorsePCCheydinhalGoHome
 If TellPC == 0 && Mounted == 1
	 If GetInCell Cheydinhal == 1
		 MessageBox "Your Black horse has returned to Cheydinhal's stables."
		 Set TellPC to 1
	 EndIf
 EndIf
End

Begin OnActivate
;this shouldn't be needed here, but I'll run it anyway
if doonce != 1
 set me to getself
 set doonce to 1
 set troubletesttimer to 0
 set introuble to 0
endif
;Now these things are needed
set rider to getactionref
if getdead == 1
 Set TellPC to 0
 activate rider
 EvaluatePackage
 return
endif
if rider != player
 Set TellPC to 0
 activate rider
 EvaluatePackage
 return
else
;run setup and make sure the player can do this
;I split the set line into several lines to avoid possible crashes
 set horsedifficulty to getav speed + getav aggression
 set horsedifficulty to horsedifficulty + getav confidence + getav agility
 set horsedifficulty to horsedifficulty + getav strength + getav endurance
 set horsedifficulty to horsedifficulty - getdisposition player
 set horsedifficulty to horsedifficulty / 7.0 +0.5
 if horsedifficulty > 100
	 set horsedifficulty to 100
 endif
 if MSKQuest.MSKRiding - 10 < horsedifficulty
;The player can't ride the horse
	 message "The horse refuses to allow you to get on. You need to improve your riding skill."
;Give the player some experience, just for good mesure
	 set ftemp to rand 0.0001 0.001
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
 elseif MSKQuest.MSKRiding - 10 >= horsedifficulty && MSKQuest.MSKRiding <= horsedifficulty
;Player can ride the horse, but barely. We give the player a warning and then activate
	 message "This horse doesn't like you. You should train your riding skill."
	 set ftemp to rand 0.001 0.005
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
	 If Horses.CheydinhalMivrynaPresent == 1
		 Set Horses.CheydinhalMivrynaPresent to 0
		 Set Mounted to 1
	 Endif
	 Set TellPC to 0
	 activate player
	 EvaluatePackage
 elseif MSKQuest.MSKRiding > horsedifficulty
;The player can ride the horse. Just give the player some XP and then activate
	 set ftemp to rand 0.001 0.005
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
	 If Horses.CheydinhalMivrynaPresent == 1
		 Set Horses.CheydinhalMivrynaPresent to 0
		 Set Mounted to 1
	 Endif
	 Set TellPC to 0
	 activate player
	 EvaluatePackage
 endif
 if MSKQuest.MSKRidingXP >= 1 && MSKQuest.MSKRiding < MSKQuest.MSKMaxSkillLevel
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP - 1
	 set MSKQuest.MSKRiding to MSKQuest.MSKRiding + 1
	 message "Your riding skill has been increased!"
 endif
endif
End

Begin GameMode
if doonce != 1
 set me to getself
 set doonce to 1
 set troubletesttimer to 0
 set introuble to 0
endif
if getdead == 1
 return
endif
if getrider == player
 if hassetup != 1 || setuptimer == 50
;I split the set line into several lines to avoid possible crashes
	 set horsedifficulty to getav speed + getav aggression
	 set horsedifficulty to horsedifficulty + getav confidence + getav agility
	 set horsedifficulty to horsedifficulty + getav strength + getav endurance
	 set horsedifficulty to horsedifficulty - getdisposition player
	 set horsedifficulty to horsedifficulty / 7.0 +0.5
	 if horsedifficulty > 100
		 set horsedifficulty to 100
	 endif
	 set hassetup to 1
	 set setuptimer to 0
 else
 set setuptimer to setuptimer + 1
 set troubletesttimer to troubletesttimer + 1
 endif
 if MSKQuest.MSKRiding - 10 < horsedifficulty && introuble != 1 || troubletesttimer == 120
;The player just got into trouble
	 set stemp to rand 1 4
	 set introuble to 1
	 set troubletesttimer to 0
	 if stemp <= 2
		 if horseslowed != 1
		;The horse slows
			 message "Your horse is trying to get you off. It won't move very quickly untill you dismount."
			 set ftemp to rand 0.001 0.1
			 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
			 set oldspeed to getav speed
			 setav speed 1
			 set horseslowed to 1
		 else
		;The horse is already slowed.
			 set stemp to stemp + 2
		 endif
	 elseif stemp == 3
	;The horse bites the player
		 if player.getav health < 6
			 message "Your horse is trying to get you off. It bit you to death!"
			 player.kill me
		 else
			 message"Your horse is trying to get you off. It bit you!"
			 set ftemp to rand 0.001 0.1
			 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
			 player.modav2 health -5
		 endif
	 elseif stemp == 4
	;decrease fatigue
		 if player.getav fatigue < 26
			 if player.getav health < 6
				 message "Your horse is trying to get you off. You hurt yourself and died trying to stop it."
				 player.kill me
			 else
				 message "Your horse is trying to get you off. You hurt yourself trying to stop it."
				 set ftemp to rand 0.001 0.1
				 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
				 player.modav2 health -5
			 endif
		 else
			 message "Your horse is trying to get you off. You start getting tired."
			 set ftemp to rand 0.001 0.1
			 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
			 player.modav2 fatigue -25
		 endif
	 endif
 elseif MSKQuest.MSKRiding - 10 >= horsedifficulty && MSKQuest.MSKRiding <= horsedifficulty && troubletesttimer == 120
	 message "Your horse doesn't like you. You should train your riding skill."
	 set ftemp to rand 0.001 0.05
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
	 set troubletesttimer to 0
 elseif MSKQuest.MSKRiding > horsedifficulty && troubletesttimer == 120
	 set ftemp to rand 0.001 0.01
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP + ftemp
	 set troubletesttimer to 0
 endif
 if MSKQuest.MSKRidingXP >= 1 && MSKQuest.MSKRiding < MSKQuest.MSKMaxSkillLevel
	 set MSKQuest.MSKRidingXP to MSKQuest.MSKRidingXP - 1
	 set MSKQuest.MSKRiding to MSKQuest.MSKRiding + 1
	 message "Your riding skill has been increased!"
 endif
Endif
End

This is the script for a tripwire

scn MSKCTrigTripwire01SCRIPT

float ftemp
short difficulty
short doonce
short endskill
short triggered
ref target
ref mySelf

begin onActivate
if doonce != 1
 set doonce to 1
 set triggered to 0
endif
if getactionref == player
;the mean difficulty is 15. After all, all you'd have to do is hold the rope after cutting it and then tie it to the poles or similar. Even an orc could figure that out.
 set difficulty to rand 13 17
 set endskill to MSKQuest.MSKTrapLore
 if player.getav luck > 75
	 set endskill to endskill + 10
 endif
 if endskill > 100
	 set endskill to 100
 endif
 if endskill >= difficulty
;success!
	 if triggered == 0
		 playgroup forward 0
		 set triggered to 1
		 setDestroyed 1
		 message "You successfully manage to disable the tripwire."
	;and the experience
		 set ftemp to rand 0.01 0.001
		 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + ftemp
	 endif
 else
;Man, that sucks
	 if triggered == 0
		 set target to getParentRef
		 set mySelf to getSelf
		 target.activate mySelf 1
		 playgroup forward 0
		 set triggered to 1
		 setDestroyed 1
		 set ftemp to rand 0.05 0.001
		 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + ftemp
	 endif
 endif
 if MSKQuest.MSKTrapLoreXP >= 1 && MSKQuest.MSKTrapLore < MSKQuest.MSKMaxSkillLevel
	 set MSKQuest.MSKTrapLoreXP to 0
	 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + 1
	 message "Your trap lore skill has been increased!"
 endif
elseif triggered == 0
 set target to getParentRef
 set mySelf to getSelf
 target.activate mySelf 1
 playgroup forward 0
 set triggered to 1
 setDestroyed 1
 set ftemp to rand 0.05 0.001
 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + ftemp
endif
end

begin onTrigger
if doonce != 1
 set doonce to 1
 set triggered to 0
endif
if getactionref == player
;the mean difficulty here is 20, but it needs some other skills too. The only way to stop it is to quickly grab the wire and make sure that the trap isn't triggered
 set difficulty to rand 18 22
 set endskill to MSKQuest.MSKTrapLore
 if player.getav luck > 80
	 set endskill to endskill + 10
 endif
 set endskill to endskill + player.getav agility * 2
 set endskill to endskill / 3.0 + 0.5
 if endskill > 100
	 set endskill to 100
 endif
 if endskill >= difficulty
	 if triggered == 0
		 playgroup forward 0
		 set triggered to 1
		 setDestroyed 1
		 message "You successfully manage to disable the tripwire."
		 set ftemp to rand 0.1 0.01
		 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + ftemp
	 endif
 else
	 if triggered == 0
		 set target to getParentRef
		 set mySelf to getSelf
		 target.activate mySelf 1
		 playgroup forward 0
		 set triggered to 1
		 setDestroyed 1
		 set ftemp to rand 0.001 0.0001
		 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + ftemp
	 endif
 endif
 if MSKQuest.MSKTrapLoreXP >= 1 && MSKQuest.MSKTrapLore < MSKQuest.MSKMaxSkillLevel
	 set MSKQuest.MSKTrapLoreXP to 0
	 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + 1
	 message "Your trap lore skill has been increased!"
 endif
elseif triggered == 0
 set target to getParentRef
 set mySelf to getSelf
 target.activate mySelf 1
 playgroup forward 0
 set triggered to 1
 setDestroyed 1
endif
end

begin onReset

 reset3DState
 set triggered to 0
 setDestroyed 0

end

And this is for a pressure plate

scn MSKCTrigPressurePlate01SCRIPT

; Activates trap linked as Parent

float ftemp
short difficulty
short doonce
short endskill
short triggered
ref target
ref mySelf

begin onActivate
if doonce != 1
 set doonce to 1
 set triggered to 0
endif
if getactionref == player
;the mean difficulty is 40. Why? Well, this is hard. We have a pressure plate, and we want it not to trigger.
 set difficulty to rand 35 45
 set endskill to MSKQuest.MSKTrapLore
;We add endskill here as well in order to make it more important than intelligence
 set endskill to endskill + player.getav intelligence + endskill
 set endskill to endskill / 3.0 + 0.5
 if player.getav agility < 30
;Bad noise, that's a bad noise!
	 set difficulty to difficulty + 10
 endif
 if player.getav luck > 75
	 set endskill to endskill + 10
 endif
 if endskill > 100
	 set endskill to 100
 endif
 if endskill >= difficulty
;success!
	 if triggered == 0
		 set triggered to 1
		 setDestroyed 1
		 message "You successfully manage to disable the pressure plate."
	;and the experience
		 set ftemp to rand 0.05 0.001
		 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + ftemp
	 endif
 elseif endskill - 10 >= difficulty
	 if triggered == 0
		 message "You fail to disable the pressure plate, but you managed not to trigger it."
		 set ftemp to rand 0.05 0.001
		 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + ftemp
	 endif
 else
;Man, that sucks
	 if triggered == 0
		 set target to getParentRef
		 set mySelf to getSelf
		 target.activate mySelf 1
		 playgroup forward 0
		 set triggered to 1
		 setDestroyed 1
		 message "You fail to disable the pressure plate, and accidentially triggered it."
		 set ftemp to rand 0.01 0.001
		 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + ftemp
	 endif
 endif
 if MSKQuest.MSKTrapLoreXP >= 1 && MSKQuest.MSKTrapLore < MSKQuest.MSKMaxSkillLevel
	 set MSKQuest.MSKTrapLoreXP to 0
	 set MSKQuest.MSKTrapLore to MSKQuest.MSKTrapLore + 1
	 message "Your trap lore skill has been increased!"
 endif
elseif triggered == 0
 set target to getParentRef
 set mySelf to getSelf
 target.activate mySelf 1
 playgroup forward 0
 set triggered to 1
 setDestroyed 1
endif
end

begin onTrigger
if doonce != 1
 set doonce to 1
 set triggered to 0
endif
 if triggered == 0

	 set target to getParentRef
	 set mySelf to getSelf
	 target.activate mySelf 1
	 set triggered to 1
	 playgroup forward 0
	 setdestroyed 1

 endif

end

begin onReset

 reset3DState
 set triggered to 0
 setdestroyed 0

end

 

Can you find where the problems are?

Link to comment
Share on other sites

Didn't really go through most of that, the problem with large scripts is that few will. This is why it's kinda a good idea to be very familiar with scripting, and understand all the mechanics of these scripts, used in smaller versions, before making a large script. It's easier to debug, people are more willing to do more than glance over it, and once it's working, you can usually work it into whatever project you have in mind.

 

It would also help to explain specifically what parts of these scripts aren't working. As you're likely aware, real skills are hard coded, and scripted skills are subject to conflicts with other mods, as well as the innate limitations of scripting.

 

For the horse script, all those horses without scripts are all the generic horses that the player can steal, not the ones that the player can own. The ones that the player can own are specially scripted to work with horsemarkers, city transitions, and other stuff. Rather than apply, or alter the scripts on horses, maybe use a scripted ability placed on the horses to control all the functions with that skill. This will require a bit of re-working, but will make the effect less likely to break due to conflicts, means only having 1 script, and means that you won't need to blend things together with the normal horse scripts. Doing it as an ability can also allow for application to non-vanilla mounts if a method of adding that ability is added somehow.

 

Dunno about the traps.

Link to comment
Share on other sites

Yes I realized the amount of stuff there is. I'll add commentaries to them. I will simply edit the post, to save space. Accutaly the main difference between the stealable horses and the buyable ones are that the buyable ones will cause the stablehands to do something when you first get on (probably stop staying near to tell the player that the horse is ready). The ciry transitions are either locked into the game engine or a quest script. I have been thinking of attatching it to a quest script, but that could cause game performance issues.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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