Tree climbing script

Started by Construed, Sun 08/04/2012 06:21:06

Previous topic - Next topic

Construed

Trying to make a tree climbing animation, But need to get the hero to do the climbing animation and go slowly up the tree and the only way i found to make it possible for the hero to climb the tree was by adding another walkable area which then makes it possible for the hero to just walk up the tree.

Also trying to figure out how to make some sort of way points where when the hero is walking across the limb he has a set amount of random chances to fail within his walk and fall off the tree.

Code: ags

function hHotspot5_Interact()
{

player.Walk(31, 164, eBlock);


if ((player.View==42)||(player.View==16)) {
 player.ChangeView(96); 
 player.Animate(0, 5, eOnce);
player.Animate(0, 5, eOnce);
player.Animate(0, 5, eOnce);
if (balance <= 15){
  balance += 1;
  Display("Your unable to climb the tree, But your balance has increased by 1");
  player.ChangeView(16);
}
if (balance >= 15){
  balance += 1;
  Display("You have sucessfully climbed the tree");
  player.ChangeView(97);
  player.Move(31, 63, eBlock);
  player.IgnoreWalkbehinds = true;
  player.ChangeView(97);
  player.Move(30, 92, eBlock);
  player.ChangeView(16);
  player.IgnoreWalkbehinds = false;
}

}
else if ((player.View==17)||(player.View==59)) { //thief

player.Walk(31, 164, eBlock);


if ((player.View==42)||(player.View==16)) {
 player.ChangeView(96); 
 player.Animate(0, 5, eOnce);
player.Animate(0, 5, eOnce);
player.Animate(0, 5, eOnce);
if (balance <= 15){
  balance += 1;
  Display("Your unable to climb the tree, But your balance has increased by 1");
  player.ChangeView(16);
}
if (balance >= 15){
  balance += 1;
  Display("You have sucessfully climbed the tree");
  player.ChangeView(97);
  player.Move(31, 63, eBlock);
  player.IgnoreWalkbehinds = true;
  player.ChangeView(97);
  player.Move(30, 92, eBlock);
  player.ChangeView(16);
  player.IgnoreWalkbehinds = false;

}
else if ((player.View==18)||(player.View==58)) {

player.Walk(31, 164, eBlock);


if ((player.View==42)||(player.View==16)) {
 player.ChangeView(96); 
 player.Animate(0, 5, eOnce);
player.Animate(0, 5, eOnce);
player.Animate(0, 5, eOnce);

if (balance <= 15){
  balance += 1;
  Display("Your unable to climb the tree, But your balance has increased by 1");
  player.ChangeView(16);
}
if (balance >= 15){
  balance += 1;
  Display("You have sucessfully climbed the tree");
  player.ChangeView(97);
  player.Move(31, 63, eBlock);
  player.IgnoreWalkbehinds = true;
  player.ChangeView(97);
  player.Move(30, 92, eBlock);
  player.ChangeView(16);
  player.IgnoreWalkbehinds = false;

}
}
}
}
}
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Phillipv20

Just to throw an idea to you, why don't you make the actual climbing of the tree a cut-scene animation where the base of the tree is a hotspot and once entered the cut-scene will take over having the character climb the tree using a loop you create with your character for climbing.  Once in the tree create your walkable area's that way he can't just run off the tree and back down to the path.  As far as making him have a chance to fall while on a limb, you could probably just set up a default roll number using the character weight(if you have one), weight of items, and any stat that helps with climbing (i.e. dexterity)  add all of those up and divide by a randomly generated number that can't go over a max point you set to make it where if a character has a high dexterity and no items in the bag and isn't 300 lbs he will virtually have no chance of falling and likewise for a character with not much dexterity and a full bag that weighs a lot.  Sorry i know that's a lot of jumble so to try and clear it, here is a possible formula for climbing in the tree:

[(Char Weight) + (Dexterity) + (Inventory Weight)]/(Randomly Generated Number) == chance to fall

You would then compare the chance to fall to a preset number for the tree or even particular branch:

Chance to fall/Limb Number == balance

if(balance <= 0) then
   //Character falls from tree
else
  //Character successfully gets across limb

Hope this helps some, feel free to ask if you don't get some of the logic.

Construed

Thanks bud, I suppose I'm going to learn about CutScenes and how to move the character during them "I'm guessing I'm going to have to do a character.Changeroom to the correct position" and make 3 cutscenes for each character type. This is the biggest obstacle in my way at the moment, so any solid coding help is greatly appreciated and thanks for taking the time to post :D
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Phillipv20

I will try and work on some code for you, but I'm wrapped up in a project as well.  To help a bit with cut-scenes you would just need to take your character and make a loop of him/her climbing, import that, then add it into your game where the hotspot begins for the tree.  Easiest way to learn on a cut-scene is to read the tutorial on it.

SMF spam blocked by CleanTalk