10 import dynamic_universe
13 import generate_dyn_universe
22 where=ship.find(
".blank")
25 return ship.capitalize()
31 return ship.capitalize()
41 pathset.extend(pathtor)
44 for iind
in range(len(set)):
47 for jind
in range(len(l)):
49 if not (j
in set
or j
in r):
51 pathtor.append(pathset[iind]+[j])
56 if (preferredfaction==
None):
59 if (preferredfaction==
''):
60 preferredfaction=VS.GetGalaxyFaction(start)
63 if (VS.GetRelation(preferredfaction,VS.GetGalaxyFaction(l[i][-1]))<0):
71 syscreds = int(VS.vsConfig(
"dynamic_universe",
"missions.defaults.jumpprice",
"3000"))
77 filename =
'../universe/companies.txt'
79 f = open (filename,
'r')
84 for i
in range(len(bnl)):
94 filename =
'../universe/cargo_brief.txt'
96 f = open (filename,
'r')
101 for i
in range(len(bnl)):
109 l=category.split(
'/')
111 cargo = l[len(l)-1]+
' '+l[0]
114 cargo = cargo.replace(
'_',
' ')
130 return VS.GetDifficulty()/.5+.9
139 return int(udiff*2)-1
153 global insysMissionNumber
154 if insysMissionNumber:
160 global totalMissionNumber
161 if totalMissionNumber:
182 if path[-1]==VS.getSystemFile():
183 name=
"In_System_"+name
184 global insysMissionNumber
185 insysMissionNumber+=1
187 global totalMissionNumber
188 totalMissionNumber+=1
189 Director.pushSaveString(plr,
"mission_names", name)
193 Director.pushSaveString(plr,
"mission_descriptions", name.replace(
"_",
" "))
196 Director.pushSaveString(plr,
"mission_scripts", name)
202 Director.clearSaveString(plr,
"mission_scripts")
203 Director.clearSaveString(plr,
"mission_names")
204 Director.clearSaveString(plr,
"mission_descriptions")
205 Director.clearSaveString(plr,
"mission_vars")
209 len=Director.getSaveStringLength(plr,
"mission_scripts")
210 if (len!=Director.getSaveStringLength(plr,
"mission_names")
or len!=Director.getSaveStringLength(plr,
"mission_descriptions")):
211 sys.stdout.write(
"Warning: Number of mission descs., names and scripts are unequal.\n")
213 for i
in range(len-1,-1,-1):
214 Director.eraseSaveString(plr,
"mission_scripts", i)
215 Director.eraseSaveString(plr,
"mission_names", i)
216 Director.eraseSaveString(plr,
"mission_descriptions", i)
217 Director.eraseSaveString(plr,
"mission_vars", i)
235 pricescale = float(VS.vsConfig(
"dynamic_universe",
"missions.cleansweep.pricescale",
"16000")),
236 jumpscale = float(VS.vsConfig(
"dynamic_universe",
"missions.cleansweep.jumpscale",
"1.2")),
237 sweepmod = float(VS.vsConfig(
"dynamic_universe",
"missions.cleansweep.pricemod.sweep",
"4")),
238 capshipmod = float(VS.vsConfig(
"dynamic_universe",
"missions.cleansweep.pricemod.capship",
"4")),
239 forceattackmod = float(VS.vsConfig(
"dynamic_universe",
"missions.cleansweep.pricemod.forceattack",
"0.25"))
248 creds = ( pricescale * (
251 capshipprob*capshipmod+
252 forceattack*forceattackmod
253 ) * minships * fighterprob
254 + jumpscale * syscreds * len(path) )
260 addstr+=
"#F#bases/fixers/confed.spr#Talk to the Confed Officer#Thank you. Your help makes space a safer place.#\n"
261 elif isFixer<guildpct:
264 addstr+=
"#G#Bounty#\n"
266 addstr+=
"#G#Patrol#\n"
267 missiontype=
"patrol_enemies"
269 additionalinstructions=
""
270 patrolorclean=
"Patrol"
275 patrolorclean=
"Clean_Sweep"
276 missiontype=
"cleansweep"
277 additionalinstructions+=
" Eliminate all such forces encountered to receive payment."
279 additionalinstructions+=
" Capital ships are possibly in the area."
281 writemissionsavegame (addstr+
"import %s\ntemp=%s.%s(0, %d, %d, %d, %s,'',%d,%d,%f,%f,'%s',%d%s)\ntemp=0\n"%(missiontype,missiontype,missiontype,numplanets, dist, creds,
str(path),minships,maxships,fighterprob,capshipprob,enemy,forceattack,additional))
282 writedescription(
"Authorities would like a detailed scan of the %s system. We require %d nav locations be visited on the scanning route. The pay for this mission is %d. Encounters with %s forces likely.%s"%(
processSystem(path[-1]),numplanets,creds,enemy,additionalinstructions))
287 mistype =
'IN-SYSTEM ATTACK'
294 planetprice = float(VS.vsConfig(
"dynamic_universe",
"missions.patrol.planetprice",
"100")),
295 baseprice = float(VS.vsConfig(
"dynamic_universe",
"missions.patrol.baseprice",
"2400")),
296 jumpscale = float(VS.vsConfig(
"dynamic_universe",
"missions.patrol.jumpscale",
"1"))
299 creds = numplanets*planetprice+baseprice+jumpscale*syscreds*len(path)
305 addstr+=
"#F#bases/fixers/confed.spr#Talk to the Confed Officer#Thank you. Your help makes space a safer place.#\n"
306 elif isFixer<guildpct:
308 addstr+=
"#G#Patrol#\n"
309 writemissionsavegame (addstr+
"import patrol\ntemp=patrol.patrol(0, %d, %d, %d, %s)\ntemp=0\n"%(numplanets, dist, creds,
str(path)))
310 writedescription(
"Insystem authorities would like a detailed scan of the %s system. We require %d nav locations be visited on the scanning route. The pay for this mission is %d."%(
processSystem(path[-1]),numplanets,creds))
315 mistype =
'IN-SYSTEM PATROL'
322 return VS.GetRelation(fac,VS.getPlayer().getFactionName())<0
325 waveprice = float(VS.vsConfig(
"dynamic_universe",
"missions.escort.local.waveprice",
"5500"))
330 if typ
in faction_ships.unescortable:
331 typ = faction_ships.unescortable[typ]
337 creds=waveprice*diff*(1+waves);
346 addstr+=
"#F#bases/fixers/merchant.spr#Talk to the Merchant#Thank you. I entrust that you will safely guide my collegue until he reaches the destination.#\n"
347 elif isFixer<guildpct:
349 addstr+=
"#G#Escort#\n"
350 additionalinfo=
"to the jump point"
352 additionalinfo=
"from the jump point to a nearby base"
354 mistype =
'IN-SYSTEM ESCORT'
357 writemissionsavegame(addstr+
"import escort_local\ntemp=escort_local.escort_local('%s',0,%d,%d,500,%d,%d,'%s',(),'','%s','','%s','%s')"%(enfac,diff,waves,creds,incoming,fac,enfg,fg,typ))
358 writedescription(
"Escort %s is required for the %s type %s starship from the %s flightgroup in this system. Attacks from the %s faction are likely. You will be paid %d credits if the starship survives in this starsystem until it reaches its destination."%(additionalinfo,
formatShip(typ),fac,fg,enfac,int(creds)))
363 baseprice = float(VS.vsConfig(
"dynamic_universe",
"missions.escort.waveprice",
"500")),
364 jumpscale = float(VS.vsConfig(
"dynamic_universe",
"missions.escort.jumpscale",
"0.5"))
370 if typ
in faction_ships.unescortable:
371 typ = faction_ships.unescortable[typ]
373 creds=baseprice*diff+jumpscale*syscreds*len(path)
379 addstr+=
"#F#bases/fixers/merchant.spr#Talk to the Merchant#Thank you. I entrust that you will safely guide my collegue until you reach the destination.#\n"
380 elif isFixer<guildpct:
382 addstr+=
"#G#Escort#\n"
384 mistype =
'IN-SYSTEM ESCORT'
387 writemissionsavegame (addstr+
"import escort_mission\ntemp=escort_mission.initrandom('%s', %d, %g, 0, 0, %s, '','%s','%s')\ntemp=0\n"%(fac, diff, float(creds),
str(path),fg,typ))
393 l=category.split(
'/')
395 return l[-1]+
'_'+l[0]
404 message+=
"\nPrecautions to ensure the success of this mission should be taken at your expense."
407 sysfac = VS.GetGalaxyFaction(system)
408 if sysfac
not in factions:
409 factions.append(sysfac)
410 message+=
"\n\nYou are responsible for the success of this mission. Precautions taken to ensure this outcome will be at your expense. With that in mind, I will advise you that you will be travelling through systems dominated by the "
411 if len(factions) == 1:
412 message+=dnewsman_.data.getFactionData(factions[0],
'full')[0]+
"."
414 message+=
"following factions: "
418 message+=dnewsman_.data.getFactionData(fac,
'full')[0]
419 if jj<len(factions)-1:
421 elif jj<len(factions):
426 return 3+int((max-3)*VS.GetDifficulty())
429 planetlist=VS.GetGalaxyProperty(system,
"planets")
430 if (len(planetlist)==0):
432 planets=planetlist.split(
' ')
433 for planet
in planets:
434 if planet==
"i" or planet==
"a" or planet==
"am" or planet==
"u" or planet=="com" or planet=="bd" or planet=="s" or planet=="o" or planet=="at" or planet=="bs" or planet=="bdm" or planet=="bsm" or planet=="f" or planet=="fm" or planet=="t":
440 baseprice = float(VS.vsConfig(
"dynamic_universe",
"missions.cargo.waveprice",
"500")),
441 jumpscale = float(VS.vsConfig(
"dynamic_universe",
"missions.cargo.jumpscale",
"0.2")),
442 cargoprice = float(VS.vsConfig(
"dynamic_universe",
"missions.cargo.cargoprice",
"250")),
443 contrabandprice = float(VS.vsConfig(
"dynamic_universe",
"missions.cargo.contrabandprice",
"5000")),
444 starshipprice = float(VS.vsConfig(
"dynamic_universe",
"missions.cargo.starshipprice",
"20000"))
455 +jumpscale*syscreds*len(path)
456 +contrabandprice*(category[:10]==
"Contraband")
457 +starshipprice*(category[:9]==
"starships")
464 addstr+=
"#F#bases/fixers/merchant.spr#Talk to the Merchant#Thank you. I entrust you will make the delivery successfully.#\n"
465 elif isFixer<guildpct:
467 addstr+=
"#G#Cargo#\n"
468 writemissionsavegame (addstr+
"import cargo_mission\ntemp=cargo_mission.cargo_mission('%s', 0, %d, %d, %g, %d, 0, '%s', %s, '')\ntemp=0\n"%(fac, numcargos, diff, creds, launchcap, category,
str(path)))
472 if (randCompany==
''):
473 strStart =
"We need to deliver some "
475 strStart = randCompany+
" seeks delivery of "
478 composedBrief = brief.replace(
'$CL',randCompany)
480 composedBrief = composedBrief.replace(
' $DB',
'')
481 composedBrief = composedBrief.replace(
'$DS',
processSystem(path[-1]))
482 composedBrief = composedBrief.replace(
'$PY',
str(int(creds)))
489 mistype =
'IN-SYSTEM CARGO'
495 totmaxprice = int(VS.vsConfig(
"dynamic_universe",
"missions.rescue.totmaxprice",
"21000")),
496 shipminprice = int(VS.vsConfig(
"dynamic_universe",
"missions.rescue.pership.minprice",
"4041")),
497 shipmaxprice = int(VS.vsConfig(
"dynamic_universe",
"missions.rescue.pership.maxprice",
"8640")),
498 jumpminprice = int(VS.vsConfig(
"dynamic_universe",
"missions.rescue.perjump.minprice",
"4041")),
499 jumpmaxprice = int(VS.vsConfig(
"dynamic_universe",
"missions.rescue.perjump.maxprice",
"8640"))
505 creds =
min(totmaxprice, creds)
508 mistype =
'IN-SYSTEM RESCUE'
511 writemissionsavegame(
"import rescue\nntemp=rescue.rescue(%d,0,'%s',%d,'%s','%s',%s)\nntemp=0"%(creds,rescuelist[0],numships,rescuelist[2],rescuelist[1],
str(path)))
512 writedescription(
"SOS! This is an ejected %s pilot under attack by at least %d %s craft. I request immediate assistance to the %s system and will offer %d credits for a safe return to the local planet where I may recover."%(rescuelist[0],numships,rescuelist[2],
processSystem(path[-1]),creds))
513 writemissionname(
"Rescue/Rescue_%s_from_%s_ships"%(rescuelist[0],rescuelist[2]),path,0)
517 baseprice = float(VS.vsConfig(
"dynamic_universe",
"missions.bounty.baseprice",
"20000")),
518 runawayprice = float(VS.vsConfig(
"dynamic_universe",
"missions.bounty.runaway",
"5000")),
519 diffprice = float(VS.vsConfig(
"dynamic_universe",
"missions.bounty.diffprice",
"500")),
520 jumpscale = float(VS.vsConfig(
"dynamic_universe",
"missions.bounty.jumpscale",
"1")),
521 capscale = float(VS.vsConfig(
"dynamic_universe",
"missions.bounty.capscale",
"4"))
530 +runawayprice*runaway
532 +jumpscale*syscreds*len(path)
542 addstr+=
"#F#bases/fixers/hunter.spr#Talk with the Bounty Hunter#We will pay you on mission completion. And as far as anyone knows - we never met."
544 addstr +=
'#Also-- we have information that the target may be informed about your attack and may be ready to run. Be quick!'
546 elif isFixer<guildpct:
548 addstr+=
"#G#Bounty#\n"
549 writemissionsavegame(addstr+
"import bounty\ntemp=bounty.bounty(0, 0, %g, %d, %d, '%s', %s, '', '%s','%s')\ntemp=0\n"%(finalprice, runaway, diff, fac,
str(path), fg,typ))
552 diffstr=
" The ship in question is thought to have %d starships for protection."%diff
554 mistype =
'IN-SYSTEM BOUNTY'
557 writedescription(
"A %s starship in the %s flightgroup has been harassing operations in the %s system. Reward for the termination of said ship is %d credits.%s"%(
formatShip(typ),fg,
processSystem(path[-1]), finalprice,diffstr))
565 baseprice = float(VS.vsConfig(
"dynamic_universe",
"missions.defend.baseprice",
"5000")),
566 jumpscale = float(VS.vsConfig(
"dynamic_universe",
"missions.defend.jumpscale",
"1"))
582 creds=creds*quantity+jumpscale*syscreds*len(path)
587 addstr+=
"#F#bases/fixers/confed.spr#Talk to the Confed Officer#Thank you. Your defense will help confed in the long run. We appreciate the support of the bounty hunting community.#\n"
588 elif isFixer<guildpct:
590 addstr+=
"#G#Defend#\n"
591 writemissionsavegame(addstr+
"import defend\ntemp=defend.defend('%s', %d, %d, 8000.0, 100000.0, %g, %s, %d, '%s', %s, '%s', '%s', '%s', '%s')\ntemp=0\n"%
592 (attackfac, 0, quantity, creds, reallydefend, isbase, defendfac,
str(path),
'',attackfg, attacktyp,defendfg))
597 mistype =
'IN-SYSTEM DEFEND'
600 writedescription(
"A %s assault wing named %s has jumped in and is moving for an attack on one of our %sassets in the %s system.\nYour task is to eradicate them before they eliminate our starship.\nIntelligence shows that they have %d starships of type %s. Your reward is %d credits."%(attackfac, attackfg, iscapitol,
processSystem(path[-1]),quantity,
formatShip(attacktyp),creds))
605 baseprice = float(VS.vsConfig(
"dynamic_universe",
"missions.wingman.baseprice",
"10000")),
606 shipprice = float(VS.vsConfig(
"dynamic_universe",
"missions.wingman.shipprice",
"15000"))
609 creds=baseprice+shipprice*numships
610 writemissionsavegame(
"import wingman\newmission = wingman.wingman (%f, '%s', %d, 0)\newmission=0"%(creds, faction, numships))
615 s=
str(numships)+
" pilots"
618 writedescription(s+
" in the %s faction %s willing to help you out and fight with you as long as you pay %d credits."%(faction, are, creds))
619 writemissionname(
"Wingmen/Hire_%d_%s_Wingm%sn"%(numships,faction,EorA),[VS.getSystemFile()],0)
623 m = fg_util.FGsInSystem (
"merchant",cursys)
625 m+=fg_util.FGsInSystem (thisfaction,cursys)
627 m+=fg_util.FGsInSystem (fac,cursys)
628 return (m,nummerchant,numthisfac)
631 global totalMissionNumber
632 global insysMissionNumber
636 enemies = list(faction_ships.enemies[facnum])
638 cursystem = VS.getSystemFile()
639 thisfaction = VS.GetGalaxyFaction (cursystem)
640 preferredfaction=
None
641 if (VS.GetRelation (fac,thisfaction)>=0):
642 preferredfaction=thisfaction
658 for i
in range(plr.numCargo()):
659 usedcats[plr.GetCargoIndex(i).GetCategory()]=1
660 for i
in range (minsysaway,maxsysaway+1):
662 import dynamic_battle
663 if (i<2
and num_rescue>0):
664 if j[-1]
in dynamic_battle.rescuelist:
673 if (VS.GetRelation(fac,k[1][1])>=0):
674 if ((j[-1]==VS.getSystemFile()
and num_idefend<=0)
or (j[-1]!=VS.getSystemFile()
and num_defend<=0)):
685 debug.debug(
"Generated defendX with insys at: "+
str(num_idefend)+
" and outsys at "+str (num_defend))
689 for kk
in faction_ships.enemies[faction_ships.factiondict[thisfaction]]:
695 insys=(j[-1]==VS.getSystemFile())
696 if (insys
and num_idefend<=0):
698 elif (num_defend<=0
and not insys):
713 debug.debug(
"Generated defendY with insys at: "+
str(num_idefend)+
" and outsys at "+str (num_defend))
716 if ((j[-1]==VS.getSystemFile()
and num_ibounty<=0)
or (j[-1]!=VS.getSystemFile()
and num_bounty<=0)):
739 if ((j[-1]==VS.getSystemFile()
and num_ipatrol<=0)
or (j[-1]!=VS.getSystemFile()
and num_patrol<=0)):
756 if (rnd>.87
and fac!=
'confed' and fac !=
"ISO" and fac!=
"militia" and fac!=
"homeland-security" and fac!=
"kilrathi" and fac!=
"merchant" and fac!=
"klkk"):
757 category=
'Contraband'
759 for myiter
in range (100):
760 carg=VS.getRandCargo(numcargos,category)
761 category=carg.GetCategory()
762 if ((
not category
in usedcats)
and category[:9] !=
'Fragments' and category[:10]!=
'Contraband' and category.find(
'upgrades')!=0
and (category.find(
'starships')!=0
or rnd>.999)):
767 if not category
in usedcats:
771 if (numescort>len(m)):
783 if count>=nummerchant:
785 if count>=numthisfac:
817 plr=plrun.isPlayerStarship()
819 while(i.notDone()
and not i.current().isDocked(plrun)):
822 basefac=i.current().getFactionName()
823 if (basefac==
'neutral'):
824 basefac=VS.GetGalaxyFaction(VS.getSystemFile())