Last active
November 18, 2019 07:37
-
-
Save dalen/dede713a18c7c1a70170dca5910cc397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scriptname _RC_QuestScript extends Quest | |
Keyword Property ActorTypeNPC Auto | |
Actor Property PlayerRef Auto | |
GlobalVariable Property _RC_GlobalToggleMessages Auto | |
GlobalVariable Property _RC_GlobalCapacityBase Auto | |
GlobalVariable Property _RC_GlobalCuirassBase Auto | |
GlobalVariable Property _RC_GlobalCuirassPerc Auto | |
GlobalVariable Property _RC_GlobalGauntletsBase Auto | |
GlobalVariable Property _RC_GlobalGauntletsPerc Auto | |
GlobalVariable Property _RC_GlobalBootsBase Auto | |
GlobalVariable Property _RC_GlobalBootsPerc Auto | |
Armor ArmorShield = None | |
Weapon WeaponSmall1 = None | |
Weapon WeaponSmall2 = None | |
Weapon WeaponMedium1 = None | |
Weapon WeaponMedium2 = None | |
Weapon WeaponLarge = None | |
Weapon WeaponRanged = None | |
bool Calculating = false | |
bool Enabled = true | |
String CarryWeight = "CarryWeight" | |
Function ItemEquipped(Form Item) | |
if((Item as Armor || Item as Weapon) && Item != ArmorShield && Item != WeaponSmall1 && Item != WeaponSmall2 && Item != WeaponMedium1 && Item != WeaponMedium2 && Item != WeaponLarge && Item != WeaponRanged) | |
CalculateEncumberance() | |
elseif(Item as Weapon) | |
Int WeaponType = (Item as Weapon).GetWeaponType() | |
if((WeaponType == 2) && WeaponSmall1 != WeaponSmall2 && PlayerRef.GetEquippedWeapon(false) == PlayerRef.GetEquippedWeapon(true));Small Weapons | |
CalculateEncumberance() | |
elseif((WeaponType == 1 || WeaponType == 3 || WeaponType == 4) && WeaponMedium1 != WeaponMedium2 && PlayerRef.GetEquippedWeapon(false) == PlayerRef.GetEquippedWeapon(true));Medium Weapons | |
CalculateEncumberance() | |
endIf | |
endIf | |
endFunction | |
Function ItemUnequipped(Form Item) | |
if(Item as Armor && (!ArmorShield || Item != ArmorShield)) | |
CalculateEncumberance() | |
endIf | |
endFunction | |
Function ItemRemoved(Form Item) | |
if(Item && (Item == ArmorShield || Item == WeaponSmall1 || Item == WeaponSmall2 || Item == WeaponMedium1 || Item == WeaponMedium2 || Item == WeaponLarge || Item == WeaponRanged)) | |
CalculateEncumberance() | |
endIf | |
endFunction | |
string Function GetItemName(int Item) | |
if(Item == 0) | |
if(ArmorShield) | |
return ArmorShield.GetName() | |
else | |
return "No Item Equipped" | |
endIf | |
elseif(Item == 1) | |
if(WeaponSmall1) | |
return WeaponSmall1.GetName() | |
else | |
return "No Item Equipped" | |
endIf | |
elseif(Item == 2) | |
if(WeaponSmall2) | |
return WeaponSmall2.GetName() | |
else | |
return "No Item Equipped" | |
endIf | |
elseif(Item == 3) | |
if(WeaponMedium1) | |
return WeaponMedium1.GetName() | |
else | |
return "No Item Equipped" | |
endIf | |
elseif(Item == 4) | |
if(WeaponMedium2) | |
return WeaponMedium2.GetName() | |
else | |
return "No Item Equipped" | |
endIf | |
elseif(Item == 5) | |
if(WeaponLarge) | |
return WeaponLarge.GetName() | |
else | |
return "No Item Equipped" | |
endIf | |
elseif(Item == 6) | |
if(WeaponRanged) | |
return WeaponRanged.GetName() | |
else | |
return "No Item Equipped" | |
endIf | |
endIf | |
endFunction | |
Function CalculateEncumberance() | |
if(!Calculating && Enabled) | |
Calculating = true | |
Utility.Wait(0.5) | |
float CalcStart = Utility.GetCurrentRealTime() | |
if(PlayerRef.HasKeyword(ActorTypeNPC)) | |
int PlayerItem = PlayerRef.GetNumItems() | |
float PlayerCapacity = _RC_GlobalCapacityBase.GetValue() | |
if(ArmorShield && PlayerRef.GetItemCount(ArmorShield) < 1) | |
ArmorShield = None | |
endIf | |
if(WeaponSmall1 && WeaponSmall2 && WeaponSmall1 == WeaponSmall2) | |
if(PlayerRef.GetItemCount(WeaponSmall1) < 2) | |
WeaponSmall2 = None | |
if(PlayerRef.GetItemCount(WeaponSmall1) < 1) | |
WeaponSmall1 = None | |
endIf | |
endIf | |
else | |
if(WeaponSmall1 && PlayerRef.GetItemCount(WeaponSmall1) < 1) | |
WeaponSmall1 = None | |
endIf | |
if(WeaponSmall2 && PlayerRef.GetItemCount(WeaponSmall2) < 1) | |
WeaponSmall2 = None | |
endIf | |
endIf | |
if(WeaponMedium1 && WeaponMedium2 && WeaponMedium1 == WeaponMedium2) | |
if(PlayerRef.GetItemCount(WeaponMedium1) < 2) | |
WeaponMedium2 = None | |
if(PlayerRef.GetItemCount(WeaponMedium1) < 1) | |
WeaponMedium1 = None | |
endIf | |
endIf | |
else | |
if(WeaponMedium1 && PlayerRef.GetItemCount(WeaponMedium1) < 1) | |
WeaponMedium1 = None | |
endIf | |
if(WeaponMedium2 && PlayerRef.GetItemCount(WeaponMedium2) < 1) | |
WeaponMedium2 = None | |
endIf | |
endIf | |
if(WeaponLarge && PlayerRef.GetItemCount(WeaponLarge) < 1) | |
WeaponLarge = None | |
endIf | |
if(WeaponRanged && PlayerRef.GetItemCount(WeaponRanged) < 1) | |
WeaponRanged = None | |
endIf | |
while(PlayerItem >= 0) | |
Form Item = PlayerRef.GetNthForm(PlayerItem) | |
if(Item as Armor) | |
if(PlayerRef.IsEquipped(Item)) | |
int Slot = (Item as Armor).GetSlotMask() | |
if(Math.LogicalAnd(Slot,0x00000200)) | |
ArmorShield = (Item as Armor) | |
else | |
float Weight = Item.GetWeight() | |
PlayerCapacity += Weight | |
if(Math.LogicalAnd(Slot,0x00000004)) | |
float Space = Weight * _RC_GlobalCuirassPerc.GetValue() | |
float Base = _RC_GlobalCuirassBase.GetValue() | |
if(Space < Base) | |
PlayerCapacity += Base | |
else | |
PlayerCapacity += Space | |
endIf | |
elseif(Math.LogicalAnd(Slot,0x00000008) || Math.LogicalAnd(Slot,0x00000010)) | |
float Space = Weight * _RC_GlobalGauntletsPerc.GetValue() | |
float Base = _RC_GlobalGauntletsBase.GetValue() | |
if(Space < Base) | |
PlayerCapacity += Base | |
else | |
PlayerCapacity += Space | |
endIf | |
elseif(Math.LogicalAnd(Slot,0x00000080) || Math.LogicalAnd(Slot,0x00000100)) | |
float Space = Weight * _RC_GlobalBootsPerc.GetValue() | |
float Base = _RC_GlobalBootsBase.GetValue() | |
if(Space < Base) | |
PlayerCapacity += Base | |
else | |
PlayerCapacity += Space | |
endIf | |
endIf | |
endIf | |
endIf | |
elseif(Item as Weapon) | |
Weapon WeaponItem = Item as Weapon | |
if(PlayerRef.GetEquippedWeapon(false) == WeaponItem || PlayerRef.GetEquippedWeapon(true) == WeaponItem) | |
Int WeaponType = WeaponItem.GetWeaponType() | |
if(WeaponType == 2);Small Weapons | |
if(PlayerRef.GetEquippedWeapon(false) == PlayerRef.GetEquippedWeapon(true)) | |
WeaponSmall1 = WeaponItem | |
WeaponSmall2 = WeaponItem | |
else | |
if(WeaponSmall1 == None) | |
WeaponSmall1 = WeaponItem | |
elseif(WeaponSmall2 == None && WeaponSmall1 != WeaponItem) | |
WeaponSmall2 = WeaponItem | |
elseif(!PlayerRef.IsEquipped(WeaponSmall1)) | |
WeaponSmall1 = WeaponItem | |
elseif(!PlayerRef.IsEquipped(WeaponSmall2) && WeaponSmall1 != WeaponItem) | |
WeaponSmall2 = WeaponItem | |
endIf | |
endIf | |
elseif(WeaponType == 1 || WeaponType == 3 || WeaponType == 4);Medium Weapons | |
if(PlayerRef.GetEquippedWeapon(false) == PlayerRef.GetEquippedWeapon(true)) | |
WeaponMedium1 = WeaponItem | |
WeaponMedium2 = WeaponItem | |
else | |
if(WeaponMedium1 == None) | |
WeaponMedium1 = WeaponItem | |
elseif(WeaponMedium2 == None && WeaponMedium1 != WeaponItem) | |
WeaponMedium2 = WeaponItem | |
elseif(!PlayerRef.IsEquipped(WeaponMedium1)) | |
WeaponMedium1 = WeaponItem | |
elseif(!PlayerRef.IsEquipped(WeaponMedium2) && WeaponMedium1 != WeaponItem) | |
WeaponMedium2 = WeaponItem | |
endIf | |
endIf | |
elseif(WeaponType == 5 || WeaponType == 6 || WeaponType == 8);Large Weapons | |
WeaponLarge = WeaponItem | |
elseif(WeaponType == 7 || WeaponType == 9);Ranged Weapons | |
WeaponRanged = WeaponItem | |
endIf | |
endIf | |
endIf | |
PlayerItem -= 1 | |
endWhile | |
if(ArmorShield) | |
PlayerCapacity += ArmorShield.GetWeight() | |
endIf | |
if(WeaponSmall1) | |
PlayerCapacity += WeaponSmall1.GetWeight() | |
endIf | |
if(WeaponSmall2) | |
PlayerCapacity += WeaponSmall2.GetWeight() | |
endIf | |
if(WeaponMedium1) | |
PlayerCapacity += WeaponMedium1.GetWeight() | |
endIf | |
if(WeaponMedium2) | |
PlayerCapacity += WeaponMedium2.GetWeight() | |
endIf | |
if(WeaponLarge) | |
PlayerCapacity += WeaponLarge.GetWeight() | |
endIf | |
if(WeaponRanged) | |
PlayerCapacity += WeaponRanged.GetWeight() | |
endIf | |
PlayerRef.SetActorValue(CarryWeight, PlayerCapacity) | |
if(_RC_GlobalToggleMessages.GetValue() == 1) | |
;DisplayWeapons() | |
Debug.Notification("Inventory Organized in " + (Utility.GetCurrentRealTime() - CalcStart) + " seconds, Capacity set to: " + PlayerCapacity) | |
endIf | |
else | |
PlayerRef.SetActorValue(CarryWeight, 1000) | |
endIf | |
Calculating = false | |
endIf | |
endFunction | |
Function DisplayWeapons() | |
if(ArmorShield) | |
Debug.Notification("Shield Equipped: " + ArmorShield.GetName()) | |
endIf | |
if(WeaponSmall1) | |
Debug.Notification("Small Weapon Equipped (1): " + WeaponSmall1.GetName()) | |
endIf | |
if(WeaponSmall2) | |
Debug.Notification("Small Weapon Equipped (2): " + WeaponSmall2.GetName()) | |
endIf | |
if(WeaponMedium1) | |
Debug.Notification("Medium Weapon Equipped (1): " + WeaponMedium1.GetName()) | |
endIf | |
if(WeaponMedium2) | |
Debug.Notification("Medium Weapon Equipped (2): " + WeaponMedium2.GetName()) | |
endIf | |
if(WeaponLarge) | |
Debug.Notification("Large Weapon Equipped: " + WeaponLarge.GetName()) | |
endIf | |
if(WeaponRanged) | |
Debug.Notification("Ranged Weapon Equipped: " + WeaponRanged.GetName()) | |
endIf | |
endFunction | |
Function EnableMod() | |
Enabled = true | |
if(!Calculating) | |
CalculateEncumberance() | |
endIf | |
endFunction | |
Function DisableMod() | |
Enabled = false | |
PlayerRef.SetActorValue(CarryWeight, 300 + (((PlayerRef.GetBaseActorValue("Stamina") - 100)/2) as int)) | |
endFunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment