MaddDreamer Posted April 16, 2017 Share Posted April 16, 2017 (edited) What am I doing wrong please?Event OnHit (akAggressor) if (akAggressor) = game.player int random = Utility. IntRandom (1,20) if int random <= 10 Debug. Trace "bad" elseif int random >= 11 Debug. Trace "good" endif endifEndEvent Edited April 16, 2017 by MaddDreamer Link to comment Share on other sites More sharing options...
Lisselli Posted April 16, 2017 Share Posted April 16, 2017 (edited) What am I doing wrong please?Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \bool abBashAttack, bool abHitBlocked) if (akAggressor) == game.getplayer() int random = Utility.RandomInt (1,20) if random <= 10 Debug.Trace("bad") elseif random >= 11 Debug. Trace("good") endif endifEndEventFixed lots of mistakes. You had multiple syntax errors. Edited April 16, 2017 by Lisselli Link to comment Share on other sites More sharing options...
MaddDreamer Posted April 17, 2017 Author Share Posted April 17, 2017 Thank you, I'm still new to scripting; I didnt realise i needed to keep the other onhit pieces. That said, what else am I missing, when I attach the script to an npc it does nothing. Link to comment Share on other sites More sharing options...
Lisselli Posted April 17, 2017 Share Posted April 17, 2017 (edited) Hitting the actor doesn't return anything on screen? I just gotta ask.Also you need to make sure the script is extending Actor. Edited April 17, 2017 by Lisselli Link to comment Share on other sites More sharing options...
MaddDreamer Posted April 17, 2017 Author Share Posted April 17, 2017 Correct, the notification isnt appearing. thats with the title right? (Scriptname HitMissScript Extends Actor) Do I need to claim a property before the event? Link to comment Share on other sites More sharing options...
Deleted3897072User Posted April 17, 2017 Share Posted April 17, 2017 Debug.Trace() doesn't put anything on screen. It writes to the papyrus log file, provided you have logging and tracing enabled in your .ini file. If you want to see immediate notification on screen, use Debug.Notification() instead. Also, how are you attaching the script to the actor? Link to comment Share on other sites More sharing options...
MaddDreamer Posted April 17, 2017 Author Share Posted April 17, 2017 (edited) okay so notification to display on screen. I'm attaching it directly to the actor for now. I will try other ways, but what wouldyou suggest to be the easiest as I would eventually like to have the script affect all other npcs. Edited April 17, 2017 by MaddDreamer Link to comment Share on other sites More sharing options...
Lisselli Posted April 18, 2017 Share Posted April 18, 2017 Gotta warn you about OnHit though. In addition to what the event is listening for, it will also run for all other hits as well. This will create issues like stack dumping. So whatever you are trying to accomplish with the NPC, make sure it's only for as long as you need. Link to comment Share on other sites More sharing options...
MaddDreamer Posted April 18, 2017 Author Share Posted April 18, 2017 (edited) Thats my goal, i want to bring into my game hit chance among other things that i plan to expand from this. nothing seems to work however, neither attatching it directly to the actor, by way of ability or perk. will changing it to the weapons still allow npcs to use the script? edit, misunderstood the first time, how would I get it to only activate when hit with a sword or such martial weapons and ignore spell and ranged? Edited April 18, 2017 by MaddDreamer Link to comment Share on other sites More sharing options...
Lisselli Posted April 21, 2017 Share Posted April 21, 2017 (edited) OnHit will do its thing you have coded for it to do, but it will still fire under the hood for other things as well. That's what I meant. You can't make it ignore those other things. But you can put it in a state so that it doesn't run at all for as long as its in said state. All you do is take the original code, and place it in a state like this: Auto State Waiting ; event here EndState State Done ; event here but nothing in the event block EndState And to change the state you use this in your event code block, people usually place this before all the other code(as your code will still fire prior to changing states) GoToState("Done") Auto State Waiting Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \ bool abBashAttack, bool abHitBlocked) if (akAggressor) == game.getplayer() GoToState("Done") int random = Utility.RandomInt (1,20) if random <= 10 Debug.Trace("bad") elseif random >= 11 Debug. Trace("good") endif endif EndEvent EndState State Done Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \ bool abBashAttack, bool abHitBlocked) ; nothing, event thrown out. EndEvent EndState There maybe a more creative way of using this event, but I don't know what that is, and generally people approach this Event with caution. Edited April 21, 2017 by Lisselli Link to comment Share on other sites More sharing options...
Recommended Posts