Jump to content

Scripting Help Again lol


morrowind1979

Recommended Posts

I am trying to write a script that makes my boss play a sound when he kills the player but I cant get it to compile. My script is:

 

Scriptname DagothVict extends ObjectReference

 

Sound Property UrVictory Auto

 

Event OnDeath(Game.GetPlayer())

UrVictory.Play(self)

 

EndEvent

 

But I get an error and it wont compile. Does anyone know how to sort this?

Link to comment
Share on other sites

In order to receive the OnDeath event, the script must extend Actor instead of ObjectReference. On the other hand, Play must extend ObjectReference. Since there's no way to "cast an event", the script should extend the type of events needed. Here you need the OnDeath event so the script should extend Actor and then cast the Actor to an ObjectReference to play the sound.

 

Also, events don't take variables, they pass them. IE: Event OnDeath(Actor akKiller)

 

If the player killed this Actor, "akKiller" will equal "Game.GetPlayer()".

 

Scriptname DagothVict extends Actor  

Sound Property UrVictory Auto

Event OnDeath(Actor akKiller)

If (akKiller == Game.GetPlayer())
	Debug.Notification("The Player Killed Me!")
EndIf

UrVictory.Play(self as ObjectReference) ; cast this Actor as an ObjectReference

EndEvent

Edited by Ez0n3
Link to comment
Share on other sites

In order to receive the OnDeath event, the script must extend Actor instead of ObjectReference. On the other hand, Play must extend ObjectReference. Since there's no way to "cast an event", the script should extend the type of events needed. Here you need the OnDeath event so the script should extend Actor and then cast the Actor to an ObjectReference to play the sound.

 

Also, events don't take variables, they pass them. IE: Event OnDeath(Actor akKiller)

 

If the player killed this Actor, "akKiller" will equal "Game.GetPlayer()".

 

Scriptname DagothVict extends Actor  

Sound Property UrVictory Auto

Event OnDeath(Actor akKiller)

If (akKiller == Game.GetPlayer())
	Debug.Notification("The Player Killed Me!")
EndIf

UrVictory.Play(self as ObjectReference) ; cast this Actor as an ObjectReference

EndEvent

 

Thanks man but this dosent solve my problem. I want my script to play a sound when the actor kills the player not when the player kills the actor lol

 

So I would need Actor to = player not akkiller=player

Edited by morrowind1979
Link to comment
Share on other sites

I don't know if this would work...

 

make a blank quest and assign a script to a reference alias of the player using a script kinda like this

Scriptname DagothVict extends Actor  

Sound Property UrVictory Auto
Actor Property TheOneWhoKillsPlayer Auto

Event OnDeath(Actor akKiller)

       If (akKiller == TheOneWhoKillsPlayer)
               Debug.Notification("I killed the player!")
       
               UrVictory.Play(TheOneWhoKillsPlayer as ObjectReference) ; cast this Actor as an ObjectReference
       EndIf

EndEvent

you may need to use ActorBase instead of Actor not sure as I've never done anything like this. but in theory it (or something similar) could work since the script is running on an alias of the player and its checking that the player's death is done by a specific actor.

Link to comment
Share on other sites

I don't know if this would work...

 

make a blank quest and assign a script to a reference alias of the player using a script kinda like this

Scriptname DagothVict extends Actor  

Sound Property UrVictory Auto
Actor Property TheOneWhoKillsPlayer Auto

Event OnDeath(Actor akKiller)

       If (akKiller == TheOneWhoKillsPlayer)
               Debug.Notification("I killed the player!")
       
               UrVictory.Play(TheOneWhoKillsPlayer as ObjectReference) ; cast this Actor as an ObjectReference
       EndIf

EndEvent

you may need to use ActorBase instead of Actor not sure as I've never done anything like this. but in theory it (or something similar) could work since the script is running on an alias of the player and its checking that the player's death is done by a specific actor.

Edited by morrowind1979
Link to comment
Share on other sites

Hey thanks for trying to help me with this but unfortunately it didnt work the script compiled fine but just didnt play the sound ingame. Guess theres no way to really do this.

 

Hey I found out how to do it. There is an actor called "player" I just assigned a simple on eventdeath script to that actor if killed by DagothUr. Now the only problem i have is getting teh game to wait long enough to play the full sound before autoloading

Edited by morrowind1979
Link to comment
Share on other sites

you don't want to assign a script directly to the player actor. that will mean that your script will always attempt to run even if your mod has been uninstalled (i.e. leave error messages & possibly cause save game bloat). That is why I suggested to use an alias of the player character.

 

Maybe this will help in establishing the player alias

http://forums.nexusmods.com/index.php?showtopic=814571

Scroll down to section 4

replace step g with assigning the script in the script box per normal -- use the script that you got to work on the player actor itself.

Link to comment
Share on other sites

Thats great thanks. But now do you know how i can get the death cam to wait long enough for Dagoth Ur to finish his speech before the game auto loads the last save??

 

For some reason the script does not work when created via the alias method only when the script is attached to the player actor does it work. I will just have to leave a note in my mod description telling to delete the script when u uninstall the mod. just trying to figure out this deathcam issue now.

Edited by morrowind1979
Link to comment
Share on other sites

Thats great thanks. But now do you know how i can get the death cam to wait long enough for Dagoth Ur to finish his speech before the game auto loads the last save??

No.

 

For some reason the script does not work when created via the alias method only when the script is attached to the player actor does it work. I will just have to leave a note in my mod description telling to delete the script when u uninstall the mod. just trying to figure out this deathcam issue now.

It's not about deleting the script. Its that any object in the game that has a script assigned and then has that script removed will continue to try to run that script even if the script is no longer present.

 

Of course now you've got me curious as to why the script won't work on the player alias. Care to post the script and I'll see what I can do? I'll have to substitute the boss actor of course and replace the sound with something else, but it would still be useful for developing something that would work on the player alias...

Link to comment
Share on other sites

  • Recently Browsing   0 members

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