need help adding weapons to Lorkhan Heart Script

Post » Wed Aug 19, 2009 4:21 am

I'm attempting to make a mod where the players the ability to switch between a short, long, spear, and ax version of keening. I've got the switch scripts down but now i'm having trouble with giving the individual weapons the ability to act as the normal keening. As the script currently is, the heart of lorkhan is destroyed after one one sunder strike, without hitting it with keening. I'm still new to scripting so i don't totally understand how to fix it, so any help would be appreciated.
here is what the script looks like now.

begin LorkhanHeart

short sunderHit
;were hit by Sunder THIS FRAME
short keeningHit
short keening_axeHit
short keening_lswordHit
short keening_spearHit
;were hit by Keening THIS FRAME
short countHits
;number of times you hit with Keening
short countSays
;make sure you don't Say over and over
short doOnce
;teleport Dagoth Ur once


if ( menumode == 1 )
return
endif

if ( HeartDestroyed == 1 )
if ( doOnce == 2 )
return
endif

if ( CellChanged == 1 )
Disable
Set doOnce to 2
endif

if ( CellChanged == 0 )
if ( GetSoundPlaying "endrumble" == 0 )
;play rumbling sound after heart is dead, until player leaves
PlayLoopSound3D "endrumble"
endif
endif
if ( GetSoundPlaying "heart" == 1 )
StopSound "heart"
endif
if ( GetSoundPlaying "heartSunder" == 1 )
StopSound "heartSunder"
endif

return
endif

if ( sunderHit == 0 )
;test if you hit with Sunder until you hit with Sunder
Set sunderHit to HitOnMe Sunder
endif

;test if you hit with Keening every frame, also make heart immortal
Set keeningHit to HitOnMe Keening
Set keening_AxeHit to HitOnMe Keening_axe
Set keening_lswordHit to HitOnMe Keening_lsword
Set keening_spearHit to HitOnMe Keening_spear
SetHealth 5000

if ( doOnce == 0 )
if ( GetDistance Player < 500 )
"dagoth_ur_2"->PositionCell -40 2590 -180 320 "Akulakhan's Chamber"
"dagoth_ur_2"->StartCombat Player
Set doOnce to 1
endif
endif

if ( sunderHit == 1 )
;play correct sounds before & after sunder
;return if you've never hit with Sunder
if ( HeartDestroyed == 0 )
if ( CellChanged == 0 )
if ( GetSoundPlaying "heartSunder" == 0 )
PlayLoopSound3D "heartsunder"
endif
endif
endif
else
if ( CellChanged == 0 )
if ( GetSoundPlaying "heart" == 0 )
PlayLoopSound3D, "heart"
endif
endif
return
endif

if ( keeningHit == 0 )
elseif ( keening_axeHit == 0 )
elseif ( keening_lswordHit == 0 )
elseif ( keening_spearHit == 0 )
;only process rest of script when hit with keening
return
endif

;if player hit with Keening THIS FRAME, do all this stuff...

Set countHits to ( countHits + 1 )

if ( countHits == 0 )
if ( countSays != 0 )
Set countSays to 0
endif
return
endif

if ( countHits == 1 )
if ( countSays == 0 )
Say "vo\misc\Hit Heart 1.wav" "What are you doing?"
"dagoth_ur_2"->SetFight 100
"dagoth_ur_2"->StartCombat Player
Set countSays to 1
endif
PlayGroup Idle2
endif

if ( countHits == 2 )
if ( countSays == 1 )
Say "vo\misc\Hit Heart 2.wav" "WHAT ARE YOU DOING?!"
Set countSays to 2
endif
PlayGroup Idle3
endif

if ( countHits == 3 )
if ( countSays == 2 )
Say "vo\misc\Hit Heart 3.wav" "FOOL!"
Set countSays to 3
endif
PlayGroup Idle4
endif

if ( countHits == 4 )
if ( countSays == 3 )
Say "vo\misc\Hit Heart 4.wav" "STOP!"
Set countSays to 4
endif
PlayGroup Idle5
endif

if ( countHits > 4 )
if ( countSays == 4 )
Say "vo\misc\Hit Heart 6.wav" "This is the end. The bitter, bitter end."
Set countSays to 5
endif
if ( GetSoundPlaying "heart" == 1 )
StopSound "heart"
endif
if ( GetSoundPlaying "heartSunder" == 1 )
StopSound "heartSunder"
endif
PlayGroup Death1
set HeartDestroyed to 1
endif

End



Keening_axe/lsword/spear are the new IDs for the keening weapons.
User avatar
Claire Mclaughlin
 
Posts: 3361
Joined: Mon Jul 31, 2006 6:55 am

Post » Wed Aug 19, 2009 4:18 pm

Here's the block with the issue:
if ( keeningHit == 0 )elseif ( keening_axeHit == 0 )elseif ( keening_lswordHit == 0 )elseif ( keening_spearHit == 0 );only process rest of script when hit with keeningreturnendif


That return at the end of the if/elseif block only applies when that last test is true but the others are false(which would never happen). Here are some ways to fix it:
set keeninghit to ( keeninghit + keening_axeHit + keening_lswordHit + keening_spearHit )if ( keeningHit == 0 )returnendif


if ( keeningHit == 0 )  if ( keening_axeHit == 0 )    if ( keening_lswordHit == 0 )      if ( keening_spearHit == 0 )        ;only process rest of script when hit with keening        return      endif    endif  endifendif


if ( keeningHit == 1 )elseif ( keening_axeHit == 1 )elseif ( keening_lswordHit == 1 )elseif ( keening_spearHit == 1 )else;only process rest of script when hit with keeningreturnendif


edit: fixed options 2 and 3, in case someone with a similar problem sees this. Not sure what happened with option 1
User avatar
quinnnn
 
Posts: 3503
Joined: Sat Mar 03, 2007 1:11 pm

Post » Wed Aug 19, 2009 1:30 pm

okay so after trying out all the combination of the scripts narfblat posted, i wasn't able to make it work with all the weapons. for the first two scripts sunder would destroy the heart by itself, while for the last script the heart would only be destroyed by the spear-keening.

begin LorkhanHeart

short sunderHit
short keeningHit
short keening_axeHit
short keening_lswordHit
short keening_spearHit
short countHits
short countSays
short doOnce


if ( menumode == 1 )
return
endif

if ( HeartDestroyed == 1 )
if ( doOnce == 2 )
return
endif

if ( CellChanged == 1 )
Disable
Set doOnce to 2
endif

if ( CellChanged == 0 )
if ( GetSoundPlaying "endrumble" == 0 )
;play rumbling sound after heart is dead, until player leaves
PlayLoopSound3D "endrumble"
endif
endif
if ( GetSoundPlaying "heart" == 1 )
StopSound "heart"
endif
if ( GetSoundPlaying "heartSunder" == 1 )
StopSound "heartSunder"
endif

return
endif

if ( sunderHit == 0 )
;test if you hit with Sunder until you hit with Sunder
Set sunderHit to HitOnMe Sunder
endif

;test if you hit with Keening every frame, also make heart immortal
Set keeningHit to ( HitOnMe Keening + HitOnMe Keening_axe + HitOnMe Keening_lsword + HitOnMe Keening_spear )
SetHealth 5000

if ( doOnce == 0 )
if ( GetDistance Player < 500 )
"dagoth_ur_2"->PositionCell -40 2590 -180 320 "Akulakhan's Chamber"
"dagoth_ur_2"->StartCombat Player
Set doOnce to 1
endif
endif

if ( sunderHit == 1 )
;play correct sounds before & after sunder
;return if you've never hit with Sunder
if ( HeartDestroyed == 0 )
if ( CellChanged == 0 )
if ( GetSoundPlaying "heartSunder" == 0 )
PlayLoopSound3D "heartsunder"
endif
endif
endif
else
if ( CellChanged == 0 )
if ( GetSoundPlaying "heart" == 0 )
PlayLoopSound3D, "heart"
endif
endif
return
endif

if ( keeningHit == 0 )
return
elseif ( keening_axeHit == 0 )
return
elseif ( keening_lswordHit == 0 )
return
elseif ( keening_spearHit == 0 )
;only process rest of script when hit with keening
return
endif

;if player hit with Keening THIS FRAME, do all this stuff...

Set countHits to ( countHits + 1 )

if ( countHits == 0 )
if ( countSays != 0 )
Set countSays to 0
endif
return
endif

if ( countHits == 1 )
if ( countSays == 0 )
Say "vo\misc\Hit Heart 1.wav" "What are you doing?"
"dagoth_ur_2"->SetFight 100
"dagoth_ur_2"->StartCombat Player
Set countSays to 1
endif
PlayGroup Idle2
endif

if ( countHits == 2 )
if ( countSays == 1 )
Say "vo\misc\Hit Heart 2.wav" "WHAT ARE YOU DOING?!"
Set countSays to 2
endif
PlayGroup Idle3
endif

if ( countHits == 3 )
if ( countSays == 2 )
Say "vo\misc\Hit Heart 3.wav" "FOOL!"
Set countSays to 3
endif
PlayGroup Idle4
endif

if ( countHits == 4 )
if ( countSays == 3 )
Say "vo\misc\Hit Heart 4.wav" "STOP!"
Set countSays to 4
endif
PlayGroup Idle5
endif

if ( countHits > 4 )
if ( countSays == 4 )
Say "vo\misc\Hit Heart 6.wav" "This is the end. The bitter, bitter end."
Set countSays to 5
endif
if ( GetSoundPlaying "heart" == 1 )
StopSound "heart"
endif
if ( GetSoundPlaying "heartSunder" == 1 )
StopSound "heartSunder"
endif
PlayGroup Death1
set HeartDestroyed to 1
endif

End


this is what the current script looks like. as is, the heart is no longer affected by either sunder or keening. again any help in solving this problem is greatly appreciated.
User avatar
matt
 
Posts: 3267
Joined: Wed May 30, 2007 10:17 am

Post » Wed Aug 19, 2009 6:21 pm

I messed up a little with that last fix I posted; it should only have the return statement at the plain else. Go back to your original, except change the ifkeeninghit testing block to this:
if ( keeningHit == 1 )elseif ( keening_axeHit == 1 )elseif ( keening_lswordHit == 1 )elseif ( keening_spearHit == 1 )else;only process rest of script when hit with keeningreturnendif


I also see why the second fix doesn't work; it returns if any of the hit tests are 0.

All I don't see is why the first option doesn't work. If you tried that fix only as shown in your current script, maybe it doesn't like hitonme calls being added together; they seem to be boolean values, which only become numbers when stored.
User avatar
Greg Cavaliere
 
Posts: 3514
Joined: Thu Nov 01, 2007 6:31 am

Post » Wed Aug 19, 2009 11:35 am

Once again Narfblat, thanks for your help! that last fix did the trick and now each version of keening is working as indented. It felt great taking down the heart with a spear!
User avatar
liz barnes
 
Posts: 3387
Joined: Tue Oct 31, 2006 4:10 am

Post » Wed Aug 19, 2009 3:36 pm

Awesome, glad I could help. It looks like approval on PES is still pending.
User avatar
scorpion972
 
Posts: 3515
Joined: Fri Mar 16, 2007 11:20 am


Return to III - Morrowind