Author Topic: What are you working on? :D  (Read 261001 times)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #200 on: June 09, 2011, 11:28:11 PM »
I am working on Deactivated Pseudo-Vertices!  Intersecting plane management!  And other neat stuff.  :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #201 on: June 09, 2011, 11:50:23 PM »
I am releasing a new function!

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #202 on: June 10, 2011, 08:58:58 PM »
Today I have focused on three things:


1) Tidying up the 3D Engine so it's neat and concise, before I start working on faces..

2) Modifying the 3D Engine so that it will accept copy+pasted objects without any additional code changes.

3) Planning an overall structure for the face-inclusive code:


Code: [Select]
-- 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
« Last Edit: June 10, 2011, 09:05:43 PM by annikk.exe »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #203 on: June 14, 2011, 03:39:48 AM »
Working on somethuing secret... It is similar to Gravity in some ways...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #204 on: June 16, 2011, 12:39:34 AM »
The vertex visibility problem has got me stumped. :S
It should work.... I have theorycrafted out all the formulas used and it works for sample data written out on paper..  but the observed behaviour is different from what is expected.

I need a breakthrough.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #205 on: June 16, 2011, 12:46:10 AM »
What's the problem, exactly?

EDIT:Ha... I'm having trouble in my computing lessons. I keep putting Lua constructs into VB.NET programs. And looking like an idiot.
« Last Edit: June 16, 2011, 12:53:22 AM by Pilchard123 »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #206 on: June 16, 2011, 03:52:03 AM »
Lol Pilchard xD

I can't wait til I start with computer science, though it is 5 years to wait...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #207 on: June 16, 2011, 04:08:10 AM »
Dropped my idea, It was about waves pushing asteroids, making a randomly changing asteroid field...

New idea: Some kind of adventure thing, with quests(Eufloria style :D)

What I want:

 - Some kind of randomly generated asteroidfield, maybe even several :)
 - A SFX generator, like mists and... stuff...
 - Random quests, so each time you do the map, you'll get different objectives
 - A neat display for the objectives :D
 *The objectives thing needs an engine to do that stuff, maybe I could even save it on the harddrive, so when you play there will be some positive and negative things happening?

What I need to do(hate this list :P):

 - A random terrain generator, capable of generating neat and organic asteroidfields, but still there will be something nifty and scary(not achieveable in Eufloria(flowerpower :D) :/) things and places...
 - An Objective generator, storer, displayer, tracker and starter, this might be done in fewer functions tough :P).
 - Create a SFX... thing...

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #208 on: June 16, 2011, 05:30:37 AM »
@Aino: Check out the map “Project Asteroids”  by Crypton, if you haven’t done so yet, IIRC this created a new asteroid field every time, maybe it can be of some help?

http://www.dyson-game.com/smf/index.php?topic=695.msg4022;topicseen#msg4022

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #209 on: June 16, 2011, 05:31:35 AM »
Bonobo, for me it only creates a filled circle of asteroids...

I'm more interested in Annikks EverSwarm map generator...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #210 on: June 16, 2011, 05:58:18 AM »
EverSwarm was successful in addressing some very complicated problems like creating a field of asteroids that are all interconnected.  However there _is_ a pattern to the levels it generates, and there is room for improvement.  Dig in!  Ask questions if you're unsure of anything in the Everswarm code.. :>

I fixed a bug with the cube - one of the faces was misdeclared.  I've also enabled all the faces now, and there is definitely something still wrong with the vertex visibility.
Going to have a think about it tonight.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #211 on: June 16, 2011, 06:00:11 AM »
Good job annikk, and I'll see what I can do with EverSwarm :)

Thanks for letting me use it I guess then :D

Edit: Ugghh, been working on the SFX part for my adventure map, and it's only halfway done... I haven't even tested it :/

But I have all day :P
« Last Edit: June 16, 2011, 06:03:24 AM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #212 on: June 16, 2011, 03:27:15 PM »
Now it is done, it worked on the first try, so I'm really happy... Now to the quest, but school first :o

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #213 on: June 16, 2011, 05:42:40 PM »
So vertex visibility is totally fixed and working now.  The only thing left to do for it, is looking like it's going to be the hardest part so far.  That is, checking whether a vertex that is detected inside a face is further away from the camera than the face itself.

That will involve finding the equation for a plane based on 3 coordinates, and finding the intersection between a line and a plane in the 3D system.  I found some videos about that last night and it is definitely not trivial looking stuff..

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #214 on: June 16, 2011, 09:35:09 PM »
Need ideas for quests :)

Got theese on my mind:

    - A classic killblow, simpole gathering army and stuff...
    - Fighting a "castle", which has many minions at it's disposial...
    - Dunno D:

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #215 on: June 16, 2011, 09:42:38 PM »
Destroy as many crates as possible within 30 seconds.
Gather X amount of resources within a given time.
Rescue the baby dragon from the clutches of the evil princess!

Dunno..

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #216 on: June 16, 2011, 09:51:19 PM »
Ughh...

Annikk, this is about my adventure mode ghameplay for Eufluria :)

So gathering more units than the enemies(faster too) could be a sub-challenge(like in-game...)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #217 on: June 16, 2011, 10:02:35 PM »
But you have crates, right?  I think that there should be crates.  :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #218 on: June 16, 2011, 10:05:29 PM »
I don't think there is any crates in Eufloria D:

Eufloria! Y U NO have crates?!

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #219 on: June 16, 2011, 10:08:35 PM »
Eufloria does indeed lack crates.
But not for long... :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #220 on: June 16, 2011, 10:21:01 PM »
Why so?

We've gone from on topic to off topic already xD

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #221 on: June 16, 2011, 10:24:56 PM »
Working on quests, beginning the map with some fancy "newbie" maps, which will test your skills somehow, after that you'll get random missions :P

Code: [Select]
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

Looking good? Mind that that is actually directly from the code xD

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #222 on: June 16, 2011, 10:39:14 PM »
Looks interesting.. :>  And sounds complicated!  Hope you've spent lots of time planning it...  I am a big fan of planning, as you can probably tell from the amount of stuff I've written about the 3D engine.  :P

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #223 on: June 17, 2011, 02:12:26 AM »
Try generating  fractal patern of roids.

dragoonreas

  • Seedling
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #224 on: June 17, 2011, 02:23:10 AM »
Try generating  fractal patern of roids.
You mean using a tree fractal like this?

… I really need to find the time to finish that at some point. :-\

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #225 on: June 17, 2011, 02:30:40 AM »
A tree fractal isn't random.. :>  But with that said, I really like mathematically-generated levels.  The spiral in Infected Empire is my all-time favourite.. :>

Also, technically Everswarm isn't random either.  Nothing is random... :p  ./philosopher

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #226 on: June 17, 2011, 02:47:08 AM »
I'll doa nything you guys ask for, I wanna make it some kind of thing you can play 5 times and still be amazed(excluding the starts though...)

I also got plans for reinforcements, like you can place an extra amount of seedlings on the next time you play, for each time you get around 10% of the amount of seedlings you gathered max, so 4k is 400...

I wanna do portals, but because of the removing thing is crashy and unstable I won't use it... And ofcourse I'll make bridges ;D
(I fyou wonder what bridges are in Eufloria, it is a controllable asteroid that moves when another asteroid isn't being watched... Use yuo imagination to sere it :P)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #227 on: June 17, 2011, 02:48:10 AM »
This will take time and thinking, the best part about coding, the worst part is debugging and troubleshooting...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #228 on: June 17, 2011, 03:11:26 AM »
Every hour you spend planning reduces the troubleshooting time by 3.. :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #229 on: June 17, 2011, 03:19:01 AM »
You've told me before, and I've already gone through it... But my coding begins to get auto, so it works often at first attempt o.O

But there is alot going on in my head as I code, I look for problems, possible changes and neccesary ones... Sometimes though, I get errors I don't understand, cause I've never seen such a situation, like just now I had to put and end after a return() becuase it was in a for loop I think, I never did anything, so I don't know for sure :o

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #230 on: June 17, 2011, 03:23:30 AM »
Now as we are ohn it, why doesn't this code work?

Code: [Select]
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

Error:
"Index was out of range. Must be non-negative and less than size of collection. Parameter name: index"

But when I add more lines to the save myself, it still ain't workin'...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #231 on: June 17, 2011, 03:28:28 AM »
Hmm, can you explain what this line says?

Code: [Select]
for line in file:lines() do

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #232 on: June 17, 2011, 03:30:59 AM »
For each line in the file, do something... magically the output line in each loop is the text in the line :D

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #233 on: June 17, 2011, 04:04:31 AM »
Still need help though -.-

This problem was very unexpected and I don't see how to fix it... *sigh*

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #234 on: June 17, 2011, 05:55:36 PM »
Well, if you really have no idea what is going wrong, comment out tons of your code and see if it works then.  If it's still not working, comment out some more.
Once you have a level that loads, start un-commenting things bit by bit, until you find the part that stops it from loading.  Usually this method will eventually let you boil the problem down to a single line of code.  :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #235 on: June 17, 2011, 07:42:51 PM »
Code: [Select]
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

The newest code...

The "return" is the problem, but why is it causing the problems?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #236 on: June 17, 2011, 09:01:19 PM »
Try declaring linetoreturn as a global variable, rather than local.  Don't know if that will fix it or not though..

dragoonreas

  • Seedling
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #237 on: June 17, 2011, 09:56:22 PM »
It looks like you're trying to use the local variables linetoreturn and reqline outside of the blocks you declared them in.
This will tell you about the visibility rules of variables in Lua.

Try this (I'll leave you to decide whether or not the two variables need to be initialised at declaration):
Code: [Select]
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


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #238 on: June 17, 2011, 10:05:36 PM »
For the last few days, I've been thinking about a new feature I might add after I've finally finished doing this Faces shenanigans..

I was thinking about adding reflections.  You could specify that a particular face is shiny, and then draw lines on the face based on the positions of other objects in front of it.

How to make a good lookign reflection, though?

Well I had figured to have a very thin central line with an alpha of maybe 40%... and a thicker line over the top of it, with alpha 10%.. or something.
That would hopefully give a sort of diffuse glow to the thing.

Obviously the maths would be totally insane, but eh..

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #239 on: June 18, 2011, 01:08:25 AM »
I'm fairly sure the thing is amazing enough as it is...

EDIT: Also a semi-accepted golf match to create a code to check if a number is perfect or not. This may devolve into a whole tournament involving equally pointless programs.

Plus side, the guy doesn't use GOTO statements anymore.
« Last Edit: June 18, 2011, 01:19:25 AM by Pilchard123 »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #240 on: June 18, 2011, 01:37:17 AM »
It's working fine now it seems, but why is local variables affecting the return? And the error message was very missleading, telling something about that the number had to be non-negative...

Anyways, thanks... Now I can finally code the maps, and I want as many map types as possible :)


DERP!!

It ain't working after all -.-

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #241 on: June 18, 2011, 02:03:32 AM »
I acctually want to add the possability to do maps outside of the lua, doing so it runs from text files instead, much better and cleaner :P

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #242 on: June 18, 2011, 09:33:15 AM »
In the morning, I get to coding.  Lets implement this thing !

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #243 on: June 18, 2011, 08:23:09 PM »
just got a cool idea for a map, you do the Solar Conquest map generator, andf then have the capturing alike risks, but not eh spawning... After so, you must plant a fertilizer(custom tree :D) on the asteroid, which then increases the treecap to 3 after time(from 0 to 3!) :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #244 on: June 18, 2011, 11:00:30 PM »
I still need help with the loading thing, here is the code:

Code: [Select]
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

I guess the code will get around 4k lines or more :o

And please don't boother other errors like some stuff missing, I was in the middle of the coding... Gonna fix that :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #245 on: June 19, 2011, 12:41:22 AM »
I'm soon going to create the loading of levels for my map, so you can create you own :)

Though, you'll need to learn a few stuff, cause it doesn't come out simple!


Or maybe not... unless someone know how to execute a lua styled file from a lua file... Cause it would be hard to have all the flexability without that :/

EDIT: Atlewast I'll need a day of planning, better start now :D

EDIT2:

I guess a mapfile might look a little like this:

Code: [Select]
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

EDIT 3:

My guide:

Code: [Select]
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!)

But, this limits the player pretty much :/

How do you make in-game events???

EDIT 3:

Figured alot of stuff out, for example how to make custom values and then importing it :D

You'll do math at the custom values, nothing else though... But does that matter?
« Last Edit: June 19, 2011, 03:57:51 AM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #246 on: June 19, 2011, 05:31:55 AM »
Wooo!

I'm up to 2k lines already...

But now I am fixing the last of what is needed though, the map loader, which is fairly huge o.O

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #247 on: June 19, 2011, 06:19:04 AM »
Now as I am fully done(hopelyfully D:) I need to get one thing fixed, and it is not about the return, it is the MissionsDone var that is unstable x.x

EDIT: I did it!

It's so retarded that I needed to do it to a numbe... DEEERP... r, I needed to add a... Derp?... tonumber() function to convert it from a... derp -.-... string to number :/

This has been troubling me for aslong as I've been doing this code(apr. one day o.O)

Now I need maps, alot of em' guys/girls!

I'll make a guide soon, just gotta test if all the functions work properly :)

EDIT 2:

Arghhh, need help with the loadmap function, it won't work :/

Code: [Select]
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

The error I get, comes particularilry from the createvalue activation :P

It is the customvalue[id] = val that causes it :/
« Last Edit: June 19, 2011, 08:57:15 AM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #248 on: June 22, 2011, 04:27:24 AM »
May it be that local variables disappears as the for loop runs again?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #249 on: June 22, 2011, 05:08:45 AM »
http://www.lua.org/pil/4.2.html

Think that might be it.  Make them all global and see if it works.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #250 on: June 22, 2011, 05:12:55 AM »
Gonna do, tommorow :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #251 on: June 22, 2011, 10:20:50 PM »
I jsut removed the external map loading thing, causing too many problems -.-'

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #252 on: June 23, 2011, 09:04:40 PM »
Next on to-do list, create a new, less system req. CC :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #253 on: June 23, 2011, 09:53:55 PM »
A nice little code for thoose who want it:

Code: [Select]
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

Very useful for creating boxes that aren't having just one colour and fills the whole box :)
« Last Edit: June 23, 2011, 10:57:02 PM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #254 on: June 23, 2011, 10:26:43 PM »
This time I'll make CC more advanced, but easier to handle :)

If you have tested the last one, you'll see that Defense is affecting all asteroids, well, I'm trying to make it affect the asteroids with enemies nearby, and if you want, the other asteroids can provide the "threatned" ones with seedlings :)

And the global values won't be shown anymore, if you want to see the current values for the asteroid, hover your mouse over and it will display :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #255 on: June 24, 2011, 01:40:08 AM »
I've been coding CC so much that it automatically comes to me how/wat to write :D

there has been no problems for now, luckily :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #256 on: June 24, 2011, 07:49:10 AM »
I love the new CC setup, it's so much more dynamic than the last one :D

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #257 on: June 24, 2011, 10:13:16 AM »
The new CC:

*Spoiler alert: this image contains some of the features of the map "Adventure"!
(click to show/hide)

What do you think?

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #258 on: June 24, 2011, 10:38:54 PM »
I'm not good at names, but some of you might be: I need a name for this action: "Select asteroid to get a disallowed path"

You see how bad I am? xD

It's for the CC, to disallow a path, this time it's more complex but yet simplier than last, last time there were barriers, now a SPECIFIC neighbour is disallowd to be traveled to, instead it will choose another(if possible) path, rather than crossing that one :)

I'm also gonna add a double click shortcut, you can choose what it is gonna be, default is rally :P

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #259 on: June 24, 2011, 10:48:20 PM »
Avoid.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #260 on: June 24, 2011, 11:09:54 PM »
Damn xD

Why didn't I think of that D:

Anyways, thanks alot :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #261 on: June 25, 2011, 03:06:35 AM »
Yes! Now there are waypoints shown from each asteroid the player owns, if wanted... Also if you hover over and the waypoints are no shown, there will be waypoints flowing out of the asteroid hovered over!

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #262 on: June 25, 2011, 05:58:30 AM »
How can you visualize a shortcut, not IR but on the computer?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #263 on: June 25, 2011, 09:34:19 PM »
...wut?

Also, trying to learn how to use Unity.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #264 on: June 25, 2011, 09:57:50 PM »
Unity uses JavaScript :D

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #265 on: June 25, 2011, 09:59:19 PM »
I am working on my computer.  It won't start. :<  Writing this from another machine...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #266 on: June 25, 2011, 10:23:41 PM »
When does it fail?

[bad joke]Btw, this belongs in the Support / troubleshooting / bug reports :P[/bad joke]

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #267 on: June 25, 2011, 11:05:52 PM »
Unity uses JavaScript :D

A variant thereof, yes. The only real similarity is it's syntax. You can also use C# or Boo.

Upside, it's free.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #268 on: June 25, 2011, 11:34:12 PM »
I got it installed, grats on your 500th post xD

I like C# best... Because it is very alike lua IMO :P

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #269 on: June 26, 2011, 02:28:50 AM »
Maybe I should update my AI, now it will save a file, saying how badass or frightened and crazy the AI is?

Maybe have several values like:

Combat (how often the AI will/wants to come into combat)
Defendant(this one might be combined with the Combat one, over 50 and it's more combat, under and it's more defending? At the middle it has no effect :D)

Risking(how much will the AI risk? 0 is nothing, gather a huge army for attacking and 100 is jsut sending the army at once, even if it's not large... Combine this with defendant and you get how many seedlings(percent) the AI will leave behind)

Caring(Will the ai send back seedlings after a lost battle? Or will it not care...)
Supportive(if the AI looses a battle, will it send some to support?)

This is just an Idea, it might not happen though. Atleast it needs tons of programming just to make it know when it lost something and some values should be increased D:

Then afterward I'll need another tons of codes to make the AI respond to lose/winning of battles...

Planning...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #270 on: June 26, 2011, 02:38:50 AM »
Maybe just make a plain new AI?

This time supporting the Neigbour system CC has, you can use the old one if you set Movingroids = true though :D

This time I'll make it dependant on the neighbours, nothing will happen individually, like in the "old" one :P

Edit: Also, I'll make it occupate all the mpires you wish, not only one :D
« Last Edit: June 26, 2011, 02:45:24 AM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #271 on: June 26, 2011, 02:55:52 AM »
Because of several empires, I got no real idea how to save tha values, I don't want the AI's to act the same way, but still be dependant on the same Engine :D

So maybe I should make the best settings win? If it's your first play with the AI, every faction(AI owned) will get a very spread variety of number for each variable, the last AI standing is the one being saved?

After that you'll end up with AIs having something close to those values, and one empire WILL include the numbers on the save, so we can say it evolves randomly: Survival of the fittest FTW :D

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #272 on: June 26, 2011, 05:28:24 AM »
I added a frightened priority and removed if it is unexplored, still the AI must explore before any future stuff happens to the roid :D

The frightened priority tells that the AI might be in danger, though, the defend rating tells how often it will be recognized as in danger :P

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #273 on: June 26, 2011, 06:51:57 AM »
This looks right, right?

(click to show/hide)

IMO it looks right, so I'll start coding :P

I'm gonna remove the frightened proprty, it sucked, gonna replace it with Defend :D

Update: Planning alot now, I haven't started Coding after I released that list :O

This must be a good thing?
« Last Edit: June 26, 2011, 07:11:12 AM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #274 on: June 26, 2011, 07:31:49 AM »
Full plan:

Code: [Select]
--[[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:

))

}}
]]

I'm guessing thats the plans :D

Random Fact: I love making thoose Logic Maps, but I don't make them very often D:

Edit:

New plans:

Code: [Select]
--[[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?

))

}}
]]

327 lines of plans, thats pretty neat :D
« Last Edit: June 26, 2011, 08:00:08 AM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #275 on: June 26, 2011, 12:42:30 PM »
Ok, the AI is up and running(retardidly) and shows significantly difference in behaviour :D

Some of the AIs are careful with attacking(yeah, they attack: dangerously too!), meaning they send more than double of your amount of seedlings, and cares less(risking much)...

I got it working perfectly with 11 factions(max)... though the AI needs some tweaking, like planting trees on neutral(greys) roids, I don't really think there is more...

And the AI seems to be lagless, if you have 100 asteroid, there won't be much lag, unless all asteroids reach eachother xD, but in a classic map, it won't lag :P
Why? Because of the neighbour system in the new CC and the New AI now, though it doesn't support moving asteroids, but I can change it to do so, but most maps are static as far as I know :)

Edit: Added a picture, going to sleep, I'm dead tired now...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #276 on: June 26, 2011, 09:42:02 PM »
I need a new logic map, and the defend priority is going into the trash :P

The attached picture says why, the AI has alot of seedlings to attack me, but the defend priority sucks that down D:

Or maybe I've done it wrong?

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #277 on: June 27, 2011, 05:55:53 AM »
OMG, almost fazing out, the AI is traveling through multiple asteroid at the time if possible, but also seems to be godly aware of the priorities :D

But I got a problem with the priorities building up, the most common problem in creating this AI :S
*this results in long delays and the AI sending seed from one asteroid to another all the time!

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #278 on: June 27, 2011, 07:23:57 PM »
I am working on my computer.  It won't start. :<  Writing this from another machine...

Fixed.

As a side effect of the fix, my CPU is 100Mhz faster than before, and my memory is 267Mhz faster.  w00t.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #279 on: June 27, 2011, 09:59:10 PM »
What the heck? You made your Computer better without putting in new parts? Or did you put in new parts? :D

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #280 on: June 27, 2011, 10:45:52 PM »
Since the AI has failed in some ways all te time, I'll try once again... this time using only two priorities :)

So 0 is being under attack and the amount of roids is everything else, that way the AI will ignore any other actions while under attack and if not, the AI will work normally :)

So now, since the AI has different flavours of doing stuff, when the neighbours priority is 100(lets say 100 instead of the amount of roids) it will send, if there is two, the AI will send to the neighbour which needs the thing the AI desires the most(war, trees or adventuring(discovery :D))...

The old AI failed by setting priroty to incredible high and not going down when there is nearby asteroids :/

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #281 on: June 27, 2011, 11:05:54 PM »
What the heck? You made your Computer better without putting in new parts?

Yes.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #282 on: June 28, 2011, 12:06:50 AM »
What the heck? You made your Computer better without putting in new parts?

Yes.

You're so lucky >.<

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #283 on: June 28, 2011, 02:32:38 AM »
I give up >.<

Seriously, after 3-4 times of rewriting the whole system, the AI now either fails to do a send command or crashes, if it crashes the first time, it fails at the second and then crashes at the thrid attempt -.-'

I'm going to re-do the current Alien AI instead, optimising and changing it to get thoose different behaviours x.x

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #284 on: June 28, 2011, 11:04:34 AM »
Annikk, maybe, if you have time, consider optimising you AI?

It lags a little on my map, it has 41 roids D:

Maybe yuoc an do some kind of static neighbouring thing, just an idea...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: What are you working on? :D
« Reply #285 on: June 28, 2011, 06:13:50 PM »
IAIv3 will appear eventually, but I'm lacking motivation for that right now, partly because I'm knee-deep in the 3D engine, but mainly because nobody has programmed an AI that can beat it yet.  :P

If someone makes an AI that can take on IAI in a fair fight, I would have to do something about that!

Still, noted... next IAI must be more efficient with clock cycles.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #286 on: June 28, 2011, 11:08:20 PM »
Ok, I'll build an AI I hope can give your AI a kicak in the back :P

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #287 on: June 29, 2011, 01:04:55 AM »
I wonder:

How do you create a function that can be changed in-game... or I mean that has changeable fields, like for example GetAsteroid(id).Radius = 1000. The GetAsteroid is the function and after the dot comes the field I change, but how do you set up your own changeable function? So I make a function called Something() with arguments x,y and then how do I set up the function to change the x and y in-game?

dragoonreas

  • Seedling
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #288 on: June 29, 2011, 01:35:38 AM »
I think what you're looking for might be the Lua equivalent of a class.

I actually used the page linked above and this page when I was figuring out how to re-writing annikk's Gravity Template into a class. You can download it from this post and have a look if you want. The 400 something line function called DynamicGravityEngine at the bottom is the class, and there's actually also a nested class (a class within a class) called GravityAsteroid in there too.
« Last Edit: June 29, 2011, 01:40:07 AM by dragoonreas »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #289 on: June 29, 2011, 02:10:33 AM »
Thanks, I'll be reading it, but first I'm going to play TF2 :D

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #290 on: June 29, 2011, 03:51:45 AM »
@dragoonreas: You’re BACK?! How nice to see you veteran mapper again here :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #291 on: June 29, 2011, 03:59:27 AM »
The text is surprisingly long, so I forget one part before I start reading another one D:

EDIT:



THERES ANOTHER LINK :O

EDIT 2:

I have... Alot to learn! :D
« Last Edit: June 29, 2011, 04:13:57 AM by Aino »

dragoonreas

  • Seedling
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #292 on: June 29, 2011, 04:17:30 AM »
@dragoonreas: You’re BACK?! How nice to see you veteran mapper again here :)
Thanks :)

To be honest though I never really left, I was just in lurker mode due to how much Uni work I've been getting… and being introduced to World of Warcraft probably didn't help either.

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).

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #293 on: June 29, 2011, 04:26:54 AM »
Hmm, gotta ask you:

Does this work:

Code: [Select]
Units = {}{}
?

But I do use:

Code: [Select]
Units = {}
Units[NumberofBases] = {}
for i = 1,NumEnemies+1 do
Units[NumberofBases][i] = 0
end

though inside of the self array:

Code: [Select]
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

}
:)
« Last Edit: June 29, 2011, 04:32:19 AM by Aino »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #294 on: June 29, 2011, 04:55:34 AM »
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)
« Last Edit: June 29, 2011, 05:05:18 AM by Pilchard123 »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #295 on: June 29, 2011, 06:27:26 AM »
Hmm, when I try to run this:

Code: [Select]
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]]

Uncommented, it crashes D:

EDIT:

Here, fixed the calling in GetBase(), but still crashing :/

Code: [Select]
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
« Last Edit: June 29, 2011, 06:30:30 AM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #296 on: June 29, 2011, 06:53:55 AM »
I think I'll make this a little better after I'm done with what I'm going to work on :)

dragoonreas

  • Seedling
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #297 on: June 29, 2011, 08:04:40 AM »
Hmm, gotta ask you:

Does this work:

Code: [Select]
Units = {}{}
?
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), but as you've got it I would have to guess it's syntactically incorrect and would throw and error.

But I do use:

(click to show/hide)

though inside of the self array:

(click to show/hide)
:)
That's almost right. Here's the section on Matrices and Multi-Dimensional Arrays… and HERE 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. ;)).


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)

I'm a bit busy at the moment, but after just glancing over it I'd suggest you try implementing some accessor and mutator methods (also know as getters and setters), rather than trying to use the variables directly. That second link in my original post on privacy should tell you about these kind of methods and why it's good to use them. ;)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #298 on: June 29, 2011, 08:18:19 AM »
Thanks, you're lots of help :D

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #299 on: June 29, 2011, 08:43:46 AM »
God damnit, I question MYSELF more questions which I can't answer before looking at a code for 5 mins, then after I leave the code I'll probably ask myself the same question, which takes me 5 mins to solve while looking at the same code...

I wondered how I could add and get a base information, I can just do newBase() and inside have a local function that is named getBase, but how do I make it return the stuf I want. Like in Eufloria, you have GetAsteroid(id).Owner, this is an example... you also have Radius and SedDistance and Position and Attributes... How do you do it, mind explaining me when you're not busy? I can wait :)