Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,119 guests, and 0 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
Page 2 of 3 1 2 3
Re: a query about c_scan [Re: LogantheHogan] #147318
08/11/07 18:53
08/11/07 18:53
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
ok tried that but no joy, the sprite still will not appear,
Code:

function c_ship
{
player = my;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
you = null ;
while(1)
{
if(!you)
{
c_scan(player.x, temp, vector(360, 60, 1000), ignore_me);
wait(-0.25);
}wait(1);
}
}




Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: a query about c_scan [Re: jigalypuff] #147319
08/11/07 19:32
08/11/07 19:32
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
I'm testing my code and debugging it. I'll post the working version in a minute.

Re: a query about c_scan [Re: LogantheHogan] #147320
08/11/07 19:36
08/11/07 19:36
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
Haha okay. I have a tendency to write really buggy code and then slowly debug it over time. It always ends up working, but I NEVER do it right the first time.

In any case, here's your whole code, which should work like magic.

Code:
 
function c_ship
{
player = my;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
while(1)
{
if(you == null)
{
c_scan(player.x, temp, vector(360, 60, 1000),ignore_me+ignore_you);
}
wait(-0.25);
}
}

function event_scn();
function got_target();

function f_ship
{
my.scale_x = 2.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
my.enable_scan = on;
my.event = event_scn;
}

var enemy_handle; // a global handle we can use for transferring pointers
function event_scn()
{
if (event_type == event_scan)
{
enemy_handle = handle(me);
ent_create("cross.pcx", my.x, got_target);
}
}

function got_target
{
my.scale_x = 0.1;
my.scale_y = my.scale_x;
my.oriented = on;
my.facing = off;
you = ptr_for_handle(enemy_handle); // now YOU is the enemy
while(you != null)
{
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // turn the target toward the player
vec_set(temp,nullvector);
temp.x = 20; // change this if you need to - the distance in front of the enemy
vec_rotate(temp,my.pan);
vec_add(temp,your.x);
vec_set(my.x,temp);
wait(1);
}
ent_remove(me);
}



Re: a query about c_scan [Re: LogantheHogan] #147321
08/11/07 19:51
08/11/07 19:51
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
i`m getting a parameter unknown event_scn bad keyword in {}

here is the event_scn it is the same as your code above is`nt it?
Code:

event_scn()
{
if (event_type == event_scan)
{
enemy_handle = handle(me);
ent_create(lockon, my.x, got_target);
}
}


o and thanks for all this help btw


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: a query about c_scan [Re: jigalypuff] #147322
08/11/07 20:37
08/11/07 20:37
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
Yeah, it's the same, except yours just says event_scn, not function event scan. Was that just a post typo?

EDIT: And did you include the function protoypes from my code up there? ^^ Those are very important.

Last edited by LogantheHogan; 08/11/07 20:39.
Re: a query about c_scan [Re: LogantheHogan] #147323
08/11/07 20:59
08/11/07 20:59
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
man i`m a dunce, i forgot to write function, however the target sprite still is not appearing, here is all the code from the test level
Code:

string stars_mdl = "stars.mdl";
string galor_mdl = "galor.mdl";
string excelsior_mdl = "excelsior.mdl";

entity* enemy;

string lockon = "lockon+3.tga";
string cphaser_mdl = "cphaser.mdl";

bmap hempire_tga = "hempire.tga";

function stars();
function c_ship();
function f_ship();
function event_scn();
function got_target();
//function beam_weapons();

function main
{
///init_radar();
mouse_map = hempire_tga;
mouse_mode = 1;
level_load ("new_beginings.wmb");
wait(1);
ent_create (stars_mdl, nullvector, stars);
ent_create (galor_mdl, vector(0, 0, 0), c_ship);
ent_create (excelsior_mdl, vector(100,0,0), f_ship);
///ent_create (excelsior_mdl, vector(200,40,0), f_ship);
///ent_create (jungle_mdl, vector(1500, 10000, 0), planets);
///ent_create (clouds_mdl, vector(1500, 10000, 0), clouds);
///ent_create (jungle_mdl, vector(25000, 10000, 0), planets);
/// ent_create (clouds_mdl, vector(25000, 10000, 0), clouds);
while (1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
wait (5);
}
}

function c_ship
{
player = my;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
while(1)
{
if(you == null)
{
c_scan(player.x, temp, vector(360, 60, 1000),ignore_me+ignore_you);
}
wait(-0.25);
}
}

function f_ship
{
my.scale_x = 2.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
my.enable_scan = on;
my.event = event_scn;
}

var enemy_handle; // a global handle we can use for transferring pointersfunction

function event_scn()
{
if (event_type == event_scan)
{
enemy_handle = handle(me);
ent_create(lockon, my.x, got_target);
}
}

function got_target
{
my.scale_x = 0.1;
my.scale_y = my.scale_x;
my.oriented = on;
my.facing = off;
you = ptr_for_handle(enemy_handle); // now YOU is the enemy
while(you != null)
{
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // turn the target toward the player
vec_set(temp,nullvector);
temp.x = 20; // change this if you need to - the distance in front of the enemy
vec_rotate(temp,my.pan);
vec_add(temp,your.x);
vec_set(my.x,temp);
wait(1);
}
ent_remove(me);
}




Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: a query about c_scan [Re: jigalypuff] #147324
08/11/07 21:06
08/11/07 21:06
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
first put you = null back the player function. then try making the enemy transparent to see if the target is inside him. if so, inscrease the temp.x value.

Re: a query about c_scan [Re: LogantheHogan] #147325
08/11/07 21:42
08/11/07 21:42
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
ok tried the you = null; still no joy, i also made the scale of the sprite bigger so i`d see it regardless of were it was, but it does not appear, here is the player function now i think i put the you = null in the right spot
Code:

function c_ship
{
player = my;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
you = null;
while(1)
{
if(you == null)
{
c_scan(player.x, temp, vector(360, 60, 1000),ignore_me+ignore_you);
}
wait(-0.25);
}
}




Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: a query about c_scan [Re: jigalypuff] #147326
08/11/07 22:28
08/11/07 22:28
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
It's weird, I have your exact code running in SED and it works fine. The only other thing I can think of is that your player function has something else that's changing the YOU pointer for some reason. Try this.

entity* target_entity;

And then, in the player action, change the while loop to this:

Code:

while(1)
{
if(target_entity == null)
{
target_entity = c_scan(player.x, temp, vector(360, 60, 50),ignore_me);
}
wait(-0.25);
}



That might work?

Re: a query about c_scan [Re: LogantheHogan] #147327
08/11/07 22:48
08/11/07 22:48
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
i think it must be me, what i have done is compile the level and zipped it, would you be good enough to dl it and look over the code, perhaps you`ll see were i`ve gone wrong, i know it`s a lot to ask mate.

http://www.4shared.com/file/21849860/893a13a5/test_level.html


Why does everyone like dolphins? Never trust a species which smiles all the time!
Page 2 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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