Jarkon Posted August 3, 2017 Share Posted August 3, 2017 I'm trying to create an effect script that checks the race of the actor its attached to and gives the player a different item depending on what it is (I.E. a green one when the actor is a member of the human race or a red one when its anything else). However, whenever I test out the script in game on non-human enemies, it still gives me the human item. I've tried adding a debug message to at least understand what race is being scanned, but all it displays is "[Race". I have tried using different base commands (GetLeveledActorBase and GetBaseObject as ActorBase) but they end up doing the same thing. Does anyone have any idea what could be going wrong? Any input would be really appreciated! Here's the script I'm using: actor Victimbool bHasBeenCasted = falseform Property requiredItem autoform Property humanItem autoform Property creatureItem auto Race victimRace ;I manually placed the human race and ghoul race in hereRace [] Property humanRaces auto Event OnInit() victim = GetTargetActor()EndEvent Event OnDeath(Actor akKiller) if(Game.GetPlayer().GetItemCount(requiredItem) > 0) ;At this point the script is supposed to check the race of the actor and see if its a member of the race arrayActorBase VictimBase = Victim.GetActorBase()victimRace = VictimBase.GetRace() if (humanRaces.Find(victimRace));In-game this always prints "[Race" Debug.Notification(victimRace) Game.GetPlayer().addItem(humanItem, 1, false) Game.GetPlayer().removeItem(requiredItem, 1, true) else Game.GetPlayer().addItem(creatureItem, 1, false) Game.GetPlayer().removeItem(requiredItem, 1, true)endIfendEvent Link to comment Share on other sites More sharing options...
DeathMotif Posted August 3, 2017 Share Posted August 3, 2017 Your second conditional statement "if(humanRaces.Find(victimRace)) will always return true as long as any race is present. You need to compare it against your target race or the else will never fire off. Link to comment Share on other sites More sharing options...
JonathanOstrus Posted August 4, 2017 Share Posted August 4, 2017 (edited) You'll also want to use Debug.Trace not Debug.Notification if you want actually helpful data. Trace will give you the form ID and some naming information. Notification truncates and only displays simple data which isn't really helpful the way you want to use it. You'll need to then check the papyrus log file. It won't give you instant on screen info. You might also be able to use GetFormID() like: Debug.Notification(victimRace.GetFormID()) I'm guessing this script goes on a magic effect? If not you might also want to change all those properties to const in case you want to change them later. Unless you want the CK values upon first start to be sticky. If you ever changed them in CK after the script has been baked into a save you can't really. But if the script instance is created and destroyed frequently then it won't really matter. Also either passing a player ref or in oninit setting a script local player ref will be more processor efficient than calling game.getplayer() repeatedly. Doing it once is probably ok but repeatedly it will become very inefficient. Personally I always pass it as a script property since the game has already done the work and made the ref. Edited August 4, 2017 by BigAndFlabby Link to comment Share on other sites More sharing options...
Lisselli Posted August 4, 2017 Share Posted August 4, 2017 (edited) You need to close the first if statement. It's missing an endif. Edited August 4, 2017 by Lisselli Link to comment Share on other sites More sharing options...
Recommended Posts