Hi,
this is just a thread I'll use to give out code I've created to be
implemented into various mods.
Uncapped Scripts
Description: Removes the 350 line cap on scripts, thus removing a
large engine limitation, and making the engine run slightly faster in
some circumstances. This version is more optimized than the version I
have included in the community mod, but this will be put into the
community mod soon enough
Replace this code:
_ai_loaddata:
rem Ensure AI Script still exists
if file exist(aidir$+ai$)=1
`
rem About to add conditions
conindexfirst=conindexcount
`
rem Load AI Script Data from file
dim data$(350)
load array aidir$+ai$,data$()
addfiletocollection(aidir$+ai$)
founddescfield=0
for l=0 to 349
line$=data$(l)
`
rem V109 BETA8 - desc issue correction (ensure desc not empty)
if lower$(left$(line$,4))="desc" and len(line$)<8 then line$="desc = FPI Script"
`
if len(line$)>0
if left$(line$,1)<>";"
`
rem Field or Triggerline
if left$(line$,1)<>":"
`
rem Standard Field Line
rem take fieldname and value
for c=0 to len(line$)
if mid$(line$,c)="=" then mid=c : exit
next c
field$=lower$(removeedgespaces(left$(line$,mid-1)))
value$=removeedgespaces(right$(line$,len(line$)-mid))
`
rem take value 1 and 2 from value
for c=0 to len(value$)
if mid$(value$,c)="," then mid=c : exit
next c
value1=val(removeedgespaces(left$(value$,mid-1)))
value2$=removeedgespaces(right$(value$,len(value$)-mid))
if len(value2$)>0 then value2=val(value2$) else value2=-1
`
rem AI header
if field$="desc" then ailist(aiindex).desc$=value$ : founddescfield=1
`
else
`
rem AI Triggerline (slice line marked by leading colon:)
cutline$=right$(line$,len(line$)-1)
`
rem find : seperator
sep=0
for c=1 to len(cutline$)
if mid$(cutline$,c)=":" then sep=c : exit
next c
if sep>0
`
rem conditions collected
conditions$=left$(cutline$,sep-1)
cutline$=right$(cutline$,len(cutline$)-(len(conditions$)+1))
rem now rest is actions
if len(cutline$)>0
rem actions collected
actions$=cutline$
endif
`
rem Parse through conditions
aicondfirst=aicondseqcount
stringblock$=conditions$
while len(stringblock$)>0
gosub _ai_dividetriggerblock
for tindex=0 to AICONDLAST
if word$=conword$(tindex)
if aicondseqcount+10>array count(aiconditionseq()) then dim aiconditionseq(aicondseqcount+1000) as aiconditiontype
aiconditionseq(aicondseqcount).type=tindex
aiconditionseq(aicondseqcount).valuea=value1
aiconditionseq(aicondseqcount).valueb=value2
aiconditionseq(aicondseqcount).valuec=value3
rem Variable System - Setting the string variables passed from the parser to our conditionseq
aiconditionseq(aicondseqcount).string1=value1$
aiconditionseq(aicondseqcount).string2=value2$
inc aicondseqcount
exit
endif
next tindex
endwhile
if conindexcount+10>array count(aicond()) then dim aicond(conindexcount+100) as aiconditionitemtype
aicond(conindexcount).first=aicondfirst
aicond(conindexcount).last=aicondseqcount-1
aicond(conindexcount).action=actindexcount
inc conindexcount
`
rem Parse through actions
aiactfirst=aiactseqcount
stringblock$=actions$
while len(stringblock$)>0
gosub _ai_dividetriggerblock
for tindex=0 to AIACTLAST
if word$=actword$(tindex)
if aiactseqcount+10>array count(aiactionseq()) then dim aiactionseq(aiactseqcount+1000) as aiactiontype
aiactionseq(aiactseqcount).type=tindex
aiactionseq(aiactseqcount).value=value1
aiactionseq(aiactseqcount).filename=value$
rem - Setting the second variable passed from the parser to our actionseq
aiactionseq(aiactseqcount).valueb=value2
rem - Setting the string variables passed from the parser to our actionseq
aiactionseq(aiactseqcount).string1=value1$
aiactionseq(aiactseqcount).string2=value2$
inc aiactseqcount
exit
endif
next tindex
endwhile
if actindexcount+10>array count(aiaction()) then dim aiaction(actindexcount+100) as aiactionitemtype
aiaction(actindexcount).first=aiactfirst
aiaction(actindexcount).last=aiactseqcount-1
inc actindexcount
`
endif
`
endif
endif
endif
next l
undim data$()
`
Rem Fix desc issue (user did not even use desc)
if founddescfield=0 then ailist(aiindex).desc$="desc = FPI Script"
`
rem Finalise condition data values
conindexlast=conindexcount-1
ailist(aiindex).conditionfirst=conindexfirst
ailist(aiindex).conditionlast=conindexlast
`
rem File not exist endif
endif
return
With this code:
_ai_loaddata:
`
rem Ensure AI Script still exists
if file exist(aidir$+ai$)=1
`
rem About to add conditions
conindexfirst=conindexcount
`
rem Ensure included with built game
addfiletocollection(aidir$+ai$)
`
rem Read script
founddescfield=0
open to read 1,aidir$+ai$
while file end(1)=0
read string 1,line$
if lower$(left$(line$,4))="desc" and len(line$)<8 then line$="desc = FPI Script"
if len(line$)>0
if left$(line$,1)<>";"
if left$(line$,1)<>":"
for c=0 to len(line$)
if mid$(line$,c)="=" then mid=c : exit
next c
field$=lower$(removeedgespaces(left$(line$,mid-1)))
value$=removeedgespaces(right$(line$,len(line$)-mid))
for c=0 to len(value$)
if mid$(value$,c)="," then mid=c : exit
next c
value1=val(removeedgespaces(left$(value$,mid-1)))
value2$=removeedgespaces(right$(value$,len(value$)-mid))
if len(value2$)>0 then value2=val(value2$) else value2=-1
if field$="desc" then ailist(aiindex).desc$=value$ : founddescfield=1
else
cutline$=right$(line$,len(line$)-1)
sep=0
for c=1 to len(cutline$)
if mid$(cutline$,c)=":" then sep=c : exit
next c
if sep>0
conditions$=left$(cutline$,sep-1)
cutline$=right$(cutline$,len(cutline$)-(len(conditions$)+1))
if len(cutline$)>0
actions$=cutline$
endif
aicondfirst=aicondseqcount
stringblock$=conditions$
while len(stringblock$)>0
gosub _ai_dividetriggerblock
for tindex=0 to AICONDLAST
if word$=conword$(tindex)
if aicondseqcount+10>array count(aiconditionseq()) then dim aiconditionseq(aicondseqcount+1000) as aiconditiontype
aiconditionseq(aicondseqcount).type=tindex
aiconditionseq(aicondseqcount).valuea=value1
aiconditionseq(aicondseqcount).valueb=value2
aiconditionseq(aicondseqcount).valuec=value3
aiconditionseq(aicondseqcount).string1=value1$
aiconditionseq(aicondseqcount).string2=value2$
inc aicondseqcount
exit
endif
next tindex
endwhile
if conindexcount+10>array count(aicond()) then dim aicond(conindexcount+100) as aiconditionitemtype
aicond(conindexcount).first=aicondfirst
aicond(conindexcount).last=aicondseqcount-1
aicond(conindexcount).action=actindexcount
inc conindexcount
aiactfirst=aiactseqcount
stringblock$=actions$
while len(stringblock$)>0
gosub _ai_dividetriggerblock
for tindex=0 to AIACTLAST
if word$=actword$(tindex)
if aiactseqcount+10>array count(aiactionseq()) then dim aiactionseq(aiactseqcount+1000) as aiactiontype
aiactionseq(aiactseqcount).type=tindex
aiactionseq(aiactseqcount).value=value1
aiactionseq(aiactseqcount).valueb=value2
//aiactionseq(aiactseqcount).valuec=value3 // this didn't exist before, it's something I've added
aiactionseq(aiactseqcount).filename=value$
aiactionseq(aiactseqcount).string1=value1$
aiactionseq(aiactseqcount).string2=value2$
inc aiactseqcount
exit
endif
next tindex
endwhile
if actindexcount+10>array count(aiaction()) then dim aiaction(actindexcount+100) as aiactionitemtype
aiaction(actindexcount).first=aiactfirst
aiaction(actindexcount).last=aiactseqcount-1
inc actindexcount
endif
endif
endif
endif
endwhile
close file 1
`
rem Fix desc issue (user did not even use desc)
if founddescfield=0 then ailist(aiindex).desc$="desc = FPI Script"
`
rem Finalise condition data values
conindexlast=conindexcount-1
ailist(aiindex).conditionfirst=conindexfirst
ailist(aiindex).conditionlast=conindexlast
`
rem File not exist endif
endif
`
return
More coming soon when I get it all ready.
-TZK