Krazyguy75 Posted February 25, 2016 Author Share Posted February 25, 2016 (edited) Well, I'm probably just going to borrow that code, looking on it, but how do I get it to give a random buff (like how mindspin gives 1 of 3 results)? For reference, the results I want are +10 aim, +20 defense, +3 mobility, +20 crit chance, +5 health healed, or a 3 bar shield. Most, if not all of those are simple eStat changes, and I can make his code fit all of them individually, but I don't know how to make it randomly choose 1. Less importantly, I'm not sure how to make it heal without being able to go above max health, but first thing is first. EDIT: Also, don't feel the need to apologize for trying to help me :) You two have been great help, whether in understanding how the code works or figuring out my ability. Edited February 25, 2016 by Krazyguy75 Link to comment Share on other sites More sharing options...
Lucubration Posted February 25, 2016 Share Posted February 25, 2016 (edited) Well, I'm probably just going to borrow that code, looking on it, but how do I get it to give a random buff (like how mindspin gives 1 of 3 results)? For reference, the results I want are +10 aim, +20 defense, +3 mobility, +20 crit chance, +5 health healed, or a 3 bar shield. Most, if not all of those are simple eStat changes, and I can make his code fit all of them individually, but I don't know how to make it randomly choose 1. Less importantly, I'm not sure how to make it heal without being able to go above max health, but first thing is first. EDIT: Also, don't feel the need to apologize for trying to help me :smile: You two have been great help, whether in understanding how the code works or figuring out my ability.If you look at the X2Effect_Regeneration script, there's actually a line (with a comment!) in there showing how the regen effect doesn't go over max health. I think the XComGameState_Unit won't allow it to begin with, so you try to apply the heal and then check the actual value afterwards if you want to see how much it actually healed. As for random ability choice, that I do not know. Edited February 25, 2016 by Lucubration Link to comment Share on other sites More sharing options...
traenol Posted February 25, 2016 Share Posted February 25, 2016 (edited) for random ability choice, there is probably a built in rng function that you could use to roll, then just use a switch/if clause to pick what you want to use. I'd suggest looking into either unrealscript code or take a look at the weapon damage and how its applied for making it roll, or the dodge/armor chance codes as well. edit: in fact, I would look for the code that grabs the next seed value and just call that ... since thats what its there for. Edited February 25, 2016 by traenol Link to comment Share on other sites More sharing options...
Krazyguy75 Posted February 25, 2016 Author Share Posted February 25, 2016 (edited) So I'm probably gonna pick one of the other methods of randomization mentioned above... but can someone please tell me how mindspin works? EDIT: nvm, figured it out. Edited February 25, 2016 by Krazyguy75 Link to comment Share on other sites More sharing options...
eXecator Posted February 25, 2016 Share Posted February 25, 2016 for random ability choice, there is probably a built in rng function that you could use to roll, then just use a switch/if clause to pick what you want to use. [...] Another very convenient way to solve this is to use an array<> and access it by a randomly rolled index. When your list starts to grow, you realy appreciate not having to deal with several hundred lines of switch-case. ;-) Link to comment Share on other sites More sharing options...
Lucubration Posted February 26, 2016 Share Posted February 26, 2016 Now that I'm home and can look at the scripts, I'm finding a macro which seems to be how they get the next number from their seed: `SYNC_RAND(100) Dunno if you've already run into that or not. Link to comment Share on other sites More sharing options...
Krazyguy75 Posted February 26, 2016 Author Share Posted February 26, 2016 Ran into that, but now I don't know how to code it. Trying to put the switch into the ability file seems to cause errors. Do I need to create another class just to make this work? Link to comment Share on other sites More sharing options...
Lucubration Posted February 26, 2016 Share Posted February 26, 2016 (edited) I think what eXecator was suggesting was to pick the random effect out of an array built in code, but you could probably pull the array out of an .ini file as well if you wanted to get fancy. Here's roughly how you'd do it in code: var array<X2Effect> Effects; var X2Effect RandomEffect; var int Index; // Add possible effects into an array Effects.AddItem(new class'X2Effect_1'); Effects.AddItem(new class'X2Effect_2'); // and so on... // Should produce a number 0 through Effects.Length-1 Index = `SYNC_RAND(Effects.Length); // Pick the random effect out of the array RandomEffect = Effects[Index]; That should get you part of the way. Now to figure out where to actually perform that. It seems to me like you'd want to make a new effect to apply to the target, and it its OnEffectAdded method it would select a random buff to also apply to the affected unit. Edited February 26, 2016 by Lucubration Link to comment Share on other sites More sharing options...
eXecator Posted February 26, 2016 Share Posted February 26, 2016 Thanks Lucubration for the actual implementation. :cool: Link to comment Share on other sites More sharing options...
Krazyguy75 Posted February 27, 2016 Author Share Posted February 27, 2016 Well, I suck at unrealscript. I'm gonna put this project on the side burner until I have more experience. I'm not sure what class to extend to put that kind of effect in, as I want both the regeneration effect and the persistantstatchange effect to be options, and I'm really not experienced in how unrealscript actually works. Link to comment Share on other sites More sharing options...
Recommended Posts