Guest Messenjah Posted July 25, 2012 Share Posted July 25, 2012 So, I wrote this script. Basically, during my quest, If you kill the actor, a human heart should be added to his inventory onDeath. Anyway, I can't get it compile. Is it not possible to use an Alias property for an onDeath event script? Or do I need to use the actor? You collect the heart to complete the quest but you don't want to just be able to pick-pocket someone's heart. ;) Yes, this is an alias script for a Quest I'm writing: Scriptname ASXAddOnDeath extends ReferenceAlias Alias Property TargetNPC Auto Alias Property Heart Auto Event OnDeath (TargetNPC akKiller) if (akKiller== Game.GetPlayer()) TargetNPC.AddItem (Heart 1) Endif EndEvent Link to comment Share on other sites More sharing options...
Guest Messenjah Posted July 26, 2012 Share Posted July 26, 2012 Anyone take a look at this yet? Can you use an alias in this way? Or do I have to use an actor for this? Link to comment Share on other sites More sharing options...
steve40 Posted July 26, 2012 Share Posted July 26, 2012 (edited) Try this. I haven't tested compiling it.I'm not quite sure if I need to call GetRef on the heart or not, but I think this should work regardless. Scriptname ASXAddOnDeath extends ReferenceAlias Alias Property TargetNPC Auto Alias Property Heart Auto Event OnDeath (Actor akKiller) if (akKiller == Game.GetPlayer()) ObjectReference HeartRef = Heart.GetRef() TargetNPC.GetRef().AddItem(HeartRef, 1) Endif EndEvent EDIT: I'm not sure, but maybe the two properties should be ReferenceAlias rather than Alias. It might still work as is anyway. Edited July 26, 2012 by steve40 Link to comment Share on other sites More sharing options...
gasti89 Posted July 26, 2012 Share Posted July 26, 2012 (edited) I'm quite sure you'll need ReferenceAlias for properties (at least i alawys use it) EDIT: i didn't understand you purpose well. If you want the heart to spawn in the victim inventory after the death, you can just set the heart as the NPCs "death item". Edited July 26, 2012 by gasti89 Link to comment Share on other sites More sharing options...
Guest Messenjah Posted July 26, 2012 Share Posted July 26, 2012 So it worked but I had to change them to referencealias. What is the difference between alias and referencealias? The values allowed me to select the exact same aliases. But the heart is not a referenceobject? Nor do I want it to be because I would then have to place it somewhere in-game before adding it to the player inventory wouldn't I? Link to comment Share on other sites More sharing options...
gasti89 Posted July 26, 2012 Share Posted July 26, 2012 The alias form extends the Alias itself, it has few functions for it. The ReferenceAlias form extends the Reference the alias is pointing at. So as long as you call GetRef() is exactly an ObjectReference, so there are a lot of callable functions. Btw if you created an alias for the heart you HAVE to put it in the world, would it be specific reference, create reference or find matching reference. If you want an heart to spawn in players inventory out of thin air, you can delete its alias and change the property to MiscObject. But it think the best way to do this is setting a stage with the OnDeath event. Then create the heart alias as "create reference to object" "in" "myNPC". And condition it to the stage you just called. Then set the heart to optional. With this, when you kill the NPC the stage will be set, so the heart alias will match conditions and be created in NPC's inventory. Link to comment Share on other sites More sharing options...
Guest Messenjah Posted July 26, 2012 Share Posted July 26, 2012 Ok, I will try this. Thanks for the idea gasti89. The problem is that I could put it in the quest but then it would be a trick to move the item from the chest into the inventory. Not to mention, a bit over-complex for what we are trying to do. Just picking up the heart as a generic object was not enough. It needed to be a quest object so that the player doesn't do something stupid like eat it lol. ;) Too bad I can't sever the head and bag it instead of the heart. :P Link to comment Share on other sites More sharing options...
gasti89 Posted July 26, 2012 Share Posted July 26, 2012 If you use additem on a reference alias it will automatically move it from its container to your inventory. So you can put it in a chest somewhere in the world and then just call a additem in the NPCs inventory. This way you can set is a quest item. Or like listed above, adding it with condition. Link to comment Share on other sites More sharing options...
Guest Messenjah Posted July 26, 2012 Share Posted July 26, 2012 Ok, got the quest to start and the actor dies, updating the quest to stage 20. I had to add this line into stage 20: Actor Target = alias_Target.getReference() as Actor I believe this line resolves the alias of the npc to the actor. The problem is, that I need to do the same thing with the heart but it says that "types are incompatible." I've tried using miscobject, ingredient, and I tried adding a property for heartobject and it still tells me that they are incompatible. :\ How do I cast an alias to an ingredient? Link to comment Share on other sites More sharing options...
gasti89 Posted July 26, 2012 Share Posted July 26, 2012 (edited) You don't need any script on the stage fragment. You just need: - an Alias pointing to the NPC (can be unique actor or specific reference) - an Alias put UNDER the NPC alias ---> type is "create reference to object", select your heart base, select "in", select your NPC alias. Then put a GetStage 20 condition on the heart alias and mark it as "optional". Updating to stage 20 will automatically fill the alias and so create a heart in the NPCs inventory. EDIT: btw, for actors you don't need all that stuff. You can just call "GetActorRef()" Edited July 26, 2012 by gasti89 Link to comment Share on other sites More sharing options...
Recommended Posts