YolkfolkThe Dizzy Fansite 1 logged in0 playing
Community discussion

HELP - Item change - Dizzy sink

Started by Marcell Fischer on 10 April 2020 • 3,108 views

11 posts
#55797

Hello, it's me again.

Regarding the current situation, I have gained more time for my project. For some issues I would appreciate your assistance.

On the one hand I created two items, "an empty and a full bottle". If I fill the empty bottle with water I`d like to receive the item "full bottle". - With what command can I get the "full bottle" brush inserted into this code?

func UseObject_3103( idx )
{
if(ObjGet(idx,O_ID)==111) // empty bottle
{
idx = ObjFind(111);
if(ObjGet(idx,O_STATUS)==0)
{
Message0(5,4,"you fill the bottle with water");
MessagePop();
idx = ObjFind(111);
ObjSetName(idx,"bottle with water");
ObjSet(idx,O_STATUS,1);
ida = ObjFind(3103); // fountain disabled
ObjSet(ida,O_DISABLE,1);
return;
}
else
{
idx = ObjFind(111);
DropObject(idx);
}
}
}

  {yolkfolk}:scratch:

Secondly, I created a hilly landscape (moor). Here I want to "walk over" and slowly sink after stopping (after 1 second). I tried "material = cloud" but it only works if I "bounce" and land on the spot. When I walk on it, I sink while I'm running. - Does anyone know how it can be implemented?

Stay well :tup:

Kind Regards
Kalle

👍 0
#88052

Kalle, the easiest way to swap two items is to use a function devised by Jamie and put it in the util file. The 'old' and 'new' are just the items ID numbers, ie empty bottle = 111, full bottle = 112 (and they are the IDs in the ObjectsSetNames function in the game file). This way, you can use the Replace function globally.

func ReplaceInventoryItem(old,new)
{
SamplePlay(FX_BEEP1); //or whatever sound you use for picking up an inventory item
idx = ObjFind(old);
InventorySub(idx);
idx = ObjFind(new);
InventoryAdd(idx);
}

Then when using the fountain's action object

func UseObject_3103(idx)
{
ida = ObjFind(3103);
if (idx == ObjFind(111))
{
ReplaceInventoryItem(111,112);
ObjSet(ida, O_DISABLE, 1);
Message1 (4,3, ""I'll fill the bottle"");
MessagePop();
return;
}
else
{
DropObject(idx);
}
}

Can't really help with the second problem as it seems you want different things to happen if Dizzy is walking or running. All I can suggest is that if you're changing a block static brush to a cloud static brush you need to add the command 'GameCommand(CMD_REFRESH);' so that the change takes place immediately - you can't do this with dynamic brushes as you have to 'action' them again after changing the property (and adding the ObjPresent command).

Hope this helps.

👍 0
#88053

I have some thoughts about your second question.

The code that makes you sink through cloud materials is in func HandlerPlayerUpdate(). If you're not using clouds elsewhere in your game, you could modify the code there. For example you could try:

// Check clouds
if(IsMaterialUnderPlayer(MAT_CLOUD))
{
if(PlayerGet(P_DIR)==0) PlayerSet(P_Y, PlayerGet(P_Y)+1);
}

That's meant to stop Dizzy from sinking unless he's standing still. Or you could try:

// Check clouds
if(IsMaterialUnderPlayer(MAT_CLOUD))
{
if(PlayerGet(P_STATUS)==STATUS_IDLE) PlayerSet(P_Y, PlayerGet(P_Y)+1);
}

These are just ideas - I haven't tried them out.

If you want to have clouds in your game as well you'll need to define a new material (maybe MAT_MOOR?) You can maybe see how to do that by looking in the def.gs file and at func HandlerGameInit()

Hope this helps you out.

👍 0
#88060

Hello and good afternoon everyone. {dizzy}:lookup:

Many thanks to Grandad and Noggin the Nog for their quick answers.

The code for changing the item within the inventory worked perfectly. But I had to place the "bottle full" item outside the map to actually have it in my inventory. Maybe there is another way?

I experimented with both codes for the "moor" for a really long time. It works well on flat paths. Unfortunately not when climbing a hill. Dizzy just walks in and through. The small step is missing like over a stone (material = block). One possibility would be to extend the "start" for "sinking". It would be nice from the second two on. Would that be possible?

Looking forward to your answers.

In the meantime, I will continue to work on my little world.

Kind regards
Kalle

👍 0
#88061

I experimented with both codes for the "moor" for a really long time. It works well on flat paths. Unfortunately not when climbing a hill. Dizzy just walks in and through. The small step is missing like over a stone (material = block). One possibility would be to extend the "start" for "sinking". It would be nice from the second two on. Would that be possible?
Couldn't resist trying to solve this puzzle. I haven't tested my solution, so please let me know if it works!

1. Go to the movement.gs file and find the function: CM_CheckCollision()

2. Copy+Paste it somewhere and change the name so you have a new function you can edit. I've called mine NewCollision()

3. The line: step = MaterialGetFreeDist(x1,y2-CM_STEPY,x2,y2,0,1); Change the final "1" to a "0"

4. Edit your existing code to:

// Check clouds
if(IsMaterialUnderPlayer(MAT_CLOUD))
{
if(PlayerGet(P_STATUS)==STATUS_IDLE) PlayerSet(P_Y, PlayerGet(P_Y)+1);
else NewCollision();
}

In general, the movement.gs contains all the code for Dizzy's motion and interactions with the material map. What I'm trying to do is borrow the code that makes Dizzy rise through block materials and use it here.

👍 0
#88063

Kalle, I always use room 0,0 to put anything global in and don't include it as part of the 'map'. That way I know where stuff such as 'swapped' items and dynamic brushes used as status checks etc are, without having to check out the whole map whilst scratching my head {yolkfolk}:scratch:

I can't help with the 'soggy moor' as it seems extremely complicated, as you have to take so much into consideration, such as what happens when you jump, or how far down you sink before drowning - is the end result something special, such as dropping into a secret area, or is it just supposed to make it hard to reach the other side.

Best of luck with your helping hand Simon ...perhaps it'll give you inspiration to have another look at your 'Pleasantville' demo, especially as now you have Nowhere Girls recommendation {yolkfolk}:cheers:

👍 0
#88064

Hello and good morning.
is the end result something special, such as dropping into a secret area,...

That's exactly the plan. You scare me, Grandad. :surprise:  
Storing in room 0.0 is still a great idea from you. Hopefully I can keep an overview.
Where exactly can I find this 'Pleasantville' demo? {yolkfolk}:scratch:  

movements.gs

func CM_CheckSink()
{
x1=0;y1=0;x2=0;y2=0;
PlayerMakeBB(&x1,&y1,&x2,&y2);
step = MaterialGetFreeDist(x1,y2-CM_STEPY,x2,y2,0,0); // top to bottom
if(step<CM_STEPY) // has some block 
PlayerSet(P_Y,PlayerGet(P_Y)-(CM_STEPY-step)); // rise up
}

handlers.gs

if(IsMaterialUnderPlayer(MAT_CLOUD))
{
if(PlayerGet(P_STATUS)==STATUS_IDLE) 
PlayerSet(P_Y, PlayerGet(P_Y)+1);
else CM_CheckSink();
}

Simon's codes (thanks a lot at this point) work almost perfectly. Dizzy now runs over everything and when he stands still he sinks.
If now a "wait" function could be inserted before Dizzy sinks it would be perfect. (So ​​that Grandad doesn't immediately solve the puzzle!) :x_x:  

Kind Regards
Kalle

👍 0
#88065

[quote data-userid="1935" data-postid="88064"]

Where exactly can I find this ‘Pleasantville’ demo? {yolkfolk}:scratch:   

[/quote]

Steve is referring to the video I posted:

https://www.youtube.com/watch?v=I8Hvyj7DPtE

It shows some the things I've been working on the past couple of years. I wasn't planning on finishing any of them but if the lockdown goes on for a long time then who knows? {dizzy}:lookup:

As to your question about a wait function. You need to do a counter, which is a very useful thing I've used over and over again in my games.

First thing is define a new game variable in def.gs (Look down at the bottom where the global variables are listed)

For Example: #def G_SINKCOUNT 80

You can call it whatever you want of course. You can then use your new variable as a counter.

The new code counts up one every time the Player Handler is called and Dizzy is standing still on some MAT_CLOUD. He starts sinking once the count gets above 3. The counter is reset to zero when he moves.

if(IsMaterialUnderPlayer(MAT_CLOUD))
{
if(PlayerGet(P_STATUS)==STATUS_IDLE)
{
count = GameGet(G_SINKCOUNT);
GameSet(G_SINKCOUNT,count+1);
if(count>3) PlayerSet(P_Y, PlayerGet(P_Y)+1);
}
else
{
GameSet(G_SINKCOUNT,0);
CM_CheckSink();
}
}

For good measure, I'd find the HandlerJump() and insert a GameSet(G_SINKCOUNT,0); to make sure the counter always resets when you jump.

Hopefully that'll do everything you want. :smile:

👍 0
#88066

[quote data-userid="1935" data-postid="88064"]

(So ​​that Grandad doesn’t immediately solve the puzzle!) :x_x:

[/quote]

Too late Kalle, I've already got my hiking boots ready for walking on the moor {yolkfolk}:clap:

👍 0
#88068

Hello and good evening,

Many thanks to you for the active support.

For Steve I will create an extra version with MAT_BLOCK to make the moor puzzle more difficult. :cool:

The counter function is exactly what I wanted. It works perfectly and blends in well with the sinking. Thanks Simon for the code.

The video is worth seeing and inspiring. The idea of ​​collecting the colors is great! I will use 1-2 given ideas e.g. climbing ladders. Is there already an extractable game in which climbing has been integrated? Maybe one of you, Steve? {yolkfolk}:scratch:

My short-time work has been over so I have to put my creative phase back ... Unfortunately ... but I'm staying on!

We hear from each other. {yolkfolk}:cheers:

Stay healthy

Marcell

👍 0
#88069

Kalle, download and upack 'Hush'. At the start of the game.GS file you'll find some instructions on climbing ladders, the global response which is func LadderCollide() and a hashed out template for the collide. See func CollideObject_245_1() further down the file to see it in action.

The tiles used are 26 (idle) and 25 (animated climbing). However, in this game, there are also tiles 56 and 55 as Dizzy can be either white or black, but the coding used is the 'standard' for when Dizzy wears a scuba ...see the costume section at the start of the HandlerPlayerUpdate section of the Handler.GS file, which adds 30 to the basic tile number when Dizzy is wearing a scuba (or covered in soot in this game).

Also, remember to add 12 to the starting upper and lower positions of the collide function as you need to make sure that when walking past the collide object he clings onto the ladder and can then either walk away or start to climb, and also not climbing too high before dropping. Fixing this is just adding or subtracting the y axis top and bottom positions (I usually add or subtract 12 to see what happens and then make smaller adjustments till I'm happy). Likewise, I usually make sure the 'middle' of the collide object's x axis is divisable by 4, so that Dizzy is in the middle when climbing and not the sides. This can be easier if you make the collide object invisible and place a static picture of the ladder over it so that Dizzy climbs in the middle.

Have fun {yolkfolk}:clap:

👍 0