Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Nymphodora, VoroneTZ), 1,485 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
HOW:Create entity at mousepoint IF texname == etc. #158588
10/04/07 09:35
10/04/07 09:35
Joined: Sep 2006
Posts: 106
FairyLand!!!
RruthH Offline OP
Member
RruthH  Offline OP
Member

Joined: Sep 2006
Posts: 106
FairyLand!!!
Hiya guys!

I got a bit of a problem here. My create-at-mousepoint doesn't work, and I can't seem to find the cause of the problem!

This is what I want to happen:

1. player clicks 'build unit'.
2. panel shows up saying "right click on the GROUND to place entity".
3. When player clicks on ground, entity will be created at mousepoint.

That's basically it. But let's dwelve deeper in number 2. "click on the GROUND". ..So I do a c_trace here and check the tex_name if it is equal to my ground texture name. (here comes the problem!) However, even if I click at some points where there is no "ground" (just a big invisible collision block), it still creates an entity there(on top of the collision block)! I just want to create an entity IF the mousepoint is on the ground. Hope I made sense here.

Here's the c_trace code.

Code:

function createAtMousePoint()
{
while(metro_created == 0)
{
// Trace starting point
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 0;

// Trace target
target.x = mouse_pos.x;
target.y = mouse_pos.y;
target.z = mouse_range;

// Convert 2D -> 3D
vec_for_screen(temp,camera);
vec_for_screen(target,camera);
// Do a trace to find the point where the mouse-ray hits non-passable level geometry
c_trace(camera.x,target,ignore_models|ignore_me|scan_texture);
// Now the predefined target vector holds the coordinates of the hitpoint

if(str_cmpi("Concrete01",tex_name))//CHECKS IF MOUSE IS ON THE GROUND
{
main_hint.visible = off;
close_hint();
ent_create("metroaide_final.mdl",target,metroaide);
metro_created = 1;
metro_wait = 0;
}
wait(1);
}
}



Here's the button function code:
Code:
 

panel metro_pan
{
bmap = metro_bmp;
pos_x = 8; pos_y = 416; layer = 15;
button = 0,0, metro_bmp, metro_bmp, metro_bmp2, create_metroaide,touch_null,touch_metro;
}

function create_metroaide(button_number)
{
if(tutorial_check == 0)
{
if(money >= 350)&&(metro_wait == 0) //if player still has money
{
metro_wait = 1;
snd_play(switch2_snd,20,0);
money -= 350; //Used
money_used += 350; //same as above but multiplied by 100

main_hint.string = metro_create;
open_hint();

on_mouse_right = createAtMousePoint;
metro_created = 0; //reset back to 0.
}
if(money < 350) //show NO MORE MONEY panel
{
snd_play(error_snd,100,0);
hint_nomoney.visible = on; hint_nomoney.alpha = 100; wait(-2);
while(hint_nomoney.alpha > 0){hint_nomoney.alpha -= 5 * time; wait(1);}
hint_nomoney.visible = off;
}
}
}



I'm pretty sure the problem lies in the code. I tried a couple of things in WED but it still didn't work. Hope someone can answer this. my DEADLINE is nearing....
Thank you in advance.

Re: HOW:Create entity at mousepoint IF texname == [Re: RruthH] #158589
10/04/07 11:10
10/04/07 11:10
Joined: Apr 2005
Posts: 3,076
Germany, NRW
rvL_eXile Offline

3D Artist
rvL_eXile  Offline

3D Artist

Joined: Apr 2005
Posts: 3,076
Germany, NRW
Hi RruthH,

I have contribute som RTS Scripts in the User Contributions. There are a Function, to Buld Buildings on Terrains/Models at the Mouse Cursor.

Here The Link to my Blog, the Files are in the Contribnution Section

http://rvlexile.wordpress.com/

Hope this helps u

cYa Sebastian


Tutorials:
[Blender]Terrain creation ENG/GER
[Blender]Low Poly Tree Modeling
[GIMP]Create a Texture for Terrains
CLICK HERE


Re: HOW:Create entity at mousepoint IF texname == [Re: rvL_eXile] #158590
10/04/07 11:47
10/04/07 11:47
Joined: Sep 2006
Posts: 106
FairyLand!!!
RruthH Offline OP
Member
RruthH  Offline OP
Member

Joined: Sep 2006
Posts: 106
FairyLand!!!
I'll check it out. Thanks rvL_eXile!

Re: HOW:Create entity at mousepoint IF texname == [Re: RruthH] #158591
10/04/07 12:10
10/04/07 12:10
Joined: Sep 2006
Posts: 106
FairyLand!!!
RruthH Offline OP
Member
RruthH  Offline OP
Member

Joined: Sep 2006
Posts: 106
FairyLand!!!
Hmmmm...I tried a bit of your code (don't know how to speak german, so it was a tad hard to understand the code)and put into mine, but it still doesn't work... O_O Does anyone see a problem w/ the code above?

Re: HOW:Create entity at mousepoint IF texname == [Re: RruthH] #158592
10/04/07 12:25
10/04/07 12:25
Joined: Sep 2006
Posts: 106
FairyLand!!!
RruthH Offline OP
Member
RruthH  Offline OP
Member

Joined: Sep 2006
Posts: 106
FairyLand!!!
nevermind! I solved the problem (yippiee!). w/ the help of your code eXile, thanks again. What I did was, instead of scanning the block texture, I checked the you entity if it was the ground or not. O_O wooo! I got working code!

Re: HOW:Create entity at mousepoint IF texname == [Re: RruthH] #158593
10/04/07 12:34
10/04/07 12:34
Joined: Apr 2005
Posts: 3,076
Germany, NRW
rvL_eXile Offline

3D Artist
rvL_eXile  Offline

3D Artist

Joined: Apr 2005
Posts: 3,076
Germany, NRW
Great to Hear, if u have some other Questions u can write me a PM

btw thx for Rating How much? ^^

cYa Sebastian


Tutorials:
[Blender]Terrain creation ENG/GER
[Blender]Low Poly Tree Modeling
[GIMP]Create a Texture for Terrains
CLICK HERE


Re: HOW:Create entity at mousepoint IF texname == [Re: rvL_eXile] #158594
10/04/07 12:44
10/04/07 12:44
Joined: Sep 2006
Posts: 106
FairyLand!!!
RruthH Offline OP
Member
RruthH  Offline OP
Member

Joined: Sep 2006
Posts: 106
FairyLand!!!
5* ofcourse! That was the last bug I was having trouble fixing. Okay I'll PM you when I have further questions...


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1