Last active
December 14, 2020 14:19
-
-
Save yggdrasil75/0066568b8658dcdb56dc4aef3eb4abcc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| procedure templatelists; | |
| begin | |
| //setup template files | |
| //ALLATemplate.ini | |
| //ALLAUserTemplate.ini | |
| //ALLA+<modname>+template.ini in data folder (ie: ALLAYggKeywordsTemplate.ini | |
| //templates at +<name> are in scripts folder, templates at -<name> are in data. | |
| IniTemplates := TStringList.Create; | |
| IniTemplates.add('+ALLATemplate.ini'); | |
| IniTemplates.add('+ALLAUserTemplate.ini'); | |
| for i := 0 to filecount - 1 do begin | |
| if FileExists(Datapath+'alla'+GetFileName(fileByIndex(i))+'template.ini') then | |
| IniTemplates.add('-alla'+GetFileName(fileByIndex(i))+'template.ini'); | |
| end; | |
| for i := IniTemplates.count - 1 downto 0 do begin | |
| cini := IniTemplates[i] | |
| if startsWith('+', cini) then | |
| tempstream := TMemIniFile.Create(scriptsPath+copy(cini,1,cini.length)) | |
| else tempstream := TMemIniFile.Create(datapath+copy(cini,1,cini.length)) | |
| IniFilestreams.addobject(cini,tempstream); | |
| {debug} if debugmsg then msg('collection of files complete'); | |
| end; | |
| for i := IniFilestreams.count - 1 downto 0 do begin | |
| groupings.delimitedText(IniFilestreams.objects[i].readstring('explanation','groupings','')); | |
| end; | |
| for j := groupings.count - 1 downto 0 do begin | |
| currentgrouping := groupings[j]; | |
| for i := IniFilestreams.count - 1 downto 0 do begin | |
| CurrentIni := IniFilestreams.objects[i]; | |
| templist1.delimitedText(CurrentIni.readstring(currentgrouping,'types','')); | |
| templist2.delimitedText(CurrentIni.readstring(currentgrouping,'grup','')); | |
| templist3.delimitedText(CurrentIni.readstring(currentgrouping,'ident','')); | |
| PrimaryPath := CurrentIni.readstring(currentgrouping,'primaryPath',''); | |
| templist4.delimitedText(CurrentIni.readstring(currentgrouping,'secondaryPath','')); | |
| MaxLevel := CurrentIni.readint(currentgrouping,'maxLevel',''); | |
| {debug} if debugmsg then msg('collection of explanations complete'); | |
| templist.addobject('types',templist1); | |
| templist.addobject('grup',templist2); | |
| templist.addobject('ident',templist3); | |
| templist.addobject('path1',primaryPath); | |
| templist.addobject('path2',templist4); | |
| templist.addobject('max',MaxLevel); | |
| end; | |
| groupings2.addobject(groupings[i],templist); | |
| end; | |
| for j := groupings2.count - 1 downto 0 do begin | |
| cg := groupings2[j]; | |
| cgi := cg.objects[cg.indexof(types)]; | |
| for k := cgi.count - 1 downto 0 do begin | |
| cgik := cgi[k]; | |
| for i := IniFilestreams.count - 1 downto 0 do begin | |
| CurrentIni := IniFilestreams.objects[i]; | |
| tempitemlist.delimitedText(CurrentIni.readstring(cg, cgik,'')); | |
| tempkywdlist.delimitedText(CurrentIni.readstring(cg, cgik+keywords,'')); | |
| templistprimary.addobject(cgik,tempitemlist); | |
| templistprimary.addobject(cgik+keywords,tempkywdlist); | |
| end; | |
| tml.addobject(cgik,templistprimary); | |
| {debug} if debugmsg then msg('collection of '+ cg +' complete'); | |
| end; | |
| tml2 := tcompact(tml); | |
| TemplateMegalist.addobject(cg,tml2); | |
| end; | |
| end; | |
| function tcompact(tml: tstringlist): tstringlist; | |
| begin | |
| for i := tml.count - 1 downto 0 do begin | |
| end; | |
| for i := items.count - 1 downto 0 do begin | |
| cs := items[i]; | |
| t := pos(':', cs); | |
| f := pos('|', cs); | |
| tier := copy(cs, t+1, cs.length); | |
| ciEDID := copy(cs,f+1,t-1) | |
| templist := items.objects[tier-1]; | |
| templist.addobject(ciEDID, recordbyeditorid(copy(cs,0,f-1), copy(cs, f+1,t-1))); | |
| items2.objects[tier-1] := templist; | |
| end; | |
| for items2.count - 1 downto 0 do begin | |
| end; | |
| for i := items2.count - 1 downto 0 do begin | |
| templist := items2.objects[i]; | |
| j := random(templist.count) - 1; | |
| jit := jit; | |
| if signature(jit, 'armo') then begin | |
| if ((StrTofloat(geev(aRecord, 'data\weight')) + | |
| StrTofloat(geev(aRecord, 'DNAM')) / 5 + | |
| StrTofloat(geev(aRecord, 'data\value')) / 100) / 3 > | |
| ((StrTofloat(geev(jit, 'data\weight')) + | |
| StrTofloat(geev(jit, 'DNAM')) / 5 + | |
| StrTofloat(geev(jit, 'data\value')) / 100) / 3) + 2) and not (downgraded > 15) then begin | |
| upgraded := upgraded + 1; | |
| continue; | |
| end else if ((StrTofloat(geev(aRecord, 'data\weight')) + | |
| StrTofloat(geev(aRecord, 'DNAM')) / 5 + | |
| StrTofloat(geev(aRecord, 'data\value')) / 100) / 3 < | |
| ((StrTofloat(geev(jit, 'data\weight')) + | |
| StrTofloat(geev(jit, 'DNAM')) / 5 + | |
| StrTofloat(geev(jit, 'data\value')) / 100) / 3) - 2) and not (upgraded > 2) then begin | |
| downgraded := downgraded + 1; | |
| i := i - 2; | |
| continue; | |
| end else result := jit; | |
| end else if signature(jit, 'weap') then begin | |
| if ((StrTofloat(geev(aRecord, 'DNAM\speed')) * 5 + | |
| StrTofloat(geev(aRecord, 'DNAM\reach')) * 5 + | |
| StrTofloat(geev(aRecord, 'DNAM\stagger')) * 5 + | |
| StrTofloat(geev(aRecord, 'DATA\weight')) + | |
| StrTofloat(geev(aRecord, 'DATA\Damage')) + | |
| StrTofloat(geev(aRecord, 'CRDT\Damage')) + | |
| StrTofloat(geev(aRecord, 'data\value')) / 100) / 7 > | |
| ((StrTofloat(geev(jit, 'DNAM\speed')) * 5 + | |
| StrTofloat(geev(jit, 'DNAM\reach')) * 5 + | |
| StrTofloat(geev(jit, 'DNAM\stagger')) * 5 + | |
| StrTofloat(geev(jit, 'DATA\weight')) + | |
| StrTofloat(geev(jit, 'DATA\Damage')) + | |
| StrTofloat(geev(jit, 'CRDT\Damage')) + | |
| StrTofloat(geev(jit, 'data\value')) / 100) / 7) + 2) and not (downgraded > 15) then begin | |
| upgraded := upgraded + 1; | |
| continue; | |
| end else if ((StrTofloat(geev(aRecord, 'DNAM\speed')) * 5 + | |
| StrTofloat(geev(aRecord, 'DNAM\reach')) * 5 + | |
| StrTofloat(geev(aRecord, 'DNAM\stagger')) * 5 + | |
| StrTofloat(geev(aRecord, 'DATA\weight')) + | |
| StrTofloat(geev(aRecord, 'DATA\Damage')) + | |
| StrTofloat(geev(aRecord, 'CRDT\Damage')) + | |
| StrTofloat(geev(aRecord, 'data\value')) / 100) / 7 < | |
| ((StrTofloat(geev(jit, 'DNAM\speed')) * 5 + | |
| StrTofloat(geev(jit, 'DNAM\reach')) * 5 + | |
| StrTofloat(geev(jit, 'DNAM\stagger')) * 5 + | |
| StrTofloat(geev(jit, 'DATA\weight')) + | |
| StrTofloat(geev(jit, 'DATA\Damage')) + | |
| StrTofloat(geev(jit, 'CRDT\Damage')) + | |
| StrTofloat(geev(jit, 'data\value')) / 100) / 7) - 2) and not (upgraded > 2) then begin | |
| downgraded := downgraded + 1; | |
| i := i - 2; | |
| continue; | |
| end else begin | |
| result := jit; | |
| i := i - 1; | |
| end; | |
| end else begin | |
| if assigned(elementBypath(aRecord, 'DATA\value')) then begin | |
| if strtofloat(geev(aRecord, 'data\value')) / 100 > strtofloat(geev(jit, 'data\value')) / 100 + 2 and not downgraded > 15 then begin | |
| upgraded := upgraded + 1; | |
| continue; | |
| end else if strtofloat(geev(aRecord, 'data\value')) / 100 < strtofloat(geev(jit, 'data\value')) / 100 - 2 and not upgraded > 2 then begin | |
| downgraded := downgraded + 1; | |
| i := i - 2; | |
| continue; | |
| end else begin | |
| result := jit; | |
| i := i - 1; | |
| end; | |
| end; | |
| end; | |
| end; | |
| end; | |
| function GetTemplate(aRecord: IInterface): IInterface; | |
| begin | |
| for i := templateMegaList.count - 1 downto 0 do begin | |
| Identifiers.commatext := templateMegaList[i] | |
| if SLWithinStr(identifiers, EditorID(aRecord)) then begin | |
| primary := templateMegaList.objects[i]; | |
| if not primary.objects[1] = signature(aRecord) then continue; | |
| for j := primary.count - 1 downto 0 do begin | |
| if not containsText(primary[j], 'keywords') then continue; | |
| keywords.commatext := primary.objects[j]; | |
| if hasakeyword(aRecord, keywords) then begin | |
| result := getATier(aRecord, primary.objects[j-1]); | |
| end; | |
| end; | |
| end; | |
| end; | |
| end; | |
| function getATier(aRecord: IInterface, items: TStringList): IInterface; | |
| begin | |
| for i := items.count - 1 downto 0 do begin | |
| cs := items[i]; | |
| t := pos(':', cs); | |
| f := pos('|', cs); | |
| tier := copy(cs, t+1, cs.length); | |
| ciEDID := copy(cs,f+1,t-1) | |
| templist := items.objects[tier-1]; | |
| templist.addobject(ciEDID, recordbyeditorid(copy(cs,0,f-1), copy(cs, f+1,t-1))); | |
| items2.objects[tier-1] := templist; | |
| end; | |
| for i := items2.count - 1 downto 0 do begin | |
| templist := items2.objects[i]; | |
| j := random(templist.count) - 1; | |
| jit := jit; | |
| if signature(jit, 'armo') then begin | |
| if ((StrTofloat(geev(aRecord, 'data\weight')) + | |
| StrTofloat(geev(aRecord, 'DNAM')) / 5 + | |
| StrTofloat(geev(aRecord, 'data\value')) / 100) / 3 > | |
| ((StrTofloat(geev(jit, 'data\weight')) + | |
| StrTofloat(geev(jit, 'DNAM')) / 5 + | |
| StrTofloat(geev(jit, 'data\value')) / 100) / 3) + 2) and not (downgraded > 15) then begin | |
| upgraded := upgraded + 1; | |
| continue; | |
| end else if ((StrTofloat(geev(aRecord, 'data\weight')) + | |
| StrTofloat(geev(aRecord, 'DNAM')) / 5 + | |
| StrTofloat(geev(aRecord, 'data\value')) / 100) / 3 < | |
| ((StrTofloat(geev(jit, 'data\weight')) + | |
| StrTofloat(geev(jit, 'DNAM')) / 5 + | |
| StrTofloat(geev(jit, 'data\value')) / 100) / 3) - 2) and not (upgraded > 2) then begin | |
| downgraded := downgraded + 1; | |
| i := i - 2; | |
| continue; | |
| end else result := jit; | |
| end else if signature(jit, 'weap') then begin | |
| if ((StrTofloat(geev(aRecord, 'DNAM\speed')) * 5 + | |
| StrTofloat(geev(aRecord, 'DNAM\reach')) * 5 + | |
| StrTofloat(geev(aRecord, 'DNAM\stagger')) * 5 + | |
| StrTofloat(geev(aRecord, 'DATA\weight')) + | |
| StrTofloat(geev(aRecord, 'DATA\Damage')) + | |
| StrTofloat(geev(aRecord, 'CRDT\Damage')) + | |
| StrTofloat(geev(aRecord, 'data\value')) / 100) / 7 > | |
| ((StrTofloat(geev(jit, 'DNAM\speed')) * 5 + | |
| StrTofloat(geev(jit, 'DNAM\reach')) * 5 + | |
| StrTofloat(geev(jit, 'DNAM\stagger')) * 5 + | |
| StrTofloat(geev(jit, 'DATA\weight')) + | |
| StrTofloat(geev(jit, 'DATA\Damage')) + | |
| StrTofloat(geev(jit, 'CRDT\Damage')) + | |
| StrTofloat(geev(jit, 'data\value')) / 100) / 7) + 2) and not (downgraded > 15) then begin | |
| upgraded := upgraded + 1; | |
| continue; | |
| end else if ((StrTofloat(geev(aRecord, 'DNAM\speed')) * 5 + | |
| StrTofloat(geev(aRecord, 'DNAM\reach')) * 5 + | |
| StrTofloat(geev(aRecord, 'DNAM\stagger')) * 5 + | |
| StrTofloat(geev(aRecord, 'DATA\weight')) + | |
| StrTofloat(geev(aRecord, 'DATA\Damage')) + | |
| StrTofloat(geev(aRecord, 'CRDT\Damage')) + | |
| StrTofloat(geev(aRecord, 'data\value')) / 100) / 7 < | |
| ((StrTofloat(geev(jit, 'DNAM\speed')) * 5 + | |
| StrTofloat(geev(jit, 'DNAM\reach')) * 5 + | |
| StrTofloat(geev(jit, 'DNAM\stagger')) * 5 + | |
| StrTofloat(geev(jit, 'DATA\weight')) + | |
| StrTofloat(geev(jit, 'DATA\Damage')) + | |
| StrTofloat(geev(jit, 'CRDT\Damage')) + | |
| StrTofloat(geev(jit, 'data\value')) / 100) / 7) - 2) and not (upgraded > 2) then begin | |
| downgraded := downgraded + 1; | |
| i := i - 2; | |
| continue; | |
| end else begin | |
| result := jit; | |
| i := i - 1; | |
| end; | |
| end else begin | |
| if assigned(elementBypath(aRecord, 'DATA\value')) then begin | |
| if strtofloat(geev(aRecord, 'data\value')) / 100 > strtofloat(geev(jit, 'data\value')) / 100 + 2 and not downgraded > 15 then begin | |
| upgraded := upgraded + 1; | |
| continue; | |
| end else if strtofloat(geev(aRecord, 'data\value')) / 100 < strtofloat(geev(jit, 'data\value')) / 100 - 2 and not upgraded > 2 then begin | |
| downgraded := downgraded + 1; | |
| i := i - 2; | |
| continue; | |
| end else begin | |
| result := jit; | |
| i := i - 1; | |
| end; | |
| end; | |
| end; | |
| end; | |
| end; | |
| function hasakeyword(aRecord: IInterface, keywords: tstringlist): boolean; | |
| begin | |
| // Begin debugMsg section | |
| debugMsg := false; | |
| Result := False; | |
| tempRecord := ebp(aRecord, 'KWDA'); | |
| for i := 0 to Pred(ec(tempRecord)) do begin | |
| for j := 0 to keywords.count - 1 do begin | |
| {Debug} if debugMsg then msg('[HasaKeyword] if ('+EditorID(LinksTo(ebi(tempRecord, i)))+' = '+keywords[j]+' ) then begin'); | |
| if (EditorID(LinksTo(ebi(tempRecord, i))) = keywords[j]) then begin | |
| {Debug} if debugMsg then msg('[HasaKeyword] Result := True'); | |
| Result := True; | |
| exit; | |
| end; | |
| end; | |
| end; | |
| debugMsg := false; | |
| // End debugMsg section | |
| end; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment