qwertypol012 Posted March 23, 2020 Share Posted March 23, 2020 (edited) Hello everyone, I'm currently having a problem with my player alias script. So, i have this player alias script which is supposed to check whenever the player equip and unequip something. The script gets its reference from the quest script which have the flags 'start game enabled' and 'run once' and have a priority of 75. There are actually 2 different aliases from the script: player alias (which i'm having problem now) and an NPC alias, with their own alias script. More about my player alias script, this script is supposed to check the equipped item (and also the unequipped one), and if it's an ammo or a weapon, then further functions are fired. The function for the ammo (ie. if the equipped/unequipped item is an ammo) works to add or remove the ammo to/from a formlist. The formlist is used by the quest script which i mentioned previously, so the alias script takes the formlist from the quest property. As for the function for the weapon (ie. if the equipped/unequipped item is a weapon), if the weapon has weight equal or higher than 30 units, then the function works by adding the weapon into another formlist and checking whether the weapon has a specific keyword; if it hasn't, then add/remove a perk into/from the player (depends on the bool parameter). For a more detailed view, here's the copy of my player alias script: Scriptname qlBerserk_PlayerAliasScript extends ReferenceAlias ; Player alias script to add and remove worn ammo and other stuff. Armor PROPERTY ArmorBerserkerWCuirass2 auto GlobalVariable PROPERTY Berserk_Transform auto GlobalVariable PROPERTY Berserk_MassiveWeapon_Enable auto Keyword PROPERTY WeapTypeMassive auto Perk PROPERTY MassiveWeaponPerk auto FormList PROPERTY MassiveWeaponList auto qlBerserk_QuestScript ps ; -- EVENTs -- 3 EVENT OnInit() ps = self.GetOwningQuest() as qlBerserk_QuestScript ENDEVENT EVENT OnObjectEquipped(Form akBaseObject, ObjectReference akReference) Utility.Wait(0.1) ; wait a little bit for OnObjectUnEquipped to be finished first IF (akBaseObject as Ammo) myF_Ammo(akBaseObject, TRUE) ELSEIF (Berserk_MassiveWeapon_Enable.GetValue() as Bool) && (akBaseObject as Weapon) && ((akBaseObject as Weapon).GetWeight() >= 30.0) myF_Weapon(akBaseObject, TRUE) ; Check if the weapon has WeapTypeMassive keyword or not, then add MassiveWeaponPerk to player if not. ENDIF ENDEVENT EVENT OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject as Ammo) myF_Ammo(akBaseObject, False) ELSEIF (Berserk_MassiveWeapon_Enable.GetValue() as Bool) && (akBaseObject as Weapon) && ((akBaseObject as Weapon).GetWeight() >= 30.0) myF_Weapon(akBaseObject, False) ; Check if the weapon has WeapTypeMassive keyword or not, then remove MassiveWeaponPerk to player if not. ENDIF ENDEVENT ; -- FUNCTIONs -- 2 ;---------------------------------------------- FUNCTION myF_Ammo(Form akBaseObject, Bool bAdd) ;---------------------------------------------- IF ( ps ) ELSE Debug.Messagebox(" myF_Ammo(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) ; will be removed later Debug.Trace(" myF_Ammo(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) RETURN ; - STOP - ENDIF ;===================== formList fmL = ps.WornAmmoList IF ( fmL ) ELSE Debug.Messagebox(" myF_Ammo(" +bAdd+ ") - Error: formlist for worn ammo is missing!") ; will be removed later Debug.Trace(" myF_Ammo(" +bAdd+ ") - Error: formlist for worn ammo is missing!") RETURN ; - STOP - ENDIF ;--------------------- IF ( bAdd ) fmL.AddForm(akBaseObject) ; gets filled as ammo is equipped by the player Debug.Messagebox("worn ammo added to WornAmmoList") ; will be removed later ELSE fmL.RemoveAddedForm(akBaseObject) ; gets removed as ammo is unequipped by the player Debug.Messagebox("worn ammo removed from WornAmmoList") ; will be removed later ENDIF ENDFUNCTION ;---------------------------------------------- FUNCTION myF_Weapon(Form akBaseObject, Bool bAdd) ;---------------------------------------------- IF ( ps ) ELSE Debug.Messagebox(" myF_Weapon(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) ; will be removed later Debug.Trace(" myF_Weapon(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) RETURN ; - STOP - ENDIF ;===================== IF !(MassiveWeaponList.HasForm(akBaseObject)) MassiveWeaponList.AddForm(akBaseObject) ENDIF ;--------------------- actor player = Game.GetPlayer() IF !((akBaseObject as Weapon).HasKeyword(WeapTypeMassive)) ELSE Debug.Messagebox("equipped weapon already has WeapTypeMassive keyword, myF_Weapon function aborted") ; will be removed later RETURN ; - STOP - The weapon has WeapTypeMassive keyword, no need to add MassiveWeaponPerk to player ENDIF ;--------------------- ;IF MassiveWeaponList.HasForm(akBaseObject) IF ( bAdd ) player.AddPerk(MassiveWeaponPerk) Debug.Messagebox("MassiveWeaponPerk added to player") ; will be removed later ELSE player.RemovePerk(MassiveWeaponPerk) Debug.Messagebox("MassiveWeaponPerk removed from player") ; will be removed later ENDIF ;ENDIF ENDFUNCTION When i tested it in the game several times, i couldn't get the notifications/messageboxes shown in the game, so i suppose the script isn't working as intended. So, am i missing something here? Or is there any better way on how to implement what i'm trying to achieve here?Any helps are appreciated. Thanks :smile: Edit:For further details and explanations, read my 4th comment below (ie. the #7 post) Edited March 28, 2020 by qwertypol012 Link to comment Share on other sites More sharing options...
ReDragon2013 Posted March 23, 2020 Share Posted March 23, 2020 please try to find your own coding style, it does not make sense to use my version and merging your new code inside (with your own style) about your problem, maybe something like this..qlBerserk_PlayerAliasScript Scriptname qlBerserk_PlayerAliasScript extends ReferenceAlias ; Player alias script to add and remove worn ammo and other stuff. ; https://forums.nexusmods.com/index.php?/topic/8518963-my-playeralias-script-doesnt-seem-to-be-working/ ;Armor PROPERTY ArmorBerserkerWCuirass2 auto ; UnUSED !!! ;GlobalVariable PROPERTY Berserk_Transform auto ; UnUSED !!! GlobalVariable PROPERTY Berserk_MassiveWeapon_Enable auto FormList PROPERTY MassiveWeaponList auto ; You have to create this formlist with CreationKit!! (also if its an empty list) Keyword PROPERTY WeapTypeMassive auto ; special keyword Perk PROPERTY MassiveWeaponPerk auto ; special perk qlBerserk_QuestScript ps ; pointer to quest script (quickly handshake) ; -- EVENTs -- 3 EVENT OnInit() ps = self.GetOwningQuest() as qlBerserk_QuestScript ENDEVENT EVENT OnObjectEquipped(Form akBaseObject, ObjectReference akReference) Utility.Wait(0.1) ; wait a little bit for OnObjectUnEquipped to be finished first IF (akBaseObject as Ammo) myF_Ammo(akBaseObject, TRUE) RETURN ; - STOP - ENDIF ;--------------------- IF (akBaseObject as Weapon) myF_Weapon(akBaseObject, TRUE) ENDIF ENDEVENT EVENT OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject as Ammo) myF_Ammo(akBaseObject, False) RETURN ; - STOP - ENDIF ;--------------------- IF (akBaseObject as Weapon) myF_Weapon(akBaseObject, False) ENDIF ENDEVENT ; -- FUNCTIONs -- 3 ;---------------------------------------------- FUNCTION myF_Ammo(Form akBaseObject, Bool bAdd) ;---------------------------------------------- IF ( ps ) ELSE myF_Error(0, bAdd) RETURN ; - STOP - ENDIF ;===================== formList fmL = ps.WornAmmoList IF ( fmL ) ELSE myF_Error(1, bAdd) RETURN ; - STOP - ENDIF ;======================= IF ( bAdd ) fmL.AddForm(akBaseObject) ; gets filled as ammo is equipped by the player Debug.Trace("Add to WornAmmoList: " +akBaseObject) ; will be removed later ELSE fmL.RemoveAddedForm(akBaseObject) ; gets removed as ammo is unequipped by the player Debug.Trace("Remove from WornAmmoList: " +akBaseObject) ; will be removed later ENDIF ENDFUNCTION ;----------------------------------- FUNCTION myF_Error(Int i, Bool bAdd) ; for debugging only ;----------------------------------- IF (i == 0) Debug.Messagebox(" myF_Ammo(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) ; will be removed later Debug.Trace(" myF_Ammo(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) RETURN ; - STOP - ENDIF ;--------------------- IF (i == 1) Debug.Messagebox(" myF_Ammo(" +bAdd+ ") - Error: formlist for worn ammo is missing!") ; will be removed later Debug.Trace(" myF_Ammo(" +bAdd+ ") - Error: formlist for worn ammo is missing!") RETURN ; - STOP - ENDIF ;--------------------- IF (i == 10) Debug.Messagebox(" myF_Weapon(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) ; will be removed later Debug.Trace(" myF_Weapon(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) RETURN ; - STOP - ENDIF ;--------------------- IF (i == 11) Debug.Messagebox(" myF_Weapon(" +bAdd+ ") - Error: formlist is missing!") ; will be removed later Debug.Trace(" myF_Weapon(" +bAdd+ ") - Error: formlist is missing!") RETURN ; - STOP - ENDIF ;--------------------- ENDFUNCTION ;------------------------------------------------ FUNCTION myF_Weapon(Form akBaseObject, Bool bAdd) ;------------------------------------------------ IF ( ps ) ELSE myF_Error(10, bAdd) RETURN ; - STOP - ENDIF ;===================== IF ( MassiveWeaponList ) ELSE myF_Error(11, bAdd) RETURN ; - STOP - ENDIF ;===================== ; "if the weapon has weight equal or higher than 30 units, ; then the function works by adding the weapon into another formlist and ; checking whether the weapon has a specific keyword; ; if it has not, then add/remove a perk into/from the player (depends on the bool parameter)." IF ( bAdd ) ; == TRUE ELSE ; unequipped weapon, try to remove it from formlist regardeless of globalVar state ; == False IF MassiveWeaponList.HasForm(akBaseObject) MassiveWeaponList.RemoveAddedForm(akBaseObject) ; gets removed if unequipped by the player Debug.Trace("Remove from MassiveWeaponList: " +akBaseObject) ; will be removed later actor player = self.GetActorReference() ; get Ref for this alias IF player.HasPerk(MassiveWeaponPerk) player.RemovePerk(MassiveWeaponPerk) Debug.Messagebox("MassiveWeaponPerk removed from player") ; will be removed later ENDIF ENDIF RETURN ; - STOP - ENDIF ;--------------------- equipped weapon, try to add to formlist and special perk IF (Berserk_MassiveWeapon_Enable.GetValue() == 1) IF (akBaseObject.GetWeight() >= 30.0) MassiveWeaponList.AddForm(akBaseObject) IF (akBaseObject as Weapon).HasKeyword(WeapTypeMassive) ; weapon has WeapTypeMassive keyword, no need to add MassiveWeaponPerk to player ELSE Game.GetPlayer().AddPerk(MassiveWeaponPerk) Debug.Messagebox("MassiveWeaponPerk added to player") ; will be removed later ENDIF ENDIF ENDIF ENDFUNCTION Link to comment Share on other sites More sharing options...
qwertypol012 Posted March 23, 2020 Author Share Posted March 23, 2020 please try to find your own coding style, it does not make sense to use my version and merging your new code inside (with your own style) about your problem, maybe something like this..qlBerserk_PlayerAliasScript Scriptname qlBerserk_PlayerAliasScript extends ReferenceAlias ; Player alias script to add and remove worn ammo and other stuff. ; https://forums.nexusmods.com/index.php?/topic/8518963-my-playeralias-script-doesnt-seem-to-be-working/ ;Armor PROPERTY ArmorBerserkerWCuirass2 auto ; UnUSED !!! ;GlobalVariable PROPERTY Berserk_Transform auto ; UnUSED !!! GlobalVariable PROPERTY Berserk_MassiveWeapon_Enable auto FormList PROPERTY MassiveWeaponList auto ; You have to create this formlist with CreationKit!! (also if its an empty list) Keyword PROPERTY WeapTypeMassive auto ; special keyword Perk PROPERTY MassiveWeaponPerk auto ; special perk qlBerserk_QuestScript ps ; pointer to quest script (quickly handshake) ; -- EVENTs -- 3 EVENT OnInit() ps = self.GetOwningQuest() as qlBerserk_QuestScript ENDEVENT EVENT OnObjectEquipped(Form akBaseObject, ObjectReference akReference) Utility.Wait(0.1) ; wait a little bit for OnObjectUnEquipped to be finished first IF (akBaseObject as Ammo) myF_Ammo(akBaseObject, TRUE) RETURN ; - STOP - ENDIF ;--------------------- IF (akBaseObject as Weapon) myF_Weapon(akBaseObject, TRUE) ENDIF ENDEVENT EVENT OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject as Ammo) myF_Ammo(akBaseObject, False) RETURN ; - STOP - ENDIF ;--------------------- IF (akBaseObject as Weapon) myF_Weapon(akBaseObject, False) ENDIF ENDEVENT ; -- FUNCTIONs -- 3 ;---------------------------------------------- FUNCTION myF_Ammo(Form akBaseObject, Bool bAdd) ;---------------------------------------------- IF ( ps ) ELSE myF_Error(0, bAdd) RETURN ; - STOP - ENDIF ;===================== formList fmL = ps.WornAmmoList IF ( fmL ) ELSE myF_Error(1, bAdd) RETURN ; - STOP - ENDIF ;======================= IF ( bAdd ) fmL.AddForm(akBaseObject) ; gets filled as ammo is equipped by the player Debug.Trace("Add to WornAmmoList: " +akBaseObject) ; will be removed later ELSE fmL.RemoveAddedForm(akBaseObject) ; gets removed as ammo is unequipped by the player Debug.Trace("Remove from WornAmmoList: " +akBaseObject) ; will be removed later ENDIF ENDFUNCTION ;----------------------------------- FUNCTION myF_Error(Int i, Bool bAdd) ; for debugging only ;----------------------------------- IF (i == 0) Debug.Messagebox(" myF_Ammo(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) ; will be removed later Debug.Trace(" myF_Ammo(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) RETURN ; - STOP - ENDIF ;--------------------- IF (i == 1) Debug.Messagebox(" myF_Ammo(" +bAdd+ ") - Error: formlist for worn ammo is missing!") ; will be removed later Debug.Trace(" myF_Ammo(" +bAdd+ ") - Error: formlist for worn ammo is missing!") RETURN ; - STOP - ENDIF ;--------------------- IF (i == 10) Debug.Messagebox(" myF_Weapon(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) ; will be removed later Debug.Trace(" myF_Weapon(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) RETURN ; - STOP - ENDIF ;--------------------- IF (i == 11) Debug.Messagebox(" myF_Weapon(" +bAdd+ ") - Error: formlist is missing!") ; will be removed later Debug.Trace(" myF_Weapon(" +bAdd+ ") - Error: formlist is missing!") RETURN ; - STOP - ENDIF ;--------------------- ENDFUNCTION ;------------------------------------------------ FUNCTION myF_Weapon(Form akBaseObject, Bool bAdd) ;------------------------------------------------ IF ( ps ) ELSE myF_Error(10, bAdd) RETURN ; - STOP - ENDIF ;===================== IF ( MassiveWeaponList ) ELSE myF_Error(11, bAdd) RETURN ; - STOP - ENDIF ;===================== ; "if the weapon has weight equal or higher than 30 units, ; then the function works by adding the weapon into another formlist and ; checking whether the weapon has a specific keyword; ; if it has not, then add/remove a perk into/from the player (depends on the bool parameter)." IF ( bAdd ) ; == TRUE ELSE ; unequipped weapon, try to remove it from formlist regardeless of globalVar state ; == False IF MassiveWeaponList.HasForm(akBaseObject) MassiveWeaponList.RemoveAddedForm(akBaseObject) ; gets removed if unequipped by the player Debug.Trace("Remove from MassiveWeaponList: " +akBaseObject) ; will be removed later actor player = self.GetActorReference() ; get Ref for this alias IF player.HasPerk(MassiveWeaponPerk) player.RemovePerk(MassiveWeaponPerk) Debug.Messagebox("MassiveWeaponPerk removed from player") ; will be removed later ENDIF ENDIF RETURN ; - STOP - ENDIF ;--------------------- equipped weapon, try to add to formlist and special perk IF (Berserk_MassiveWeapon_Enable.GetValue() == 1) IF (akBaseObject.GetWeight() >= 30.0) MassiveWeaponList.AddForm(akBaseObject) IF (akBaseObject as Weapon).HasKeyword(WeapTypeMassive) ; weapon has WeapTypeMassive keyword, no need to add MassiveWeaponPerk to player ELSE Game.GetPlayer().AddPerk(MassiveWeaponPerk) Debug.Messagebox("MassiveWeaponPerk added to player") ; will be removed later ENDIF ENDIF ENDIF ENDFUNCTION Thank you very much. I'll try it :smile: And i'm sorry about the usage of your coding style. It's just that it's what left in my alias script and i didn't think of changing something which isn't actually needed. I'll write my future scrips with my own style. Link to comment Share on other sites More sharing options...
foamyesque Posted March 24, 2020 Share Posted March 24, 2020 Your quest *is* starting, right? You've used sqv to verify that? Link to comment Share on other sites More sharing options...
qwertypol012 Posted March 26, 2020 Author Share Posted March 26, 2020 (edited) Okay, i'm back here to report my testing the previous 2 days. So, i'm not sure whether it worked or not. The notifications (ie. i changed the messageboxes into notifications in the script) didn't show at all. But sometimes (probably about 60%) my tested weapons (i made 2 weapons with weight 30 and 35 respectively for the testing purposes) can successfully stagger the targets. Oh, and sorry if i haven't explained it yet; actually the perk "MassiveWeaponPerk" is to add a configurable chance (via MCM) to stagger the target on each weapon swing/attack (and i set it to 100% for the test). So, once again, i'm still unsure whether it worked or not, but probably not because the messageboxes/notifications didn't show, although the stagger effect came out everal times but it could be from a combat mod i'm using which adds a poise system to actors in combat (ie. Vigor mod). And about the ammo function, i think it worked more or less (but still not sure because no notification shown). I need my equipped ammo (both arrows and bolts) to be added to the list because the list is going to be used by other function in the quest script. And as far as i know, it worked somehow (ie. my equipped ammo shown and worn by the NPC alias i talked in my first post). But i just tested this once, because i was more troubled by the weapon function. Here's the script based on what ReDragon2013 wrote above, which i commented out some lines because they didn't suit what i actually need (once again, sorry ReDragon2013 if this one came directly from your writen script so it has your coding style; but i need it fast for testing purposes only, i swear): Scriptname qlBerserk_PlayerAliasScript extends ReferenceAlias ; Player alias script to add and remove worn ammo and other stuff. Armor PROPERTY ArmorBerserkerWCuirass2 auto ; currently unused GlobalVariable PROPERTY Berserk_Transform auto ; currently unused GlobalVariable PROPERTY Berserk_MassiveWeapon_Enable auto FormList PROPERTY MassiveWeaponList auto Keyword PROPERTY WeapTypeMassive auto Perk PROPERTY MassiveWeaponPerk auto qlBerserk_QuestScript ps ; -- EVENTs -- 3 EVENT OnInit() ps = self.GetOwningQuest() as qlBerserk_QuestScript ENDEVENT EVENT OnObjectEquipped(Form akBaseObject, ObjectReference akReference) Utility.Wait(0.1) ; wait a little bit for OnObjectUnEquipped to be finished first ;------------------------ IF (akBaseObject as Ammo) myF_Ammo(akBaseObject, TRUE) RETURN ; - STOP - ENDIF ;------------------------ IF (akBaseObject as Weapon) myF_Weapon(akBaseObject, TRUE) ENDIF ;------------------------ ;ELSEIF (akBaseObject as Armor) == ArmorBerserkerWCuirass2 ENDEVENT EVENT OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject as Ammo) myF_Ammo(akBaseObject, False) RETURN ; - STOP - ENDIF ;------------------------ IF (akBaseObject as Weapon) myF_Weapon(akBaseObject, False) ENDIF ENDEVENT ; -- FUNCTIONs -- 3 ;---------------------------------------------- FUNCTION myF_Ammo(Form akBaseObject, Bool bAdd) ;---------------------------------------------- IF ( ps ) ELSE myF_Error(0, bAdd) RETURN ; - STOP - ENDIF ;===================== formList fmL = ps.WornAmmoList IF ( fmL ) ELSE myF_Error(1, bAdd) RETURN ; - STOP - ENDIF ;======================= IF ( bAdd ) fmL.AddForm(akBaseObject) ; gets filled as ammo is equipped by the player Debug.Notification("Added to WornAmmoList: " +akBaseObject) ; will be removed later Debug.Trace("Added to WornAmmoList: " +akBaseObject) ; will be removed later ELSE fmL.RemoveAddedForm(akBaseObject) ; gets removed as ammo is unequipped by the player Debug.Notification("Removed from WornAmmoList: " +akBaseObject) ; will be removed later Debug.Trace("Removed from WornAmmoList: " +akBaseObject) ; will be removed later ENDIF ENDFUNCTION ;----------------------------------- FUNCTION myF_Error(Int i, Bool bAdd) ; for debugging only ;----------------------------------- IF (i == 0) Debug.Notification(" myF_Ammo(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) ; will be removed later Debug.Trace(" myF_Ammo(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) RETURN ; - STOP - ENDIF ;--------------------- IF (i == 1) Debug.Notification(" myF_Ammo(" +bAdd+ ") - Error: formlist for worn ammo is missing!") ; will be removed later Debug.Trace(" myF_Ammo(" +bAdd+ ") - Error: formlist for worn ammo is missing!") RETURN ; - STOP - ENDIF ;--------------------- IF (i == 10) Debug.Notification(" myF_Weapon(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) ; will be removed later Debug.Trace(" myF_Weapon(" +bAdd+ ") - Error: quest = " + self.GetOwningQuest() + ", script = " +ps) RETURN ; - STOP - ENDIF ;--------------------- IF (i == 11) Debug.Notification(" myF_Weapon(" +bAdd+ ") - Error: formlist is missing!") ; will be removed later Debug.Trace(" myF_Weapon(" +bAdd+ ") - Error: formlist is missing!") RETURN ; - STOP - ENDIF ;--------------------- ENDFUNCTION ;------------------------------------------------ FUNCTION myF_Weapon(Form akBaseObject, Bool bAdd) ;------------------------------------------------ IF ( ps ) ELSE myF_Error(10, bAdd) RETURN ; - STOP - ENDIF ;===================== IF ( MassiveWeaponList ) ELSE myF_Error(11, bAdd) RETURN ; - STOP - ENDIF ;===================== IF ( bAdd ) ; == TRUE ELSE ; unequipped weapon ; == False ; IF MassiveWeaponList.HasForm(akBaseObject) ; i dont need the function to remove the weapon from the list, just keep it there ; MassiveWeaponList.RemoveAddedForm(akBaseObject) ; gets removed if unequipped by the player ; Debug.Trace("Removed from MassiveWeaponList: " +akBaseObject) ; will be removed later actor player = self.GetActorReference() ; get Ref for this alias IF player.HasPerk(MassiveWeaponPerk) player.RemovePerk(MassiveWeaponPerk) Debug.Notification("MassiveWeaponPerk removed from player") ; will be removed later ENDIF ; ENDIF RETURN ; - STOP - ENDIF ;--------------------- equipped weapon, try to add to formlist and special perk IF (Berserk_MassiveWeapon_Enable.GetValue() == 1) IF (akBaseObject.GetWeight() >= 30.0) IF !(MassiveWeaponList.HasForm(akBaseObject)) MassiveWeaponList.AddForm(akBaseObject) ENDIF IF (akBaseObject as Weapon).HasKeyword(WeapTypeMassive) ; weapon has WeapTypeMassive keyword, no need to add MassiveWeaponPerk to player ELSE Game.GetPlayer().AddPerk(MassiveWeaponPerk) Debug.Notification("MassiveWeaponPerk added to player") ; will be removed later ENDIF ENDIF ENDIF ENDFUNCTION Your quest *is* starting, right? You've used sqv to verify that?I think yes. Because i also need the quest to make my mod work (yes, this playeralias script is actually part of a mod i'm working at). If the quest isn't starting, then some other functions from my mod shouldn't work. But they did work as far as i realize. Should i put my quest script too here? It's too long though, and there's only a line there to fill the PlayerAlias property for the alias script and another line to clear it when it's not needed anymore.Oh, the "optional" flag has also been set in the alias record (in the .esp), so it should work by filling it via the script right. Edit:Honestly, if this kind of method is difficult to work, i don't mind changing into another method. So guys, if you know other better method to achieve what i'm trying to get here, you're very welcomed. :smile:Basically i just want to make sure any weapons which weigh 30 units or more will have a configurable chance to stagger target on each attack. Actually i'm trying to use the formlist to be checked by the perk using 'IsWeaponInList' condition, but not sure if it'll work. So, if you guys have other better methods, then i'd be very eager to hear. Thanks for helps :) Edited March 26, 2020 by qwertypol012 Link to comment Share on other sites More sharing options...
ReDragon2013 Posted March 27, 2020 Share Posted March 27, 2020 (edited) I am sorry, I do not understand the aim you have with this script. You have a script in the background you forgot to tell us. You are using a mcm menu to config your not fully working script. You have unused properties in the script which you have used in an earlier version. Too many black holes for me. If you need help, make it short and understandable to read for others. Edited March 27, 2020 by ReDragon2013 Link to comment Share on other sites More sharing options...
qwertypol012 Posted March 28, 2020 Author Share Posted March 28, 2020 (edited) I am sorry, I do not understand the aim you have with this script. You have a script in the background you forgot to tell us. You are using a mcm menu to config your not fully working script. You have unused properties in the script which you have used in an earlier version. Too many black holes for me. If you need help, make it short and understandable to read for others.Sure, i'm also sorry. I'll try to explain it once more. Should be clearer now. What i'm trying to achieve?I want to make a feature named 'Massive Weapon Effect'. The feature basically works by making any weapon which has a weight of 30 units or more to have a chance to stagger the target on each hit/attack. The chance to stagger is configurable via MCM (i have set it in my own MCM script), which has a range from 0% (zero chance to stagger) to 100% (100% chance to stagger). The feature works via a specific perk named "MassiveWeaponPerk" which adds a stagger spell (ie. the stagger effect) via "Apply Combat Hit Spell" Perk Entry Point. Another thing i want to achieve is by putting any equipped ammo into the ammo FormList. This FormList will be used by the quest script for other functions. This is a fully different thing from the 'Massive Weapon Effect' i mentioned above. What method i'm using to make it work?At the time being, i'm doing it by trying to check each equipped weapon whether it has a weight of 30 units or more. If they have, then add the weapon to the FormList (as a way to "mark" the weapon that it should has the chance to stagger) and then add the perk to the player whenever the weapon is being equipped. Once the weapon is unequipped, the perk is removed from the player (because it's not used anymore), but the weapon is kept being stored in the FormList, so whenever the player equip the weapon again in the future, the function doesn't need to add it into the FormList anymore (to reduce an unnecessary function).As for the % chance to stagger, i simply using a condition "UseGlobal" in the magic effect of the stagger spell along with the function "GetRandomPercent". The global value used there is the one where the % chance is stored (ie. the GlobalVar used in the MCM menu). What problem i'm still having?The main problem i'm having is how to make my PlayerAlias script to work. This script is supposed to check whenever the player is equipping and unequipping a weapon. By checking the weapon, the function in the script will determine whether the weapon meets the requirement (as stated in what i'm trying to achieve above) and run further steps if it does. The problem is, this script doesn't seem to work at all. I put several debug functions (nofitication/messagebox) which you can see in the code i put in my previous comments, but they never shown up in the game whenever i tried to equip a weapon which has a weight of 30 units or more. I also tried to set the stagger chance to 100% (in my MCM menu), but they also don't seem to work because the target actors i hit with the weapon didn't always get staggered. Another problem is that, i'm not sure whether using FormList is a reliable way. There's a condition function "IsWeaponInList" which determines if the current weapon in the FormList, but i'm not sure if it'll work in my case here. Basically i'm putting this condition function in the MassiveWeaponPerk as a condition for the stagger spell to be applied. But after a bit of testing, it didn't seem to work. Now, for the specific questions you asked in the quote:> "You have a script in the background you forgot to tell us."Yes, they are the MCM menu i explained above and a quest script. Why didn't i mention the quest script? Because, in regards of this 'Massive Weapon Effect' functionality, the quest script only serves as a place to store the ammo FormList for the equipped ammo (which i mentioned previously) and to force the reference of PlayerAlias to the player actor. The quest script doesn't have anything to do with the player alias script other than using the items stored in the FormList for other functions. Of course the stored FormList will be further used by other functions in the quest script, but i didn't have any problem with the functions in the quest script, so i didn't mention it to make things simple. > "You have unused properties in the script which you have used in an earlier version."They'll be used in my future to-do-list, but for now my priority is to make sure that the player alias script works first. So i wrote it there in advance. Just ignore them for the time being. If you have any more questions, please do ask. Once again, thanks for the concern :smile: Edited March 28, 2020 by qwertypol012 Link to comment Share on other sites More sharing options...
foamyesque Posted March 28, 2020 Share Posted March 28, 2020 (edited) If the quest is starting, are you sure the player alias is being filled? There's a reason I suggested the sqv console command; it provides a lot of very valuable data on a quest's state -- stage, whether it's running, what's in each alias, that sort of thing. And apologies if I'm harping on this a bit, but I don't want to try and debug code (especially ReDragon's, whose style is very different from my own) without eliminating things that could simply keep it from running at all. Related to this, are you testing on a fresh save? Edited March 28, 2020 by foamyesque Link to comment Share on other sites More sharing options...
qwertypol012 Posted March 28, 2020 Author Share Posted March 28, 2020 If the quest is starting, are you sure the player alias is being filled? There's a reason I suggested the sqv console command; it provides a lot of very valuable data on a quest's state -- stage, whether it's running, what's in each alias, that sort of thing. And apologies if I'm harping on this a bit, but I don't want to try and debug code (especially ReDragon's, whose style is very different from my own) without eliminating things that could simply keep it from running at all. Related to this, are you testing on a fresh save?I'll try to check using that console command later.This mod was installed on a new fresh save, yes. But as you can see, some tweaks happen, but the main quest has been there since the beginning of this fresh save. Link to comment Share on other sites More sharing options...
dylbill Posted March 28, 2020 Share Posted March 28, 2020 Hello, I've also had some problems with getting a player alias script to work in the past. I've found, if your quest has more than one alias, it can cause problems with your player alias for some reason. If you're using an MCM, try putting your script the MCM playerAlias, or, create a completely new quest and have the only thing that's on the quest be the player alias. Link to comment Share on other sites More sharing options...
Recommended Posts