parent
926761764b
commit
67b3dd3b2d
3 changed files with 273 additions and 0 deletions
@ -0,0 +1,9 @@ |
||||
unit userscript; |
||||
|
||||
function Process(e: IInterface): Integer; |
||||
begin |
||||
if GetElementNativeValues(e, 'Record Header\Record Flags\Compressed') <> 0 then |
||||
SetElementNativeValues(e, 'Record Header\Record Flags\Compressed', 0); |
||||
end; |
||||
|
||||
end. |
@ -0,0 +1,152 @@ |
||||
{ |
||||
Generates conditions for dismantling recipes in Enderal SE |
||||
Author: Eddoursul, condition generation borrowed from fireundubh's work |
||||
Version: 1.0 |
||||
|
||||
One-handed weapon conditions: |
||||
>= 1 |
||||
&& |
||||
> 2 || temp < 2 |
||||
&& |
||||
> 1 || temp == 0 |
||||
&& |
||||
arcane perk check |
||||
|
||||
All other weapons and armor: |
||||
>= 1 |
||||
&& |
||||
> 1 || ! equipped |
||||
&& |
||||
arcane perk check |
||||
} |
||||
|
||||
unit UserScript; |
||||
|
||||
function Process(e: IInterface): integer; |
||||
var |
||||
rec, item, conditions, condition, ctda, lastcondition, lastctda, checkcondition, checkctda, baseItem: IInterface; |
||||
i, iLastIndex, iResults: integer; |
||||
equipType: string; |
||||
begin |
||||
item := ElementByPath(e, 'Items\Item\CNTO\Item'); |
||||
baseItem := LinksTo(item); |
||||
|
||||
// Recreate conditions |
||||
Remove(ElementByName(e, 'Conditions')); |
||||
conditions := Add(e, 'Conditions', true); |
||||
|
||||
// GetItemCount >= 1 |
||||
ctda := ElementByPath(e, 'Conditions\Condition\CTDA'); |
||||
SetEditValue(ElementByIndex(ctda, 0), '11000000'); |
||||
SetNativeValue(ElementByIndex(ctda, 2), GetNativeValue(ElementByPath(e, 'Items\Item\CNTO\Count'))); |
||||
SetEditValue(ElementByIndex(ctda, 3), 'GetItemCount'); |
||||
SetEditValue(ElementByName(ctda, 'Inventory Object'), GetEditValue(item)); |
||||
|
||||
equipType := ShortName(LinksTo(ElementByPath(baseItem, 'ETYP'))); |
||||
|
||||
// One-handed weapons |
||||
if (Signature(baseItem) = 'WEAP') and ((Pos('[EQUP:00013F42]', equipType) > 0) or (Pos('[EQUP:00013F43]', equipType) > 0) or (Pos('[EQUP:00013F44]', equipType) > 0)) then begin |
||||
|
||||
// GetItemCount > 2 OR |
||||
condition := ElementAssign(conditions, HighInteger, nil, true); |
||||
conditions := ElementByName(e, 'Conditions'); |
||||
iLastIndex := ElementCount(conditions) - 1; |
||||
lastcondition := ElementByIndex(conditions, iLastIndex); |
||||
lastctda := ElementBySignature(ElementByIndex(conditions, iLastIndex), 'CTDA'); |
||||
|
||||
SetEditValue(ElementByIndex(lastctda, 0), '01010000'); |
||||
SetNativeValue(ElementByIndex(lastctda, 2), 2.0); |
||||
SetEditValue(ElementByIndex(lastctda, 3), 'GetItemCount'); |
||||
SetEditValue(ElementByName(lastctda, 'Inventory Object'), GetEditValue(item)); |
||||
|
||||
// Temp < 2 |
||||
condition := ElementAssign(conditions, HighInteger, nil, true); |
||||
iLastIndex := ElementCount(conditions) - 1; |
||||
lastcondition := ElementByIndex(conditions, iLastIndex); |
||||
lastctda := ElementBySignature(ElementByIndex(conditions, iLastIndex), 'CTDA'); |
||||
|
||||
SetEditValue(ElementByIndex(lastctda, 0), '00100000'); |
||||
SetNativeValue(ElementByIndex(lastctda, 2), 2.0); |
||||
SetEditValue(ElementByIndex(lastctda, 3), 'GetItemCount'); |
||||
SetEditValue(ElementByName(lastctda, 'Inventory Object'), GetEditValue(item)); |
||||
SetEditValue(ElementByName(lastctda, 'Run On'), 'Reference'); |
||||
SetEditValue(ElementByName(lastctda, 'Reference'), '[REFR:000469E7]'); |
||||
|
||||
|
||||
// GetItemCount > 1 OR |
||||
condition := ElementAssign(conditions, HighInteger, nil, true); |
||||
conditions := ElementByName(e, 'Conditions'); |
||||
iLastIndex := ElementCount(conditions) - 1; |
||||
lastcondition := ElementByIndex(conditions, iLastIndex); |
||||
lastctda := ElementBySignature(ElementByIndex(conditions, iLastIndex), 'CTDA'); |
||||
|
||||
SetEditValue(ElementByIndex(lastctda, 0), '01010000'); |
||||
SetNativeValue(ElementByIndex(lastctda, 2), 1.0); |
||||
SetEditValue(ElementByIndex(lastctda, 3), 'GetItemCount'); |
||||
SetEditValue(ElementByName(lastctda, 'Inventory Object'), GetEditValue(item)); |
||||
|
||||
// Temp == 0 |
||||
condition := ElementAssign(conditions, HighInteger, nil, true); |
||||
conditions := ElementByName(e, 'Conditions'); |
||||
iLastIndex := ElementCount(conditions) - 1; |
||||
lastcondition := ElementByIndex(conditions, iLastIndex); |
||||
lastctda := ElementBySignature(ElementByIndex(conditions, iLastIndex), 'CTDA'); |
||||
|
||||
SetEditValue(ElementByIndex(lastctda, 0), '10000000'); |
||||
SetNativeValue(ElementByIndex(lastctda, 2), 0); |
||||
SetEditValue(ElementByIndex(lastctda, 3), 'GetItemCount'); |
||||
SetEditValue(ElementByName(lastctda, 'Inventory Object'), GetEditValue(item)); |
||||
SetEditValue(ElementByName(lastctda, 'Run On'), 'Reference'); |
||||
SetEditValue(ElementByName(lastctda, 'Reference'), '[REFR:000469E7]'); |
||||
|
||||
end |
||||
else if (Signature(baseItem) = 'WEAP') or (Signature(baseItem) = 'ARMO') then begin |
||||
|
||||
// GetEquipped == 0 OR |
||||
condition := ElementAssign(conditions, HighInteger, nil, true); |
||||
iLastIndex := ElementCount(conditions) - 1; |
||||
lastcondition := ElementByIndex(conditions, iLastIndex); |
||||
lastctda := ElementBySignature(ElementByIndex(conditions, iLastIndex), 'CTDA'); |
||||
|
||||
SetEditValue(ElementByIndex(lastctda, 0), '10010000'); |
||||
SetNativeValue(ElementByIndex(lastctda, 2), 0); |
||||
SetEditValue(ElementByIndex(lastctda, 3), 'GetEquipped'); |
||||
SetEditValue(ElementByName(lastctda, 'Inventory Object'), GetEditValue(item)); |
||||
|
||||
|
||||
// GetItemCount > 1 |
||||
condition := ElementAssign(conditions, HighInteger, nil, true); |
||||
iLastIndex := ElementCount(conditions) - 1; |
||||
lastcondition := ElementByIndex(conditions, iLastIndex); |
||||
lastctda := ElementBySignature(ElementByIndex(conditions, iLastIndex), 'CTDA'); |
||||
|
||||
SetEditValue(ElementByIndex(lastctda, 0), '01000000'); |
||||
SetNativeValue(ElementByIndex(lastctda, 2), 1.0); |
||||
SetEditValue(ElementByIndex(lastctda, 3), 'GetItemCount'); |
||||
SetEditValue(ElementByName(lastctda, 'Inventory Object'), GetEditValue(item)); |
||||
|
||||
end; |
||||
|
||||
|
||||
// Check the arcane perk if the dismantled item is enchanted |
||||
if Assigned(ElementByPath(baseItem, 'EITM')) then begin |
||||
condition := ElementAssign(conditions, HighInteger, nil, true); |
||||
iLastIndex := ElementCount(conditions) - 1; |
||||
lastcondition := ElementByIndex(conditions, iLastIndex); |
||||
lastctda := ElementBySignature(ElementByIndex(conditions, iLastIndex), 'CTDA'); |
||||
|
||||
SetEditValue(ElementByIndex(lastctda, 0), '10000000'); |
||||
SetNativeValue(ElementByIndex(lastctda, 2), 1); |
||||
SetEditValue(ElementByIndex(lastctda, 3), 'HasPerk'); |
||||
SetEditValue(ElementByName(lastctda, 'Perk'), '[PERK:0005218E]'); |
||||
end; |
||||
|
||||
end; |
||||
|
||||
function Finalize: integer; |
||||
begin |
||||
AddMessage('Done'); |
||||
Result := 1; |
||||
end; |
||||
|
||||
end. |
@ -0,0 +1,112 @@ |
||||
{ |
||||
Create patch plugin with "No Respawn" flag on references. |
||||
} |
||||
unit FindRespawningItems; |
||||
|
||||
var |
||||
plugin: IInterface; |
||||
bNewFile: bool; |
||||
bSkipSection: bool; |
||||
sFormType: string; |
||||
|
||||
function Initialize: Integer; |
||||
begin |
||||
if not InputQuery('Filter By Form', 'WEAP, ARMO, etc.', sFormType) then |
||||
Exit; |
||||
|
||||
if sFormType = '' then |
||||
Exit; |
||||
|
||||
bNewFile := False; |
||||
if MessageDlg('Create a new plugin [YES] or set flags, modifying source files [NO]?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then |
||||
bNewFile := True; |
||||
end; |
||||
|
||||
function HasScript(e: IInterface; aScript: string): Boolean; |
||||
var |
||||
i: integer; |
||||
begin |
||||
if Name(e) = 'scriptName' then begin |
||||
Result := SameText(GetEditValue(e), aScript); |
||||
bSkipSection := True; |
||||
end else |
||||
for i := 0 to Pred(ElementCount(e)) do begin |
||||
Result := HasScript(ElementByIndex(e, i), aScript); |
||||
if bSkipSection then begin |
||||
bSkipSection := False; |
||||
Exit; |
||||
end; |
||||
if Result then Exit; |
||||
end; |
||||
end; |
||||
|
||||
function Process(e: IInterface): Integer; |
||||
var |
||||
sFormID: string; |
||||
r: IInterface; |
||||
begin |
||||
// process only references |
||||
if Signature(e) <> 'REFR' then |
||||
Exit; |
||||
|
||||
// only master references |
||||
if not IsMaster(e) then |
||||
Exit; |
||||
|
||||
// but work with the current winning override |
||||
e := WinningOverride(e); |
||||
|
||||
// references of activator only |
||||
if Signature(BaseRecord(e)) <> sFormType then |
||||
Exit; |
||||
|
||||
if GetElementEditValues(e, 'Record Header\Record Flags\No Respawn') = '1' then |
||||
exit; |
||||
|
||||
if bNewFile then begin |
||||
if not Assigned(plugin) then begin |
||||
plugin := AddNewFile; |
||||
if not Assigned(plugin) then begin |
||||
Result := 1; |
||||
Exit; |
||||
end; |
||||
end; |
||||
end; |
||||
|
||||
try |
||||
|
||||
if Assigned(plugin) then begin |
||||
// add masters before copying as override for parent CELL |
||||
AddRequiredElementMasters(LinksTo(ElementByIndex(e, 0)), plugin, False); |
||||
// and REFR itself |
||||
AddRequiredElementMasters(e, plugin, False); |
||||
|
||||
// winning cell override |
||||
r := WinningOverride(LinksTo(ElementByName(e, 'Cell'))); |
||||
if GetFile(r) <> plugin then begin |
||||
AddRequiredElementMasters(r, plugin, False); |
||||
wbCopyElementToFile(r, plugin, False, True); |
||||
end; |
||||
|
||||
// copy reference as override |
||||
e := wbCopyElementToFile(e, plugin, False, True); |
||||
end; |
||||
|
||||
// set No Respawn flag |
||||
SetElementNativeValues(e, 'Record Header\Record Flags\No Respawn', 1); |
||||
|
||||
except |
||||
on Ex: Exception do begin |
||||
AddMessage('Failed to copy: ' + FullPath(e)); |
||||
AddMessage(' reason: ' + Ex.Message); |
||||
end; |
||||
end; |
||||
end; |
||||
|
||||
function Finalize: integer; |
||||
begin |
||||
if Assigned(plugin) then |
||||
SortMasters(plugin); |
||||
end; |
||||
|
||||
end. |
Loading…
Reference in new issue