The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 5:46 am

Forum rules


IMPORTANT

This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.



 [ 8 posts ] 
[Request] Flash Damage Counter 
Author Message
User avatar

Joined: Mon Aug 11, 2008 8:40 am
Posts: 1505
Location: Los Angeles
Country: United States (us)
Gender: Anime Girl
MGN Username: Suli
Skype: na_suliboy
Currently Playing: Fire Emblem 1-13, Tales of Xillia/Graces, Smash 4
For a game I'm making, I need to know how to generate random damage between a certain set range depending on if hit, the strength of the attack, and the distance between players.

Lets say one MC on the stage/library is instanced "Player_1" and the second is "Player_2"
Each player has 4 attacks.
So lets just say that player 1 used attack#2 on Player 2, which would deal 10-15 damage.
(just so you know, this is a meter, not percent. Once the meter reaches 100, the person dies)
I've tried MANY scripts.
EVERY SINGLE TIME, when you make contact, when it should deal damage, either the meter doesnt increase, or the game freezes.

What would be a script to cause damage ONLY upon contact, and deal randomly between a set range depending on distance?

_________________
*Hiatus*


Tue Aug 12, 2008 1:58 am

Joined: Mon Aug 11, 2008 11:33 am
Posts: 22
Trie this code(not really sure if it works)

Code:
onClipEvent(enterFrame){
  if(player_1.hitTest(_root.player_2._x, _root.player_2._y, true)){
    "Code to execute on hit here";
  }
}


Tue Aug 12, 2008 7:01 am

Joined: Mon Aug 11, 2008 9:22 am
Posts: 1
What's that suppost to mean?


Wed Aug 13, 2008 12:16 pm

Joined: Mon Aug 11, 2008 7:01 am
Posts: 1
But it is somthing strange. When i hit the charceter whit up smash attack the character want fly


Thu Aug 14, 2008 4:32 am
User avatar

Joined: Mon Aug 11, 2008 8:40 am
Posts: 1505
Location: Los Angeles
Country: United States (us)
Gender: Anime Girl
MGN Username: Suli
Skype: na_suliboy
Currently Playing: Fire Emblem 1-13, Tales of Xillia/Graces, Smash 4
...
Noobs...spamming this topic.



Ok, uh, thats just for the hit_test, the "if-hit"
but kinda, I also need an improved code for the damage counter, it needs to be all together, I mean, the animation for hit plays but still the damage doesnt change, and my code still makes it freeze if the damage randomized is greater than the set amount.

_________________
*Hiatus*


Sun Aug 17, 2008 11:57 am
User avatar

Joined: Sun Aug 17, 2008 5:39 pm
Posts: 1248
Gender: Anime Girl
Skype: Nacritico
Currently Playing: LOL
try this code:

Code:
MovieClip.prototype.life = 100;
MovieClip.prototype.maxLife = 100;
//all the attacks from the characters will be acummulated here
MovieClip.prototype.atks = new Array();
//
player1 = new MovieClip();
/*
the attacks will be writen this way:
[ minum damage, difference beetwen max damage and minimun damage, accuracy]
*/
player1.atks.push([5, 5, 100]);
player2 = new MovieClip();
/*
//this code modifies the life of any of the two characters
//(if their life is negative, it is automatically turned into 0;
//if it's more than it's max life, its turn into the max life)

//note: you need the movieclip to have a maxLife variable.
*/
MovieClip.prototype.setLife = function(amount) {
   this.life += amount;
   if (this.life<0) {
      this.life = 0;
   }
   if (this.life>this.maxLife) {
      this.life = this.maxLife;
   }
};
/*
//This code is for the attack itself. To make it work, you should introduce which attackç
//the char is using, and to which target
*/
MovieClip.prototype.attack = function($attack, target) {
   //this gives you the possibility of missing
   if ($attack[2]>(Math.random()*100)) {
      //NOTE:
      //Create an integre random number of the difference...
      // in other words, if 10 is the minum, and 15 is the max
      // then the extra will be a random number beetwen 0 and 5,
      //and it will be added to the min damage
      var minDamage = $attack[0];
      var extra = Math.round($attack[1]*Math.random());
      var modification = (minDamage+extra)*-1;
      target.setLife(modification);
   }
   else {
      trace("attack missed");
   }
};


so, if you wish player1 to use attack#2 on player2 doing 10-15 damage, all you have to do is this:
Code:
player1.atks.push ([10,5,100])
player1.attack(player1.atks[1],player2)

_________________
SALU2'S Image
_________________
Original forum: show
join date: January 08, 2007
Posts on old MG: 2432, level 16

Image
Image chóu


Sun Aug 17, 2008 6:55 pm
User avatar

Joined: Mon Aug 11, 2008 1:04 pm
Posts: 42
Mega Ninja wrote:
What's that suppost to mean?

its programing language idiot

_________________
Image


Tue Aug 19, 2008 11:05 am
User avatar

Joined: Mon Aug 11, 2008 8:40 am
Posts: 1505
Location: Los Angeles
Country: United States (us)
Gender: Anime Girl
MGN Username: Suli
Skype: na_suliboy
Currently Playing: Fire Emblem 1-13, Tales of Xillia/Graces, Smash 4
nacritico wrote:
try this code:

Code:
MovieClip.prototype.life = 100;
MovieClip.prototype.maxLife = 100;
//all the attacks from the characters will be acummulated here
MovieClip.prototype.atks = new Array();
//
player1 = new MovieClip();
/*
the attacks will be writen this way:
[ minum damage, difference beetwen max damage and minimun damage, accuracy]
*/
player1.atks.push([5, 5, 100]);
player2 = new MovieClip();
/*
//this code modifies the life of any of the two characters
//(if their life is negative, it is automatically turned into 0;
//if it's more than it's max life, its turn into the max life)

//note: you need the movieclip to have a maxLife variable.
*/
MovieClip.prototype.setLife = function(amount) {
   this.life += amount;
   if (this.life<0) {
      this.life = 0;
   }
   if (this.life>this.maxLife) {
      this.life = this.maxLife;
   }
};
/*
//This code is for the attack itself. To make it work, you should introduce which attackç
//the char is using, and to which target
*/
MovieClip.prototype.attack = function($attack, target) {
   //this gives you the possibility of missing
   if ($attack[2]>(Math.random()*100)) {
      //NOTE:
      //Create an integre random number of the difference...
      // in other words, if 10 is the minum, and 15 is the max
      // then the extra will be a random number beetwen 0 and 5,
      //and it will be added to the min damage
      var minDamage = $attack[0];
      var extra = Math.round($attack[1]*Math.random());
      var modification = (minDamage+extra)*-1;
      target.setLife(modification);
   }
   else {
      trace("attack missed");
   }
};


so, if you wish player1 to use attack#2 on player2 doing 10-15 damage, all you have to do is this:
Code:
player1.atks.push ([10,5,100])
player1.attack(player1.atks[1],player2)


Thanks nac, I'm off to try that right now :wee:

_________________
*Hiatus*


Tue Aug 19, 2008 11:19 am
Display posts from previous:  Sort by  
 [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.