YolkfolkThe Dizzy Fansite 0 logged in0 playing
Community discussion

Flipping a baddie

Started by DoughJammer on 10 February 2023 • 1,067 views

9 posts
#90747

Hello forum! I've picked up Dizzyage last month, and it's been great! I've worked out most of the engine through the manual alone, however I have a question for something that I assumed would be easy.
Instead of a symetrical bat I drew a character facing one side. How do I flip it if it's moving in a specific direction?
I know to flip it is: ObjSet(idx,B_FLIP,1), but how do I make it if it's moving left from right (considering I'm using the same method as the bats in the demo)?
I thought maybe using O_X I can make it flip whenever the X is suddenly smaller than the previous one,but can someone show me a demonstration?

I'm really sorry for the newbie question! I'm choosing to think of it as giving life to the forums.

👍 1
#90748

Hi DoughJammer, if you're using AI to move 'baddies', then you only need to edit the waypoints that the 'baddie' uses to move to.

Flip to the 'user' tab on the properties box. #32 determines the speed the 'baddie' moves to that waypoint (the higher the number, the faster the movement) and #33 determines the flip properties and  normally uses either 0 or 1 for going left and right.

0 is the number to use if the 'baddie' is flying in the same direction as the original tile, and 1 automatically reverses the tile travelling in the opposite direction.

PS - ObjSet requires O_, BrushSet uses B_

👍 2
#90837

Thank you, Grandad! I don't know how I missed that. I've learnt a lot since my last post. I even made a demo and my friends played it. My new question is this : can I somehow increase the object status by a point instead of setting it so specific value? This is because I want to make a puzzle in which you make wine by putting the ingredients in a barrel, and this way it wouldn't matter in which order you put them in.
Ex. Starts with status 1
Put grapes =+1 point
Put grapes =+1 point
If status = 3 then you get wine
Or do I have to do it another way? I don't really understand how to use logic operators with functions (like I understand how && works in gs9 but I don't understand how to apply it to a puzzle)
I hope this isn't pushy, thank you so much! I saw this engine accidentally one day, and I'm glad I decided to check it out!  {yolkfolk}:music: {yolkfolk}:yo: {yolkfolk}:zxlove: love these emoticons btw


Edit: this is what I have made, it doesn't work but if I don't fix it in the meantime someone with better eyes will.

func ActionObject_113()
{
	idx = ObjFind(113);
	if(ObjGet(idx,O_STATUS)==0)
	{
		Message(3,8,"A SIMPLE WINE BARREL",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		ObjSet(idx,O_STATUS,1);
		return;
	}
	if(ObjGet(idx,O_STATUS)==1)
	{
		idx = OpenDialogInventory();
		if(idx!=-1) UseObject(idx);
	}
	if(ObjGet(idx,O_STATUS)==2)
	{
		Message(3,8,"NOT FINISHED!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
	}
	if(ObjGet(idx,O_STATUS)==3)
	{
		Message(3,8,"YOU NEED SOMETHING TO CARRY IT IN!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
	}
}

func UseObject_113( idx )
{
	status = ObjGet(idx,O_STATUS);
	if(idx==ObjFind(107))
	{
		Message(3,8,"YOU PUT IN GRAPES...",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		InventorySub(idx);
		status++;
		return;
	}
	if(idx==ObjFind(111)) 
	{
		Message(3,8,"YOU PUT IN YEAST...!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		InventorySub(idx);
		status++;
		return;
	}
	if(status == 3 && idx==ObjFind(106))
	{
		Message(3,8,"YOU MADE WINE!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();

		ObjSet(idx,O_CLASS,0);
		ObjSet(112,O_DISABLE,0);
		return;
	}
	else
	{		
		Message(15,3,"THAT'S NO GOOD!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		DropObject(idx);
	}
}

Edit 2:
Is this better? Still doesn't work


func UseObject_113( idx )
{
	status = ObjGet(idx,O_STATUS);
	if(idx==ObjFind(107))
	{
		Message(3,8,"YOU PUT IN GRAPES...",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		InventorySub(idx);
		status+=1;
		if(status == 3)
		{
			Message(3,8,"YOU NEED SOMETHING TO CARRY IT IN!",COLOR_WHITE,COLOR_WHITE);
			MessagePop();
		}
		return;
	}
	if(idx==ObjFind(111)) 
	{
		Message(3,8,"YOU PUT IN YEAST...!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		InventorySub(idx);
		status+=1;
		if(status == 3)
		{
			Message(3,8,"YOU NEED SOMETHING TO CARRY IT IN!",COLOR_WHITE,COLOR_WHITE);
			MessagePop();
		}
		return;		
	}
	if(idx==ObjFind(106))
	{
		Message(3,8,"YOU PUT A BOTTLE DOWN..",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		status+=1;
		return;
	}
	else if(status == 4)
	{
		ObjSet(idx,O_CLASS,0);
		ObjSet(112,O_DISABLE,0);
		return;
	}
	else
	{		
		Message(15,3,"THAT'S NO GOOD!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		DropObject(idx);
	}
}
👍 0
#90848

Feeling stumped.  {yolkfolk}:sob:  
There were lots of other edits but none of them were posted since nothing worked!

👍 0
#90851

There's a clever little bit of code for adding to the status of a dynamic object:

ida = ObjFind(1000); ObjSet(ida, O_STATUS, ObjGet(ida, O_STATUS) +1);

then using the 'or' separators in the UseObject coding for each 'grape' should work. I'd suggest swapping the empty barrel for a full barrel (different IDs, if you then need to find a glass to dip into it.

ActionObject_1000()
{
ida = ObjFind(1000);
if (ObjGet(ida, O_STATUS) == 0)
{
// add message about empty barrel making wine
ObjSet(ida, O_STATUS, 1);
return;
}
if (ObjGet(ida, O_STATUS) == 1)
{
//add message about needing grapes (always best to give hints about what is required rather than just opening the inventory)
idx = OpenDialogInventory();
if (idx!=-1) UseObject(idx);
}
}

func UseObject_1000(idx)
{
if (idx == ObjFind(1001) || idx == ObjFind(1002) || idx == ObjFind(1003)) //three grapes
{
InventorySub(idx); Message0 (5,2, "Dizzy adds a grape"); MessagePop();
ida = ObjFind(1000);
ObjSet(ida, O_STATUS, ObjGet(ida, O_STATUS) +1);
if (ObjGet(ida, O_STATUS) == 4) //remember that object 1000 starts at status 1
{
ObjSet(ida, O_DISABLE, 1);
idb = ObjFind(1004) //full barrel
ObjSet(idb, O_DISABLE, 0);
Message1 (4,3, "I've made some wine\""); MessagePop();
}
return;
}
else
{
DropObject (idx);
}

// sometimes a message saying that's an incorrect item works better than just dropping it.

Hope I haven't messed up the coding, but hopefully you should get the gist. Best of luck. :tup:  

 

👍 0
#90858
@grandad Thank you again for responding, but there seems to be an error! When the status is higher than 1 you can't open your inventory. Is there a simple fix for this or do I need to paste the open inventory code somewhere later in the code?
👍 0
#90859

Aaaghh! Sorry about that DoughJammer, I should have added an extra 'hidden, dynamic object' to the map and used that to increase the status,  not the empty barrel. I should have realised that adding to the status of the empty barrel caused the coding to mess up once the engine made it status 2.

Something like :

func UseObject_1000(idx)
{
if (idx == ObjFind(1001) || idx == ObjFind(1002) || idx == ObjFind(1003)) //three grapes
{
InventorySub(idx); Message0 (5,2, “Dizzy adds a grape”); MessagePop();
ida = ObjFind(1005);
ObjSet(ida, O_STATUS, ObjGet(ida, O_STATUS) +1);
if (ObjGet(ida, O_STATUS) == 3) //make sure this is 'mat' so not shown on map
{
idb = ObjFind(1000);
ObjSet(idb, O_DISABLE, 1); //empty barrel
idc = ObjFind(1004);
ObjSet(idc, O_DISABLE, 0);
Message1 (4,3, “I’ve made some wine\””); MessagePop();
}
return;
}
else
{
DropObject (idx);
}

No excuse, but blame too much alcohol on Thursday night when out quizzing {special}:chug:  

 

👍 0
#90921

Hello! It's me again. Things have been going smoothly.

I have new puzzle! I want to try making a fishing puzzle which implements a random number generator if possible.
This code doesn't work, but hopefully you will understand what I'm doing (a random number generator picks number between 0 and 99, if it's smaller than 30 it updates an invisible object that disables a fish next to you).
Can someone tell me if this is possible and if I'm on the right track? Thank you in advance!!!!

//////////////////Fishing puzzle
func ActionObject_2001()
{
	idx = ObjFind(2001); ///Internal index of object
	if(ObjGet(idx,O_STATUS)==0)
	{
		Message(3,8,"FISHING IS A NICE SPORT",COLOR_WHITE,COLOR_WHITE);
		Message(4,10,"AS LONG AS IT IS A SPORT",COLOR_WHITE,COLOR_WHITE);
		Message(6,2,"WHY?",COLOR_WHITE,COLOR_GREEN);
		MessagePop();
		Message(3,8,"BEEN HUNGRY FOR AGES",COLOR_WHITE,COLOR_WHITE);
		Message(3,12,"I NEED FOOD!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		Message(6,2,"I WILL HELP!",COLOR_WHITE,COLOR_GREEN);
		MessagePop();
		Message(6,2,"THANKS THERES A ROD THERE",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		ObjSet(idx,O_STATUS,1);
		ObjSet((ObjFind(2002)),O_DISABLE,0);
		return;
	}
	if(ObjGet(idx,O_STATUS)==1)
	{
		idx = OpenDialogInventory();
		if(idx!=-1) UseObject(idx);
	}
	if(ObjGet(idx,O_STATUS)==2)
	{
		Message(6,2,"YOU CAUGHT ALL FISH!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
	}
}


func UseObject_2001()
{
	if(ObjGet(idx,O_ID) == ObjFind(232) || ObjGet(idx,O_ID) == ObjFind(233) || ObjGet(idx,O_ID) == ObjFind(234) || ObjGet(idx,O_ID) == ObjFind(235))
	{
		Message(3,8,"THANKS MAN!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		Message(3,8,"HERE!",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		InventorySub(idx);
		idx = ObjFind(6);
		ObjSet(idx,O_DISABLE,0);
		idx = ObjFind(2001);
		ObjSet(idx,O_STATUS,2);
	}
	else
	{ 
 	Message(15,3,"WHAT WOULD I\n NEED THAT \nFOR!",COLOR_WHITE,COLOR_WHITE);
    MessagePop();
	DropObject(idx);
    }
}
	
	
func ActionObject_2002()
{
	idx = ObjFind(2002);
	if(ObjGet(idx,O_STATUS)==0)
	{
		Message(3,8,"A FISHING ROD",COLOR_WHITE,COLOR_WHITE);
		Message(3,8,"YOU NEED BAIT",COLOR_WHITE,COLOR_WHITE);
		MessagePop();
		ObjSet(idx,O_STATUS,1);
		return;
	}
	else
	{
		idx = OpenDialogInventory();
		if(idx!=-1) UseObject(idx);
	}
}

func UseObject_2002( idx )
{
	if(ObjGet(idx,O_ID)==122)
	{
		Random = Rand(100);
		if(Random < 30)
		{
			Message(3,8,"YOU CAUGHT A FISH!",COLOR_WHITE,COLOR_WHITE);
			MessagePop();
			Hiddenstatus = ObjFind(15);
			ObjSet(Hiddenstatus, O_STATUS, ObjGet(Hiddenstatus, O_STATUS) +1);
			return;

		}
		else
		{
			Message(3,8,"NO LUCK THIS TIME",COLOR_WHITE,COLOR_WHITE);
			MessagePop();
		}
	}
	if(ObjGet(15,O_STATUS) > 4)
	{
		idx = ObjFind(2002); // find the fish object index
		ObjSet(idx,O_STATUS,2);
	}
   	else
    { 
 	Message(15,3,"WHAT WOULD I\n NEED THAT \nFOR!",COLOR_WHITE,COLOR_WHITE);
	MessagePop();
	DropObject(idx);
    }
}

func ActionObject_15()
{
	idx = ObjFind(15);
	if(ObjGet(idx,O_STATUS) > 1)
	{
		idx = ObjFind(232); // find the fish object index
		ObjSet(idx,O_DISABLE,0);
	}
}
func ActionObject_232()
{
	idx = ObjFind(15);
	if(ObjGet(idx,O_STATUS) > 0)
	{
		idx = ObjFind(232); // find the fish object index
		ObjSet(idx,O_DISABLE,0);
	}
}

func ActionObject_233()
{
	idx = ObjFind(15);
	if(ObjGet(idx,O_STATUS) > 1)
	{
		idx = ObjFind(233); // find the fish object index
		ObjSet(idx,O_DISABLE,0);
	}
}

func ActionObject_234()
{
	idx = ObjFind(15);
	if(ObjGet(idx,O_STATUS) > 2)
	{
		idx = ObjFind(234); // find the fish object index
		ObjSet(idx,O_DISABLE,0);
	}
}

func ActionObject_235()
{
	idx = ObjFind(15);
	if(ObjGet(idx,O_STATUS) > 3)
	{
		idx = ObjFind(235); // find the fish object index
		ObjSet(idx,O_DISABLE,0);
	}
}
func ActionObject_236()
{
	idx = ObjFind(15);
	if(ObjGet(idx,O_STATUS) > 4)
	{
		idx = ObjFind(2002); // find the fish object index
		ObjSet(idx,O_STATUS,2);
	}
}
👍 0
#90927

I'm not sure if I understand what you're trying to do, as it seems that you're using a 'hit or miss' method to catch two fish and it looks awfully complicated to just catch two fish. Personally, I never use random coding as it has a tendency to only use specific numbers and ignore the rest, so you can end up with never achieving the 'generated number' or getting it spot on every time.

In this puzzle can the fish be seen swimming around, or is Dizzy just sitting there holding a rod and each time he tries to fish, you are trying to activate the random coding?

PS - why define the colours of each text message? - just add a stack of defines to the Message.gs file so that for different colours you just have between Message0 - Message8 or whatever (using the colours defined in the def.gs file). Saves so much typing:

Message3 (4,3, "\"Wotcha Dylan\""); MessagePop(); ( "\" and \"" gives the messages in quotes to indicate they are talking)

Message0 (4,3, "This is a notice"); MessagePop(); (no quotes)

👍 0