morrowind1979 Posted November 15, 2012 Share Posted November 15, 2012 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 More sharing options...
Ez0n3 Posted November 15, 2012 Share Posted November 15, 2012 (edited) 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 November 15, 2012 by Ez0n3 Link to comment Share on other sites More sharing options...
morrowind1979 Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) 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 November 15, 2012 by morrowind1979 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 15, 2012 Share Posted November 15, 2012 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 thisScriptname 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 EndEventyou 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 More sharing options...
morrowind1979 Posted November 15, 2012 Author Share Posted November 15, 2012 Hi just got back in going to try it now ill post my results let you know if it works. Thanks Link to comment Share on other sites More sharing options...
morrowind1979 Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) 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 thisScriptname 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 EndEventyou 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 November 15, 2012 by morrowind1979 Link to comment Share on other sites More sharing options...
morrowind1979 Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) 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 November 15, 2012 by morrowind1979 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 15, 2012 Share Posted November 15, 2012 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 aliashttp://forums.nexusmods.com/index.php?showtopic=814571Scroll down to section 4replace 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 More sharing options...
morrowind1979 Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) 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 November 15, 2012 by morrowind1979 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 16, 2012 Share Posted November 16, 2012 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 More sharing options...
Recommended Posts