DizzyAGE General Coding Queries

Need help with using DizzyAGE then look here
delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Sat Mar 08, 2008 6:54 pm

ok i have another question. if you have a dynamic object with collider set to 'hard collision', can you get it to recognise when dizzy is on that particular object? not just if he's on any object like that, but actually get the code to return the ID of the object he's stood on?
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

xelanoimis
Team Yolkfolk
Team Yolkfolk
Posts: 1017
Joined: Sun Jan 21, 2007 6:34 pm
Contact:

Post by xelanoimis » Sun Mar 09, 2008 8:35 am

The hard collision with dynamic objects only rises Dizzy on their top,
but you can still achieve what you need.

For example, you could add a test to see if such objects are located under Dizzy's position. Test if dizzys position (-1 or -2 on y) is inside such an object's bounding box (x,y,x+w,y+h).
Use the ObjPresentCount and ObjPresentIdx to enumerate dynamic objects from the current room, to avoid wasting cpu with all the objects in the game.

Another idea (probably better) is to "attach" a soft collider object that would call the script collide handler, on top of the hard collider, and move them together. So when you're standing on the hard collider, you're touching the soft one and get notified in the script Collide callback. Of course, by "attaching", I mean just placing such an object there, for each hard collider you need, and have the code moving them together (similar to the chain AI).

Alex

delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Sun Mar 09, 2008 10:26 am

hmmm i was thinking of doing something like on each update of the object, test if the player x and y position is within a 'box' area on top of the object. (say between objecty-20 and objecty, and also between objectx-8 and objectx+objectw+8)

i thought that would do it.

however i now have a couple of new problems (always problems with this game!)

if i animate the objects seperately to move up at different speeds, and dizzy is on top of them, he doesn't stay on top of them, he kind of moves 'through' them, and eventually falls out the bottom. i'm using the aiupdatebubbleszone() code from TOS act one.

the other problem is i'm trying to get each object to move at different speeds, using a O_SPEED set in the object properties, but that ai code doesn't like it...

i'm starting to think about scrapping that and writing my own code...

EDIT:: oh, also, using that code (and the aiupdatebubbles() code), if you try to move the objects to a different room, it seems to disable them, and i can't find where it does it. i THINK i know where it is, but i can't find how to stop it...
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Sun Mar 09, 2008 11:36 am

-TF- wrote:hmmm i was thinking of doing something like on each update of the object, test if the player x and y position is within a 'box' area on top of the object. (say between objecty-20 and objecty, and also between objectx-8 and objectx+objectw+8)

i thought that would do it.
tried it, and it works. :)
-TF- wrote:however i now have a couple of new problems (always problems with this game!)

if i animate the objects seperately to move up at different speeds, and dizzy is on top of them, he doesn't stay on top of them, he kind of moves 'through' them, and eventually falls out the bottom. i'm using the aiupdatebubbleszone() code from TOS act one.
i set a similar query to the one above, and moved the player up the same speed as the object if it found him there. works too. :)
-TF- wrote:the other problem is i'm trying to get each object to move at different speeds, using a O_SPEED set in the object properties, but that ai code doesn't like it...
still not got this to work yet :(
-TF- wrote:EDIT:: oh, also, using that code (and the aiupdatebubbles() code), if you try to move the objects to a different room, it seems to disable them, and i can't find where it does it. i THINK i know where it is, but i can't find how to stop it...
somehow this now seems to work....

one other thing, does MaterialCheckFree() return 0 if the box moves out of the room(while the object is still in the room)? cause it seems to for me, and i don't want it to... :(
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Sun Mar 09, 2008 1:03 pm

is it possible to search for a material in the current room, without using IDs, just searching by what the material is?

this is the code i'm using, but i need to add something to the start of it to get it to search only in the current room...

Code: Select all

func Find_SpawnMat()
{
    	for(i=0;i<3;i++)
    	{
    		for(id=9003;i<9006;i++)
    		{
			idx = ObjFind(id)
			if(BrushGet(i,B_MATERIAL)!=MAT_BUBSPAWN) continue;
        		if(BrushGet(i,B_STATUS)==0) continue;
        		x = BrushGet(i,B_ X) ;
        		y = BrushGet(i,B_Y);
        		w = BrushGet(i,B_W);
        		h = BrushGet(i,B_H);
        		ObjSet(idx,O_X,x);
        		ObjSet(idx,O_Y,y);
        		ObjSet(idx,O_W,w);
        		ObjSet(idx,O_H,h);
			ObjPresent(idx);
        		return;
		}
    	}
}
i could just use BrushCount, and loop through every one until it finds one with the correct material in the current room, but i think that'd be too much bother (and very CPU-heavy) just to find three things in each room...
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

xelanoimis
Team Yolkfolk
Team Yolkfolk
Posts: 1017
Joined: Sun Jan 21, 2007 6:34 pm
Contact:

Post by xelanoimis » Sun Mar 09, 2008 1:03 pm

Yes, the idea with checking the player in the object's update is better.

If you move a platform too fast (on vertical), default dizzy code doesn't keep up with it. For example if you move it with steps bigger than 4 pixels. So a special adjustment of the player's position is ok. Take care not to force him in collision with blocking materials (like in a wall or a ceiling).

About moving with different speeds, this means either moving at different steps or more updates (O_DELAY). Anyway your object update function should do it.

Consider the ObjPresent need. If you move an object from a different room, into the current one, it must be "presented" with that function. Maybe this is the case, I don't know.

The material map is valid only for the current room, and a little border around it. So the MaterialCheckFree() should be able to test coordinates little outside the current room, but not too far. You can add checks for the coordinates to test, before testing them if you want to limit to the current room.

Alex

delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Sun Mar 09, 2008 1:12 pm

right, i've solved one issue but found another. the objects do appear in the next room, however the game seems to recognise the dynamic object that i use to spawn the objects as a 'hard' object (like a block), and stops the objects going any further when it hits them. surely a dynamic object doesn't write in the material mat, and therefore they should go straight through it?
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

xelanoimis
Team Yolkfolk
Team Yolkfolk
Posts: 1017
Joined: Sun Jan 21, 2007 6:34 pm
Contact:

Post by xelanoimis » Sun Mar 09, 2008 10:39 pm

-TF- wrote:the game seems to recognise the dynamic object that i use to spawn the objects as a 'hard' object (like a block), and stops the objects going any further when it hits them. surely a dynamic object doesn't write in the material mat, and therefore they should go straight through it?
I really don't know what is the case there.
Objects don't interact with each other and don't know about their collision, unless you added some code to do that.
Dynamic objects don't write in material map.
Check the function where you move (update) these objects.
Maybe some function you use, does some unwanted tests.

Apep
Free Range Egg
Posts: 51
Joined: Sat Feb 23, 2008 8:31 pm
Location: Milton KY
Contact:

Post by Apep » Mon Mar 10, 2008 12:26 am

In the category of coding queries,

Could someone please tell me what's wrong with this?

Code: Select all

func UseObject_235(idx)
{
     if(idx==ObjFind(128) && ObjGet(ObjFind(235),O_STATUS==0));
     {
         Message0(14,6,"MY TEXT\nMY TEXT");
         MessagePop();
         Message2(4,4,"MY TEXT\nMY TEXT");
         Message2(8,8,"MY TEXT\nMY TEXT");
         MessagePop();
         Message0(14,6,"MY TEXT");
         MessagePop();
         Message2(2,2,"MY TEXT!!!!!\nMY TEXT");
         MessagePop();
         Message0(14,6,"MY TEXT");
         MessagePop();
         Message2(3,3,"MY TEXT\nMY TEXT\nMY TEXT");
         MessagePop();
         Message0(14,6,"MY TEXT");
         MessagePop();
         ObjSet(ObjFind(5000),O_DISABLE,1);
         ObjSet(ObjFind(235),O_STATUS,1);
         return;
     }
         else
         {
              DropObject(idx);
         }
}
It's copied and pasted from my game.gs file(I changed the text so as not to give away any spoilers but the code is identical)
It comes up with this error
PARSER,0,0,"parse error"
Data\Scripts\game.gs:930
in this case line 930 is the line that says else

Bazi
Free Range Egg
Posts: 50
Joined: Fri Feb 29, 2008 2:49 pm
Location: Czech Republic

Post by Bazi » Mon Mar 10, 2008 8:34 am

Hi ! Simply remove the semicolon from the end of the third row (if ....).

Post Reply