Gamestudio Links
Zorro Links
Newest Posts
freewhyblogelsewhere
by 9489cpjf. 06/03/24 06:06
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,301 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19056 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Minimap pointer problem #70805
04/14/06 01:41
04/14/06 01:41
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline OP
User
Trooper119  Offline OP
User

Joined: Apr 2004
Posts: 516
USA
When creating a minimap for myself (in my game) I came across this final problem I can't figure out. I can't figure out why my locator models won't move with the players. I have correctly inputed pointers, these are running and everything seems fine, can anyone tell me how my pointers all exist but causes nothing to move? Code:
 string enemydot_mdl = <enemydot.mdl>;
var enemydot_pos[3];

entity* actors_pointer;
var actors_index = 0;
var my_actors[50];

entity* crosshair_pointer;
var my_crosshair[50];

var move_crosshair[3];

function create_enemydot(actors_indexes)
{
sleep(.5); //ent_create can't happen until .5 secs after level loads
actors_pointer = ptr_for_handle(my_actors[actors_indexes]); enemydot_pos.x = actors_pointer.x;
enemydot_pos.y = actors_pointer.y;
enemydot_pos.z = 145;
you = ent_create(enemydot_mdl, enemydot_pos, null);
my_crosshair[actors_indexes] = handle(you); //actor already added one
crosshair_pointer = ptr_for_handle(my_crosshair[actors_indexes]);
crosshair_pointer.unlit = on;
crosshair_pointer.ambient = 100;
crosshair_pointer.passable = on;
crosshair_pointer.visible = on;
crosshair_pointer.z = 145;

while(1)
{
wait(4);
move_crosshair.x = actors_pointer.x - crosshair_pointer.x;
move_crosshair.y = actors_pointer.y - crosshair_pointer.y;
move_crosshair.z = 0;
ent_move(move_crosshair, nullvector);
}
}

action actor_walk_fight
{
my_actors[actors_index] = handle(my); //pointer to each actor
actors_index += 1; //put in the next number for the next actor
... //main code for actor_walk_fight
create_enemydot(actors_index - 1); //calls function create_enemy
}

all my enemydot_mdl's are formed correctly but they refuse to move I tried and tried but lol can't figure it out.


A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: Minimap pointer problem [Re: Trooper119] #70806
04/14/06 02:49
04/14/06 02:49
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Keep in mind that ent_move moves the my entity.

Maybe this code is the code you posted after its been run through a dual parallel universe filter and merged...or it could just be some gibberish I typed in for kicks.

Code:
string enemydot_mdl = <enemydot.mdl>;
// entity* ent0_;
// define hEnt0, skill22;
action enemydot {

// while(my.hEnt0 == 0) { wait(1); }
// Supposedly you is set to the entity that created this entity and you is local.
// I've seen this work in practice and have viewed posts from others indicating that it works,
// but I'm still not offering a guarantee.
// ent0_ = ptr_for_handle(my.hEnt0);
my.y = your.y;
// my.y = ent0_.y;
my.z = 145;
my.unlit = on;
my.ambient = 100;
my.passable = on;
//my.visible = on;
var move_crosshair[3];
while(you != null) {
move_crosshair.x = your.x - my.x;
move_crosshair.y = your.y - my.y;
move_crosshair.z = 0;
ent_move(move_crosshair, nullvector);
wait(1);
}
/*
while(my.hEnt0 != 0) {
ent0_ = ptr_for_handle(my.hEnt0);
move_crosshair.x = ent0_.x - my.x;
move_crosshair.y = ent0_.y - my.y;
move_crosshair.z = 0;
ent_move(move_crosshair, nullvector);
wait(1);
}
*/
ent_remove(me);
}
function create_enemydot() {
sleep(.5); //ent_create can't happen until .5 secs after level loads
you = ent_create(enemydot_mdl, vector(0, my.y, my.z), enemydot);
// my.hEnt0 = handle(you);
// your.hEnt0 = handle(me);
}

action actor_walk_fight {
//...
create_enemydot(); //calls function create_enemy
//...
// I'm dead
// ent0_ = ptr_for_handle(my.hEnt0);
// ent0_.hEnt0 = 0;
}



Re: Minimap pointer problem [Re: testDummy] #70807
04/14/06 18:12
04/14/06 18:12
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline OP
User
Trooper119  Offline OP
User

Joined: Apr 2004
Posts: 516
USA
I liked your idea for the action so I implemented it, and reworked it, so that it was in working order again, although it has the same problem, here is the tweaked code. Code:
 string enemydot_mdl = <enemydot.mdl>;
var enemydot_pos[3];

entity* actors_pointer;
var actors_index = 0;
var my_actors[50];

entity* crosshair_pointer;
var my_crosshair[50];

var move_crosshair[3];

action enemydots
{
my_crosshair[actors_index] = handle(my); //actor already added one
crosshair_pointer = ptr_for_handle(my_crosshair[actors_index]);
crosshair_pointer.unlit = on;
crosshair_pointer.ambient = 100;
crosshair_pointer.passable = on;
crosshair_pointer.visible = on;
crosshair_pointer.z = 145;

while(1)
{
wait(4);
move_crosshair.x = actors_pointer.x - crosshair_pointer.x;
move_crosshair.y = actors_pointer.y - crosshair_pointer.y;
move_crosshair.z = 0;
ent_move(move_crosshair, nullvector);
}
}

function create_enemydot(actors_index1)
{
sleep(.5); //ent_create can't happen until .5 secs after level loads
actors_pointer = ptr_for_handle(my_actors[actors_index1]); //minus 1, actor added one already
enemydot_pos.x = actors_pointer.x;
enemydot_pos.y = actors_pointer.y;
enemydot_pos.z = 145;
actors_index = actors_index1;
ent_create(enemydot_mdl, enemydot_pos, enemydots);
}

action actor_walk_fight
{
my_actors[actors_index] = handle(my); //pointer to each actor
actors_index += 1; //put in the next number for the next actor
...main part of the actor's code here....
create_enemydot(actors_index - 1);
}




A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: Minimap pointer problem [Re: Trooper119] #70808
04/14/06 18:57
04/14/06 18:57
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
If I may jump in here:
I think there are too many pointers and stuff, this could be made more simple.
But I like your code, really, finally some structured code in here! yeah.
However back to your problem.

I see that you create a dot for every actor but then it gets a bit messed up.
For example: I'm not sure if its going to work to store this actor handles in an array and count up the index variable.
One question:
Are your enemies created while running the game or are they placed to the level in WED?

My approach is for the place situation:
I'm going to work with skills here.
Code:

define id, skill20; //used by the actors and dots

var my_actors[50];
var actor_dots[50];

//uses: id
action enemy_dot
{
actor_dots[my.id] = handle(my);
while(1)
{
//to move the dot:
you = ptr_for_handle(my_actors[my.id]);
//now set the dot's position based on the you.x/y/z
}
}


//uses: id
action actor_walk_fight
{
my_actors[my.id] = handle(my);
you = ent_create(enemydot_mdl,my.x,enemey_dot);
you.id = my.id;
.. rest of your code here ..
}



Ok basicly what we are doing:
Placing a model (the enemy model) into wed, assign the actor_walk_fight action to it and setting the skill 20 (id) to a certain number. NOTE: every enemy must have a different id!
Now the actor stores a handle of itself in this array (my_actor) with the index of my.id which we gave him.
Then he creates a dot model and passes its id value to it, so every dot has the same id as his "creator".
Now the dot stores a handle of itself to another array with the id as index.
So now we have to arrays one with the handle of the actors and one with the handle of the dots, this gives us the freedom to access those in both ways.
- The actor can access "his" dot
- The dot can access "his" actor (creator)

Now in the while loop of the dot's action we just get the pointer to the actor and reset the position of the dot.


Hope this was somehow helpful

bye Thunder


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