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