Jump to content

Please help with some script problems


Guest deleted726673

Recommended Posts

Guest deleted726673

I've been making some scripts for the new Dea Obscura update.

What I wanted to do is add a new source of magic enery used by the abilities. I called it "Dark Vigor" and use a global variable (short) for it so any script should be able to access/modify it.

Abilities can use 5, 10, or 20 of Dark Vigor. The total amount of Dark Vigor is calculated like this: 95 + (player level * 5), so you will start with 100 and gain 5 points each level.

When it reaches 0 the abilities (spells) will be removed (though I'd prefer to disable them, if possible). There is a script used by a daily power which restores the Dark Vigor to the maximum amount and re-adds the abilities so you can use them again.

 

When you use an ability a message will be popup which should show the current amount of Dark Vigor and the maximum amount.

This does not work, it only shows a "/" instead of "currentamount/maximum amount".

 

Also you can keep using the abilities, they do not disappear.

 

I use a quest script which defines the global variable at the start of the game, it will also show a message showing current/maximum amount of Dark Vigor when going to the stats menu (which doesn't work either like the other message).

 

The scripts I made:

 

Quest script

ScriptName 00xDarkVigorScript

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Author: Xenius
;;;;;;;;;;Mod: Dea Obscura
;;;;;;;;;;Version: V2.0
;;;;;;;;;;Date: 17-03-2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

short DVMenuMode;
short DVtemp;
float fQuestDelayTime ;
short DVmax = 95 + (player.getLevel * 5);

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Global Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; short DVvalue;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

begin GameMode
{
if (player.getisrace XDO)
{
	set fQuestDelayTime to 0.1;
	set DVvalue to 95 + (player.getLevel * 5);
}endif
}end

begin MenuMode 1003
{
if (player.getisrace XDO)
{
	if (DVMenuMode == 0)
	{
		set DVMenuMode to 1;
		set DVtemp to DVvalue;
		message "Current amount of Dark Vigor: %/%.", DVtemp, DVmax, 5;
	}endif
	set DVMenuMode to 0;
}endif
}end

Magic effect scripts

ScriptName 00xRestoreDarkVigorScript

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Author: Xenius
;;;;;;;;;;Mod: Dea Obscura
;;;;;;;;;;Version: V2.0
;;;;;;;;;;Date: 17-03-2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

short doOnce = 0;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

begin ScriptEffectStart
{
if(doOnce == 0)
{
	set doOnce to 1;
	
	if(player.getisrace XDO)
	{
		set DVvalue to (95 + (player.getLevel * 5));
		
		if(DVvalue == 95 + (player.getLevel * 5))
		{
			message "The Dark Vigor within you has been replenished.", 5;  <== This message did appear when testing
			
			player.addspell		000atrusveneficus;
			player.addspell		000atrusvestis;
			player.addspell		000senium;
			player.addspell		000visuminobscurum;
			player.addspell		00xAtraFlammaAbility;
			player.addspell		00xAtraPluviaAbility;
			player.addspell		00xAuraObscuraAbility;
			player.addspell		00xGladiusObscurusAbility;
			player.addspell		00xOculaObscuraAbility;
			player.addspell		00xTransitusAbility;
		}endif
	}endif
}endif
}end


begin ScriptEffectFinish
if(player.getisrace XDO)
{
	set doOnce to 0;
}endif
end

These 3 scripts are actually the same but just with a different value (5, 10, 20)

ScriptName 00xUseDarkVigor5Script

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Author: Xenius
;;;;;;;;;;Mod: Dea Obscura
;;;;;;;;;;Version: V2.0
;;;;;;;;;;Date: 17-03-2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

short doOnce = 0;
short DVmax = 95 + (player.getLevel * 5);

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Global Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; short DVvalue;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

begin ScriptEffectStart
{
if(doOnce == 0)
{
	set doOnce to 1;
	
	if(player.getisrace XDO)
	{
		set DVvalue to (DVvalue - 5);
		message "Current amount of Dark Vigor: %/%.", DVvalue, DVmax, 5;
		
		if(DVvalue == 0)
		{
			message "The Dark Vigor within you has vanished.", 5;
			
			player.removespell 	000atrusveneficus;
			player.removespell	000atrusvestis;
			player.removespell	000senium;
			player.removespell	000visuminobscurum;
			player.removespell	00xAtraFlammaAbility;
			player.removespell	00xAtraPluviaAbility;
			player.removespell	00xAuraObscuraAbility;
			player.removespell	00xGladiusObscurusAbility;
			player.removespell	00xOculaObscuraAbility;
			player.removespell	00xTransitusAbility;
		}endif
	}endif
}endif
}end


begin ScriptEffectFinish
if(player.getisrace XDO)
{
	set doOnce to 0;
}endif
end

 

ScriptName 00xUseDarkVigor10Script

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Author: Xenius
;;;;;;;;;;Mod: Dea Obscura
;;;;;;;;;;Version: V2.0
;;;;;;;;;;Date: 17-03-2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

short doOnce = 0;
short DVmax = 95 + (player.getLevel * 5);

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Global Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; short DVvalue;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

begin ScriptEffectStart
{
if(doOnce == 0)
{
	set doOnce to 1;
	
	if(player.getisrace XDO)
	{
		set DVvalue to (DVvalue - 10);
		message "Current amount of Dark Vigor: %/%.", DVvalue, DVmax, 5;
		
		if(DVvalue == 0)
		{
			message "The Dark Vigor within you has vanished.", 5;
			
			player.removespell 	000atrusveneficus;
			player.removespell	000atrusvestis;
			player.removespell	000senium;
			player.removespell	000visuminobscurum;
			player.removespell	00xAtraFlammaAbility;
			player.removespell	00xAtraPluviaAbility;
			player.removespell	00xAuraObscuraAbility;
			player.removespell	00xGladiusObscurusAbility;
			player.removespell	00xOculaObscuraAbility;
			player.removespell	00xTransitusAbility;
		}endif
	}endif
}endif
}end


begin ScriptEffectFinish
if(player.getisrace XDO)
{
	set doOnce to 0;
}endif
end

 

ScriptName 00xUseDarkVigor20Script

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Author: Xenius
;;;;;;;;;;Mod: Dea Obscura
;;;;;;;;;;Version: V2.0
;;;;;;;;;;Date: 17-03-2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

short doOnce = 0;
short DVmax = 95 + (player.getLevel * 5);

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Global Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; short DVvalue;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

begin ScriptEffectStart
{
if(doOnce == 0)
{
	set doOnce to 1;
	
	if(player.getisrace XDO)
	{
		set DVvalue to (DVvalue - 20);
		message "Current amount of Dark Vigor: %/%.", DVvalue, DVmax, 5;
		
		if(DVvalue == 0)
		{
			message "The Dark Vigor within you has vanished.", 5;
			
			player.removespell 	000atrusveneficus;
			player.removespell	000atrusvestis;
			player.removespell	000senium;
			player.removespell	000visuminobscurum;
			player.removespell	00xAtraFlammaAbility;
			player.removespell	00xAtraPluviaAbility;
			player.removespell	00xAuraObscuraAbility;
			player.removespell	00xGladiusObscurusAbility;
			player.removespell	00xOculaObscuraAbility;
			player.removespell	00xTransitusAbility;
		}endif
	}endif
}endif
}end


begin ScriptEffectFinish
if(player.getisrace XDO)
{
	set doOnce to 0;
}endif
end

 

 

I don't understand why it's not working... so I was wondering if someone can help me with this, I really want to get it working.

Link to comment
Share on other sites

I think your variable formatting notation isn't quite right. I would expect it to be more like this:

message "Current amount of Dark Vigor: %.0f/%.0f.", DVvalue, DVmax, 5;

 

What are all of the brackets? ( { ) Are they just in your printout of the script for posting on this forum? Or do you use them in your script in Oblivion?

 

Maybe you could try putting the check to see whether a player has run out of dark vigor in your quest script and have the quest script remove the spells from the player. It seems possible that you are getting a misfire because you set the variable to 0 after casting a spell and then check to see if it is 0 like a nanosecond later. Maybe it hasn't registered that it is zero yet when it runs the check. A quest script will check continuously, like every five seconds. Your spell scripts only get a single chance to check, and if that part glitches, there is no other check and the trigger never trips.

Link to comment
Share on other sites

Guest deleted726673

Thanks a lot for the help, really appreciate it.

 

The brackets don't do anything, but make the code easier to read in my opinion, also I got used to them because of programming in Java, C# and C.

I just changed the variable formatting notation like you said, it shows something now, but not everything it should. For example, when I use an ability which uses 20 Dark Vigor, it will show "Current amount of Dark Vigor: 80/0", also I can keep using the abilities, it will keep showing 80/0 (or 95/0 or 90/0 depending on how much they use). Also when I go to the menu it doesn't show the proper value.

 

I also moved the if-statement which checks if the value reached 0 to the quest script, but it never reaches 0. When I use an ability which costs 20 points first, it will show 80, then when I use another one which uses only 5 it will not show 75 but 95. Do you know what's going wrong?

Link to comment
Share on other sites

What are all of the brackets? ( { ) Are they just in your printout of the script for posting on this forum? Or do you use them in your script in Oblivion?

 

It's been a long time since I took my class in C programming, but I think I remember needing to put a semicolon at the end of every line and needing to put brackets for if statements, loops, etc. That's probably why they're there.

 

@Xenius

 

I see a lot of things wrong with the scripts. The first and most obvious is the GameMode block in the quest script. You have it setting DVvalue (your global variable) every 0.1 seconds. Wouldn't that mean your Dark Vigor is always at max?

Link to comment
Share on other sites

Guest deleted726673

I'm still new to scripting for Oblivion, I looked at some other scripts before starting and saw the quest delay was being used, thought it might be necessary to keep the script running, so I put it in there. I'll remove it and see what happens.

Thanks for the help.

 

Edit: I removed the quest delay. When using the abilities after each other by keeping spell cast button pressed, I could get the Dark Vigor to reach 85 with an ability that costs 5. But when I wait for a while and cast it again it will show 95 instead of 80, so somehow the value resets to the maximum. Also the message when going to the stats menu doesn't work anymore.

 

Edit 2: Added doOnce

 

	if (player.getisrace XDO && doOnce == 0)
{
	set DVvalue to 95 + (player.getLevel * 5);
	set doOnce to 1;
}endif

 

- Dark Vigor gets decreased successfully

- Abilities are getting removed when Dark Vigor reaches 0

- Restore Dark Vigor works, abilities are getting re-added and Dark Vigor gets reset to the maximum again.

 

Only thing that doesn't work properly are the messages, they still show <current value> / 0

Edited by Xenius
Link to comment
Share on other sites

I'm still new to scripting for Oblivion, I looked at some other scripts before starting and saw the quest delay was being used, thought it might be necessary to keep the script running, so I put it in there. I'll remove it and see what happens.

Thanks for the help.

 

Edit: I removed the quest delay. When using the abilities after each other by keeping spell cast button pressed, I could get the Dark Vigor to reach 85 with an ability that costs 5. But when I wait for a while and cast it again it will show 95 instead of 80, so somehow the value resets to the maximum. Also the message when going to the stats menu doesn't work anymore.

 

I didn't mean that the quest delay was the problem. What I meant was that a GameMode block is run constantly, as long as you're not in a menu. Since you are setting your DVMax variable in there (with only the GetIsRace condition), that means that you are resetting your DVMax variable to the max it can be every time the script is run.

 

I rewrote your quest script, and here it is:

 

 

ScriptName 00xDarkVigorScript

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Author: Xenius
;;;;;;;;;;Mod: Dea Obscura
;;;;;;;;;;Version: V2.0
;;;;;;;;;;Date: 17-03-2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

float fquestdelaytime 

short DVMax
short DVCurrent
short DVMenuMode
short DoOnce

Begin GameMode

if (player.GetIsRace XD0 == 0)
	Return
endif

if (GetGameLoaded)
	set DVMax to (95 + (5 * player.GetLevel))
	set fquestdelaytime to 0.1
endif

if (DoOnce == 0)
	set DVCurrent to DVMax
endif

if (DVMenuMode == 1)
	message "Current amount of Dark Vigor: %.0f/%.0f", DVCurrent, DVMax, 5
	set DVMenuMode to 0
endif

if (DVCurrent == 0)
	message "The Dark Vigor within you has vanished.", 5
	player.removespell 000atrusveneficus
	player.removespell 000atrusvestis
	player.removespell 000senium
	player.removespell 000visuminobscurum
	player.removespell 00xAtraFlammaAbility
	player.removespell 00xAtraPluviaAbility
	player.removespell 00xAuraObscuraAbility
	player.removespell 00xGladiusObscurusAbility
	player.removespell 00xOculaObscuraAbility
	player.removespell 00xTransitusAbility
endif

End

Begin MenuMode 1027

set DVMax to (95 + (5 * player.GetLevel))

End

Begin MenuMode 1003

set DVMenuMode to 1

End

 

 

Also, you do not need to use global variables; just keeping it as a quest variable is fine. In your magic effect scripts, instead of adjusting the DVMax variable everytime a spell is used, adjust 00xDarkVigor.DVCurrent (this is assuming you name the quest 00xDarkVigor).

Edited by fg109
Link to comment
Share on other sites

Guest deleted726673
Thanks, I just tried using the new quest script you made, but when saving the script I get the following error: Syntax Error: Unknown command "GetGameLoaded"
Link to comment
Share on other sites

It's an OBSE function; I guess you don't have it. I guess it's not really necessary... I'm a busybody and I decided to rework all your scripts.

 

Quest:

 

ScriptName 00xDarkVigorScript

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Author: Xenius
;;;;;;;;;;Mod: Dea Obscura
;;;;;;;;;;Version: V2.0
;;;;;;;;;;Date: 17-03-2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

float fquestdelaytime 

short DVMax
short DVCurrent
short DVMenuMode
short DVRestore
short DoOnce

Begin GameMode

if (player.GetIsRace XDO == 0)
	Return
endif

set fquestdelaytime to 0.1

if (DVRestore == 0)
	set DVRestore to 1
	set DoOnce to 0
	set DVMax to (95 + (5 * player.GetLevel))
	set DVCurrent to DVMax
	player.addspell 000atrusveneficus
	player.addspell 000atrusvestis
	player.addspell 000senium
	player.addspell 000visuminobscurum
	player.addspell 00xAtraFlammaAbility
	player.addspell 00xAtraPluviaAbility
	player.addspell 00xAuraObscuraAbility
	player.addspell 00xGladiusObscurusAbility
	player.addspell 00xOculaObscuraAbility
	player.addspell 00xTransitusAbility
endif

if (DVMenuMode == 1)
	message "Current amount of Dark Vigor: %.0f/%.0f", DVCurrent, DVMax, 5
	set DVMenuMode to 0
endif

if (DVCurrent == 0 && DoOnce == 0)
	set DoOnce to 1
	message "The Dark Vigor within you has vanished.", 5
	player.removespell 000atrusveneficus
	player.removespell 000atrusvestis
	player.removespell 000senium
	player.removespell 000visuminobscurum
	player.removespell 00xAtraFlammaAbility
	player.removespell 00xAtraPluviaAbility
	player.removespell 00xAuraObscuraAbility
	player.removespell 00xGladiusObscurusAbility
	player.removespell 00xOculaObscuraAbility
	player.removespell 00xTransitusAbility
endif

End

Begin MenuMode 1027

set DVMax to (95 + (5 * player.GetLevel))

End

Begin MenuMode 1003

set DVMenuMode to 1

End

 

 

Daily Restore Dark Vigor Power:

 

ScriptName 00xRestoreDarkVigorScript

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Author: Xenius
;;;;;;;;;;Mod: Dea Obscura
;;;;;;;;;;Version: V2.0
;;;;;;;;;;Date: 17-03-2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Begin ScriptEffectStart

set 00xDarkVigor.DVRestore to 0
message "The Dark Vigor within you has been replenished.", 5

End

 

 

Spell that costs 5 Dark Vigor:

 

ScriptName 00xUseDarkVigor5Script

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;Author: Xenius
;;;;;;;;;;Mod: Dea Obscura
;;;;;;;;;;Version: V2.0
;;;;;;;;;;Date: 17-03-2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Begin ScriptEffectStart

if (00xDarkVigor.DVCurrent >= 5)
	(code for your custom spell here)
	set 00xDarkVigor.DVCurrent to (00xDarkVigor.DVCurrent - 5)
	message "Current amount of Dark Vigor: %.0f/%.0f", 00xDarkVigor.DVCurrent, 00xDarkVigor.DVMax, 5
else
	message "Insufficient Dark Vigor to cast this spell."
endif

End

 

 

This is all assuming your quest name is 00xDarkVigor.

 

EDIT: Left a couple chunks out of the scripts when I copied/pasted...

Edited by fg109
Link to comment
Share on other sites

Guest deleted726673

The quest script now saves fine without errors.

I changed the name of the quest to 00xDarkVigor

 

But when I save the restore dark vigor script I get an error again: Unknown variable "00xDarkVigor.DVRestore"

And when saving the use dark vigor script I get a different error: Unknown variable or function "DVCurrent"

 

I hope you know what's going wrong, thanks for the help.

It's getting late here, will continue with this tomorrow.

Edited by Xenius
Link to comment
Share on other sites

  • Recently Browsing   0 members

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