Build a building

Posted By: Toryno

Build a building - 05/03/09 16:02

I want to move an entity which is a building. When the building is in an other building or in a wall of the map, the building should become red and when there is enough place for it, it should be green (so you can see if you can place it there or not). How can i realise that?
Posted By: Jaxas

Re: Build a building - 05/03/09 19:11

try this:
Code:
c_trace(my.x,my.x,USE_BOX|IGNORE_ME);
if(you != NULL)
{
 ...//make it red
}
else
{
 ...//make it green
}

Posted By: Toryno

Re: Build a building - 05/05/09 06:05

Ok nearly perfect wink
But it is green when collididating with the map, how to check this?
Posted By: Quad

Re: Build a building - 05/05/09 06:59

is map an entity or wmb block level?
Posted By: Quad

Re: Build a building - 05/05/09 07:09

also here's a small project that my sis made at the time i was teaching her lite-c.

you can build diffrent types of buildings by clicking panels, delete them by highlighting them and pressing del key, red/green shows you can build or not, also you can't build in walls and on cliffs. (i mean if one corner of the building doesn't have a ground below, you can't build it, places like edge of a cliff.)

but the code is not optimised(also pretty untidy), there are 2 or more unnecessary c_traces i guess.

f9 toggles debug mode.(you can see where c_traces hit, and the real edges of the model as a square.)

pressing r rotates the building while you are building it.

http://rapidshare.com/files/229324295/StrategyGame.rar

p.s. she's very good at lite-c but not good at English, so she doesn't post in forums. actually my cousin, but i prefer to call her my sis.

edit: fixed link
Posted By: Jaxas

Re: Build a building - 05/05/09 10:04

c_trace(my.x,my.x,USE_BOX|IGNORE_ME|IGNORE_MAPS);
Posted By: Eagelina

Re: Build a building - 05/05/09 10:07

Hi Quadraxas !
I did download your sis strategygame.
I did try to run it...
The game runs , but it is almost black. You can barley see the map. And when you select to build, you cant see a thing you are doing.
What do I need to add to the code so I can see what is happening on the screen?

I am using A7 comersial
Posted By: Quad

Re: Build a building - 05/05/09 10:31

you dont need to add anything, with 7.77 it looks like this when you run the code.c:

(i downloaded from the link to make sure.)
yeah the terrain is a bit dark but it is visible.

you can try to add lights to map, or change the skin/material of the terrain
Posted By: Jaxas

Re: Build a building - 05/05/09 10:56

Quadraxas dmeo is realy good, and for Toryno ,you can make it self and create own code wink
Posted By: Eagelina

Re: Build a building - 05/05/09 12:48

Yes the demo is okay.

I wanted to se how the code was builded up. Because I love to study code and learn that way.

It is so interesting to see how problems are being solved in so many different ways.
Posted By: Quad

Re: Build a building - 05/05/09 12:50

Hey Jaxas,
the sentence didnt make much sense, do you mean i take the code as my own and develop it further?
Posted By: Eagelina

Re: Build a building - 05/05/09 12:52

when I run it it is much darker, and when I select something to build, you se the building like shooting from the middle of the screen up to the air, and disapeares. So I dont se what you has taken pictures of.

It must be some type of setting in my version. I just bought the commercial A7 a couple of weeks ago. And havent adjusted any settings yet.
Wel I figure it out .... always do...... grin
Posted By: Jaxas

Re: Build a building - 05/05/09 12:57

hey Quadraxas, no no, it was for Toryno, i'll fix my last post wink
Posted By: Quad

Re: Build a building - 05/05/09 13:08

@Jaxas, ah i get it now laugh

@Eagelina, if they are flying up, this means that i can't find the ground, and that means either terrain is not properly loaded, or camera is looking somewhere else. i am not sure what can cause this,
but updating to 7.77 or removing the #include <default.c> line may help. I am downloading the publish-enabled 7.77 ill upload an executable so you can test if it's same or if it works. (also you can try redownloading, maybe zip is corrupted while downloading)

@Toryno, yeah you can use the code as base if you want.

---
having update problems, downloading latest update, will post the exe soon.
Posted By: Quad

Re: Build a building - 05/05/09 15:51

this is the compiled version of the file script.
if you still see the terrain black, maybe your gfx card doesnt support shader model2?

if this doesn't work too can you post a screenshot.
http://rapidshare.com/files/229473634/code.cd.rar

(this is definetely not a problem in the script probably in your pc/GS installation)
Posted By: Eagelina

Re: Build a building - 05/05/09 17:07

Originally Posted By: Quadraxas
this is the compiled version of the file script.
if you still see the terrain black, maybe your gfx card doesnt support shader model2?

if this doesn't work too can you post a screenshot.
http://rapidshare.com/files/229473634/code.cd.rar

(this is definetely not a problem in the script probably in your pc/GS installation)


Yes this one worked fine. Now I could se everything. Thanks!
What did you do?
Did you change anything in the sqript?

Edit: I did look at the content of the to downloads the first one I downloaded didnt have the terraintex3 , and I also see a skycube in the cd folder. None of these was in the other one. So it is probably those to that did the trick.... grin
Posted By: Quad

Re: Build a building - 05/05/09 18:05

the files that is not included in first download are taken from your gamestudio folder, i didnt changed anything, even aline, just publised and posted laugh

download and install latest version from announcement forum and you should be ok with the first download.
Posted By: Toryno

Re: Build a building - 05/05/09 19:05

Thank you all and thanks for the code smile
But I can't really use it, because my game is a FPS and strategy mix and the only camera option is first person and there's no cursour wink
But this is not my problem. In my game, the building should not be at the mouse cursour befor you build it, but it is in front of the player wink I also can check if the building is in another building and it becomes red then.
My only problem now is that i have not really an idea how i could check if the building is in the map(wmb file, i don't have any terrain in it yet). How could that be done?

Edit: Oh, there was a german word grin
Posted By: Jaxas

Re: Build a building - 05/05/09 19:48

sample:
Code:
var id[n]; // n is you buildings array 
var i;
...

action building()
{
 ...
 id[i]=1;
 my.skill50 = i; 
 i+=1;
 ...
 while(1)
 {
  ...
  wait(1);
 }
 id[skill50]= 0;
 ent_remove(me);
}
...

add action to building.
If you want to check building, example church has id[5], then you check if id[5]==1, if it's true, then exist, else, no.

if you can't understand what is the array, then try use some variables:
Code:
var church;
...
action church()
{
 church = 1;
 while(1)
 {
  ...
  wait(1);
 }
 church = 0;
 ent_remove(me);
}
....

then you just check if church == 1 wink
Posted By: Toryno

Re: Build a building - 05/08/09 10:54

in that way i can't check if the building is in a wall... That is my only problem now wink
Posted By: Jaxas

Re: Build a building - 05/08/09 12:48

Quote:
in that way i can't check if the building is in a wall
why not?
Posted By: Toryno

Re: Build a building - 05/09/09 18:12

Because i want to check if the building hits the map wink i mean not a terrain but a map in wmp format and no map entity
Posted By: Quad

Re: Build a building - 05/09/09 19:43

in my sister's code instead of checking for entity, you can check if all 5 c_traces return same height. then you can be sure it is on wide-enough ground.
Posted By: not_me

Re: Build a building - 08/19/09 04:51

what if im building in space...would i keep the code the same to check for models? Im planning to use a modified version of this code as a basis to build an rts...
© 2024 lite-C Forums