Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 13,346 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Create Entity pointers dinamicly (runtime) #131338
05/23/07 20:30
05/23/07 20:30
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
Hallo,

In my game the player can create some entity in runtime.
I would like to know how I could create one pointer dinamic for this entity.
I have this code:
Entity* name;

But this code I have to write it before the action. I would like to create this code into one fuction like:
Function CreateEntityDim()
{
...
Entity* name;
...
}
I tried to do this, but it is not possible.
Someone knows how I could program this code into the function?

Thanks

Re: Create Entity pointers dinamicly (runtime) [Re: amadeu] #131339
05/23/07 20:50
05/23/07 20:50
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
What do you need this for?
you´ve got the my and you pointer. You can use my.parent as well.
If you need more then these pointer, use skills or vars:

my.skill30 = you; //skill30 is set to the handle
wait(1); //you is set to null every frame
you = my.skill30; //you points at the same entity as it did before the wait(1);

Re: Create Entity pointers dinamicly (runtime) [Re: Slin] #131340
05/23/07 21:09
05/23/07 21:09
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
In my game I could create many object dinamicly (one, two, three,...) and this object have one function in the game. To create these objects my game read one xml file and I can insert more object in xml. one example (I have 1 player and 1 arrow that follow the player):
Entity* Arrow1;
Entity* player1;

action CPlayer
{
player1 = me;
my.invisible = on;
}

action ArrowAvatar1
{
ArrowAv1 = me;
my.invisible = on;
}

function ArrAv1Pos()
{
while(1)
{
if(player1 !=null)
{
ArrowAv1.x = player1.x ;
ArrowAv1.y = player1.y - 250;
}
wait(1);
}
}

If I create in xml other player and arrow I muss programming before the pointers for these two new object but I want that the function create this entity pointers automatically into the function.

How could I do?

Re: Create Entity pointers dinamicly (runtime) [Re: amadeu] #131341
05/23/07 21:20
05/23/07 21:20
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
maybe I do not understand... but can't You do this with simple you pointer?
create next player and inside his action write:

you = ent_create("arrow.mdl",my.x,arrow_fun);
and then in arrow_fun in loop
my.x = you.x;
my.y = you.y - 250;

or in player action
my.skill70 = ent_create("arrow.mdl,my.x,null)
and in the same player action in loop
you = my.skill70;
you.x = my.x;
you.y = my.y -250;

Or I missed something

Last edited by tompo; 05/23/07 21:20.

Never say never.
Re: Create Entity pointers dinamicly (runtime) [Re: tompo] #131342
05/23/07 21:28
05/23/07 21:28
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
thanks.

I have another question.
In my game I have 10 player (entity or avatars) and somewhere in the game I want to know where is the player5. How I could get the position (x,y,z) of player5 with yours solution? How would be the code?

thanks.

Re: Create Entity pointers dinamicly (runtime) [Re: amadeu] #131343
05/23/07 21:44
05/23/07 21:44
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
every player go at the begin of his action through a loop and put his pointer into an array, if u want to have the number 5 u just ahve to pcik the 5th array-element

Code:
action player
{
var i;
while(i<10&&i!=0)
{
i+=1;
}
player_ptr[i]=me;
}



if u want to get the position just write:
Code:
my=player_ptr[4];



edit: if you player 5 is a special entity u have to say it the engine per skill

so the action would be that way:

Code:
action player
{
player_ptr[my.skill1-1];//-1 becasueif he's player number 5he get the index 4
}



Last edited by Scorpion; 05/23/07 21:45.
Re: Create Entity pointers dinamicly (runtime) [Re: Scorpion] #131344
05/23/07 21:54
05/23/07 21:54
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
Thanks again.
I did not understand the array:
player_ptr=me;
I need to define the array player_ptr?
What kind of object will be the array Player_ptr (variable, string, entity, etc)? and how I will define this array?

thanks

Re: Create Entity pointers dinamicly (runtime) [Re: amadeu] #131345
05/23/07 22:29
05/23/07 22:29
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
you may create a var and define
f.e.
var number_var;
define number,skill1;

then each time you create entity (player) add +1 to number_var;
something like:

number_var +=1;
you = ent_create(bla,bla,bla)
you.number = number_var;
so every player will have his own number skill

then if(you.number == 5){show me your position;}
like:
var avatar_pos[3];
if(you.number == 5){vec_set(avatar_pos,you.pos);}
it means...
avatar_pos.x = you.x;
avatar_pos.y = you.y;
avatar_pos.z = you.z;

Last edited by tompo; 05/23/07 22:32.

Never say never.
Re: Create Entity pointers dinamicly (runtime) [Re: tompo] #131346
05/24/07 05:54
05/24/07 05:54
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
I think very few if any use it but...
Using entity linked lists / entity arrays plugin (eLL) I might find pos of player 5 like this:
Code:

entity* ent0;
define _id, skill38;

// create players
function plfCreate() {
var i = 0;
eLLsDelete();
eLLsNew(1);
while(i < 10) {
ent0 = ent_create(<player.mdl>, pos, function);
ent0._id = i + 1;
eLLPush(0, ent0);
i += 1;
}
}

// find player pos
function plfPosFind(id, &_pos) {
eLLNextReset(0);
ent0 = eLLNext(0);
while(ent0 != NULL) {
if (ent0._id == id) {
vec_set(_pos, ent0.x);
return(1);
}
ent0 = eLLNext(0);
}
return(0);
}

// plfPosFind(5, temp);


get eLL here (ver. 6.5 will be uploaded later)


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

Gamestudio download | 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