Jump to content

Can't save script in CS with OBSE


RagnaHighArc

Recommended Posts

BTW how do you check the player's health against what it was a few frames ago?
At the end of the script, put something like Set OldHealth to player.GetAV Health. Earlier on, check if player.GetAV Health < OldHealth.

 

Kinda works now, but i get my entire health restored after i parry.

 

So, if health is 50/60 parry sets the health back to 60/60.

Link to comment
Share on other sites

Mind if I see the new script?

 

Sure, but I still have a lot of stuff to add

 

Scriptname RagnaParry

short blocktracker

float timer

short bMagicEffect
short oldhealth
short oldHelmet
short oldCuirass
short oldGreaves
short oldGauntlets
short oldBoots
short oldShield
short oldWeapon

;IF HIT BY MAGIC, PARRY WILL NOT WORK. 
begin OnMagicEffectHit
set bMagicEffect to 1
end

;WHEN HIT IS PARRIED ALL DAMAGE IS NULLUFIED
Begin OnHit
;SHRINK TIMER, WHEN PARRY WORKS, TO 0.24
if (bMagicEffect == 0) && (timer > 0.0) && (timer <= 0.50)
	modEquippedCurrentHealth 0 oldHelmet
	modEquippedCurrentHealth 2 oldCuirass
	modEquippedCurrentHealth 3 oldGreaves
	modEquippedCurrentHealth 4 oldGauntlets
	modEquippedCurrentHealth 5 oldBoots
	modEquippedCurrentHealth 13 oldShield
	modEquippedCurrentHealth 16 oldWeapon
	modActorValue2 health oldhealth
endif
end

Begin GameMode

set bMagicEffect to 0

;If the player has just started blocking, set the variable to track this state and begin timer
if (player.IsBlocking) && (blocktracker == 0)
	Set blocktracker to 1
	Set timer to 0
endif

;If the player is currently blocking, increment the timer
if (player.IsBlocking) && (blocktracker == 1)
	set timer to timer + getSecondsPassed
endif

;If the player has stopped blocking, reset state and timer
if (player.IsBlocking == 0) && (blocktracker == 1)
	set blocktracker to 0
	set timer to 0
endif
end

;GETS PLAYER, WEAPON, AND ARMOR HEALTH IN ORDER TO RESTORE IT IF PARRY IS MADE
begin gameMode 
set oldHealth to player.getActorValue health
set oldHelmet to player.getEquippedCurrentHealth 0
set oldCuirass to player.getEquippedCurrentHealth 2
set oldGreaves to player.getEquippedCurrentHealth 3
set oldGauntlets to player.getEquippedCurrentHealth 4
set oldBoots to player.getEquippedCurrentHealth 5
set oldShield to player.getEquippedCurrentHealth 13
set oldWeapon to player.getEquippedCurrentHealth 16
end

 

I tried a few ways to make it check the player's health as it changes, but i haven't found a way that works, It seems that it saves the current health, but won't change it IF it changes.

Link to comment
Share on other sites

Looks like the problem is that, instead of setting to the player's health to its older version, you're adding the player's old health to its new health. So if the player had 70 health and had it reduced to 50 in a hit, the parry would add 70 to 50 and you'd get 120. Try making it something like...

 

set HealthMod to OldHealth - player.GetAV Health ;HealthMod is a new variable

player.ModAV2 health HealthMod

Link to comment
Share on other sites

Looks like the problem is that, instead of setting to the player's health to its older version, you're adding the player's old health to its new health. So if the player had 70 health and had it reduced to 50 in a hit, the parry would add 70 to 50 and you'd get 120. Try making it something like...

 

set HealthMod to OldHealth - player.GetAV Health ;HealthMod is a new variable

player.ModAV2 health HealthMod

 

Is the " - " there to subtract?

 

i didn't know it was possible to do that

 

but yeah i'll try it out.

 

///

 

I know that the modAV2 line goes in the "OnHit" block, but where should the healthmod line go?

 

I placed it as the 1st block, then as the last block, then before the last block, and the health wouldn't come back and i took damage.

Link to comment
Share on other sites

I know that the modAV2 line goes in the "OnHit" block, but where should the healthmod line go?
Healthmod line should go right before the ModAV2 line. You're allowed all basic math functions when setting variables and using if-loops (+, -, *, /), and can access more complex stuff using OBSE.

 

ok Now all the health isn't being restored, but the health restored is not exactly what it was before the hit.

 

so, if health is 50, then a 2 point damage on hit occurs and is parried, the health becomes 49. I can actually see the health bar go down then up.

 

BTW i'm doing the ingame testing during the tutorial and i have been from the start, that shouldn't effect the mod, right?

Link to comment
Share on other sites

I can't really explain that one. If it's always exactly 1 less than the previous health you can just add 1 to OldHealth, but that's even assuming your example was using real numbers. I'd take a closer look, but need to go to sleep and doubt I'd find anything. If you wanted to do some serious debugging, you could make a new variable called PlayerHealth, set it to player.GetAV health right after setting OldHealth, and right after that add the following line:

messagebox "DEBUG: the player's old health was %.1f, and the hit reduced it to %.1f.", OldHealth, PlayerHealth

 

Playtesting, whenever, shouldn't damage the mod at all. It could cause some inconsistencies if you've saved with the mod enabled and since required more things to happen when it's initialized, but I can't imagine that's the case.

Link to comment
Share on other sites

I can't really explain that one. If it's always exactly 1 less than the previous health you can just add 1 to OldHealth, but that's even assuming your example was using real numbers. I'd take a closer look, but need to go to sleep and doubt I'd find anything. If you wanted to do some serious debugging, you could make a new variable called PlayerHealth, set it to player.GetAV health right after setting OldHealth, and right after that add the following line:

messagebox "DEBUG: the player's old health was %.1f, and the hit reduced it to %.1f.", OldHealth, PlayerHealth

 

Playtesting, whenever, shouldn't damage the mod at all. It could cause some inconsistencies if you've saved with the mod enabled and since required more things to happen when it's initialized, but I can't imagine that's the case.

 

HA! It works! adding 1 to oldhealth fixed it. I knew i had to add 1 to something, but i just didn't know where and it would've taken me a while to figure it out.

 

There were so many things i didn't know that i would not have known if it weren't for you. So, thanks man. Since most of the breakthroughs were yours, I'll make sure to give you credit for it. The only credit i'm taking is from the variations i'm going to write and the visuals i'm going to attach to the script.

 

I'm going to continue testing the mod to see how it works when i'm at higher levels

Link to comment
Share on other sites

  • Recently Browsing   0 members

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