![]() |
SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997 |
|
![]() |
#1 |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]()
There are quite a few small examples in the README. Also, you can define new functions for future use by adding them to the init.py file (see the file for a few examples).
Other than that, yes, copy/paste is the best way. I wanted something simple for the non-programmer and that wasn't too hard for me to code. If there is enough interest, I can add a second interface where you can just run code directly from a file. |
![]() |
![]() |
![]() |
#2 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
I've found a "bug" when generating "zigzag's" that cross 180 longitude, it will generate positions that go around the world vice crossing the dateline correctly
|
![]() |
![]() |
![]() |
#3 | |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
Thanks, |
|
![]() |
![]() |
![]() |
#4 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
having a problem with "cargoExt & cargoInt". When I use/change them get "error" saying that these item are read only. Was using them in contection with editing / creating merchants.
also is there code to "randomly" selecting "crewratings" ? |
![]() |
![]() |
![]() |
#5 |
Navy Seal
![]() Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
|
![]()
^^^ wow, that would be an amazing set of functionality. The ability to pick a number of objects (which it does now) then repopulate some fields with values from a list of possible values randomly.
You can do this after a fashion now by having a few ships of the same type with a % chance of appearing, each with a different crew rating, the only problem being you might very well see ALL of them at once. Sometimes you might want only 1 ship, but of variable skill (or internal/external cargo, etc) |
![]() |
![]() |
![]() |
#6 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
Here some test code that I'm working on, it's for Japanese Convoys ( 41a / 42a /42b /43a / 44a / 44b.
I've play test this and some other code for Merchants / TF / SubHunters, and let be the one to tell you, "patrols" are no longer boring Code:
if group.groupName.find("Convoy") != -1: i = group.units.iterator () for unit in i: if unit.type == UnitType.CARGO: i.remove () i = group.units.iterator () for unit in i: if unit.type == UnitType.TANKER: i.remove () i = group.units.iterator () for unit in i: if unit.type == UnitType.DESTROYER: i.remove () if group.groupName.find("Convoy") != -1: if group.groupName.find("Jap") != -1: if group.gameEntryDate.after(Mission.date("19411101")) and group.gameEntryDate.before(Mission.date("19420831")): #merchant 1 mer=RndUnit.createCargo("Japan", 100) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 2 from random import randint padd= randint(65,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 3 from random import randint padd= randint(45,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 4 from random import randint padd= randint(35,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #tanker 1 from random import randint padd= randint(80,100) tkr=RndUnit.createTanker("Japan", padd) tkr.configurationDate=group.gameEntryDate group.units.add(tkr) if group.groupName.find("Convoy") != -1: if group.groupName.find("Jap") != -1: if group.gameEntryDate.after(Mission.date("19420831")) and group.gameEntryDate.before(Mission.date("19430831")): #merchant 1 mer=RndUnit.createCargo("Japan", 100) mer.number=2 mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 2 from random import randint padd= randint(65,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 3 from random import randint padd= randint(45,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 4 from random import randint padd= randint(35,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #tanker 1 from random import randint padd= randint(80,100) tkr=RndUnit.createTanker("Japan", padd) tkr.configurationDate=group.gameEntryDate group.units.add(tkr) #tanker 2 from random import randint padd= randint(35,65) tkr=RndUnit.createTanker("Japan", padd) tkr.configurationDate=group.gameEntryDate group.units.add(tkr) #escorts from random import randint padd= randint(75,85) escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, padd) escort.configurationDate=group.gameEntryDate group.units.add(escort) if group.groupName.find("Convoy") != -1: if group.groupName.find("Jap") != -1: if group.gameEntryDate.after(Mission.date("19430831")) and group.gameEntryDate.before(Mission.date("19440531")): #merchant 1 mer=RndUnit.createCargo("Japan", 100) mer.number=2 mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 2 from random import randint padd= randint(65,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 3 from random import randint padd= randint(45,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 4 from random import randint padd= randint(35,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #tanker 1 from random import randint padd= randint(80,100) tkr=RndUnit.createTanker("Japan", padd) tkr.configurationDate=group.gameEntryDate group.units.add(tkr) #tanker 2 from random import randint padd= randint(35,65) tkr=RndUnit.createTanker("Japan", padd) tkr.configurationDate=group.gameEntryDate group.units.add(tkr) #escorts escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, 100) escort.configurationDate=group.gameEntryDate escort.crewRating = CrewRating.VETERAN group.units.add(escort) from random import randint padd= randint(75,85) escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, padd) escort.number=1 escort.configurationDate=group.gameEntryDate escort.crewRating = CrewRating.VETERAN group.units.add(escort) from random import randint padd= randint(45,85) escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, padd) escort.configurationDate=group.gameEntryDate escort.crewRating = CrewRating.ELITE group.units.add(escort) if group.groupName.find("Convoy") != -1: if group.groupName.find("Jap") != -1: if group.gameEntryDate.after(Mission.date("19440530")) and group.gameEntryDate.before(Mission.date("19450831")): #merchant 1 mer=RndUnit.createCargo("Japan", 100) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 2 from random import randint padd= randint(65,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 3 from random import randint padd= randint(45,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #merchant 4 from random import randint padd= randint(35,85) mer=RndUnit.createCargo("Japan", padd) mer.configurationDate=group.gameEntryDate group.units.add(mer) #tanker 1 from random import randint padd= randint(80,100) tkr=RndUnit.createTanker("Japan", padd) tkr.configurationDate=group.gameEntryDate group.units.add(tkr) #tanker 2 from random import randint padd= randint(35,65) tkr=RndUnit.createTanker("Japan", padd) tkr.configurationDate=group.gameEntryDate group.units.add(tkr) #escorts escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, 100) escort.configurationDate=group.gameEntryDate escort.crewRating = CrewRating.VETERAN group.units.add(escort) from random import randint padd= randint(75,85) escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, padd) escort.crewRating = CrewRating.VETERAN escort.configurationDate=group.gameEntryDate group.units.add(escort) if group.columns > 1: group.columns = 2 if group.spacing > 1: from random import randint group.spacing = randint(500,995) if group.groupName.find("Convoy") != -1: if group.groupName.find("Jap") != -1: if group.gameEntryDate.before(Mission.date("19421231")): from random import randint group.spawnProbability = randint(25,45) elif group.gameEntryDate.before(Mission.date("19431231")): from random import randint group.spawnProbability = randint(35,85) elif group.gameEntryDate.before(Mission.date("19441231")): from random import randint group.spawnProbability = randint(45,90) else: from random import randint group.spawnProbability = randint(35,50) if group.repeatIntervalMinutes > 1: from random import randint group.repeatIntervalMinutes = randint(3000,10000) if group.autoReportProbability > 1: from random import randint group.autoReportProbability = randint(5,25) if group.autoReportInterval > 1: from random import randint group.autoReportInterval = randint(1440,9999) if group.columns > 1: group.columns = 2 if group.spacing > 1: from random import randint group.spacing = randint(500,995) i = group.waypoints.iterator () for waypoint in i: if waypoint.loopProbability > 0: from random import randint waypoint.loopProbability = randint(2,8) i = group.waypoints.iterator () for waypoint in i: if waypoint.radius > 0: waypoint.radius = 0 i = group.waypoints.iterator () for waypoint in i: if waypoint.length > 500*1852: zigZagToWaypoint(waypoint,i,0,100) i = group.waypoints.iterator () for waypoint in i: if waypoint.length > 99*1852: from random import randint angle= randint(15,35) distance= randint(12,50) zigZagToWaypoint(waypoint,i,angle,distance) from random import randint for waypoint in group.waypoints: waypoint.speed = randint(7,12) Last edited by lurker_hlb3; 05-18-07 at 04:22 PM. |
![]() |
![]() |
![]() |
#7 |
Navy Seal
![]() Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
|
![]()
Damn.
I wish I knew half of what that was doing, looks pretty interesting, though. |
![]() |
![]() |
![]() |
#8 | |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
![]() Seeing the kind of things people are doing, next version will definitely have a "run script from file" option. Let's see if I have time to put it together tomorrow. |
|
![]() |
![]() |
![]() |
#9 | ||
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
Quote:
Code:
unit.crewRating=choice((CrewRating.POOR, CrewRating.NOVICE, CrewRating.COMPETENT)) |
||
![]() |
![]() |
![]() |
#10 | |||
Navy Seal
![]() Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
|
![]() Quote:
For example: Code:
unit.crewRating=choice((CrewRating.COMPETENT, CrewRating.COMPETENT, CrewRating.COMPETENT, CrewRating.COMPETENT, CrewRating.COMPETENT, CrewRating.COMPETENT, CrewRating.VETERAN, CrewRating.VETERAN, CrewRating.VETERAN, CrewRating.ELITE)) tater |
|||
![]() |
![]() |
![]() |
|
|