Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - lucasio6

#1
(laugh)
ok, thank you for your feedback! Glad I can profit from experienced coders' knowledge on this forum.
#2
By the way:
here's the code I am using now:

Code: ags

function room_Load()
{
SetTimer(1, 1);
}

function room_RepExec()
{  
	intChickenRun = Random(2);
      
		if (IsTimerExpired(1)){
			if (intChickenRun !=0) {
				SetTimer(1, 45);  	  
				bool found;
				int x,y;
				cChicken.UnlockView();
					if (!cChicken.Moving) {
							while(!found) {
							x = Random(Room.Width);
							y = Random(Room.Height);
							if (Region.GetAtRoomXY(x, y) == region[1]) found = true;
							}
					cChicken.Walk(x, y, eNoBlock);      
                    }
		  
	        }
		    else if (intChickenRun ==0) {
				 SetTimer(1,38);         
				 cChicken.LockView(25);
				 cChicken.Animate(Random(3), 4, eOnce, eNoBlock);
			     }
	 }         

}


It works fine for me. You can adjust the SetTimer() functions to the animation length. I have a feeling that it is rather complicated for what it does though. However, I think I will leave it at that for now.. Thanks again to Snarky and Kumpel for the help!
#3
Thanks a lot to both of you!
I appreciate your explanations of how the codes actually work. helps me a lot!
:)

#4
Hello there.

I tried out some of the code in this topic:

I want a NPC (a chicken) to randomly walk around on a defined region and occasionally interrupt walking around and do a different animation.

Here's what I have come up with:
Code: ags

function room_RepExec()
{
 
 intChickenRun = Random(2);
   
  if (intChickenRun !=0) {
  
  bool found;
  int x,y;
  if (!cChicken.Moving) {
    while(!found) {
      x = Random(Room.Width);
      y = Random(Room.Height);
      if (Region.GetAtRoomXY(x, y) == region[1]) found = true;
                  }
    cChicken.Walk(x, y);
  }
  }
  
  else if (intChickenRun ==0)
  {
    cChicken.LockView(25);
      cChicken.Animate(Random(3), 5, eOnce); //chicken has 3 animations to chose from: picking a corn to the left or to the right or just standing still)
      cChicken.UnlockView();
  }         
                       
}


However, I have two problems with this code:
1. the script does not wait until the chicken has finished walking so it is constantly executing 'cChicken.Animate(Random(3), 5, eOnce)'
2. My script blocks the gui so the player character can not do anything while the chicken walks around.

As I am new to scripting, I would appreciate some suggestions..

Thanks in advance!

Lucasio6
#5
So I found the problem.

AGS did not (always) recognize/execute the script for the door hotspot in room 2 because I had not manually set the function in the 'events' tab for the hotspot. Instead, I had copied the script from room 1 to room 2 directly into the 'room script'. (roll)
Does this make sense?
#6
Hi there.

I have a question about the door system in the 9 verb template. I tried to follow the instructions of the 9Verbs.pdf manual but could not find an answer. (I am not actually making a game - I am just playing around.)

I set up 2 rooms and a door to connect the two rooms. However, only the door in room 1 works and I can't find out why the one in room 2 does not work. The gui correctly displays "open" when I point at the hotspot but nothing happens on right-click. Also, the default message is not displayed when I tell the CHAR to look at the hotspot.

Room 2 script:
Code: ags
// room script file

function room_FirstLoad()
{
 // close door on startup when entering the room (0 = closed; 1 = open; 2 = closed & locked)
 set_door_state(21, 0);
 init_object(21, oDoor.ID);
}

function hDoor_AnyClick()
{ 
     if (any_click_on_door_special(21, oDoor.ID, 75, 175, eDir_Left, 1, 280, 260, eDir_Down, null, null, 4, 0)==0) Unhandled();
      
}


I double checked that the hotspot is called 'hDoor' and the object is called 'oDoor'.

Thanks in advance for any suggestions.

Lucasio6
SMF spam blocked by CleanTalk