DizzyAGE General Coding Queries
Started by delta on 9 February 2008 • 258,915 views
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
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...
[quote data-userid="23" data-postid="59852"]
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.
[/quote]
tried it, and it works. :smile:
[quote data-userid="23" data-postid="59852"]
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.
[/quote]
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. :smile:
[quote data-userid="23" data-postid="59852"]
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…
[/quote]
still not got this to work yet :sad:
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... :sad:
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...
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...
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
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.
In the category of coding queries,
Could someone please tell me what's wrong with this?
func UseObject_235(idx)
{
if(idx==ObjFind(128) && ObjGet(ObjFind(235),O_STATUS==0));
{
Message0(14,6,"MY TEXTnMY TEXT");
MessagePop();
Message2(4,4,"MY TEXTnMY TEXT");
Message2(8,8,"MY TEXTnMY 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 TEXTnMY TEXTnMY 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"
DataScriptsgame.gs:930
in this case line 930 is the line that says else
Gah!
I can't believe I didn't see that.....thank you {yolkfolk}:dizzy:
You just saved me a lot of headaches.
[quote data-userid="17" data-postid="59876"]
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.
[/quote]
ermm yeah i did add some code. the CheckMaterialFree() code (or something like that, i'm at work) which checks if the object is in a 'hard' material, and if dizzy is stood on top, checks if dizzy is in a hard material. it seems to be reading the dynamic object as a hard material. i'm gonna try something tonight anyway, i'll see if it works.
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?
right, after a lot of messing around, i've determined that the dynamic object isn't to blame. it's the fact that the objects disappear when they move to the next room. this is the code i've used:
func Check_Material(idx)
{
x = ObjGet(idx,O_ X) ;
y = ObjGet(idx,O_Y);
w = ObjGet(idx,O_W);
h = ObjGet(idx,O_H);
roomw = GameGet(G_ROOMW);
roomh = GameGet(G_ROOMH);
if(MaterialCheckFree(x%roomw,y%roomh,x%roomw+w,y%roomh+h)!=0)
{
return 0;
}
return 1;
}
so if it finds a 'hard' material anywhere, i get it to make the object disappear using:
if(Check_Material(idx)==1) { ObjSet(idx,O_DISABLE,1); continue; }
the problem is that it's classing outside the current room as a 'hard' material. and is making them disappear. i tried putting a check in the AI code to see if the object was is the current room, and if not, not to check the code above, but it massively slowed the game down. :sad:
actually, i've just played around with it a bit, and i *think* it may be because the 'life' of the object expires just as it gets to the top of the screen. so it seems that for the moment, it's not a problem.
however it does bring me onto another problem i mentioned earlier:
is it possible to search for a material in the current room, without using IDs, just searching by what the material is? i need to place objects i can use in the code in certain rooms (well, all of them!), but they need to have set positions in each room, but not the same position in each room. so i thought if i set 'blocks' in each room that had a specific material, then searched for that mat in that room, i could then set the object to the same coordinates as the mat! good in theory, but can it be done in practice?
if i can get this problem fixed (and assuming the issue at the top of this (rather long) post is not a problem, the rest of this game will be a doddle to code.
the code you posted has a problem when object gets out of the current room.
for example, if current room starts at a x=240, room's width is 240,
but the object has x=230 (is in the left room), you get:
x%240 = 230%240 = 230
when material is tested at this position this is in the right side of the current room, not in the left room (that would be -10)
as I said, the material map is from [0 to 239], with a small border for safety (below 0 and over 239).
You should adjust your test to perform inside the room.
or if the object is all outside it, to skip the test.
I'm not sure what you mean by
"is it possible to search for a material in the current room, without using IDs"
However, there might be simpler solution than to search for materials for positioning objects. Have some predefined positions, or at least have some dynamic objects and use their bounds. Searching for materials in a big area, is cpu expensive.
nice one! :tup:
alex, in the Room Properties, there are 4 'name' properties, and 8 'number' properties. how are they numbered? is it:
0 - 3: named
4 - 11: numbered
or is it
0 - 7: numbered
8 - 11: named
in other words, if i set the first numbered variable in the map, then call it in the game, which number do i need to call?? {dizzy}:huh:
Name and number properties are both numbered from 0.
Name prop.: 0 - 3
Number prop.: 0 - 7
And first number from editor from room e.g. 2,1 you get in the script in this way:
RoomGet( 2, 1, 0 );
{yolkfolk}:scratch: how does it then know you're wanting a number property and not a name property?
Hi !
This is only for number properties, you can reach them in run time, read and write them. But (due to what I see in scripts) names run in a different way. Look at the roomprops.gs file on RoomsLoadTexts() function. This is run when the map is loaded and this function calls RoomSetCustomText() callback from game.gs for each room and each text property of the room (if it is not empty) and you have to test input params of this function and then do what you want to.
So I think it's only read-only property from the map editor stored in dizzy.rt file and only at the time when the map is loaded. If you want to reach texts in run time, check first function I mentioned above and make your own read function from dizzy.rt file. Or maybe better, in the second function I mentioned above (callback), fill your own global table (array) and then read from it whenever you want.
Number properties you can read with RoomGet(rx, ry, idx - 0..7) and write with RoomSet(rx, ry, idx, value) and they are saved in the save *.gam files like object properties, so you don't have to take care of them - look at the file.gs script.
Hope I'm right and Alex will not hit me {yolkfolk}:scratch:
Bazi is right. Thanks for assistance :smile:
Numbers are 0..7 read/write anytime, saved and everything else.
Texts are just for receiving some "stuff" in the game, when it starts.
How they are interpreted in the callback is up for each game.
For example, in TOS, I keep on the first text in a room, names of enviromental sounds.
Like: "underwater,forest" or similar, depending on what sounds I need and how many.
When the games starts, in the callback, I parce the line for each room, extract the sound names (they're more like audio shaders) and store relevant info in a big matrix of rooms, for later use during gameplay.
As a remember note, avoid extensive use of strings, especially per frame.
They are not too fast in DizzyAGE.
For work with strings see the default library in GS9
Alex