Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (Quad, AndrewAMD), 1,007 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: function not effecting neighbour [Re: rtsgamer706] #322164
05/05/10 01:33
05/05/10 01:33
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
I think I see two problems here. In your invader_one action you write "ene = me". This won't work. Every time this function is startet ene is overwritten so that "ene" will finally point to the last invader you created, the one at 0,-8050,520.

Second thing jumping to my eye ist that you're trying to remove the rocket twice. Once in the action rocket and the other time in explode(). Removing entities twice will result in a crash.

In general I recommend not using global pointers, like rocket or ene. This often leads to confusion. There are well reasoned exceptions, like for your turret.

Are you aware your local variable "there" has no effect?

If none of the hints work, try the following: Create a new project. Add a single entity in WED and assign an action that does nothing more but moving the entity in a while loop. From there you can continue to increase the complexity of your project step by step. Be sure to test regularly. The earlier you notice an error, the easier it is to find.


Always learn from history, to be sure you make the same mistakes again...
Re: function not effecting neighbour [Re: Uhrwerk] #322449
05/07/10 01:05
05/07/10 01:05
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
Thanks for all the help you did help me fix my problem.
The only way to fix it is to make every invader run a separate action.
I don't know why but it works, thanks so much for the help.
rtsgamer706

Re: function not effecting neighbour [Re: rtsgamer706] #322563
05/07/10 21:53
05/07/10 21:53
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
ok... I lied making them separate doesn't work I just thought it did.
I still get invalid arguments in explode PLEASE HELP, I really don't know why it isn't working.
Thanks
rtsgamer706

Re: function not effecting neighbour [Re: rtsgamer706] #322568
05/07/10 22:12
05/07/10 22:12
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Every invader has to run it's own action, that's right. But they are all equal. So you can assign the same action to all of your invaders, but the me pointer will be different for each entity when the game starts.

So you got an invalid argument in explode. If you haven't changed the code the error can only come from either ent_morph(me, "pixlexplo.mdl") or
ent_remove(missile) or ent_remove(me). Comment all three lines out with a double slash like

// ent_remove(me)

The error should be gone. Remove one comment marker after the other. If the error reoccurs you found out which line gives the crash and you can think about the reason for this.


Always learn from history, to be sure you make the same mistakes again...
Re: function not effecting neighbour [Re: Uhrwerk] #322582
05/07/10 23:13
05/07/10 23:13
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
Thanks smart idea, I found that the problem is

ent_remove(missile);
but I now have some new problems!
If I put

ent_remove(me);

in an action tied to the rocket by a my.event line of code
the missile just won't disappear no matter what happens.
The other problem (get ready this is a weird one)
is that once I have gotten rid of the line

ent_remove missile

all except one of the invaders explode!
I have no clue why please help. thanks
rtsgamer706

here is my entire code
(I know most of the ent_creates are commented I am testing with the first nine invaders):



//////////////////////////////////////////////////////////////////////
ENTITY* tank;
//////////////////////////////////////////////////////////////////////
ENTITY* missile;
//////////////////////////////////////////////////////////////////////
ENTITY* ene;
//////////////////////////////////////////////////////////////////////

var invader_left = 24;

var missile_on = 0;

action miss_boom()
{
if(event_type == EVENT_IMPACT)
{
wait(1);
ent_remove(me);
}
}

action explode()
{
if(event_type == EVENT_IMPACT)
{
ent_morph(me, "pixlexplo.mdl");
wait(1);
wait (-0.25);
ent_remove(me);
missile_on = 0;
invader_left -= 1;
}
}

action invader_1()
{
my.pan = -90;
my.emask |= (ENABLE_IMPACT);
c_setminmax(me);
my.event = explode;
//////////////////////////////////
c_move (me, vector(-100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(1);
}

action invader_2()
{
my.pan = -90;
my.emask |= (ENABLE_IMPACT);
c_setminmax(me);
my.event = explode;
//////////////////////////////////
c_move (me, vector(-100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(1);
}

action invader_3()
{
my.pan = -90;
my.emask |= (ENABLE_IMPACT);
c_setminmax(me);
my.event = explode;
//////////////////////////////////
c_move (me, vector(-100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(1);
}

action invader_4()
{
my.pan = -90;
my.emask |= (ENABLE_IMPACT);
c_setminmax(me);
my.event = explode;
//////////////////////////////////
c_move (me, vector(-100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(1);
}

action invader_5()
{
my.pan = -90;
my.emask |= (ENABLE_IMPACT);
c_setminmax(me);
my.event = explode;
//////////////////////////////////
c_move (me, vector(-100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(1);
}

action invader_6()
{
my.pan = -90;
my.emask |= (ENABLE_IMPACT);
c_setminmax(me);
my.event = explode;
//////////////////////////////////
c_move (me, vector(-100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(1);
}

action invader_7()
{
my.pan = -90;
my.emask |= (ENABLE_IMPACT);
c_setminmax(me);
my.event = explode;
//////////////////////////////////
c_move (me, vector(-100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(1);
}

action invader_8()
{
my.pan = -90;
my.emask |= (ENABLE_IMPACT);
c_setminmax(me);
my.event = explode;
//////////////////////////////////
c_move (me, vector(-100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(1);
}

action invader_9()
{
my.pan = -90;
my.emask |= (ENABLE_IMPACT);
c_setminmax(me);
my.event = explode;
//////////////////////////////////
c_move (me, vector(-100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(-1);
c_move (me, vector(100, 0, 0), nullvector, GLIDE); // move invaders
wait(1);
}

action invader_ai()
{

}

action rocket()
{
my.emask |= (ENABLE_IMPACT);
missile = me;
missile_on += 120;
var there = 1;
my.event = miss_boom;
while (1)
{
c_move (my, vector(0*time_step, 0,11), nullvector, GLIDE); // move the rocket up
if (there == 1)
missile_on -= 1;
if (missile_on <= 0)
{
missile_on = 0;
there = 0;
// ent_remove(me);
}
wait(1);
}
}

action si_tank()
{
tank = me;
while (1)
{
if (key_cur)
{
c_move (my, vector(0*time_step, -5.5, 0), nullvector, GLIDE); // move the tank right
}

if (key_cul)
{
c_move (my, vector(0*time_step, 5.5, 0), nullvector, GLIDE); // move the tank left
}

if (key_space)
{
if (missile_on <= 1)
ent_create("si_rocket.mdl", vector (me.x, me.y, me.z+70), rocket); //create your tank
}
wait (1);
}
}

function main()
{
video_screen = 1;
video_mode = 7;
level_load ("");
ent_create("tank.mdl", vector (0, 50, -300), si_tank); //create your tank
ent_create("invader_I.mdl", vector (0, 750, 300), invader_1); //create an enemy
ent_create("invader_I.mdl", vector (0, 550, 300), invader_2); //create an enemy
ent_create("invader_I.mdl", vector (0, 350, 300), invader_3); //create an enemy
ent_create("invader_I.mdl", vector (0, 150, 300), invader_4); //create an enemy
ent_create("invader_I.mdl", vector (0, -50, 300), invader_5); //create an enemy
ent_create("invader_I.mdl", vector (0, -250, 300), invader_6); //create an enemy
ent_create("invader_I.mdl", vector (0, -450, 300), invader_7); //create an enemy
ent_create("invader_I.mdl", vector (0, -650, 300), invader_8); //create an enemy
ent_create("invader_I.mdl", vector (0, -8050, 300), invader_9); //create an enemy
/* ////////////////////////////////////////////////////////////////////////////////////////
ent_create("invader_II.mdl", vector (0, 750, 400), invader_one); //create an enemy
ent_create("invader_II.mdl", vector (0, 550, 400), invader_one); //create an enemy
ent_create("invader_II.mdl", vector (0, 350, 400), invader_one); //create an enemy
ent_create("invader_II.mdl", vector (0, 150, 400), invader_one); //create an enemy
ent_create("invader_II.mdl", vector (0, -50, 400), invader_one); //create an enemy
ent_create("invader_II.mdl", vector (0, -250, 400), invader_one); //create an enemy
ent_create("invader_II.mdl", vector (0, -450, 400), invader_one); //create an enemy
ent_create("invader_II.mdl", vector (0, -650, 400), invader_one); //create an enemy
ent_create("invader_II.mdl", vector (0, -8050, 400), invader_one); //create an enemy
////////////////////////////////////////////////////////////////////////////////////////
ent_create("invader_III.mdl", vector (0, 750, 520), invader_one); //create an enemy
ent_create("invader_III.mdl", vector (0, 550, 520), invader_one); //create an enemy
ent_create("invader_III.mdl", vector (0, 350, 520), invader_one); //create an enemy
ent_create("invader_III.mdl", vector (0, 150, 520), invader_one); //create an enemy
ent_create("invader_III.mdl", vector (0, -50, 520), invader_one); //create an enemy
ent_create("invader_III.mdl", vector (0, -250, 520), invader_one); //create an enemy
ent_create("invader_III.mdl", vector (0, -450, 520), invader_one); //create an enemy
ent_create("invader_III.mdl", vector (0, -650, 520), invader_one); //create an enemy
ent_create("invader_III.mdl", vector (0, -8050, 520), invader_one); //create an enemy */
////////////////////////////////////////////////////////////////////////////////////////
ent_create("invader_III.mdl", vector (0, 0, 6520), invader_ai); //create a control
ent_create("bg_black.mdl", vector (1000, 0, 0), NULL); //create the black BG
vec_set(camera.x, vector (-1900, 0, 200)); // set a proper camera position
}

Re: function not effecting neighbour [Re: rtsgamer706] #322585
05/07/10 23:41
05/07/10 23:41
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Ok, I guess it's time for some serious words. The code above shows, that you clearly missed some ideas and concepts of programming. Writing 9 times the same action for 9 equal entities is clearly beyond good and evil. Please don't take offense. You're a beginner and I am aware of this. It's a good thing you're continuously working on your skills. Keep that up.

The code above is just a mess. I will not debug it for you. That's athing you have to do yourself. The problems you describe above lead to the assumption that you have messed with pointers.

The best recommendation I can give: Delete the whole code. You're working beyond your skills here. Don't get frustrated. Sometimes when you code you realize that you're on the wrong track. This is a totally normal thing and happens from time to time - even to the most experienced gurus. Start again and start small. With small I mean that you should pick a very simple task, even if it appears to be trivial. Complete that task and make sure it runs without problems.

Some ideas for tasks you could work out one after another.
1. Create an empty level - without the invades, without the tank.
2. Done task nr. 1? Great. Now add the tank to it. Make sure you can move the tank from let to right and vice versa.
3. Up for task nr. 3? Add one (and only one!) invader to your level. Make sure the invader moves slowly down and ensure the tank still behaves as wanted.
4. No we're getting into the action. Add the missiles to the game. Look if you can hit the invader with the missile. For a start allow just one missile at a time. Then advance to multiple missiles at a time.
5. Made it this far? Superb. Even more action: Add a second (and I mean only one more) invader. Does everything work as expected.
6. Now the grande finale: Once you got everything to work add as many invaders as you want. If you've come this far you achieved a lot!

Other than that: Read the tutorials. I'm aware you stated you read them. Do it a second time. You're still messing around with very basic problems.


Always learn from history, to be sure you make the same mistakes again...
Re: function not effecting neighbour [Re: Uhrwerk] #322588
05/08/10 02:15
05/08/10 02:15
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
Thanks for the advice and I don't take offence.
I did start making the game in the order you posted but when I run
into problems I try and solve them in one way which causes a bigger error...
Obviously I am a beginner I will delete a lot of my code to try and fix the problems.
The one thing I would like to say is I did follow your instructions when I started.
I just created an empty level.
Then the tank
Then one invader
Then the ability to kill invaders
Then a bunch more invaders
I am assuming this is where I messed up so i'll go back to that stage and change destruction to movement.
The only reason I don't think this idea will work completely
is that one invader works!
If I change nothing but add a second invader I get my weird errors.
Thats why I asked the forum instead of trying more debugging.
I just don't get it. Thanks for the help and all the suggestions.
I'm going to spend some time deleting and fixing up my code but eventually I'll try and reply again once I've gotten to a later step
if only for the reason of telling you that I got it working because of your help.
Thanks again
rtsgamer706

Re: function not effecting neighbour [Re: rtsgamer706] #322626
05/08/10 14:38
05/08/10 14:38
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

Here's some more help...I hope wink

I see that you are having problems with the names of your entities and the concept of my or me.
You have declared 3 names
Quote:

ENTITY* tank;
ENTITY* missile;
ENTITY* ene;

Yet you use me or my in all your code because you want more than one missile or more than one ene.

Here's the situation. Start small as Uhrwerk said.
Open an action and give me or my a name.
Use that name and only that name in that code. (think small...only one)
That should clear up what is being done to what.

Next write only one general action for every entity.
Then in the following code of the action use the name.
Code:
action xyx ()
{
	ene = my;
	wait (1);
	ene.trigger_range = 100;
	ene.flags |= (PASSABLE | BRIGHT);
	....
}


Once you have a name you can control it
from any function at any time. So use functions to control your names.

Later, you will have to change the name and there are many ways of doings this.
ex: Arrays...


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Page 2 of 2 1 2

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