Trying to bodge together a map consisting of three planetoids, each surrounded by a dozen or so moonlets. The idea is that each moon system should work more-or-less like a small map with one or more close enough to send to the much larger asteroid they surround. Each of the larger asteroids would have a send distance that could reach the outer moons of the other two systems but not the main asteroid itself.
The basic idea is to have at least one empire starting in the moons of each system and (if I can make it work adequately) a steadily increasing number of greys on the central 'roid. All the asteroids' stats would be influenced by scale (including the tree cap) so hopefully I can balance it to have an initial empire-building phase followed by a late-game three-way war. I'm not sure, the main 'roids might need to be dramatically weakened, in relative terms. And it all depends on getting the map laid out adequately in the first place.. the map I plotted on graph paper was too small to take remotely accurate measurements :-\
GetAsteroid(37):MoveTo(7530,-1900)
to place the asteroid at those coordinates, or...GetAsteroid(37):MoveBy(50,0)
to nudge it east a little.dude, this idea is similar to what i wanted to do. i cant wait to see it. as you say, if you can get the balancing right, it should be most excellent. i wish you luck.
looking forward to its eventual release...
Widget, I know a nifty trick for positioning asteroids that you might like:
Wow. That looks pretty impressive dude..
I can't imagine A&R would be anything other than delighted to hear about this.. :>
How are you doing the communication between clients and server? The screenshot you posted doesnt look like lua.. :>
What language is it.. looks like C..?
Are you actually reverse engineering the game in order to do this ?
C# is what Eufloria is built in, so that may be why Inu's using it. However, A&R are rewriting it in C++. Sorry to be the bearer of bad news if that's a problem.
http://www.dyson-game.com/smf/index.php?topic=1217.msg7607#msg7607
If you want testers, I'd love to help sometime. I know no C or any of its variants, but I'm fairly good with EufLuaria (u c wut i did thar?) and playing the game.
Sounds cool. :> Are you making your own AI? I'm kind of hoping eventually we can have lots of different AI's. We could make them fight each other, and have competitions to see who can make the best one. :>I could, if I only know how to make the AI select the correct roid, have been experimenting allready with no success... Hoping I eventually will make one though :D
It would only take a small amount of work for me to modify the engine to turn off Infected AI on asteroids that don't belong to a particular faction. I keep meaning to try IAI versus the default AI, but the thing is the default AI has tons of different settings, so the performance could well vary...
if GetAsteroid(asteroids).Attribs.Strenght > GetAsteroid(asteroids).Attribs.Energy and GetAsteroid(asteroids).Attribs.Strenght > GetAsteroid(asteroids).Attribs.Energy then
PlantDefenseTree(caiid)
else
PlantDysonTree(caiid)
end
gives error: attempt to compare number with stringso... lol? What does this mean D:
PlantDefenseTree(caiid)
GetAsteroid(0):PlantDefenseTree(2)
attempt to compare number with nil
if cairoidpriority[asteroids] < cairoidpriority[i] then
I am working on chilling out, at the end of another large coding project. :>
(For thorough fun be sure to go through the comments, too.)
You could always continue your own one, and make a version you like better.. :>
After all that I'll take a break and calm down for some days, maybe...
Microsoft has become EXTREMELY unfriendly to indies in various ways, and on top of that they demand all kinds of features to be bolted on to games even if it makes no sense for the game in question.
Thanks for the offers guys, more detail soon. :-)
We did not go the 360 route because Microsoft has become EXTREMELY unfriendly to indies in various ways, and on top of that they demand all kinds of features to be bolted on to games even if it makes no sense for the game in question. As a result developing an xbla version is too expensive and too risky.
If the AI have lost all of their asteroids and have one left(which has the attribs of: 0.5 energy, 0.6 speed and 0.5 strength and with 25 seedlings), then it will look at the neighbours:
The firsth neighbours has as following:now the AI look at the asteroid with most of all the stats, which is their only asteroid and calculate how many points the attribs will give. Now, since the neighbour have 20 enemy seedlings the AI must find the amount of difference the two asteroids have. it will get an ending score at: 1.25
- Energy=0.7
- Speed=0.4
- Strength=0.5
The second neighbour has:
- Energy=0.6
- Speed=0.3
- Strength=0.7
- Seedlings=17
- Score: 1.47
The roid with highest score is reccomended to capture and the AI will do so...(hope you understood, if not... read is closely! :))
SeedAmount - ((Seedamount/10)/Deftreesamount)
Maybe you can work out on that one??
0|1|0|0|0|100|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0.47816401720047
1|1|0|0|0|100|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0.93597215414047
2|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.68686866760254
3|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.29292929172516
4|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.56565654277802
5|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.10000000149012
6|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.88888889551163
7|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.69696968793869
8|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.58585858345032
9|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.17171716690063
10|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.27272728085518
11|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.1414141356945
12|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.75757575035095
13|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.33333334326744
14|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.63636362552643
15|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.31313130259514
16|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.3737373650074
17|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.5151515007019
18|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.13131313025951
19|0|28|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.98989897966385
20|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.59595960378647
21|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.70707070827484
22|0|12|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.78787881135941
23|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.47474747896194
24|0|32|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.38383838534355
25|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.2323232293129
26|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.7474747300148
27|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.66666668653488
28|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.96969699859619
29|0|17|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.72727274894714
30|3|0|0|0|0|0|0|0|0|0|20|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0|1|0|0.71717172861099
31|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.89898991584778
32|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.82828283309937
33|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.30303031206131
34|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.92929291725159
35|2|0|0|0|0|0|0|20|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0|1|0|0.47474747896194
36|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.53535354137421
37|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.92929291725159
38|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.77777779102325
39|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.88888889551163
40|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.41414141654968
41|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.27272728085518
io.output(io.open(x .. filename, "w" or "r"))
io.output(io.open("D:\\" .. "cool.txt","w"))
local txt = "this is\na cool\nlittle snippet\nfrom fluffyland :D"
io.write(txt)
io.close()
-0.092614301817784|-0.033666943740996|-0.0015675112872755|-0.00075895622089649|-5.9181165563956e-005|-3.1153533672533e-005|2|1|0.066000000759959|
-66.094856570761|-75.882323731876|-0.00177005091845|0.16381054493077|1.4562314010574e-006|4.4885269368803e-006|1.78|1|2.9939999721944|
-8.8475224795368|-33.804391354459|0.052681760821877|-0.11522255108318|-5.5499821000586e-006|6.8260957899153e-006|1.78|1|0.082000001519918|
1.2463784729883|-75.609026779198|-0.1068262994227|0.17010144972033|-3.1968609870431e-005|1.2109259534869e-005|1.9|1|1.1530000280589|
78.63797036449|61.043499755844|0.073127903462542|0.096889234466921|-4.7110628571054e-005|-1.4736114576687e-005|2.696|1|0.082000001519918|
44.572884178928|38.247044831401|-0.012679897826631|-0.057330794392724|2.8881123357708e-005|4.3639962415557e-005|2.38|1|0.082000001519918|
75.510599849763|18.148281175179|-0.17788871277994|-0.038741802098897|-1.1491766623343e-005|-1.6684903965938e-006|2.06|1|1.2270000252873|
-38.960195775396|46.756176206926|0.063812756214887|0.046060204282989|4.3289812220749e-006|-1.6458391564846e-006|2.26|1|0.64200002811849|
-70.420393459409|22.462400274137|0.042525749917015|0.029119425410296|9.542609146265e-006|1.6230602240458e-005|1.68|1|0.082000001519918|
41.877475129766|73.215157645292|-0.10969354054408|-0.021865929438175|5.440299617117e-006|-1.9690348369526e-005|1.78|1|2.4279999911785|
-26.382650672476|-18.902856193521|-0.059196532615506|0.034467627616724|-1.0582318627099e-005|6.4660490131011e-006|1.62|1|0.70600003115833|
-7.6424160798402|-70.076715151126|-0.14678916246521|-0.057691173411257|3.0707421259163e-006|-1.4947936731156e-006|2.38|1|0.082000001519918|
-61.601044106737|-47.34435976063|0.093019275648765|0.08761447994304|1.5365784766541e-005|1.0249473132916e-005|1.62|1|0.082000001519918|
-80.228755173361|-12.650584112261|0.12835868450721|-0.012514200113014|8.2757081452846e-006|8.6320685601118e-006|1.94|1|0.082000001519918|
23.159969481427|-25.123704104524|-0.16848503553262|0.17494417131664|-1.5021985174732e-006|2.494118343071e-006|2.04|1|0.082000001519918|
79.843032974438|-73.673931942878|0.043409252227917|0.09136489705583|-2.1375542833282e-005|1.0075813621975e-006|2.368|1|0.082000001519918|
-70.684649058975|85.491293231745|-0.13600688459234|0.019052801672317|1.2379577256417e-006|-1.5535329458456e-005|2.24|1|0.082000001519918|
53.588665122706|60.050889050055|0.081933306825834|0.0074376975924834|8.4971062148463e-006|-2.5851442474453e-005|1.6|1|0.082000001519918|
67.582442332479|58.697797157606|-0.046484407922066|-0.016858217191975|-1.2108813632391e-005|-8.502482741794e-006|1.84|1|0.082000001519918|
75.275532269272|-42.123819399824|0.10808454014474|-0.16295351371022|-5.5314294323094e-006|9.8813238791691e-007|2.26|1|0.098000002279878|
-96.453020504494|44.485907906133|-0.042425425878625|0.065861386941521|2.2183326824816e-005|1.4273988943423e-006|1.62|1|0.082000001519918|
-26.906850422729|94.719638278651|-0.086867385657762|-0.017646664958139|-9.1506295324531e-007|-1.0734140841291e-005|2.12|1|0.082000001519918|
64.860245704169|-8.1741652004927|-0.074278597861817|0.043603447692891|-4.1663763204391e-006|5.5069780950268e-007|2.16|1|1.0190000321716|
-8.7805442755023|50.211785486021|0.097493153522531|-0.079866551753526|-4.8018783722441e-005|1.70497655573e-006|1.94|1|0.082000001519918|
-63.223627641602|-25.109169111808|-0.085877903227692|0.13158148683517|8.6717376391042e-006|4.837504082831e-006|1.76|1|0.082000001519918|
50.193716954471|45.845506895218|-0.16972414068949|-0.1477188024367|-3.9401435148776e-006|-1.2101907788115e-006|2.276|1|0.082000001519918|
-6.662916290175|-3.4277490436549|0.14240252833499|0.040412692369575|-5.7842000014941e-006|4.5867795490037e-007|1.74|1|0.082000001519918|
-44.994155990195|-51.897742859361|0.15158169884285|-0.098626468677847|1.6680508214901e-007|2.4303995497445e-006|2.04|1|1.6080000132322|
-90.398741080588|2.4305804203678|-0.12137699095759|0.16749951744541|5.15622300711e-006|3.8034619138075e-006|1.82|1|0.082000001519918|
64.049379844498|-78.936975784796|0.1233569834513|0.093828841219425|-3.3946919454669e-006|1.5558957566087e-008|2.54|1|0.082000001519918|
-66.090660949748|69.728694981785|0.053473086381555|0.15982369558952|-2.6680649098244e-006|-9.0596295973309e-006|1.9|1|0.082000001519918|
-12.533250373412|64.428106952572|0.011479058410825|-0.18886537050484|-6.5940394295006e-006|-1.3352607016622e-005|1.9|1|0.70600003115833|
-85.211584862106|99.67482003335|-0.098557998943147|0.09461288342725|1.1198509368721e-006|-3.4241843300381e-006|2|1|0.082000001519918|
-77.566312208915|-89.734268845128|-0.12190846067966|0.028854750168995|1.4981372417308e-006|1.1246646006092e-006|2.22|1|0.082000001519918|
11.929676879481|-94.213564788347|-0.2145489973698|0.058263283048193|-4.4650559728191e-005|5.0112679703102e-006|2.4|1|2.861999976635|
-63.400833246456|34.781011866306|-0.052928554116572|-0.17586651808218|-5.6044342593024e-006|6.4603720818261e-006|1.9|1|0.082000001519918|
2.9693886078101|-93.454970297293|0.15249466131222|-0.10487910206626|-3.5210527877053e-007|7.5803432812334e-007|1.86|1|0.082000001519918|
-78.160989442637|48.782550860722|-0.013745778640769|-0.13426474610804|1.511732529903e-006|-7.8928959572435e-007|2.32|1|0.082000001519918|
-18.207839304874|47.740003065472|-0.18814659906143|0.14538825926628|-4.0479713097143e-007|-9.4493092799253e-007|1.94|1|0.082000001519918|
-43.59539314518|-11.381886899287|0.020916640384232|0.18991773647627|0|0|2.14|1|0.082000001519918|
if not io.open(BasicSaveFolder .. "acces.acces") then
os.execute("mkdir " .. BasicSaveFolder)
io.output(io.open(BasicSaveFolder .. "acces.acces", "w"))
io.write("Don't delete this file unless you want to remove the Eufloria Saves. Thank you!")
io.close()
end
io.output(io.open(BasicSaveFolder .. savename .. ".TCS", "w"))
local txt = "truesave\n"
for i = 1,NumDrawings do
txt = txt .. Px[i] .. "\n"
txt = txt .. Py[i] .. "\n"
txt = txt .. Vx[i] .. "\n"
txt = txt .. Vy[i] .. "\n"
txt = txt .. Ax[i] .. "\n"
txt = txt .. Ay[i] .. "\n"
txt = txt .. Mass[i] .. "\n"
if Drawn[i] == true then
txt = txt .. "1" .. "\n"
else
txt = txt .. "0" .. "\n"
end
if IsAlive[i] == true then
txt = txt .. "1" .. "\n"
else
txt = txt .. "0" .. "\n"
end
if i < NumDrawings then
txt = txt .. SpawnP[i] .. "\n"
else
txt = txt .. SpawnP[i]
end
end
io.write(txt)
io.close()
Ok, gonna make an even more feature rich save system, quicksave and quickload/loadlast :D
SaveStats(string filename) e.g. SaveStats("myfile.bin") - saves out the current game stats to the given file
LoadStats(string filename) e.g. LoadStats("myfile.bin") - loads myfile.bin into the current stats register
-- Initialise the level, globals, etc
-- Initialise variables, arrays and matrices
-- Initialise object(s)
-- Perform any transforms as required
-- Calculate new 2dX and 2dY positions of all vertices
-- Calculate Vertex Visibility
-- Edge-to-Face check - are any edges intersecting faces?
-- Edge-to-Edge check - are any edges intersecting other edges?
-- Edge-to-Roid check - are any edges intersecting asteroids?
-- Calculate Pseudo-Vertex Visibility
-- Draw Vertices
-- Draw Edges
Variables
numberofvertices -- Total number of vertices. Object templates should increment this number with each added vertex.
numberofasteroids -- Total number of asteroids in the level (calculated)
spriteindex -- The ID of the sprite used for drawing vertices (specified)
zscalefactor -- How "zoomed" is the camera. The larger the value, the more zoomed in. (specified)
Arrays
vertex2dX -- 2D coordinates of the vertex (calculated)
vertex2dY
vertex3dX -- 3D coordinates of the vertex (specified)
vertex3dY
vertex3dZ
vertex3dXtransformed -- Resultant coordinates from any applied transforms (calculated and drawn)
vertex3dYtransformed
vertex3dZtransformed
SetVertexSize -- How big should the vertices look? (specified)
vertexsize -- The actual rendered size of vertices once distance from the camera is considered (calculated)
red -- Vertex colour (specified)
green
blue
threshold -- How zoomed out before each individual vertex starts to lose alpha? (specified)
Matrices
edge -- Columns contain Edge ID's, rows contain participating vertices
face -- Columns contain Face ID's, rows contain participating edges
function CreateMainQuest()
if MissionsDone == 0 then
MissionID = "beginner"
MissionObjective = "Gather 100 seedlings without dying"
MapType = "classic"
elseif MissionsDone == 1 then
MissionID = "proving"
MissionObjective = "Kill all three enemies without dying"
MapType = "triangle"
elseif MissionsDone == 2 then
MissionID = "testing"
MissionObjective = "Defend from waves without loosing any asteroids for 5 mins"
MapType = "fortress"
else
MissionID = "random"
MissionObjective = "not determined"
MapType = "random"
end
end
Try generating fractal patern of roids.You mean using a tree fractal like this (http://www.dyson-game.com/smf/index.php?topic=915.0)?
function Load()
if io.open(BasicSaveFolder .. "Adventure.EURI", "r") then
local file = assert(io.open(BasicSaveFolder .. "Adventure.EURI", "r"))
local curline = 1
GameSaveInfo = {}
for line in file:lines() do
GameSaveInfo[curline] = line
curline = curline + 1
end
end
end
for line in file:lines() do
function GetGameSaveInfo(wline)
if io.open(BasicSaveFolder .. "Adventure.EURI", "r") then
local file = assert(io.open(BasicSaveFolder .. "Adventure.EURI", "r"))
local curline = 1
for line in file:lines() do
if curline == wline then
local reqline = line
break
else
curline = curline + 1
end
end
local linetoreturn = reqline
elseif wline == 1 then
local linetoreturn = 0
end
return linetoreturn
end
function GetGameSaveInfo(wline)
local linetoreturn
if io.open(BasicSaveFolder .. "Adventure.EURI", "r") then
local file = assert(io.open(BasicSaveFolder .. "Adventure.EURI", "r"))
local curline = 1
local reqline
for line in file:lines() do
if curline == wline then
reqline = line
break
else
curline = curline + 1
end
end
linetoreturn = reqline
elseif wline == 1 then
linetoreturn = 0
end
return linetoreturn
end
function LevelSetup()
Globals.G.Asteroids=0
Globals.G.EnemyFactionsMin=0
Globals.G.EnemyFactionsMax=0
SetBackdropColour(0,0,0)
Globals.G.GreysProbability = 0
Globals.G.GreysMin=0
Globals.G.GreysMax=0
CreateFolders()
SFXInit()
BasicSaveFolder = "C:\\EufloriaSaves\\"
MissionsDone = 2
CreateMainQuest()
CreateMap()
if AIType == "infected" then
AIinit()
elseif AIType == "alien" then
AAIInit()
end
end
function SFXInit()
NumSFXs = -1
SFXPx = {}
SFXPy = {}
SFXColorAndSize = {}
SFXCurrentChange = {}
SFXChanging = {}
SFXIsActive = {}
end
function CreateSFX(x,y,r,g,b,a,size,rd,gd,bd,ad,sized,rcs,gcs,bcs,acs,scs)
NumSFXs = NumSFXs + 1
--For the matrix: 1 = the base color, 2 = the amount of change possible, 3 = the current amount of change and 4: the speed of change
SFXColorAndSize[NumSFXs] = {}
SFXColorAndSize[NumSFXs][1] = {}
SFXColorAndSize[NumSFXs][2] = {}
SFXColorAndSize[NumSFXs][3] = {}
SFXColorAndSize[NumSFXs][4] = {}
SFXCurrentChange[NumSFXs] = {}
SFXPx[NumSFXs] = x
SFXPy[NumSFXs] = y
SFXColorAndSize[NumSFXs][1][1] = r
SFXColorAndSize[NumSFXs][1][2] = g
SFXColorAndSize[NumSFXs][1][3] = b
SFXColorAndSize[NumSFXs][1][4] = a
SFXColorAndSize[NumSFXs][1][5] = size
SFXColorAndSize[NumSFXs][2][1] = rd
SFXColorAndSize[NumSFXs][2][2] = gd
SFXColorAndSize[NumSFXs][2][3] = bd
SFXColorAndSize[NumSFXs][2][4] = ad
SFXColorAndSize[NumSFXs][2][5] = sized
SFXColorAndSize[NumSFXs][3][1] = r
SFXColorAndSize[NumSFXs][3][2] = g
SFXColorAndSize[NumSFXs][3][3] = b
SFXColorAndSize[NumSFXs][3][4] = a
SFXColorAndSize[NumSFXs][3][5] = size
SFXColorAndSize[NumSFXs][4][1] = rcs
SFXColorAndSize[NumSFXs][4][2] = gcs
SFXColorAndSize[NumSFXs][4][3] = bcs
SFXColorAndSize[NumSFXs][4][4] = acs
SFXColorAndSize[NumSFXs][4][5] = scs
SFXCurrentChange[NumSFXs][1] = 1
SFXCurrentChange[NumSFXs][2] = 1
SFXCurrentChange[NumSFXs][3] = 1
SFXCurrentChange[NumSFXs][4] = 1
SFXCurrentChange[NumSFXs][5] = 1
SFXIsActive[NumSFXs] = true
if SFXColorAndSize[NumSFXs][2][1] ~= nil then
if SFXColorAndSize[NumSFXs][2][2] ~= nil then
if SFXColorAndSize[NumSFXs][2][3] ~= nil then
if SFXColorAndSize[NumSFXs][2][4] ~= nil then
if SFXColorAndSize[NumSFXs][2][5] ~= nil then
SFXChanging[NumSFXs] = true
end
end
end
end
end
end
function ChangeActiveState(id,bool)
SFXIsActive[id] = bool
end
function LevelDraw()
if NumSFXs >= 0 then
for i = 0,NumSFXs do
if SFXIsActive[i] == true then
local r = SFXColorAndSize[i][1][1]
local g = SFXColorAndSize[i][1][2]
local b = SFXColorAndSize[i][1][3]
local a = SFXColorAndSize[i][1][4]
local s = SFXColorAndSize[i][1][5]
if SFXChanging[i] == true then
SFXColorAndSize[i][3][1] = SFXColorAndSize[i][3][1] + SFXColorAndSize[i][4][1]*SFXCurrentChange[i][1]
SFXColorAndSize[i][3][2] = SFXColorAndSize[i][3][2] + SFXColorAndSize[i][4][2]*SFXCurrentChange[i][2]
SFXColorAndSize[i][3][3] = SFXColorAndSize[i][3][3] + SFXColorAndSize[i][4][3]*SFXCurrentChange[i][3]
SFXColorAndSize[i][3][4] = SFXColorAndSize[i][3][4] + SFXColorAndSize[i][4][4]*SFXCurrentChange[i][4]
SFXColorAndSize[i][3][5] = SFXColorAndSize[i][3][5] + SFXColorAndSize[i][4][5]*SFXCurrentChange[i][5]
for j = 1,5 do
if SFXCurrentChange[i][j] == 1 then
if SFXColorAndSize[i][3][j] > SFXColorAndSize[i][1][j]+SFXColorAndSize[i][2][j] then
SFXCurrentChange[i][j] = -1
end
elseif SFXCurrentChange[i][j] == -1 then
if SFXColorAndSize[i][3][j] < SFXColorAndSize[i][1][j]-SFXColorAndSize[i][2][j] then
SFXCurrentChange[i][j] = 1
end
end
end
r = SFXColorAndSize[i][3][1]
g = SFXColorAndSize[i][3][2]
b = SFXColorAndSize[i][3][3]
a = SFXColorAndSize[i][3][4]
s = SFXColorAndSize[i][3][5]
end
if a > 0 then
DrawSprite(1,SFXPx[i],SFXPy[i],r,g,b,a,s)
end
end
end
end
end
function SaveGameStats()
io.output(io.open(BasicSaveFolder .. "\\Adventure\\Adventure.EURI", "w"))
local txt = tostring(MissionsDone) .. "\n"
io.write(txt)
io.close()
end
function GetGameSaveInfo(wline)
if io.open(BasicSaveFolder .. "\\Adventure\\Adventure.EURI", "r") then
local file = assert(io.input(io.open(BasicSaveFolder .. "\\Adventure\\Adventure.EURI", "r")))
local curline = 1
for line in file:lines() do
if curline == wline then
reqline = line
end
curline = curline + 1
end
elseif wline == 1 then
reqline = 0
end
return reqline
end
function CreateMainQuest()
if MissionsDone == 0 then
MissionObjective = "Gather 100 seedlings without dying"
MapType = "classic"
elseif MissionsDone == 1 then
MissionObjective = "Kill all three enemies without dying"
MapType = "triangle"
elseif MissionsDone == 2 then
MissionObjective = "Defend from waves without loosing any asteroids for 5 mins"
MapType = "fortress"
else
MissionObjective = "not determined"
MapType = "random"
end
end
function CreateMap()
if MapType == "classic" then
for i = 0,math.random(10,20) do
a = AddAsteroid(math.random(-10000,10000),math.random(-10000,10000))
if i == 0 then
a.Owner = 1
a:AddDysonTree()
a:AddSeedlings(10)
elseif i == 4 then
a.Owner = 2
a:AddDysonTree()
a:AddSeedlings(10)
else
if math.random() > 0.7 then
a.Owner = math.random(1,2)
a:AddDysonTree()
a:AddSeedlings(10)
else
a.Owner = 0
end
end
end
OpeningText = "You play a classic random map, this one contains nothing of special stuff!\n\nKill the enemy and win, they might have more than you, or less!"
MapTime = nil
Win = "conquest"
AIType = "normal"
elseif MapType == "triangle" then
local owner = 2
for i = 1,3 do
local a = AddAsteroidWithAttribs(math.cos((i/3)*(math.pi*2))*10000,math.sin((i/3)*(math.pi*2))*10000,0.8,0.8,0.8)
a.Owner = owner
a:AddDysonTree()
a:AddSeedlings(50)
owner = owner + 1
end
local numextra = math.random(20,30)
for i = 0,numextra do
local x = math.random(-10000,10000)
local y = math.random(-10000,10000)
local a = AddAsteroid(math.random(-10000,10000),math.random(-10000,10000))
if i == 0 then
a.Owner = 1
a:AddDysonTree()
else
a.Owner = 0
end
a:AddSeedlings(20*a.Owner+math.random(0,10))
end
OpeningText = "Kill the three empires that tries to kill you, be warned as their main asteroid is very highly attributed!"
MapTime = nil
Win = "conquest"
AIType = "normal"
elseif MapType == "fortress" then
local fortx = math.random(-10000,10000)
local forty = math.random(-10000,10000)
local fortsize = math.random(2000,2500)
a = AddAsteroidWithAttribs(fortx,forty,1,1,1)
a.Owner = 1
a.TreeCap = 5
a:AddSeedlings(100)
a:AddDysonTree()
a:AddDysonTree()
a:AddDysonTree()
a:AddDysonTree()
a:AddDysonTree()
a.Moveable = false
for i = 1,5 do
a = AddAsteroidWithAttribs(fortx+math.cos((i/5)*(math.pi*2))*fortsize,forty+math.sin((i/5)*(math.pi*2))*fortsize,0.8,0.8,0.8)
a.Owner = 1
a:AddDysonTree()
a:AddSuperSeedlings(5)
a.TreeCap = 2
a.Moveable = false
end
for i = 1,20 do
a = AddAsteroid(math.random(-10000,10000),math.random(-10000,10000))
a.Owner = 2
a:AddSeedlings(20)
a.TreeCap = 8
a:AddDysonTree()
a:AddDysonTree()
a:AddDysonTree()
a:AddDysonTree()
a:AddDysonTree()
a:AddDysonTree()
a:AddDysonTree()
a:AddDysonTree()
end
OpeningText = "Watch out for incoming attacks on your fort...\n\nCan you stand against the infected AI for five minutes?"
MapTime = 60*5
Win = "timeout"
AIType = "infected"
end
end
function CreateFolders()
os.execute("mkdir " .. BasicSaveFolder .. "\\Adventure")
os.execute("mkdir " .. BasicSaveFolder .. "\\Adventure\\Maps")
end
function LevelLogic()
if MapTime ~= nil then
GameLast = GetGameTime() + MapTime
end
GameTime = GetGameTime()
while GameRunning() do
if GameTime < GetGameTime() then
GameTime = GetGameTime()
SaveGameStats()
if AIType == "infected" then
InfectedAIEngine()
elseif AIType == "alien" then
AAIEngine()
elseif AIType == "both" then
InfectedAIEngine()
AAIEngine()
end
if GameLast < GetGameTime() then
if Win == "timeout" then
DoWin()
else
DoLost()
end
end
end
coroutine.yield()
end
end
function DoLost()
Pause()
MessageBox(LostMessage)
WaitDialog()
Unpause()
Quit(false)
end
function DoWin()
Pause()
MessageBox(LostMessage)
WaitDialog()
Unpause()
MissionsDone = MissionsDone + 1
SaveGameStats()
Quit(true)
end
function AIinit()
-- *** INFECTED AI V2.3 : INIT ***
-- *** AUTHOR: ANNIKK.EXE ***
-- *** EMAIL: annikk [dot] exe [at] gmail [dot] com ***
Globals.AI.GraceTimer=(99999)
-- Number of times the engine is run per While loop:
numberofiterations = 0
-- Set to 0 for very large maps. (50 asteroids+)
-- Set to 2-4 for small maps for quicker AI response.
metric = {}
currentowner = {}
for i = 0,300 do
metric[i] = 500
end
-- *** END INFECTED AI : INIT ***
end
function InfectedAIEngine()
-- *** INFECTED AI V2.3 : ENGINE ***
-- Author: ANNIKK.EXE [at] GMAIL [dot] COM
numberofasteroids = -1
neighbours = {}
for i = 0, 300 do
if GetAsteroid(i) ~= nil then
if GetAsteroid(i).radius > 10 then
numberofasteroids = numberofasteroids + 1
end
end
end
-- now the variable called "numberofasteroids" accurately represents the number of playable asteroids on the field.
for iterations = 0,numberofiterations do
-- Select an asteroid for checking.
checkedroid = GetAsteroid(math.random(0,numberofasteroids))
-- Record the current asteroid owner
changedowner = false
if currentowner[checkedroid.id] ~= nil then
if currentowner[checkedroid.id] ~= checkedroid.owner then
currentowner[checkedroid.id] = checkedroid.owner
changedowner = true
end
else
currentowner[checkedroid.id] = checkedroid.owner
end
tree = nil
flower = nil
-- flower check !
tree = checkedroid:GetRandomDysonTree()
if tree ~= nil then
flower = tree:GetSuperSeedling()
end
if checkedroid.owner > 1 and flower ~= nil then
flower:Pluck()
end
flower = checkedroid:GetFlower(checkedroid.owner)
if checkedroid.owner > 1 and flower ~= nil then
flower:PlantOnRandomDysonTree()
end
-- calculate which asteroids are a neighbour to checkedroid
numberofneighbours = -1
for i = 0,numberofasteroids do
length = GetAsteroid(i).position.x - checkedroid.position.x
height = GetAsteroid(i).position.y - checkedroid.position.y
distancetoroid = math.sqrt((length * length) + (height * height))
distancetoroid = distancetoroid - GetAsteroid(i).Radius
if distancetoroid < checkedroid.SendDistance then
-- this asteroid is in range. Add it to the neighbours list, and increment the neighbour count by one. ALSO ADDS SELF AS NEIGHBOUR! But we trap for this in the Metric Update section.
numberofneighbours = numberofneighbours + 1
neighbours[numberofneighbours] = GetAsteroid(i)
end
end
-- Metric update
-- did we update from our own status?
updated = false
-- are we under attack? if so set metric 0
if checkedroid.owner ~= 1 and checkedroid.owner ~= 0 then
if (checkedroid:GetNumSeedlings() - checkedroid:GetNumSeedlings(checkedroid.owner)) > (checkedroid:GetNumTrees() * 5) or checkedroid:GetNumMines(1) > 0 then
-- ok well we own this asteroid, and there are more enemy seeds here than our seeds (or there's a player mine here). Now, we DO have at least 1 tree worth defending here, right?
if checkedroid:GetNumTrees() > 0 then
-- ok, we're under attack! METRIC 0!
metric[checkedroid.ID] = 0
updated = true
end
end
end
-- are we maxed on trees? if not, set metric 100
-- (make sure we don't run this if we are under attack!)
if updated == false then
if checkedroid:GetNumTrees() < checkedroid.TreeCap then
-- we don't have max trees here yet. Metric 100!
metric[checkedroid.ID] = 100
updated = true
end
end
-- Not under attack, maxed on trees, and ready to contribute to the empire.
-- Check the status of our neighbours first before trying to become a gather point.
-- only run this part of the code if we didn't get our metric from our own status
if updated == false then
-- are we a suitable gather point?
enemydetected = false
frienddetected = false
gatherpointdetected = false
lowermetricsnearby = false
for i = 0, numberofneighbours do
-- check that we're not examining ourself.
if neighbours[i] ~= checkedroid then
if neighbours[i].owner == checkedroid.owner then
-- this asteroid is friendly to us
frienddetected = true
end
if neighbours[i].owner ~= checkedroid.owner and neighbours[i].owner ~= 0 and neighbours[i]:GetNumTrees() > 0 then
-- this asteroid doesn't belong to us or player 0, and has at least 1 tree. It must be an enemy roid.
enemydetected = true
end
numberofenemies = neighbours[i]:GetNumSeedlings() - neighbours[i]:GetNumSeedlings(checkedroid.owner)
if neighbours[i].owner ~= checkedroid.owner and neighbours[i]:GetNumTrees() == 0 and numberofenemies > 0 then
-- this asteroid doesn't belong to us, has no trees on it, but has enemy seedlings on it. Treat it as enemy.
enemydetected = true
end
if neighbours[i].owner == checkedroid.owner and metric[neighbours[i].ID] == 200 then
-- this asteroid is friendly to us, and is a gather point.
gatherpointdetected = true
end
if neighbours[i].owner == checkedroid.owner and metric[neighbours[i].id] < 200 then
-- uh-oh, there's an asteroid nearby with a metric lower than 200. There are Lower Metrics Nearby!
lowermetricsnearby = true
end
if neighbours[i].owner == 0 and metric[neighbours[i].id] < 200 then
-- uh-oh, there's an asteroid nearby with a metric lower than 200. There are Lower Metrics Nearby!
lowermetricsnearby = true
end
end
end
if enemydetected == true and frienddetected == true and gatherpointdetected == false and lowermetricsnearby == false then
-- the conditions are right for me to become a gather point.
metric[checkedroid.id] = 200
elseif changedowner == true then
-- the asteroid just became mine. insta-gather point please!
metric[checkedroid.id] = 200
end
-- Find the lowest metric among my neighbours
lowestmetric = metric[checkedroid.ID]
for i = 0, numberofneighbours do
-- check that we're not examining ourself.
if neighbours[i].id ~= checkedroid.id then
if neighbours[i].owner == checkedroid.owner or neighbours[i].owner == 0 then
-- this asteroid belongs to our empire, or it doesn't belong to anyone (and we should therefore follow its metrics)
-- is this neighbour's metric less than mine? (also, have we just taken this asteroid..?)
if metric[neighbours[i].ID] < lowestmetric and changedowner == false then
-- yes it's lower.
lowestmetric = metric[neighbours[i].ID]
end
end
end
end
-- now we've established what the lowest metric is. If it's lower than ours, set ours to that +1. If the lowest metric of a neighbour is the same as our metric, increase ours by 1.
-- UNLESS we are a gather point
if metric[checkedroid.ID] > lowestmetric and metric[checkedroid.ID] ~= 200 and metric[checkedroid.ID] ~= 100 then
metric[checkedroid.ID] = lowestmetric + 5
end
if metric[checkedroid.ID] == lowestmetric and metric[checkedroid.ID] ~= 200 and metric[checkedroid.ID] ~= 100 then
-- if my metric is the same as the lowest metric of my neighbours, i must be 1 step further away than they are.
metric[checkedroid.ID] = metric[checkedroid.ID] + 5
end
-- check for errors, reset metric if necessary
if metric[checkedroid.id] > 500 then
metric[checkedroid.id] = 200
end
if metric[checkedroid.ID] > 0 and metric[checkedroid.ID] < 99 then
stillinneed = false
for i = 0,numberofasteroids do
if GetAsteroid(i).Owner == checkedroid.Owner and metric[i] == 0 then
stillinneed = true
end
end
if stillinneed == false then
for i = 0,numberofasteroids do
if GetAsteroid(i).owner == checkedroid.owner and metric[i] > 0 and metric[i] < 99 then
metric[i] = 500
end
end
end
end
if metric[checkedroid.ID] > 100 and metric[checkedroid.ID] < 199 then
stillinneed = false
for i = 0,numberofasteroids do
if GetAsteroid(i).Owner == checkedroid.Owner or GetAsteroid(i).owner == 0 then
if metric[i] == 100 then
stillinneed = true
end
end
end
if stillinneed == false then
for i = 0,numberofasteroids do
if GetAsteroid(i).owner == checkedroid.owner and metric[i] > 100 and metric[i] < 199 then
metric[i] = 500
end
end
end
end
if metric[checkedroid.ID] > 200 and metric[checkedroid.ID] < 299 then
stillinneed = false
for i = 0,numberofasteroids do
if GetAsteroid(i).Owner == checkedroid.Owner and metric[i] == 200 then
stillinneed = true
end
end
if stillinneed == false then
for i = 0,numberofasteroids do
if GetAsteroid(i).owner == checkedroid.owner and metric[i] > 200 and metric[i] < 299 then
metric[i] = 500
end
end
end
end
end
-- Now to check that if we have metric 0, 100 or 200, we still require that status.
if metric[checkedroid.id] == 0 then
-- ok. Am I REALLY still under attack?
if checkedroid:GetNumSeedlings() - checkedroid:GetNumSeedlings(checkedroid.owner) > 1 or checkedroid:GetNumMines(1) > 0 then
-- the enemy outnumber us, or there's a player mine here. Yes, we're really under attack...
else
-- we're not really under attack anymore. lets reset the metric.
for i = 0, numberofasteroids do
if GetAsteroid(i).owner == checkedroid.owner then
metric[i] = 500
end
end
metric[checkedroid.id] = 200
end
end
if metric[checkedroid.id] == 100 then
-- ok. Am I REALLY still under construction?
if checkedroid:GetNumTrees() < checkedroid.TreeCap then
-- we do indeed have less trees than the treecap, so we still need seeds.
else
-- we're not really under construction anymore. lets reset the metric.
metric[checkedroid.id] = 200
end
end
enemydetected = false
frienddetected = false
gatherpointdetected = false
lowermetricsnearby = false
-- ok. Am I REALLY still a suitable gather point?
for i = 0, numberofneighbours do
-- check that we're not examining ourself.
if metric[checkedroid.ID] == 200 and neighbours[i].ID ~= checkedroid.id and changedowner == false then
if neighbours[i].owner == checkedroid.owner or neighbours[i].owner == 0 then
-- this asteroid is friendly or neutral to us
frienddetected = true
end
if neighbours[i].owner ~= checkedroid.owner and neighbours[i].owner ~= 0 and neighbours[i]:GetNumTrees() > 0 then
-- this asteroid doesn't belong to us or player 0, and has at least 1 tree. It must be an enemy roid.
enemydetected = true
end
numberofenemies = neighbours[i]:GetNumSeedlings() - neighbours[i]:GetNumSeedlings(checkedroid.owner)
if neighbours[i].owner ~= checkedroid.owner and neighbours[i]:GetNumTrees() == 0 and numberofenemies > 9 then
-- this asteroid doesn't belong to us, has no trees on it, but has enemy seedlings on it. Treat it as enemy.
enemydetected = true
end
if neighbours[i].owner == checkedroid.owner and metric[neighbours[i].ID] == 200 then
-- this asteroid is friendly to us, and is a gather point.
gatherpointdetected = true
end
if neighbours[i].owner == checkedroid.owner and metric[neighbours[i].id] < 200 then
-- uh-oh, there's an asteroid nearby with a metric lower than 200. There are Lower Metrics Nearby!
lowermetricsnearby = true
end
if neighbours[i].owner == 0 and metric[neighbours[i].id] < 200 then
-- uh-oh, there's an asteroid nearby with a metric lower than 200. There are Lower Metrics Nearby!
lowermetricsnearby = true
end
end
end
if metric[checkedroid.id] == 200 and changedowner == false then
if enemydetected == true and gatherpointdetected == false and lowermetricsnearby == false then
-- the conditions are right for me to continue as a gather point.
else
-- the conditions are no longer right. Best to reset the metric.
metric[checkedroid.id] = 500
end
end
if frienddetected == false and enemydetected == true and checkedroid:GetNumTrees() == checkedroid.TreeCap then
-- we're an orphan with max trees! lets become a gather point.
metric[checkedroid.id] = 200
end
-- Actions
-- There are 3 different action types. We must make sure not to use any actions for players 0 and 1!
-- 1. Plant trees
-- trap for player 0, exclude player 1
if checkedroid.owner == 0 or checkedroid.owner > 1 then
-- so plant one :>
for i = 2,10 do
if metric[checkedroid.id] == 100 and (checkedroid:GetNumSeedlings() - checkedroid:GetNumSeedlings(i)) < 5 and checkedroid:GetNumSeedlings(i) > 9 then
-- this asteroid isn't owned by greys or player, the enemy only has a bit of seedlings here
-- its metric is 100
-- and it has enough seedlings belonging to the asteroid's empire to plant a tree
a = checkedroid:PlantDysonTree(i)
end
end
end
-- 2. Send seedlings to the next lowest metric
if metric[checkedroid.id] ~= 0 and metric[checkedroid.id] ~= 100 and metric[checkedroid.id] ~= 500 and checkedroid.owner > 1 then
-- we're not under attack or construction.
numberofdestinations = 0
for i = 0,numberofneighbours do
if neighbours[i].owner == checkedroid.owner or neighbours[i].owner == 0 then
-- this neighbour is one of our asteroids, or it's a blank asteroid
if neighbours[i].owner == checkedroid.owner or neighbours[i].owner == 0 then
if metric[neighbours[i].ID] < metric[checkedroid.ID] then
-- we've found a friendly neighbour with a metric lower than ours!
-- add it to the destinations list
numberofdestinations = numberofdestinations + 1
end
end
end
end
if numberofdestinations > 0 then
-- we've found some destinations to send seeds to. Lets send some.
numberofseedsleft = checkedroid:GetNumSeedlings(checkedroid.owner) - (checkedroid:GetNumSeedlings() - checkedroid:GetNumSeedlings(checkedroid.owner))
numberperdestination = numberofseedsleft / numberofdestinations
for i = 0,numberofneighbours do
if neighbours[i] ~= checkedroid then
if neighbours[i].owner == checkedroid.owner or neighbours[i].owner == 0 then
if metric[neighbours[i].ID] < metric[checkedroid.ID] then
-- this destination has less than our metric. This is one of the valid destinations. Send a proportional amount of seeds to it.
if neighbours[i].owner == 0 and numberofseedsleft < 10 then
-- don't bother sending.
elseif neighbours[i].owner == 0 and neighbours[i]:GetNumSeedlings() - neighbours[i]:GetNumSeedlings(checkedroid.owner) > 0 and numberofseedsleft > 9 + (neighbours[i]:GetNumSeedlings() - neighbours[i]:GetNumSeedlings(checkedroid.owner)) then
-- attack the greys! (or whoever is camping the roid!)
checkedroid:SendSeedlingsToTarget(checkedroid.owner, checkedroid:GetNumSeedlings(checkedroid.owner), neighbours[i])
numberofseedsleft = 0
elseif neighbours[i].owner == 0 and numberofseedsleft > 9 and (neighbours[i]:GetNumSeedlings() - neighbours[i]:GetNumSeedlings(checkedroid.owner)) == 0 then
-- this is the last we can manage. Send all 10.
checkedroid:SendSeedlingsToTarget(checkedroid.owner, 10, neighbours[i])
numberofseedsleft = numberofseedsleft - 10
elseif neighbours[i].owner == checkedroid.owner then
checkedroid:SendSeedlingsToTarget(checkedroid.owner, numberperdestination, neighbours[i])
numberofseedsleft = numberofseedsleft - numberperdestination
end
end
end
end
end
end
-- 3. Attack the weakest nearby asteroid
-- Are we a gather point? Only gather points are allowed to attack.
if metric[checkedroid.id] == 200 then
totalenemies = 0
totalfriendlies = checkedroid:GetNumSeedlings(checkedroid.owner)
weakestamount = 10000
weakestroid = checkedroid
attack = false
orphan = true
numberofenemyroids = 0
for i = 0,numberofneighbours do
if neighbours[i].owner == checkedroid.owner and neighbours[i] ~= checkedroid then
orphan = false
end
if neighbours[i].owner ~= checkedroid.owner and neighbours[i]:GetNumSeedlings() - neighbours[i]:GetNumSeedlings(checkedroid.owner) > 5 then
-- found an attack path
numberofenemyroids = numberofenemyroids + 1
end
for j = 0,10 do
if checkedroid.owner ~= j then
totalenemies = totalenemies + neighbours[i]:GetNumSeedlings(j)
if weakestamount > neighbours[i]:GetNumSeedlings(j) and neighbours[i].owner == j then
-- the owner of this asteroid has a smaller number of seeds than we've seen before...
weakestamount = neighbours[i]:GetNumSeedlings(j)
weakestroid = neighbours[i]
end
end
end
if neighbours[i] ~= checkedroid and neighbours[i].owner ~= checkedroid.owner then
if neighbours[i]:GetNumSeedlings(checkedroid.owner) > (neighbours[i]:GetNumSeedlings() - neighbours[i]:GetNumSeedlings(checkedroid.owner)) then
-- already attacking, and winning. send reinforcements.
checkedroid:SendSeedlingsToTarget(checkedroid.owner, checkedroid:GetNumSeedlings(checkedroid.owner), neighbours[i])
end
end
end
-- in the first case, we have more seedlings than all the neighbouring asteroids put together.
if totalfriendlies > totalenemies + (weakestroid:GetNumTrees() * 10) then
attack = true
end
split = false
-- in the second case, we have more than 150 seedlings on this roid, and it's time to move out!
if totalfriendlies > 150 then
attack = true
split = true
end
if totalfriendlies >= Globals.Asteroids.SpawnCap and orphan == true then
attack = true
end
if attack == true and checkedroid.owner > 1 and split == false then
-- ok so we're a gather point, we're ready to attack, and we aren't a player or greys asteroid.
-- lets move out.
checkedroid:SendSeedlingsToTarget(checkedroid.owner, totalfriendlies, weakestroid)
elseif attack == true and checkedroid.owner > 1 and split == true then
for i = 0,numberofneighbours do
if neighbours[i].owner ~= checkedroid.owner then
-- attackable path - send proportional amount of seeds.
checkedroid:SendSeedlingsToTarget(checkedroid.owner, totalfriendlies / numberofenemyroids, neighbours[i])
end
end
end
end
end
-- Set asteroid names to whatever their metric is. Uncomment the
-- line below for testing purposes if the AI shows unexpected behaviours.
-- checkedroid.Name = metric[checkedroid.ID]
end
-- *** END INFECTED AI : ENGINE ***
end
function AAIInit(empire)
Empire = empire --Which AI empire should the AI control?
Globals.AI.GraceTimer = 9999999
AAINumRoids = -1
AAISelectedRoid = 0
AAIPriority = {}
AAINo_Priority = false
AAILastCheckedOwner = {}
AAITakeBack = {}
AAITakeBackTimer = {}
AAIHaveRoots = {}
for i = 0,100000 do
if GetAsteroid(i) ~= nil then
AAINumRoids = AAINumRoids + 1
AAIPriority[i] = 0
AAITakeBack[i] = false
AAILastCheckedOwner[i] = GetAsteroid(i).Owner
AAIHaveRoots[i] = false
else
break
end
end
end
function AAIEngine()
local HighestEnergy = 0
local HighestStr = 0
local HighestSpeed = 0
for i = 0,AAINumRoids do
if GetAsteroid(i).owner ~= Empire then
GetAsteroid(i):SetGraceTime(0)
else
GetAsteroid(i):SetGraceTime(99999)
if GetAsteroid(i).attribs.energy > HighestEnergy then
HighestEnergy = GetAsteroid(i).attribs.energy
end
if GetAsteroid(i).attribs.strength > HighestStr then
HighestStr = GetAsteroid(i).attribs.strength
end
if GetAsteroid(i).attribs.speed > HighestSpeed then
HighestSpeed = GetAsteroid(i).attribs.speed
end
if AAIHaveRoots[i] == false and GetAsteroid(i):GetNumTrees() > 0 then
AAIHaveRoots[i] = true
end
end
end
AAISelectedRoid = math.random(0,AAINumRoids)
local Numneighbours = 0
local Neighbour = {}
local ChangedOwner = false
if GetAsteroid(AAISelectedRoid).Owner ~= AAILastCheckedOwner[AAISelectedRoid] then
ChangedOwner = true
end
if ChangedOwner == true and AAILastCheckedOwner[AAISelectedRoid] == Empire then
AAITakeBack[AAISelectedRoid] = true
AAITakeBackTimer[AAISelectedRoid] = GetGameTime() + 30
end
if ChangedOwner == true and AAITakeBack[AAISelectedRoid] == true and AAILastCheckedOwner[AAISelectedRoid] ~= Empire and GetAsteroid(AAISelectedRoid).Owner == Empire then
AAITakeBack[AAISelectedRoid] = false
AAITakeBackTimer[AAISelectedRoid] = nil
end
if AAITakeBackTimer[AAISelectedRoid] ~= nil then
if GetGameTime() > AAITakeBackTimer[AAISelectedRoid] then
AAITakeBack[AAISelectedRoid] = false
AAITakeBackTimer[AAISelectedRoid] = nil
end
end
--Flowertime :D No seriously -.-
local Tree = GetAsteroid(AAISelectedRoid):GetRandomDysonTree()
if Tree ~= nil then
Flower = Tree:GetSuperSeedling()
end
if Flower ~= nil and GetAsteroid(AAISelectedRoid).Owner == Empire then
Flower:Pluck()
end
local Flower = GetAsteroid(AAISelectedRoid):GetFlower(Empire)
if Flower ~= nil and GetAsteroid(AAISelectedRoid).Owner == Empire then
Flower:PlantOnRandomDysonTree()
end
--Now as we have the selectedroid here, begin making conditions for priorities to be set...
--First if the ERRoid is attacked, what do we do? We set the priority to zero, so the neighbours know that: "OMGosh, that ERRoid is attacked, help it!"
if GetAsteroid(AAISelectedRoid):GetNumSeedlingsExcluding(Empire) > GetAsteroid(AAISelectedRoid):GetNumSeedlings(Empire)/4 and GetAsteroid(AAISelectedRoid).Owner == Empire and AAIPriority[AAISelectedRoid] > 0 then
AAIPriority[AAISelectedRoid] = 0
elseif AAITakeBack[AAISelectedRoid] == true and AAIPriority[AAISelectedRoid] ~= 0 then
AAIPriority[AAISelectedRoid] = 0
end
if GetAsteroid(AAISelectedRoid):GetMine(1) ~= nil then
AAIPriority[AAISelectedRoid] = 0
end
if GetAsteroid(AAISelectedRoid):GetNumTrees() < GetAsteroid(AAISelectedRoid).TreeCap and GetAsteroid(AAISelectedRoid):GetNumTrees() >= 1 and GetAsteroid(AAISelectedRoid).Owner == Empire and AAIPriority[AAISelectedRoid] > AAINumRoids*2 then
AAIPriority[AAISelectedRoid] = AAINumRoids*2
end
if GetAsteroid(AAISelectedRoid):IsVisible(Empire) ~= true and AAIPriority[AAISelectedRoid] > AAINumRoids*4 then
AAIPriority[AAISelectedRoid] = AAINumRoids*4
end
if GetAsteroid(AAISelectedRoid):GetNumTrees() == 0 and AAIHaveRoots[AAISelectedRoid] == false and AAIPriority[AAISelectedRoid] > AAINumRoids*6 then
AAIPriority[AAISelectedRoid] = AAINumRoids*6
end
if GetAsteroid(AAISelectedRoid).Owner ~= Empire and GetAsteroid(AAISelectedRoid):IsVisible(Empire) == true and GetEmpire(Empire).NumSeedlings > GetAsteroid(AAISelectedRoid):GetNumSeedlingsExcluding(Empire)*1.5 and AAIPriority[AAISelectedRoid] > AAINumRoids*8 then
AAIPriority[AAISelectedRoid] = AAINumRoids*8
end
--Now check if all of the priorities are still correct, so we can decide if we want it to refresh or not...
--Are we still attacked?
if AAIPriority[AAISelectedRoid] == 0 and GetAsteroid(AAISelectedRoid):GetNumSeedlingsExcluding(Empire) == 0 and GetAsteroid(AAISelectedRoid).Owner == Empire and AAITakeBack[AAISelectedRoid] == false and GetAsteroid(AAISelectedRoid):GetMine(1) == nil then
AAIPriority[AAISelectedRoid] = AAINumRoids*10
elseif AAIPriority[AAISelectedRoid] == 0 and GetAsteroid(AAISelectedRoid).Owner ~= Empire and AAIPriority[AAISelectedRoid] == 0 and AAITakeBack[AAISelectedRoid] == false then
AAIPriority[AAISelectedRoid] = AAINumRoids*10
end
if AAIPriority[AAISelectedRoid] == AAINumRoids*2 and GetAsteroid(AAISelectedRoid):GetNumTrees() == GetAsteroid(AAISelectedRoid).TreeCap and GetAsteroid(AAISelectedRoid).Owner == Empire then
AAIPriority[AAISelectedRoid] = AAINumRoids*10
end
if AAIPriority[AAISelectedRoid] == AAINumRoids*4 and GetAsteroid(AAISelectedRoid):IsVisible(Empire) == true then
AAIPriority[AAISelectedRoid] = AAINumRoids*10
end
if AAIPriority[AAISelectedRoid] == AAINumRoids*6 and GetAsteroid(AAISelectedRoid):GetNumTrees() > 0 then
AAIPriority[AAISelectedRoid] = AAINumRoids*10
end
if GetAsteroid(AAISelectedRoid).Owner == Empire and AAIPriority[AAISelectedRoid] == AAINumRoids*8 then
AAIPriority[AAISelectedRoid] = AAINumRoids*10
end
if AAIPriority[AAISelectedRoid] == AAINumRoids*2 and GetAsteroid(AAISelectedRoid):GetNumSeedlings(Empire) >= 10 and GetAsteroid(AAISelectedRoid).Owner == Empire then
GetAsteroid(AAISelectedRoid):PlantDysonTree(Empire)
end
if AAIPriority[AAISelectedRoid] == AAINumRoids*6 and GetAsteroid(AAISelectedRoid):GetNumSeedlings(Empire) >= 10 then
local Lowerstats = 0
if GetAsteroid(AAISelectedRoid).attribs.energy < HighestEnergy/2 then
Lowerstats = Lowerstats+1
end
if GetAsteroid(AAISelectedRoid).attribs.strength < HighestStr/2 then
Lowerstats = Lowerstats+1
end
if GetAsteroid(AAISelectedRoid).attribs.speed < HighestSpeed/2 then
Lowerstats = Lowerstats+1
end
if Lowerstats >= 2 then
GetAsteroid(AAISelectedRoid):PlantDefenseTree(Empire)
else
GetAsteroid(AAISelectedRoid):PlantDysonTree(Empire)
end
end
local Yes_Priority = false
AAINo_Priority = false
local LowestPriority = AAINumRoids*10
--Scanning for every empire, so everyone can see the status for the ERRoid...
for i = 0,AAINumRoids do
if AAIPriority[i] < LowestPriority then
LowestPriority = AAIPriority[i]
end
if i ~= AAISelectedRoid then
--Figuring the distance between the two roids...
Xdif = GetAsteroid(AAISelectedRoid).position.X - GetAsteroid(i).position.X
Ydif = GetAsteroid(AAISelectedRoid).position.Y - GetAsteroid(i).position.Y
Dist = math.abs(math.sqrt((Xdif*Xdif)+(Ydif*Ydif)))
if Dist <= GetAsteroid(AAISelectedRoid).SendDistance+GetAsteroid(i).Radius then
--Ok, we have a neighbour, add it to the list so we can check it for several stuff later!
Numneighbours = Numneighbours+1
Neighbour[Numneighbours] = GetAsteroid(i)
end
end
end
for i = 1,Numneighbours do
if AAIPriority[AAISelectedRoid] > AAIPriority[Neighbour[i].ID] and GetAsteroid(AAISelectedRoid).Owner == Empire then
AAIPriority[AAISelectedRoid] = AAIPriority[Neighbour[i].ID]+1
if AAIPriority[Neighbour[i].ID] == AAINumRoids*8 and GetAsteroid(AAISelectedRoid):GetNumSeedlings(Empire)/1.5 > Neighbour[i]:GetNumSeedlings(Neighbour[i].Owner) then
GetAsteroid(AAISelectedRoid):SendSeedlingsToTarget(Empire, GetAsteroid(AAISelectedRoid):GetNumSeedlings(Empire), GetAsteroid(Neighbour[i].ID))
elseif AAIPriority[Neighbour[i].ID] == 0 and GetAsteroid(AAISelectedRoid):GetNumSeedlings(Empire)/1.5 > Neighbour[i]:GetNumSeedlings(Neighbour[i].Owner) then
GetAsteroid(AAISelectedRoid):SendSeedlingsToTarget(Empire, GetAsteroid(AAISelectedRoid):GetNumSeedlings(Empire), GetAsteroid(Neighbour[i].ID))
elseif AAIPriority[Neighbour[i].ID] ~= AAINumRoids*8 then
GetAsteroid(AAISelectedRoid):SendSeedlingsToTarget(Empire, GetAsteroid(AAISelectedRoid):GetNumSeedlings(Empire), GetAsteroid(Neighbour[i].ID))
end
Yes_Priority = true
elseif AAIPriority[AAISelectedRoid]~=0 and AAIPriority[AAISelectedRoid]~=AAINumRoids*2 and AAIPriority[AAISelectedRoid]~=AAINumRoids*4 and AAIPriority[AAISelectedRoid]~=AAINumRoids*6 and AAIPriority[AAISelectedRoid]~=AAINumRoids*8 and AAIPriority[AAISelectedRoid]~=AAINumRoids*10 then
AAINo_Priority = true
end
end
if Yes_Priority == true and AAINo_Priority == true then
AAINo_Priority = false
end
if AAINo_Priority == true and GetAsteroid(AAISelectedRoid).Owner == Empire then
AAIPriority[AAISelectedRoid] = AAINumRoids*10
end
for sum = 1,5 do
if LowestPriority < AAINumRoids*(sum*2) and LowestPriority > AAINumRoids*((sum*2)-2) and LowestPriority ~= AAINumRoids*(sum*2) then
for i = 0,AAINumRoids do
if AAIPriority[AAISelectedRoid] > AAINumRoids*((sum*2)-2) and AAIPriority[AAISelectedRoid] < AAINumRoids*(sum*2) then
AAIPriority[AAISelectedRoid] = AAINumRoids*10
end
end
end
end
AAILastCheckedOwner[AAISelectedRoid] = GetAsteroid(AAISelectedRoid).Owner
--GetAsteroid(AAISelectedRoid).Name = AAIPriority[AAISelectedRoid]
end
Open
"hello, boys, calm down!"
Lost
"do nothing no!"
Win
"lol!"
WinType
"conquest"
AI
"infected"
createroid
random
-1000
1000
random
5000
6000
createroidatt
random
-1000
1000
random
5000
6000
0.8
0.3
0.5
createfield
0
0
5
common
x
random
-10000
10000
y
random
-10000
10000
end
First off, make sure the whole thing is installed correctly!!!
Then you can open the example.map file, which has no content strangely...
Then you can start of by writing something like:
Open
"x"
x is your choice of text, since you make a map, you shouldn't be limited by writing anything...
Just remember: as you write texts, lua "laws" still holds, like a new line is \n and not pressing enter!
An actual new line in the file means that you are going to indicate something new... this means that you cannot do
Open
"I went to the
forest to meet my friends"
because it returns illegal.
To explain this much more I'll explain it the next few lines:
The maploader, does only recognize one line at the time, so it you state Open(short for OpeningText, which is what will appear in the messagebox at start...) the computer will automatically make the next line the OpeningText.
Now if you split it in two lines directly(meaning not with \n) you get the error, because after the line below Open, the computer either expect emptyness or a command...
Now that we know that, let's explore the boundaries of what you can do:
Open
We know that Open is the OpeningTEXT
Win
This is WinTEXT, or the text for the messagebox that appears when you've won!
Lost
This is the LoseTEXT, same deal as win, only difference is that it appears when you lose.
WinType
WinType is how to win, examples are:
"conquest" which is to capture all asteroids
"timeout" waiting some time, this is good for survival maps!
"lose" to make things clear on this one, you need to lose all asteroids to win this map.
AI
This is the AI that runs in the game, you can use both "infected" and "alien".
Time (measured in seconds!)
If the win condition is "timeout" then you must set the time, after this time period, the game ends depending on winningconditions...
Note: When text is quoted, that's how it should appear on the document.
When creating the map you can use:
Note: x and y are co-ordinates!
createroid
x
y
createroidatt
x
y
energy
strength
speed
createfield
x
y
number of roids
common(is written common in the document too, common states what is common with the asteroid in the field!)
x
y
change(change is capable of changing every property of the asteroid as yo can think of...)
Example of uses in "change":
NOTE: Value without anything telling what it is, is a number!
treecap
needs one value
owner
needs one value
numseeds
needs one value
numsuperseeds
needs one value
addtree
needs one text value and one value
moving
needs a boolean value (booleans are true/false!!!!!)
Now as you've seen the commands, let's look at the math!
random
Needs two values, like this:
random
600
1200
random acts as random in Lua, meaning that is only runs whole numbers!
cos
Needs one value!
sin
Needs one value
pi
needs no value, can be used in others!
currentinfield
Calls the current roid in the field(NOT THE ID OF THE ASTEROID!!!)
To the arithmetics, even though you might think it is a simple deal like 1-1, it is not:
for doing a simple calculation like 1-1 you must do
minus
1
useable in arithmetics:
plus (adding)
minus (subtract)
divide (dividing)
times (multiplying)
exponent (multiply by self!)
function LoadMap(ID)
if io.open(BasicSaveFolder .. "\\Adventure\\Maps\\" .. MapNames[ID] .. ".map", "r") then
assert(io.input(io.open(BasicSaveFolder .. "\\Adventure\\Maps\\" .. MapNames[ID] .. ".map", "r")))
local activation = nil
local activationlast = 0
local gettingvalue = false
local customvalue = {}
local latestid = nil
for line in io.lines() do
if activation ~= nil then
if activation == "Open" then
OpeningText = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "Win" then
WinMessage = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "Lost" then
LostMessage = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "WinType" then
Win = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "AI" then
AIType = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "Time" then
MapTime = tonumber(line)
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "createroid" then
if activationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local x = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local x = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local y = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local y = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
end
if activationlast == 0 then
AddAsteroid(x,y)
activation = nil
end
elseif activation == "createroidatt" then
if activationlast == 5 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local x = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local x = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 4 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local y = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local y = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 3 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local e = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local e = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local st = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local st = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local sp = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local sp = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
end
if activationlast == 0 then
AddAsteroidWithAttribs(x,y,e,st,sp)
activation = nil
end
elseif activation == "createroidatt" then
if activationlast == 4 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local x = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local x = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 3 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local y = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local y = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local num = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local num = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local size = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local size = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
end
if activationlast == 0 then
for i = 1,num do
AddAsteroid(x+math.random(-size,size),y+math.random(-size,size))
end
activation = nil
end
elseif activation == "createvalue" then
if activationlast == 2 then
local id = tonumber(line)
elseif activationlast == 1 then
local val = tonumber(line)
end
activationlast = activationlast - 1
if activationlast == 0 then
customvalue[id] = val
latestid = id
activation = nil
end
elseif activation == "changeid" then
activationlast = activationlast - 1
if activationlast == 0 then
latestid = tonumber(line)
activation = nil
end
elseif activation == "createsfx" then
if activationlast == 17 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local x = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local x = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 16 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local y = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local y = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 15 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local r = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local r = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 14 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local g = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local g = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 13 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local b = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local b = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 12 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local a = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local a = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 11 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local size = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local size = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 10 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local rd = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local rd = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 9 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local gd = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local gd = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 8 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local bd = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local bd = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 7 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local ad = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local ad = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 6 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local sized = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local sized = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 5 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local rcs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local rcs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 4 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local gcs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local gcs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 3 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local bcs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local bcs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local acs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local acs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local scs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local scs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
end
if activationlast == 0 then
CreateSFX(x,y,r,g,b,a,size,rd,gd,bd,ad,sized,rcs,gcs,bcs,acs,scs)
activation = nil
end
elseif activation == "change" then
if activationlast == 3 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local id = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local id = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 2 then
local what = tostring(line)
activationlast = activationlast - 1
elseif activationlast == 1 then
local changeto = line
activationlast = activationlast - 1
end
if activationlast == 0 then
if what == "owner" then
GetAsteroid(id).Owner = changeto
elseif what == "treecap" then
GetAsteroid(id).TreeCap = changeto
elseif what == "addseedlings" then
GetAsteroid(id):AddSeedlings(changeto)
elseif what == "addsuperseedlings" then
GetAsteroid(id):AddSuperSeedlings(changeto)
elseif what == "adddysontree" then
GetAsteroid(id):AddDysonTree()
elseif what == "adddefensetree" then
GetAsteroid(id):AddDefenseTree()
elseif what == "moving" then
GetAsteroid(id).Moveable = changeto
end
activation = nil
end
end
if subactivation == "add" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid] + val
subactivation = nil
end
elseif subactivation == "minus" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid] - val
subactivation = nil
end
elseif subactivation == "times" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid] * val
subactivation = nil
end
elseif subactivation == "divide" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid] / val
subactivation = nil
end
elseif subactivation == "expo" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid]^val
subactivation = nil
end
elseif subactivation == "random" then
if actionlast == 3 then
local id = tostring(line)
elseif subactivationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val1 = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val1 = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
elseif subactivationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val2 = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val2 = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[id] = math.random(val1,val2)
latestid = id
subactivation = nil
end
elseif subactivation == "sin" then
if actionlast == 2 then
local id = tostring(line)
elseif subactivationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val1 = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val1 = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[id] = math.sin(val1)
latestid = id
subactivation = nil
end
elseif subactivation == "cos" then
if actionlast == 2 then
local id = tostring(line)
elseif subactivationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val1 = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val1 = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[id] = math.cos(val1)
latestid = id
subactivation = nil
end
end
else
if line == "Open" then
activation = line
activationlast = 1
elseif line == "Win" then
activation = line
activationlast = 1
elseif line == "Lost" then
activation = line
activationlast = 1
elseif line == "WinType" then
activation = line
activationlast = 1
elseif line == "AI" then
activation = line
activationlast = 1
elseif line == "Time" then
activation = line
activationlast = 1
elseif line == "createroid" then
activation = line
activationlast = 2
elseif line == "createroidatt" then
activation = line
activationlast = 5
elseif line == "createvalue" then
activation = line
activationlast = 2
elseif line == "add" or line == "minus" or line == "divide" or line == "times" or line == "expo" then
subactivation = line
subactivationlast = 1
elseif line == "random" then
subactivation = line
subactivationlast = 3
elseif line == "sin" or line == "cos" then
subactivation = line
subactivationlast = 2
elseif line == "changeid" then
activation = line
activationlast = 1
elseif line == "createfield" then
activation = line
activationlast = 4
elseif line == "createsfx" then
activation = line
activationlast = 17
elseif line == "change" then
activation = line
activationlast = 3
end
end
end
end
end
function DrawHollowBox(x1,y1,x2,y2,r1,g1,b1,a1,r2,g2,b2,a2,size,style)
if style == 1 then --Every next colour :D
DrawLine(x1,y1,x2,y1,r1,b1,g1,a1,r2,b2,g2,a2,size)
DrawLine(x2,y1,x2,y2,r2,b2,g2,a2,r1,b1,g1,a1,size)
DrawLine(x2,y2,x1,y2,r1,b1,g1,a1,r2,b2,g2,a2,size)
DrawLine(x1,y2,x1,y1,r2,b2,g2,a2,r1,b1,g1,a1,size)
elseif style == 2 then --Horizontal fade
DrawLine(x1,y1,x2,y1,r1,b1,g1,a1,r2,b2,g2,a2,size)
DrawLine(x2,y1,x2,y2,r2,b2,g2,a2,r2,b2,g2,a2,size)
DrawLine(x2,y2,x1,y2,r2,b2,g2,a2,r1,b1,g1,a1,size)
DrawLine(x1,y2,x1,y1,r1,b1,g1,a1,r1,b1,g1,a1,size)
elseif style == 3 then --Vertical fade
DrawLine(x1,y1,x2,y1,r1,b1,g1,a1,r1,b1,g1,a1,size)
DrawLine(x2,y1,x2,y2,r1,b1,g1,a1,r2,b2,g2,a2,size)
DrawLine(x2,y2,x1,y2,r2,b2,g2,a2,r2,b2,g2,a2,size)
DrawLine(x1,y2,x1,y1,r2,b2,g2,a2,r1,b1,g1,a1,size)
end
end
Unity uses JavaScript :D
--[[Priorities:
Attacked - 0
Need trees - X2 / 3 / 4 / 5
Attack - X2 / 3 / 4 / 5
Undiscovered - X2 / 3 / 4 / 5
Defend - X2 / 3 / 4 / 5
Priorites are matrixes, per empire.
If Defense is highest, Defend is always lowest priority.
If Colonise if highest, Need Trees is first and Undiscoverd comes after!
If Risk is highest, Attack is first.
Ratio for Defender/Risker/Coloniser is
Defense > Risk :
Need trees - X3
Attack - X5
Undiscovered - X4
Defend - X2
Defense > Colonise :
Need trees - X4
Attack - X3
Undiscovered - X5
Defend - X2
Risk > Colonise :
Need trees - X5
Attack - X2
Undiscovered - X4
Defend - X3
Risk > Defense :
Need trees - X3
Attack - X2
Undiscovered - X4
Defend - X5
Colonise > Defense :
Need trees - X2
Attack - X4
Undiscovered - X3
Defend - X5
Colonise > Risk :
Need trees - X2
Attack - X5
Undiscovered - X3
Defend - X4
Each of the values will be local values and they'll be added together, then divided by the amount of adding occasions.
Since the numbers are so slightly different, we must arrange them afterward from lowest to highest whole number.
This will give the perfect value, I guess...]]
--[[Variables needed:
Globals:
Priority - A matrix, contains a value that tells how attention sick an asteroid is.
Neighbour - A matrix, contains the Asteroid value for an ai to the selected asteroid.
NumNeighbours - An array, tells how many neighbours an asteroid have.
{
NeedTrees - An Array, spanning for all AI's, it gives the value for the default priority for the event: Need Trees. This variable is dependant of the three different personalities of the AI chosen.
Attack - Same story as above, only affecting the event: Attack
Discover - Same story as above, only affecting the event: Undiscovered
Defend - Same story as above, only affecting the event: Defend
} - Can be put in a matrix!
NumRoids - A single integer, containing a number that calls how many asteroids there are on the map.
NumFactions - A single integer, containing the value of how many AI controlled factions there are.
Locals:
--Coming and going
]]
--[[Behaviour:
Most of the behaviour is chosen by the properties of the AI
]]
--[[Coding:
{{Functions:
There will be two functions for the AI, creating a simple implented Engine.
}}
{{Function Names:
Function 1: Init() - Short for Initialize, runned once in LevelSetup()
Function 2: Engine() - Run all the time inside of a while loop in LevelLogic()
}}
{{Function 1: Init():
Init() will be reposible for:((
- Finding the amount of asteroids on the map.
- Setting arrays and matrixes.
- Finding the amount of controlled factions there are.
- Finding Neighbours for the asteroids.
- Sets the globals correctly.
))
}}
{{Function 2: Engine():
Engine() will be responsible for:((
- Executing the AI for every empire.
))
Engine() logic map:((
Pick a random asteroid:
Run through all the factions:
Owns the asteroid?
Yes:
Are we threatened by enemies around us?
Yes:
Priority(Chosen by personal attribs:Defend)
No:
Are there need for more trees?
Yes:
Priority(Chosen by personal attribs:NeedTree)
No:
[s]Priority(Impossible high :O)[/s]
Are there any Neighbours needing our help?
Yes:
Do we have seedlings to send?
Yes:
Send the seedlings to the closest neighbour needing them...
No:
Are we being patient and waiting for some more seedlings?
Yes:
Good, now wait!
No:
Get patient skill and be patient, we got nothing else to do!
No:
THIS ANSWER IS INVALID, DAMN YOU LOGIC MAP!
No:
Is it discovered yet?
Yes:
Does a non-neutral own it?
Yes:
Is there seedlings on it?
Yes:
Is there more than on our asteroid?
Yes:
Priority(Chosen by personal attribs:Defend)
No:
Priority(Chosen by personal attribs:Attack)
No:
Priority(Chosen by personal attribs:Attack)
No:
Does it have enemies on it?
Yes:
Priority(Chosen by personal attribs:Attack)
No:
Is it plantable?
Yes:
Priority(Chosen by personal attribs:NeedTree)
No:
Do the AI give a sh*t?
NO, not if this condition is true D:
No:
Priority(Chosen by personal attribs:Discover)
Are there Flowers on the trees?
Yes:
Are they detachable?(this is not questionable in the code :D)
Yes:
Detach it and plant it on a random dyson tree :D
No:
Wait...
No:
Damn D:
))
}}
]]
--[[Priorities:
Attacked - 0
Need trees - X2 / 3 / 4 / 5
Attack - X2 / 3 / 4 / 5
Undiscovered - X2 / 3 / 4 / 5
Defend - X2 / 3 / 4 / 5
Priorites are matrixes, per empire.
If Defense is highest, Defend is always lowest priority.
If Colonise if highest, Need Trees is first and Undiscoverd comes after!
If Risk is highest, Attack is first.
Ratio for Defender/Risker/Coloniser is
Defense > Risk :
Need trees - X3
Attack - X5
Undiscovered - X4
Defend - X2
Defense > Colonise :
Need trees - X4
Attack - X3
Undiscovered - X5
Defend - X2
Risk > Colonise :
Need trees - X5
Attack - X2
Undiscovered - X4
Defend - X3
Risk > Defense :
Need trees - X3
Attack - X2
Undiscovered - X4
Defend - X5
Colonise > Defense :
Need trees - X2
Attack - X4
Undiscovered - X3
Defend - X5
Colonise > Risk :
Need trees - X2
Attack - X5
Undiscovered - X3
Defend - X4
Each of the values will be local values and they'll be added together, then divided by the number of adding occasions.
Since the numbers are so slightly different, we must arrange them afterward from lowest to highest whole number.
This will give the perfect value, I guess...]]
--[[Variables needed:
Globals:
Priority - A matrix, contains a value that tells how attention sick an asteroid is.
Neighbour - A matrix, contains the Asteroid value for an ai to the selected asteroid.
NumNeighbours - An array, tells how many neighbours an asteroid have.
{
NeedTrees - An Array, spanning for all AI's, it gives the value for the default priority for the event: Need Trees. This variable is dependant of the three different personalities of the AI chosen.
Attack - Same story as above, only affecting the event: Attack
Discover - Same story as above, only affecting the event: Undiscovered
Defend - Same story as above, only affecting the event: Defend
} - Can be put in a matrix!
NumRoids - A single integer, containing a number that calls how many asteroids there are on the map.
NumFactions - A single integer, containing the value of how many AI controlled factions there are.
Locals:
--Coming and going
]]
--[[Behaviour:
Most of the behaviour is chosen by the properties of the AI
]]
--[[Coding:
{{Functions:
There will be two functions for the AI, creating a simple implented Engine.
}}
{{Function Names:
Function 1: Init() - Short for Initialize, runned once in LevelSetup()
Function 2: Engine() - Run all the time inside of a while loop in LevelLogic()
}}
{{Function 1: Init():
Init() will be reposible for:((
- Finding the amount of asteroids on the map.
- Setting arrays and matrixes.
- Finding the amount of controlled factions there are.
- Finding Neighbours for the asteroids.
- Sets the globals correctly.
))
}}
{{Function 2: Engine():
Engine() will be responsible for:((
- Executing the AI for every empire.
))
Engine() logic map:((
Pick a random asteroid:
Run through all the factions:
Owns the asteroid?
Yes:
Are we threatened by enemies around us?
Yes:
Priority(Chosen by personal attribs:Defend)
No:
Are there need for more trees?
Yes:
Priority(Chosen by personal attribs:NeedTree)
No:
Priority(Impossible high :O)
No:
Is it discovered yet?
Yes:
Does a non-neutral own it?
Yes:
Is there seedlings on it?
Yes:
Is there more than on our asteroid?
Yes:
Priority(Chosen by personal attribs:Defend)
No:
Priority(Chosen by personal attribs:Attack)
No:
Priority(Chosen by personal attribs:Attack)
No:
Does it have enemies on it?
Yes:
Priority(Chosen by personal attribs:Attack)
No:
Is it plantable?
Yes:
Priority(Chosen by personal attribs:NeedTree)
No:
Do the AI give a sh*t?
NO, not if this condition is true D:
No:
Priority(Chosen by personal attribs:Discover)
Are there Flowers on the trees?
Yes:
Are they detachable?(this is not questionable in the code :D)
Yes:
Detach it and plant it on a random dyson tree :D
No:
Wait...
No:
Damn D:
Check my priority:
Is it set for me to do something?
Yes:
What is the task?
Attack:
--IMPORTANT INFO: This is a neighbours job!
Are there enough seedlings to kill the enemy?
Yes:
[coarse language!!!]Send thoose seedlings! We're raping those buttholes![/coarse language]
No:
Wait for more to come!
NeedTrees:
Are there enough seedlings for a tree?
(why need ten, when we can do it with one seed in reality?)
Yes:
Plant a dyson tree...
No:
Wait then...
Discover:
([facepalm]It's called EXPLORE...[/facepalm])
--IMPORTANT INFO: This is a neighbours job!
Are there atleast one seed on the asteroid and atleast 10*(Defend-Risk(if returning minus, do a 0!)) more to prevent any surprise buttsecks?
Yes:
Send the seed, to explore the world!
(there might be several, but maybe prevented by the limit :o)
No:
Wait... I think, unless we take a risk :D
Defend:
--IMPORTANT INFO: This is a neighbours job!
Obvious, wait for seedlings -.-
If risk is high enough:
Is there enough seedlings to buttrape the enemy?
Yes:
Do it!
No:
Okay :/
No: (I haz to do something :o)
Check all neighbours:
Are there lower priorities than me?
Yes
Priority(Nighbour+1)
Do we have seedlings to send?
Yes:
Send the seedlings to the closest neighbour needing them...
No:
Are we being patient and waiting for some more seedlings?
Yes:
Good, now wait!
No:
Get patient skill and be patient, we got nothing else to do!
No:
I'm that best, ain't I?
))
}}
]]
I am working on my computer. It won't start. :< Writing this from another machine...
What the heck? You made your Computer better without putting in new parts?
What the heck? You made your Computer better without putting in new parts?
Yes.
@dragoonreas: You’re BACK?! How nice to see you veteran mapper again here :)Thanks :)
The text is surprisingly long, so I forget one part before I start reading another one D:It's probably going to take more than one read through to understand, especially if you haven't read any of the previous sections. I think looking at the code in the second link may actually be prove more helpful than reading all the stuff in the first link (at least it was when I first came across it).
Units = {}{}
Units = {}
Units[NumberofBases] = {}
for i = 1,NumEnemies+1 do
Units[NumberofBases][i] = 0
end
local self = {
BaseNumber = NumberofBases
Position = {
X = x
Y = y
}
Owner = 0
Units = {}
Units[NumberofBases] = {}
for i = 1,NumEnemies+1 do
Units[NumberofBases][i] = 0
end
}
:)
function LevelSetup()
Globals.G.Asteroids=0
Globals.G.EnemyFactionsMin=0
Globals.G.EnemyFactionsMax=0
SetBackdropColour(0,0,0)
AddAsteroid(0,0)
Globals.Flowers.Available = 0
Initialization()
BasicSaveFolder = "C:\\EufloriaSaves\\"
end
function LevelLogic()
GetAsteroid(0).Radius = 0
GetAsteroid(0):Hide(1)
GetAsteroid(0):SetVisible(1,false)
end
function Initialization()
NumberofBases = 0
Data = {}
end
--[[function AddBase(x,y)
NumberofBases = NumberofBases + 1
Data[NumberofBases] = {
ID = NumberofBases
Position = {
X = x
Y = y
}
Owner = 0
Units = {}
Units[NumberofBases] = {}
for i = 1,NumEnemies+1 do
Units[NumberofBases][i] = 0
end
Draw = true
Production = math.random()
}
end
function GetBase(id)
local self = {
ID = Data[NumberofBases].ID
Position = {
X = Data[NumberofBases].Position.X
Y = Data[NumberofBases].Position.Y
}
Data[NumberofBases].Owner = 0
Data[NumberofBases].Units = {}
for i = 1,NumEnemies+1 do
Data[NumberofBases].Units[NumberofBases][i] = 0
end
Data[NumberofBases].Draw = true
Data[NumberofBases].Production = math.random()
}
end
function LevelDraw()
if NumberofBases > 0 then
for i = 1,NumberofBases do
DrawSprite(7,GetBase(i).Position.X,GetBase(i).Position.Y,1,1,1,1,50)
end
end
end
function ScreenDraw()
end]]
function LevelSetup()
Globals.G.Asteroids=0
Globals.G.EnemyFactionsMin=0
Globals.G.EnemyFactionsMax=0
SetBackdropColour(0,0,0)
AddAsteroid(0,0)
Globals.Flowers.Available = 0
Initialization()
BasicSaveFolder = "C:\\EufloriaSaves\\"
end
function LevelLogic()
GetAsteroid(0).Radius = 0
GetAsteroid(0):Hide(1)
GetAsteroid(0):SetVisible(1,false)
end
function Initialization()
NumberofBases = 0
Data = {}
end
function AddBase(x,y)
NumberofBases = NumberofBases + 1
Data[NumberofBases] = {
ID = NumberofBases
Position = {
X = x
Y = y
}
Owner = 0
Units = {}
Units[NumberofBases] = {}
for i = 1,NumEnemies+1 do
Units[NumberofBases][i] = 0
end
Draw = true
Production = math.random()
}
end
function GetBase(id)
local self = {
ID = Data[id].ID
Position = {
X = Data[id].Position.X
Y = Data[id].Position.Y
}
Data[id].Owner = 0
Data[id].Units = {}
for i = 1,NumEnemies+1 do
Data[id].Units[id][i] = 0
end
Data[id].Draw = true
Data[id].Production = math.random()
}
end
function LevelDraw()
if NumberofBases > 0 then
for i = 1,NumberofBases do
DrawSprite(7,GetBase(i).Position.X,GetBase(i).Position.Y,1,1,1,1,50)
end
end
end
function ScreenDraw()
end
Hmm, gotta ask you:That piece of code looks like you're trying to assign two empty tables to the variable Units. If you had a coma between to two pairs of brackets I know that Units would get assigned the first empty table and the second would be discarded (as described here (http://www.lua.org/pil/4.1.html)), but as you've got it I would have to guess it's syntactically incorrect and would throw and error.
Does this work:Code: [Select]Units = {}{}
?
But I do use:That's almost right. Here's the section on Matrices and Multi-Dimensional Arrays (http://www.lua.org/pil/11.2.html)… and HERE (http://www.lua.org/pil/index.html) is the contents page for the Lua site I seem to like spamming links for (go forth and explore! I'm sure you'll learn heaps of stuff, I know I did. ;)).(click to show/hide)
though inside of the self array::)(click to show/hide)
DR, did you know that according to massiveonlinegamer, in October last year, Azeroth had a population of approx. 12mil? That's somewhere betwwen the population of Chad and Zimbabwe, or Ohio and Pensylvania states. (data according to mog, from Activision and Wikipedia)I didn't know that, but I'm not surprised :P
Hmm, when I try to run this:(click to show/hide)
Uncommented, it crashes D:
EDIT:
Here, fixed the calling in GetBase(), but still crashing :/(click to show/hide)
function LevelSetup()
Globals.G.Asteroids=0
Globals.G.EnemyFactionsMin=0
Globals.G.EnemyFactionsMax=0
SetBackdropColour(0,0,0)
Globals.G.GreysProbability = 0
Globals.G.GreysMin=0
Globals.G.GreysMax=0
for i = 0,100 do
a = AddAsteroid(math.random(-10000,10000),math.random(-10000,10000))
if i > 0 and i <= 3 then
a.Owner = i
a:AddSeedlings(40)
else
a.Owner = 0
end
end
AIInit()
end
function LevelLogic()
while GameRunning() do
AIEngine()
coroutine.yield()
end
end
function AIInit()
--Set the globals correct:
Globals.AI.GraceTimer = 9999999
--Create variables needed for the AI
--Changeable AI, be sure to change them if you need!
AIFaction = {2,3}
AINumIterations = 10
AIGraceTime = 5 --Even though this one is here, it doesn't mean all the other normal AI variables work!
--Unchangeable, there is no real value to change...
AIPriority = {}
AINumFactions = 0
AINumRoids = -1
AINeighbour = {}
AINumNeighbours = {}
Engine = AIEngine()
--Run through all possible factions and chack if they are included, this way we can make the matrices for priorities.
for i = 1,10 do
if AIFaction[i] ~= nil then
AINumFactions = AINumFactions + 1
AIPriority[i] = {}
else
break;
end
end
--Run from 0 to a high number(more than what you would want as asteroids on a map) to find any asteroid.
for i = 0,1000 do
if GetAsteroid(i) ~= nil then
--Set all variables for the asteroids...
AINumRoids = AINumRoids + 1
AINumNeighbours[i] = 0
AINeighbour[i] = {}
for j = 1,AINumFactions do
AIPriority[AIFaction[j]][i] = 1000
end
else
break;
end
end
end
function AIEngine()
--If the gracetime is over and the AI hasn't checked yet, then the AI must do so!
if GetGameTime() > AIGraceTime and AIChecked ~= true then
--The AI will run through all of the asteroids twice to find any neighbouring asteroids.
for i = 0,AINumRoids do
for j = 0,AINumRoids do
if i ~= j then
local Xd = GetAsteroid(i).position.x-GetAsteroid(j).position.x
local Yd = GetAsteroid(i).position.y-GetAsteroid(j).position.y
local dist = (Xd^2)+(Yd^2)
if dist < GetAsteroid(i).SendDistance+GetAsteroid(j).Radius then
--As a match occours, it will make the asteroid a neighbour so the AI understands it.
AINumNeighbours[i] = AINumNeighbours[i] + 1
AINeighbour[i][AINumNeighbours[i]] = GetAsteroid(j)
end
end
end
end
AIChecked = true
else
--The gracetime is over and the AI has checked, then we iterate the chosen amount of times and...
for iteration = 1,AINumIterations do
--Choose a random asteroid to check:
local roid = GetAsteroid(math.random(0,AINumRoids))
--But also include the ID for simplicity:
local roidid = roid.ID
--Now run through all of the factions, to allow them to change the priority of the roids
for factionid = 1,AINumFactions do
local faction = AIFaction[factionid]
local ChangedPriority = false
--Check wether the faction owns the asteroid or not.
if roid.Owner == faction then
--Check conditions on the asteroid:
if roid:GetNumSeedlingsExcluding(faction) > roid:GetNumSeedlings(faction)/4 then
--The AI found out that the asteroid is under attack, so we must set the priority to lowest possible, 0!
if AIPriority[faction][roidid] ~= 0 then
AIPriority[faction][roidid] = 0
ChangedPriority = true
end
elseif roid:GetNumSeedlingsExcluding(faction) == 0 then
if AIPriority[faction][roidid] == 0 then
--We're not under attack, but our priority still says so, let's get rid of that!
AIPriority[faction][roidid] = AINumRoids*4
ChangedPriority = true
end
end
if roid:GetNumTrees() < roid.TreeCap then
if AIPriority[faction][roidid] > AINumRoids*1 then
--We need trees and our priority is high enough to not reset any attack priorities!
AIPriority[faction][roidid] = AINumRoids*1
ChangedPriority = true
if roid:GetNumSeedlings(faction) >= 10 then
roid:PlantDysonTree()
end
end
else
if AIPriority[faction][roidid] == AINumRoids*1 then
--We don't need trees, but our priority says so, let's get rid of that!
AIPriority[faction][roidid] = AINumRoids*4
ChangedPriority = true
end
end
else
end
if ChangedPriority == true then
--If we changed any priority, we have to reset all the other, "meaningless" priorities...
for checkedroid = 0,AINumRoids do
if AIPriority[faction][checkedroid] ~= 0 and AIPriority[faction][checkedroid] ~= AINumRoids*1 and AIPriority[faction][checkedroid] ~= AINumRoids*2 and AIPriority[faction][checkedroid] ~= AINumRoids*3 then
AIPriority[faction][checkedroid] = AINumRoids*4
end
end
else
--if we didn't then we must check the neighbours of all asteroids if they are important.
for checked = 0,AINumRoids do
local checkedroid = GetAsteroid(i)
if checkedroid.Owner == faction then
for j = 1,AINumNeighbours[checked] do
if AIPriority[faction][AINeighbour[checked][j].ID] < AIPriority[faction][checked] then
AIPriority[faction][checked] = AIPriority[faction][AINeighbour[checked][j].ID] + 1
if AIPriority[faction][AINeighbour[checked][j].ID] ~= AINumRoids*3 then
if checkedroid:GetNumSeedlings(faction) > 0 then
checkedroid:SendSeedlingsToTarget(faction,checkedroid:GetNumSeedlings(faction),AINeighbour[checked][j])
end
end
end
end
end
end
end
end
end
end
end
I've never actually played WoW (yes, I mean World of Warcraft), but I have seen the effects of it, viz. lack of any productive work. Minecraft on the other hand...
I'll need to do a tutorial on how to install the maps though
You could make a self-extracting RAR. That would do all the installing for you.
HAIL!!
finally, im getting back into making a level.
im using Roid forge to see what kind of resutls i can achieve with that.
ive incorporated hitman's rallysystem but am having trouble getting it to work outside of the test map it came with.. not sure why its not working in mine.
next is to add some devilish AI.
then testing begins...
;D
HAIL!!
finally, im getting back into making a level.
im using Roid forge to see what kind of resutls i can achieve with that.
ive incorporated hitman's rallysystem but am having trouble getting it to work outside of the test map it came with.. not sure why its not working in mine.
next is to add some devilish AI.
then testing begins...
;D
Ha, this made me happy to read this. Friend me on steam with hits271 or just send a message on this forum for rallysystem troubleshooting.
Make sure you paste whatever is included in the RallyModeStart to RallyModeEnd comments in the beta level code. I'm going to upload an easier to implement version by the end of today
BTW: The starfield ain't checking asteroid on the map I have :/
Any reason for that?
I use the come into the screen thing(it's seeding awesome!), but IDK how to make stars move D:
SetStarX[starID] = X coordinate of the star
SetStarY[starID] = Y coordinate of the star
SetStarZ[starID] = Z coordinate (positive is behind asteroids, negative is in front of asteroids)
SetStarX[5] = math.sin(GetGameTime()) * 500
SetStarZ[5] = math.cos(GetGameTime()) * 500
BTW, my AI doesn't pay attantion to attribs yet D:
Gonna make 'em! V 1.01 coming up then I guess :)
Which word? I removed the swear :)
function MAIEngine()
if MAINeighboursSet == false then
if GetGameTime() > MAIGraceTime then
for i = 0,MAINumRoids do
for j = 0,MAINumRoids do
if i ~= j then
local Xd = GetAsteroid(i).position.x-GetAsteroid(j).position.x
local Yd = GetAsteroid(i).position.y-GetAsteroid(j).position.y
local dist = math.sqrt((Xd^2)+(Yd^2))
if dist < GetAsteroid(i).SendDistance+GetAsteroid(j).Radius then
--As a match occours, it will make the asteroid a neighbour so the AI understands it.
MAINumNeighbours[i] = MAINumNeighbours[i] + 1
MAINeighbour[i][MAINumNeighbours[i]] = GetAsteroid(j)
end
end
end
end
MAINeighboursSet = true
end
else
for iteration = 1,MAINumIterations do
local SelRoid = GetAsteroid(math.random(0,MAINumRoids))
local roidid = SelRoid.ID
--SelRoid.Name = "P = "
for CheckedFaction = 1,MAINumFactions do
local faction = MAIFaction[CheckedFaction]
if SelRoid.Owner == faction then
local Tree = SelRoid:GetRandomDysonTree()
local Flower = nil
if Tree ~= nil then
Flower = Tree:GetSuperSeedling()
end
if Flower ~= nil then
Flower:Pluck()
end
local Flower = SelRoid:GetFlower(faction)
if Flower ~= nil then
Flower:PlantOnRandomDysonTree()
end
if SelRoid:GetNumSeedlingsExcluding(faction) > SelRoid:GetNumSeedlings(faction)/4 then
MAIPriority[faction][roidid] = 0
end
if SelRoid:GetNumTrees() < SelRoid.TreeCap and MAIPriority[faction][roidid] > MAINumRoids * 1 then
MAIPriority[faction][roidid] = MAINumRoids * 1
end
if MAIPriority[faction][roidid] == 0 and SelRoid:GetNumSeedlingsExcluding(faction) == 0 then
MAIClearPriority(0,faction)
end
if MAIPriority[faction][roidid] == MAINumRoids * 1 and SelRoid:GetNumTrees() == SelRoid.TreeCap then
MAIClearPriority(1,faction)
end
if MAIPriority[faction][roidid] == MAINumRoids * 3 then
MAIClearPriority(3,faction)
end
if MAIPriority[faction][roidid] ~= 0 and MAIPriority[faction][roidid] ~= MAINumRoids * 1 then
for CheckedNeighbour = 1,MAINumNeighbours[roidid] do
local neighbour = MAINeighbour[roidid][CheckedNeighbour]
if MAIPriority[faction][neighbour.ID] < MAIPriority[faction][roidid] then
MAIPriority[faction][roidid] = MAIPriority[faction][neighbour.ID] + 1
if MAIPriority[faction][neighbour.ID] == MAINumRoids * 1 and neighbour.Owner ~= faction then
if SelRoid:GetNumSeedlings(faction) > neighbour:GetNumSeedlingsExcluding(faction)/1.25 then
SelRoid:SendSeedlingsToTarget(faction,SelRoid:GetNumSeedlings(faction),neighbour)
end
elseif MAIPriority[faction][neighbour.ID] == 0 then
if SelRoid:GetNumSeedlings(faction) > neighbour:GetNumSeedlingsExcluding(faction) then
SelRoid:SendSeedlingsToTarget(faction,SelRoid:GetNumSeedlings(faction),neighbour)
end
else
if MAIPriority[faction][neighbour.ID] ~= MAINumRoids * 3 then
SelRoid:SendSeedlingsToTarget(faction,SelRoid:GetNumSeedlings(faction),neighbour)
end
end
end
end
end
else
if SelRoid:IsBarren() then
if MAIPriority[faction][roidid] > MAINumRoids * 1 then
MAIPriority[faction][roidid] = MAINumRoids * 1
end
else
MAIPriority[faction][roidid] = MAINumRoids * 3
local AssaultArmy = 0
for CheckedNeighbour2 = 1,MAINumNeighbours[roidid] do
local assault_neighbour = MAINeighbour[roidid][CheckedNeighbour2]
if assault_neighbour.Owner == faction then
if MAIPriority[faction][assault_neighbour.ID] > MAINumRoids * 3 then
AssaultArmy = AssaultArmy + assault_neighbour:GetNumSeedlings(faction)
end
end
end
if AssaultArmy > SelRoid:GetNumSeedlingsExcluding(faction) * 2 then
for CheckedNeighbour2 = 1,MAINumNeighbours[roidid] do
if MAINeighbour[roidid][CheckedNeighbour2].Owner == faction then
if MAIPriority[faction][MAINeighbour[roidid][CheckedNeighbour2].ID] > MAINumRoids * 3 then
MAINeighbour[roidid][CheckedNeighbour2]:SendSeedlingsToTarget(faction,MAINeighbour[roidid][CheckedNeighbour2]:GetNumSeedlings(faction),SelRoid)
end
end
end
end
end
end
if MAIPriority[faction][roidid] == MAINumRoids * 1 then
if SelRoid:GetNumSeedlings(faction) >= 10 then
SelRoid:PlantDysonTree(faction)
end
end
-- SelRoid.Name = SelRoid.Name .. MAIPriority[faction][SelRoid.ID] .. " "
end
end
end
end
But annikk, when I make movements on the star, they appear in the bottom of the starfield D:
SetStarX[1] = math.cos(GetGameTime()) * 75000
SetStarY[1] = Field + math.sin(GetGameTime()) * 75000
SetStarZ[1] = ((math.cos(GetGameTime()/1000) * math.sin(GetGameTime()/1000))/2) * 500000
Annikk, replace this with the ENGINE only!
and you have it ignore visability I guess! Gonna test :)
But annikk, when I make movements on the star, they appear in the bottom of the starfield D:
Does anyone know how an asteroid is reachable? Is it only reachable if the SendDistance of the sending 'roid hits the center of the recieving, or does it only have to touch the edge
Also, we need less stickies.
Just completed SpaceChem. :>
What is the Opposite of Bonus Called?Malus
Trying to learn Unity :)
Goin' to Abu Dhabi, are ye?Not this time.. This (long) weekend I shall be attending a wedding at a mansion in the cottswolds that used to belong to riddley scott. It will be quite insane.
-- empires 0 through 5 have default AI turned off
While Gamerunning do
for i = 0, number of asteroids do
-- AI is on by default
GetAsteroid(i).GraceTimer = 0
for j = 0, 5
if GetAsteroid(i).owner = j then
-- Asteroid belongs to a non-default-AI empire, so turn the default AI off
GetAsteroid(i).GraceTimer = 99999
end
end
end
coroutine.yield()
end
function LevelSetup()
Globals.G.Asteroids = 10
for i = 0, math.huge do
if GetAsteroid(i) == nil then
highroidID = i - 1
break
end
coroutine.yield()
end
end
function LevelLogic()
MessageBox(highroidID)
end
numberOfRoids = 0
for empireID = 0, GetNumFactions() do
numberOfRoids = numberOfRoids + GetEmpire(empireID):GetNumOwnedAsteroids()
end
Not tested:Code: [Select]numberOfRoids = 0
for empireID = 0, GetNumFactions() do
numberOfRoids = numberOfRoids + GetEmpire(empireID):GetNumOwnedAsteroids()
end
That should work. But I am still kind of a newb in lua, so test it first.
Try set highroid to -1 before the loop then make it add one to itself each time a roid is spotted :)
See if it works atleast, worth a shot :)
[...]
Won't work, didn't even test to see the result!
This is because it's so visible in the math of computers :)
Pre set the variable to -1 not 0, cause if it's 0 you count human wise: -1 it's computer wise(computers love starting at 0 :))
......
W/ever, I'll do it the old-fashioned way, by hand.
......
It wouldn't make sense starting at -1, since it's a simple counter. Add 1 when you find a asteroid, that's it.
Also the 0 starting thing, does not even apply to Lua.
While it supports it 0-starting arrays, Lua's idiom is to start at index 1. Unlike the bazilion programming languages that actually start at 0(Due to C influence).
Either way, it does not change the fact that it has nothing to do with it.
If the code doesn't work(Highly likely), it's not that.
function GetAsteroidNumber()
numberOfRoids = 0
for empireID = 0, GetNumFactions() - 1 do
numberOfRoids = numberOfRoids + GetEmpire(empireID):GetNumOwnedAsteroids()
end
return numberOfRoids
end
function Num()
asteroidnum = 0
for d = 0, 100 do
if GetAsteroid(d) ~= nil then
if GetAsteroid(d).radius > 5 then
asteroidnum = asteroidnum + 1
end
end
end
Pause()
MessageBox(asteroidnum)
WaitDialog()
Unpause()
end
FUN FACT: I'm an IDIOT!
All/Most of the codes posted work fine. However, if you put them in LevelSetup, they don't take into account any asteroids added randomly, since these are added AFTER LevelSetup. Can you guess where I was counting the asteroids? :-[
Sorry for wasting everyone's time.
.........
Heh, but the Asteroid ID's in the game starts at 0, and you don't wanna miss any of them? And it'll run a nil roid at the end, so it would be catastrophic!
Ask any programmer, things in the PC world starts with 0 usually, but Lua's arrays are intended to start at 1 so humans can easily pick it up I guess :)
numberOfRoids = numberOfRoids + GetEmpire(empireID):GetNumOwnedAsteroids()
This on the first run will return 2Not the problem, because it's not what I am doing in the code.
In the code, I am looping through all empires(which start by zero), and using the GetNumOwnedAsteroids built-in, which returns the number of asteroids.
i.e.
Empire 0 has 2 roids / Empire 1 has 7 roids / Empire 2 has 6 roids
GetNumFactions will return 3, so I need to loop between 0 and the last empire(which is GetNumFactions() - 1, because indeed it starts at zero)
Code:
numberOfRoids = numberOfRoids + GetEmpire(empireID):GetNumOwnedAsteroids()
This on the first run will return 2
On the second it will return 2 + 7 = 9
On the third run it will run 9 + 6 = 15
And in the end returns the last result, which is 15.(What I am not entirely sure, is if empty asteroids have a empire assigned to them. If not, this won't work...)
QuoteNot the problem, because it's not what I am doing in the code.
In the code, I am looping through all empires(which start by zero), and using the GetNumOwnedAsteroids built-in, which returns the number of asteroids.
i.e.
Empire 0 has 2 roids / Empire 1 has 7 roids / Empire 2 has 6 roids
GetNumFactions will return 3, so I need to loop between 0 and the last empire(which is GetNumFactions() - 1, because indeed it starts at zero)
Code:
numberOfRoids = numberOfRoids + GetEmpire(empireID):GetNumOwnedAsteroids()
This on the first run will return 2
On the second it will return 2 + 7 = 9
On the third run it will run 9 + 6 = 15
And in the end returns the last result, which is 15.(What I am not entirely sure, is if empty asteroids have a empire assigned to them. If not, this won't work...)
Thats why you just use what i posted
Empty asteroids belong to Empire 0, the greys.
public int tediousExercise(){
Scanner scan = new Scanner(System.in);
try{
int i = scan.nextInt();
scan = null;
return i;//evidence-required obvious comment
} catch (NoSuchElementException e){
System.out.println("Invalid");//evidence-required obvious comment
scan = null;
return tediousExercise();
}
}//zzzz
{2 : 1, 3, 2} //To go to planet whose ID is 2, go to 1, 3 and finally 2...
Class GlobalHook
public void Start()
{
if (!_isStarted && _hookType != 0)
{
// Make sure we keep a reference to this delegate!
// If not, GC randomly collects it, and a NullReference exception is thrown
_hookCallback = new HookProc(HookCallbackProcedure);
_handleToHook = SetWindowsHookEx(
_hookType,
_hookCallback,
System.Diagnostics.Process.GetCurrentProcess().MainModule.BaseAddress,
0);
// Were we able to sucessfully start hook?
if (_handleToHook != 0)
{
_isStarted = true;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public double Zoom = 4;
public double CameraX = 0;
public double CameraY = -100;
public int XPos = 100;
public int YPos = 100;
public bool[] MDown;
public int MouseClicks = 0;
public Form1()
{
InitializeComponent();
}
public void Render()
{
Graphics g = Panel.CreateGraphics();
g.DrawImage(Bitmap.FromFile("C:\\Users\\User\\Desktop\\C# Examples\\Test2\\WindowsFormsApplication1\\WindowsFormsApplication1\\Picture.png"), Convert.ToInt32(CameraX) + XPos, Convert.ToInt32(CameraY) + YPos, Convert.ToInt32(400 * Zoom), Convert.ToInt32(400 * Zoom));
}
private void Timer_Tick(object sender, EventArgs e)
{
Render();
}
protected override void OnMouseDown(MouseEventArgs e)
{
switch (e.Button)
{
case (MouseButtons.Left):
MDown[0] = true;
break;
case (MouseButtons.Middle):
MDown[1] = true;
break;
case (MouseButtons.Right):
MDown[2] = true;
break;
case (MouseButtons.XButton1):
MDown[3] = true;
break;
case (MouseButtons.XButton2):
MDown[4] = true;
break;
}
MouseClicks = e.Clicks;
}
private void Panel_Scroll(object sender, ScrollEventArgs e)
{
if (e.NewValue != 0)
{
Zoom = Zoom * (1 + (e.NewValue / (720*Zoom)));
}
}
}
}
NumThings = 0
Text = {}
for i = 1,math.random(1,1000) do
NumThings = NumThings + 1
Text[i] = math.random(1,100)
end
for i = 1,NumThings do
print(Text[NumThings])
end
Name: Betty
Income: 300$ daily
Taxes: 50
Children: 0
Name: Chuck Testa
Income: 999999999$ daily
Taxes: 0
Children: 35557968 dead animals
Name: Alex
Income: 750$ daily
Taxes: 100
Children: 2
Now each have their individual name, income, taxe and amount of children. But they all come from the same class... This is called polymorphism!
What I looked for was how do I check a field/run a method from every single object from the same class?
Class Shape(object):
def getArea(self):
pass
class Square(Shape):
def getArea(self):
return self.side ** 2)
class Circle(Shape):
def getArea(self):
return math.pi *self.radius ** 2
public class something{
public int squareroot(double a)
{
return Math.round(Math.round(Math.Sqrt(a)));
}
public float squareroot(double a)
{
return Math.round(Math.Sqrt(a));
}
public double squareroot(double a)
{
return Math.Sqrt(a);
}
}
public class lol {
private Something s;
public static void main(String[] args){
s = new Something();
}
}
public class Something{
private x;
private static numThings;
public Something(){
x = 1;
numThings++;
}
}
List:
0: 0,0,0
1: 0,0,1
2: 0,0,2
3: 0,0,3
4: 0,0,4
5: 0,0,5
6: 0,0,6
7: 0,1,0
...
You want the data in 7, but you don't really know that 7 contains the data. So you do a for loop though all of them to find the perfect match. But this takes performance... So we'd like to go directly to the object with the data you require, meaning no for loop. But how the heck would you do this if theres over 1000 objects on the list and only one match?
...currently each block(like in minecraft) checks for a neighbour and does that by doing a for loop throuhg all the blocks(around 10.000) when created and updated....
arr=Euflorium:GetForumAsTopicArray("User levels and modifications")
--this loop is obviously not infinite, however it's still in progress
for counter,value in ipairs(arr) do
ReadTopicCarefully(value) --yep, all of them to the last one
end
while collapsoul:GetNumCreativeIdeas()>0 do
collapsoul:CreateMoarMaps()
end
Welcome to the forum btw, you made quite the nice intro!
roid.SendDistance == math.sqrt(differenceX^2+differenceY^2)
BUT. As long as distance itself isn't needed there, it is possible to compare it this way either:roid.SendDistance^2 == differenceX^2+differenceY^2
so... can second comparation be in any way faster than first one? Asking because it's planned to run it extensively inside a loop at LevelLogic()
The second one should be faster, as you get rid of sqrt(which is very CPU costly) and still have the core. The only thing you need to do is to ^2 everything compared to it, else things will go wrong. You probably knew that already :)Kudos! Heard about sqrt before, yet wasn't so sure about it (as this operation is not that widely used with accounting)
What are you making btw? :)
First things to try are:
- a semi-random (or fractal maybe) generated map, as I'm highly impressed at EverSwarm's replayability rate.
- Own rally system integrated in it, as same EverSwarm gets me tired because of all seed sendings at Endspiel.
- An occasionally discovered nebula-like visual effect may also happen to be included, if I'll manage to make it look fine all the time and not just sometimes (consists of a bunch of huge, highly transparent, partially overlapping DrawSprite's with different colours - ID 1 and/or 5, and, sometimes, slow backdrop colour changes).
---snip---
Also, if anything that is to come from me has to be finished, it should be pretty much optimised. Currently using P4 2.8 (single core) / 1 gb ram / radeon x1600 pro(512). Default Eufloria runs just fine, but any lag coming from unefficient code is spotted easily and painfully :D
Anyways, nice to see you here! Were always looking for freshfaces...hooded figures made of binary strings.
There's a few rallying systems that shouldn't be too hard to drop into a map. Mine, I know shouldn't mess with the game.Well, you may be right. Maybe it's better to start off with something less complex and to use some modules that already has been released to not be sunk down by own ambitions. In RPG, for instance, you never go for raid-boss if you're level one ;) Gonna think on it.
Also, how does your computer still work? I though P4 chips were designed to overheat and explode?Nah-uh. Old horse runs good and feels alright since mid 2006. The only part that required replacement since this time was power supply unit.
Anyways, nice to see you here! Were always looking for freshThx, and it's nice to see that community ain't hibernated completely. Such a pain being a slowpoke like me ;)faces...hooded figures made of binary strings.
I might dust of the old programmer's notepad and restart my AI experiments, too.Been watching Merchant vs Infected and Merchant vs Mihhaelo's AI guy. Been, like, amazed. Wanting moar show. Dreaming of participation 8)
Pilchard, a bot in a human disguise!A somewhat 'matricized' Darlok actually. They were my all-time favourites at MOO series.
Anyways, cool to hear about your ideas, I'm here to help, unless I'm at school or sleeping, if you come to need help :PHehe. Shall do my best to keep you busy :P
local points = 6
for point = 1,points do
local angle = (point/points)*(math.pi*2)
local angle2 = angle
DrawSprite(1,X[roid]+math.cos(angle)*size, Y[roid]+math.sin(angle)*size, 1, 1, 1, 1, size/points) --DrawSprite(ID,X,Y,R,G,B,A,Size)
if (point == points) then
angle2 = (1/points)*(math.pi*2)
else
angle2 = (point+1/points)*(math.pi*2)
end
DrawLine(X[roid]+math.cos(angle)*size, Y[roid]+math.sin(angle)*size, X[roid]+math.cos(angle2)*size, Y[roid]+math.sin(angle2)*size, 1, 1, 1, 1, 1, 1, 1, 1, (size/points)/1.33)
end
or anything else?
Hope you get what I mean, there are variables missing and stuff, but that's how :)The code is clearly understandable, thanks. Though it's not quite what I meant, it will certainly come handy at some point anyways.
webangle = 0
should bewebangle = -1
to be sure that all works as intended. Anyway, it happens approx 1 time out of 50...
Wow! Very nice. My head is spinning but I had a good laugh at 287.
Next I'll just populate lines and intersections with asteroids. SendDistances, Radiuses, mutual reachabiities, their dependencies on minimum line lenghts, proper randomizations etc......and that's when I must thank RingDesigner and its authors for its existence! Currently implanted the web-drawing thingy into it and estimating variations of roid values of all sorts, writing down reasonable boundaries =-)
Anyways, cool to hear about your ideasIt appears that you have already done (http://www.dyson-game.com/smf/index.php?topic=1289.0) something very similar to Nebula which I've listed as planned. Holy Pluck. Sorry. Didn't mean any plagiarism. The only difference is that my plan was to bind those coloured transparent sprites to/near asteroids and make em big and dynamic (pulse/move slowly). Like, Nebula's insides. Well, I understand that those are released for public use. Just won't state anymore that such effects were my idea at first place.
Next I'll just populate lines and intersections with asteroids. SendDistances, Radiuses, mutual reachabiities, their dependencies on minimum line lenghts, proper randomizations etc... Seems not too complicated (holding fingers crossed ;) )
x=(x₁+λx₂)/(1+λ), y=(y₁+λy₂)/(1+λ).
where λ=L₁/L₂
where L₁ and L₂ are lenghts of two lines we get by splitting initial one with point we calculate.
Code: [Select]--this loop is obviously not infinite, however it's still in progress
for counter,value in ipairs(arr) do
ReadTopicCarefully(value) --yep, all of them to the last one
end
v = true
while v do
-- Derp?
Coroutine.yield()
end
for i = 0,math.huge do
--blahblahblah
end
while true do
Live()
end
Heh, Aino is faster =-)CompareVar = math.huge -- (or '-math.huge' if used with math.max)
for x = y , z do
CompareVar = math.min(CompareVar, arr[x])
end
ima leave this map makeing stuff to the geniusses i cant compute any of this oh whats that thing calld peoplke do to test maps .lol :tester thats right Please send me any map i can test or try out i might not get back to u about it in a lilBeta (or what can be called so) is underway. I absolutely don't see any reason why stuff made for the community (and own amusement of course :) ) should be closed at any stage of its development. So look for a new topic regarding open beta-test in next 24-36 hours if interested.
I want to call a function at regular intervals- every 1 second, or every half-second, etc. Ideally, I'd be able to adjust the interval to less than a second if needed. This interval, once set, does not need to be changed during the game. My computer runs much slower than most, so the time should be based on the system clock vs. "Game Time" in Eufloria so that the time interval is not dependent on the speed of the computer. The result must be whole numbers in ascending sequence. In other words, I need to have a count, but possibly slower or faster than second-intervals. I also need to be able to reset the count back to "1" when reaching a certain number, so that, for example, on reaching 100 it will reset to 1 and count up again.
Does anyone know how I can achieve this?
t = GetGameTime()
myInterval = 1
if GetGameTime() > t+myInterval then
--do stuff
t = GetGameTime()
end
So look for a new topic regarding open beta-test in next 24-36 hours if interested
On another note...;D Yeah, yeah, should read as '82 hours' actually :PQuoteSo look for a new topic regarding open beta-test in next 24-36 hours if interested
I've been holding my breath for 45 hours and am turning purple!
Hello everyone. :>Hello and I the first thing I wanted to say to you is: thank you. Your creativity is what led me to this forum, your awesome maps made me wanting to create something cool too.
What's been happening around here lately?Two new modders happened recently. One is fast and creative (http://www.dyson-game.com/smf/index.php?action=profile;u=2271), another is slow and heavy-minded (http://www.dyson-game.com/smf/index.php?action=profile;u=2264) ;)
Welcome back! I hope you stick around- your knowledge has been sorely missed by all. Aino just hasn't been the same since you disappeared! I assume you've been spending your creative energies elsewhere, like your music, perhaps? Care to share? How is Fluffy?
How is Fluffy?
Welcome back Annikk! :D
Hello and I the first thing I wanted to say to you is: thank you. Your creativity is what led me to this forum, your awesome maps made me wanting to create something cool too.
Two new modders happened recently. One is fast and creative (http://www.dyson-game.com/smf/index.php?action=profile;u=2271), another is slow and heavy-minded (http://www.dyson-game.com/smf/index.php?action=profile;u=2264) ;)
Welcome back! I hope you stick around- your knowledge has been sorely missed by all. Aino just hasn't been the same since you disappeared! I assume you've been spending your creative energies elsewhere, like your music, perhaps? Care to share? How is Fluffy?
(http://img502.imageshack.us/img502/143/fluffyandpacketfluffy.jpg)
Footage of BattleFluffy: http://www.youtube.com/watch?v=QitIEsuXwro
Now without further ado, bring on the insurmountable (hah!) programming challenges!
(http://img502.imageshack.us/img502/143/fluffyandpacketfluffy.jpg)
Footage of BattleFluffy: http://www.youtube.com/watch?v=QitIEsuXwro
Oh look, a cat sat in some cables - there's a surprise. Does she always sit in awkward/weird places? My cats do. Like, on a newspaper, while I'm reading it.Now without further ado, bring on the insurmountable (hah!) programming challenges!
Pilchard, she's from tech support :P
Is P in NP?
Annikk, IIRC, lives in Scotland. They/we drive on the left side of the road, therefore right-hand drive.
Scotland and England are part of the UK. IDK what Annikk thinks of the whole independence thing so I thought I'd specify Scotland, rather than the UK.
At least, I think he's up in Scotland...
Annikk?
(Pilchard123 08/06/11) I am actually trying to produce a method of determining strategically important asteroids atm, based on stats, how many other asteroids it can reach, and how many it can be reached by. Stats are fairly self-explanatory, but the send/recieve thing is related to its defensibility and use in offence. If it can send to lots of asteroids, it can attack lots of asteroids and be evacuated easily. It it can't be reached easily, defense can be managed easier, but can't be reinforced well.
because of the risk of losing all of my work to a new version with different Lua bindings.
AverageUsers = 17(as of today)
if Active then
Activity = Activity * 0.95
Posts = math.floor(Activity*AverageUsers)
if math.random() < 0.33 then
Active = false
end
elseif math.random() < 0.01 or Posts > 1 then
Active = true
end
function mapcreation()
for x = 1,TotalRoidCount do
AstMap[1][x] = math.random(MaxRoidRadius * 1.5,MapSize)
AstMap[2][x] = math.random(MaxRoidRadius * 1.5,MapSize)
AstMap[3][x] = math.random(MinRoidRadius,MaxRoidRadius)
q = q + 1
z = x
if x > 1 then
for y = 1,z-1 do
if math.abs(AstMap[1][z] - AstMap[1][y]) <= (AstMap[3][z] + AstMap[3][y]) * 2 then
if math.abs(AstMap[2][z] - AstMap[2][y]) <= (AstMap[3][z] + AstMap[3][y]) * 2 then
--x = x - 1
overlap = true
end
end
end
end
end
if overlap == true then
overlap = false
mapcreation()
end
end
Here, I've changed it from random coords to trigonometry(meaning no collision detection needed) :)
Could you try storing the desired send distances to an array in LevelSetup?
EG you could create an array called SendDistanceStored[n] where n refers to the ID of each asteroid.
Then, at the beginning of LevelLogic(), set all the send distances a second time like this: GetAsteroid(n).SendDistance = SendDistanceStored[n]
That should correct the send distance problems. :>
You call MapCreation() from inside itself. This has the potential to create an infinite loop, resulting in a Stack Overflow.
If you instead test the following:
if overlap == true and counter < 50 then
Where counter is initialised with the value 0 prior to calling the function, and then if overlap is equal to true then it increments the counter by one, and then calls the function again.
This means that the code will get a maximum of 50 attempts to do what it wants to do. If it hasn't managed after 50 attempts, it will abandon the attempt and proceed instead of overflowing.
The reason why it's snake shaped is because it goes outwards all the time. I made it add some distance for each asteroid so that they wouldn't touch at all.
Also, you can solve the "outside bounds" asteroid creation by taking away a small fraction from the angle.Yes. That's what I was pointing out as one of the difficulties. If I don't take away enough of the angle, they will be out-of-bounds. Take away too much, and connections between adjoining sections becomes less likely as it moves outward, and the only contact is at the center and the field takes on a wheel-spoke appearance. This is further complicated by the variation in Roid sizes- the larger the potential roid, the greater the fraction you must account for. By using a random-seed, it allows asteroids to occupy the same diameter-ring resulting in a more dense and natural-looking field (at the cost of potential collisions at the boundaries). I think these calculations could be fairly well optimized given time.
Easiest way for me to explain is by showing the code:
AstMap[0]
- .Angle = math.pi/4 + (math.random()*2-1)*(math.pi/5)[/b]
Also, hope you know that PI*2 = 360 degrees, and that you're calculating angles with radians.
Hope that explains it. If I didn't cover what you needed, tell me :)
What do you expect it to do- start an invasion of Skyrim? Is this for the new game or the Classic version? Does anyone know yet if classic stuff will be easily adapted into the new game? Will EVE be ready for modders when the new version is released?
1. Are you using the original Mutant AI that I published or the version inside the "Prisoners" map? The original Mutant AI was only supposed to "assist" the human player and not really meant to be a competitive stand-alone AI, although it could compete very well by itself under certain conditions. The newer AI inside the "Prisoners" map has been "defanged", or crippled. I don't want it to "win" but merely test the player's ability to use their resources smartly and make it enjoyable for the player.
2. The answer to your question in either case is this: The only "advantage" I've given Mutant AI is the ability to examine a Mutant-owned asteroid's neighbors without actually sending a seedling to "reveal" it, as Merchant does. Beyond that, it has no idea of anything that lies beyond its own borders.
3. I was very close to releasing a new, updated version of Mutant AI until I got side-tracked creating "The Prisoners" and "A Day in the Life". I warn you, though, that it was beating Infected quite handily and Merchant most of the time. Of course, I had the advantage of being able to tailor the AI logic to defeat the very specific behaviors of Infected and Merchant. This was very difficult, though, as the two AI's are quite different in their approaches. Merchant is light, fast, and extremely aggressive whereas Infected is slow, methodical, but extremely committed in its attacks. Merchant's downfall is the way it spreads its forces too thinly, and Infected's weakness is its predictability and ponderous reactions in moving its forces.
So I was debating whether to polish and release "Mutant II", or whatever I'll call it, as a "classic" AI or wait for the new game and release it then, if at all. After it repeatedly and convincingly beat the heavily lopsided "Infected Empire Epic Edition" map against Annikk's original AI engine (something I was never able to do playing as a human without a little cheating!) I felt that I had accomplished what I set out to do and was ready to take a break from programming. As Bonobo can attest, spending too much time at the computer can be hazardous to your health.
4. If you come up with a new AI, Annikk comes up with a new AI, and Pilchard ever gets around to developing HIS mythical AI, I would be forced to finish my new AI as well. Frankly, though, I am exhausted from these last two projects, so need to take a break before finishing Mutant II.
5. If you like, I could give you a copy of an early version that I used in testing with the "Star" map and you can play with it with the understanding that it is a developmental version. It might give your new AI some tasty food to chew on!
Aino, the 3D cubes you and Annikk have created are fun to play with, but I can't see them adding widespread value to Eufloria gameplay as constructed. However, I can see a LOT of possibilities if the objects were rendered in LevelDraw and rotated in conjunction with asteroid-plane scrolling. This would allow a map-maker to construct 3-dimensional playing fields similar to a game board with 3D objects, for example, or something similar to The Prisoners map graphics. Can you adjust the rotation so that one face is "fixed" to the asteroid plane?
I can also envision a 3D version of the Eufloria Arts Project allowing a map-maker to easily construct complex 3D polygons for map designs or illustrations. That would open up a lot of creative possibilities for entertaining eye-candy.
I believe all you need to do is change "ScreenDraw()" with "LevelDraw()". I can release a version which allows all of these things on the playing field rather than the HUD :)
I have already created more things with this 3D rendering method, like a moving background of stars(3 points for originality!), but this is not a flat plane of stars like Annikk's starfield, rather a "sphere" with a thick outer layer of stars, and the sphere rotates around the camera. The downside is the cost of comparing distances vs asteroids :(
And one more thing, polygons is likely not going to exist in Eufloria (atleast solid ones), sadly the functions we have now makes it impossible to render polygons, unless you fill every single pixel with colored rectangles(very slow!)
Awesome to see that you folks are still here … and I dearly hope to see some more up-to-date “euflorious” stuff from youse.
Speaking for myself, I anxiously check the Euflorium every day in my own hopes of seeing some new content. I fully understand Aino's above reference to "amazement" and the "out of this world" pleasure he derives from the process of turning an idea into digital reality via careful and precise mathematical figuring. Unfortunately, as you and Pilchard123 have noted in the past, "real life" interferes with the time I can devote to such pleasure. Although I have numerous ideas on cool new maps and content, I'm afraid my math and coding skills are far too poor to make them a reality in a reasonable time I can devote to such efforts. I "know" they can be done but I'm just too inefficient at the coding process to do it. So, I'm afraid it's unlikely you'll see anything substantial from me in the foreseeable future.
That being said, I do run Eufloria AI war simulations nearly every day, and it kills me to know Aino has a new super-formidable AI but won't unleash it.
Why now PM me some of your cool ideas, I'd love to work on some projects, and I currently have the time to spare. I'll need to rewrite the AI, sadly I had to wipe my Hard Drive and lost everything on it, including all my coding projects :(
The 3D thing would be an easy issue to fix (the pseudo vertices). I do believe Annikk, with the help of some programming friends, found the solution to his 3D problems. I think, after extensive math at school and a lot of recapping before exams, I have an idea on how to solve it too. I guess the problem when Annikk did it was I lacked 3D programming experience :o
You've got to be kidding!! You didn't have a back-up? That's crazy! How is that even possible? I value my time and effort way too much not to have multiple back-ups! I'm sorry for your losses!
Okay, I will try to PM you in the next few days. I'm terribly busy right now but will try to find some of my old files (I've backed up) to send you. They will help describe my ideas.
GetCameraZoom() float Gets the camera zoom - warning this value is different from the value passed in from SetCameraZoom for arcane and ridiculous reasons... the formula is (0.05f + ((float)(Zoom * Zoom * Math.Sign(Zoom)) / 10)) where Zoom is the value you passed in
...why not try to make something of your own?
I can’t remember when the last time was that I launched the classical Eufloria...And yet you keep leaving your goban to return here.
...than with what we have now...Sorry, but I'm doing the best I can!
Heh — so you know Go :) If you’re ever up for a slow correspondence game, ping me on OGS (link below), but Im not a strong player, perhaps 11 or 10 kyu.QuoteI can’t remember when the last time was that I launched the classical Eufloria...And yet you keep leaving your goban to return here.
Oh, nothing for you to be sorry — I thank you and the other folks some of my finest game experiences. It’s just that at some time I saw seedlings everywhere, and I realised I needed to do something different.Quote...than with what we have now...Sorry, but I'm doing the best I can!