fg109 Posted April 18, 2012 Author Share Posted April 18, 2012 (edited) @ArcaneSmith Yes, it is a pain that you can't do something like: weapon[] weaponarray = new weapon[intVar] Instead, I think you'll just have to create a form array property and fill it with "None" entries. I think the max size of an array is 128 entries, but I'm not sure. So something like this: Form[] Property MyArray Auto {Set elements 0 to 127 to None by default} Then check out this BethSoft thread for some array functions you can use. I don't really see the point of using a container though. Example with using those functions: Form[] Property MyArray Auto {Set elements 0 to 127 to None by default} Int property MyArrayLastElement = -1 Auto {Used to keep track of just how many elements are filled in the array} Function AddRewardToArray(Form Reward) if (MyArrayLastElement >= MyArray.Length - 1) ;failure, the array is already full elseif (ArrayHasForm(MyArray, Reward) >= 0) ;duplicate reward, ignore it else MyArrayLastElement += 1 MyArray[MyArrayLastElement] = Reward endif EndFunction Function GiveRandomRewardToPlayer() int index = Utility.RandomInt(0, MyArrayLastElement) Form Reward = MyArray[index] MyArray[index] = None ArraySort(MyArray, index) MyArrayLastElement -= 1 Game.GetPlayer().AddItem(Reward) EndEvent Edited April 18, 2012 by fg109 Link to comment Share on other sites More sharing options...
fg109 Posted April 19, 2012 Author Share Posted April 19, 2012 (edited) @avenger404 Try changing the names of the factions so that they don't begin with numbers. @kryptopyr I don't think there's any way to reduce the delay. I'll try and think of how to use scripting to do what you wanted. The first thing I can think of so far is this: Scriptname Example extends Actor Float property MaxAggroDistance = 1024.0 auto Float property UpdateInterval = 5.0 auto bool Registered Event OnCombatStateChanged(Actor akTarget, int aeCombatState) if (Registered) && (some check to see if the actor is not currently a follower) UnregisterForUpdate() Registered = False elseif (!Registered && some check to see if the actor is currently a follower) RegisterForSingleUpdate(UpdateInterval) Registered = True endif EndEvent Event OnUpdate() Registered = False if (some check to see if the actor is currently a follower) if (GetDistance(Game.GetPlayer()) > MaxAggroDistance) StopCombatAlarm() endif RegisterForSingleUpdate(UpdateInterval) Registered = True endif EndEvent Edited April 19, 2012 by fg109 Link to comment Share on other sites More sharing options...
ArcaneSmith Posted April 19, 2012 Share Posted April 19, 2012 That was really helpful! Also I should had found that post myself, don't know how I missed it! =X Hopefully I'll be able to make something out of it. If you need anything I can help with, feel free to pm me Many thanks! Link to comment Share on other sites More sharing options...
kryptopyr Posted April 19, 2012 Share Posted April 19, 2012 Thank you! I'll try the script out and see how it does. I understand that it just may not be possible to do what I want here. The more I read about it, the less likely it sounds that the game's combat behavior can be modified in this way. Still, I think it's worth a try, and maybe I can at least get something that is an improvement over the current behavior, even if it's not ideal. I think I should be able to use IsPlayerTeammate() as the follower check. Would I write this as "if (Registered) && (akTarget.IsPlayerTeammate(False))" and "elseif (!Registered) && (akTarget.IsPlayerTeammate())" ? Also, can I use the script on a Reference Alias? Link to comment Share on other sites More sharing options...
Korodic Posted April 19, 2012 Share Posted April 19, 2012 you could always fill an array, with arrays to expand the limit :P Link to comment Share on other sites More sharing options...
fg109 Posted April 19, 2012 Author Share Posted April 19, 2012 (edited) @kryptopyr It would be if (Registered && !IsPlayerTeammate()) and elseif (!Registered && IsPlayerTeammate()) But I'm not sure if that's exactly what you want. It might be better to check for the NPC's faction rank in the CurrentFollowerFaction. @Korodic It sucks, but Papyrus doesn't support nested arrays. :( Edited April 19, 2012 by fg109 Link to comment Share on other sites More sharing options...
Korodic Posted April 19, 2012 Share Posted April 19, 2012 @Korodic It sucks, but Papyrus doesn't support nested arrays. :( there is a way to fake it. Link to comment Share on other sites More sharing options...
fg109 Posted April 19, 2012 Author Share Posted April 19, 2012 You mean the linked lists created by Redwood Elf? Or did you mean something like: Scriptname MyArrayObjectScript extends ObjectReference Form[] Property FormArray Auto {128 element array} Int Property LastElementPosition = -1 Auto {The last non-None element in the array} Int Property NestedArrayCount = 0 Auto {Just how many layers of arrays do we have?} Function AddFormToArray(Form akForm) LastElementPosition += 1 int Position = LastElementPosition - (NestedArrayCount * 128) Form[] TempArray = FormArray int Count = 0 while (Count < NestedArrayCount) TempArray = (TempArray[127] as MyArrayObjectScript).FormArray Count += 1 endwhile if (Position == 127) ;the last element in the array TempArray[127] = PlaceAtMe(GetBaseObject(), 1, false, true) NestedArrayCount += 1 AddFormToArray(akForm) else TempArray[Position] = akForm endif EndFunction ? Link to comment Share on other sites More sharing options...
AwesomeSkyrimDude Posted April 19, 2012 Share Posted April 19, 2012 Very new to modding, not totally new to writing code but still I need help. Want to make a mod that would produce different effects in combat based on the timing of a block (like stagger or disarm if you block at a certain time before getting hit), can't figure out how to do it. Sorry if perhaps there was another place I should have put this instead or something like this has already been brought up, I'm new to the forums as well. Link to comment Share on other sites More sharing options...
fg109 Posted April 19, 2012 Author Share Posted April 19, 2012 Very new to modding, not totally new to writing code but still I need help. Want to make a mod that would produce different effects in combat based on the timing of a block (like stagger or disarm if you block at a certain time before getting hit), can't figure out how to do it. Sorry if perhaps there was another place I should have put this instead or something like this has already been brought up, I'm new to the forums as well. Well, keep in mind that Papyrus isn't exactly fast. It's not going to be much good for controlling combat. That said, you could try this: Scriptname Example extends ReferenceAlias Bool Blocking Float BlockStartTime Event OnInit() RegisterForAnimationEvent(GetActorReference(), "BlockStart") RegisterForAnimationEvent(GetActorReference(), "BlockStop") EndEvent Event OnAnimationEvent(ObjectReference akSource, String asEventName) if (asEventName == "BlockStart") BlockStartTime = Utility.GetCurrentRealTime() Blocking = True elseif (asEventName == "BlockStop") Blocking = False endif EndEvent Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if (akSource as Weapon) && !((akAggressor as Actor).GetEquippedItemType(0) == 7) ;melee weapon if (Blocking) float BlockTime = Utility.GetCurrentRealTime() - BlockStartTime ;time in menu is counted if (BlockTime < 0.25) (akAggressor as Actor).UnequipItem(akSource) (akAggressor as Actor).DropObject(akSource) elseif (BlockTime < 1.0) Debug.SendAnimationEvent(akAggressor, "StaggerStart") endif endif endif EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts