HELP - Item change - Dizzy sink

Need help with using DizzyAGE then look here
User avatar
Kalle Neumann
Your Backpack is Empty
Posts: 25
Joined: Sat Jan 18, 2020 5:16 pm
Location: Germany

HELP - Item change - Dizzy sink

Post by Kalle Neumann » Fri Apr 10, 2020 3:29 pm

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?

Code: Select all


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);
		}
	}
}
:v2_dizzy_confused2:

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

Grandad
Hard Boiled Egg
Posts: 1575
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Re: HELP - Item change - Dizzy sink

Post by Grandad » Sat Apr 11, 2020 9:03 am

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.

Code: Select all

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

Code: Select all

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.

User avatar
Noggin the Nog
Hard Boiled Egg
Posts: 446
Joined: Sun Jul 01, 2012 12:04 am

Re: HELP - Item change - Dizzy sink

Post by Noggin the Nog » Sat Apr 11, 2020 10:39 pm

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:

Code: Select all

// 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:

Code: Select all

// 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.

User avatar
Kalle Neumann
Your Backpack is Empty
Posts: 25
Joined: Sat Jan 18, 2020 5:16 pm
Location: Germany

Re: HELP - Item change - Dizzy sink

Post by Kalle Neumann » Wed Apr 15, 2020 4:57 pm

Hello and good afternoon everyone. :dizzy_rolleyes:

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

User avatar
Noggin the Nog
Hard Boiled Egg
Posts: 446
Joined: Sun Jul 01, 2012 12:04 am

Re: HELP - Item change - Dizzy sink

Post by Noggin the Nog » Wed Apr 15, 2020 10:01 pm

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:

Code: Select all

// 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.

Grandad
Hard Boiled Egg
Posts: 1575
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Re: HELP - Item change - Dizzy sink

Post by Grandad » Thu Apr 16, 2020 8:34 am

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 :v2_dizzy_confused2:

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 :v2_dizzy_cheers:

User avatar
Kalle Neumann
Your Backpack is Empty
Posts: 25
Joined: Sat Jan 18, 2020 5:16 pm
Location: Germany

Re: HELP - Item change - Dizzy sink

Post by Kalle Neumann » Sat Apr 18, 2020 10:34 am

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. :O
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? :v2_dizzy_confused2:


movements.gs

Code: Select all

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

Code: Select all

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)

Kind Regards
Kalle

User avatar
Noggin the Nog
Hard Boiled Egg
Posts: 446
Joined: Sun Jul 01, 2012 12:04 am

Re: HELP - Item change - Dizzy sink

Post by Noggin the Nog » Sat Apr 18, 2020 9:00 pm

Where exactly can I find this 'Pleasantville' demo? :v2_dizzy_confused2:
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_rolleyes:


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.

Code: Select all

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. :)

Grandad
Hard Boiled Egg
Posts: 1575
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Re: HELP - Item change - Dizzy sink

Post by Grandad » Sun Apr 19, 2020 8:12 am

(So ​​that Grandad doesn't immediately solve the puzzle!) X)
Too late Kalle, I've already got my hiking boots ready for walking on the moor :v2_dizzy_clapping:

User avatar
Kalle Neumann
Your Backpack is Empty
Posts: 25
Joined: Sat Jan 18, 2020 5:16 pm
Location: Germany

Re: HELP - Item change - Dizzy sink

Post by Kalle Neumann » Thu Apr 23, 2020 6:10 pm

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? :v2_dizzy_confused2:

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. :v2_dizzy_cheers:

Stay healthy

Marcell

Post Reply