Progress towards next big Clashflash update:
AuthorMessage
reaven
avatarposts
Excelling Guardian
Level: 20 - Posts: 312
Joined: Dec 11, 2008
aahh this is so confusing.
And tempEnemy and _enemy are the same thing.
Code:
if (tempEnemy == _enemy) {
      trace("Enemy removed: tempEnemy");
      
      //remove enemy from array
      enemyArray.splice(i,1);
      //remove movieclip from stage
      removeMovieClip(tempEnemy);  


So thats why i used
function checkEnemyHitt(_enemy:MovieClip):Void

In that way i can check if it hit something like the player or the deathwall.

I only need to implant something into the checkenemyhitt
that does all the hp of the enemys and i dont know how to do that thats the whole problem.

Hope you can help.

Greetings/Regards

Reaven


picture
Crisis
avatar
Administrator
Level: 99 - Posts: 921
Joined: Dec 8, 2006
Can you just explicitly state your question? what exactly do you want to do or need to know?


"The absence of rules is the enemy of art." ~Orson Wells
picture
reaven
avatarposts
Excelling Guardian
Level: 20 - Posts: 312
Joined: Dec 11, 2008
Ok i will start over tongue

I need a function that holds the hp for each enemy.

I already got functions that deletes them etc so if i could create an other function that if the hp for a
enemy = 0 it will call the destroy enemy function
and ofcourse i will call that function in the
onenterframe function.
The codes/scripts etc are in the previous posts.

if you need any more info ask wink

Greetings/Regards

Reaven


picture
Myth
avatar
Administrator
Level: 99 - Posts: 477
Joined: Dec 9, 2006
functions are often meant for repetitive tasks, and apparently not for storing variables. As I told you in my previous post you can can iterate over two arrays to compare all enemies with all the stuff they can be damaged by.
You need the enemies array to store your enemy hp, as I already mentioned you can store objects inside your array.

example:
Code:
var enemies:Array = new Array();
enemies.push({clip: enemymovieclip, hp: 5});
enemies.push({clip: enemymovieclip, hp: 10});
enemies.push({clip: enemymovieclip, hp: 3});


use the piece of code from my previous post to do the damage checking.

you can check the hp for each enemy like this:
Code:
for (var i = 0; i < enemies.length; i++) {
trace(enemies[i].hp);
}


so i guess you don't need a function that holds the hp for each enemy.



picture
reaven
avatarposts
Excelling Guardian
Level: 20 - Posts: 312
Joined: Dec 11, 2008
THANKS!! bigsmile bigsmile bigsmile
it works now bigsmile
but the enemys need there own hp like a circle need to have 5 hp but 1 time he has 10 and a other time he has 3.
So could you tell me how to seperate them and tell which one is which.

Greetigns/Regards

Reaven


picture
reaven
avatarposts
Excelling Guardian
Level: 20 - Posts: 312
Joined: Dec 11, 2008
Could i ahve a bit more info about your script myth?

It says Quote:
enemymovieclip
but it gives random health to the enemys.
The enemys need to have there own hp there are like 3 types type 1 has 5 hp and type 2 has 10 hp for example.

Could you help a bit further with this?

I realy appreciate your help bigsmile

Greetings

Reaven


picture
reaven
avatarposts
Excelling Guardian
Level: 20 - Posts: 312
Joined: Dec 11, 2008
hi.

i dont know whats wrong but your script doesnt work for 100% it gives them random health and sometimes they just have 1 hp confused

hope you can help.

Greetings

Reaven


picture
Crisis
avatar
Administrator
Level: 99 - Posts: 921
Joined: Dec 8, 2006
lol, I have no clue what your script even looks like in this stage so sadly I can't help you.


"The absence of rules is the enemy of art." ~Orson Wells
picture
reaven
avatarposts
Excelling Guardian
Level: 20 - Posts: 312
Joined: Dec 11, 2008
i mean myth his script
Code:
var enemies:Array = new Array();
enemies.push({clip: enemymovieclip, hp: 5});
enemies.push({clip: enemymovieclip, hp: 10});
enemies.push({clip: enemymovieclip, hp: 3});



picture
Crisis
avatar
Administrator
Level: 99 - Posts: 921
Joined: Dec 8, 2006
I figured that much since that was the exact code Myth posted. I just have no clue how you implemented it into your own code.


"The absence of rules is the enemy of art." ~Orson Wells
picture
reaven
avatarposts
Excelling Guardian
Level: 20 - Posts: 312
Joined: Dec 11, 2008
Oh my bad. wink
this is the script
Code:
function createEnemy(enemyAmount:Number, enemyBehavior:String, enemyLibraryClip:String):Void
{

  for(var i = 0; i < enemyAmount; i++)
  {
    
    var tempEnemy:MovieClip = _root.attachMovie(enemyLibraryClip, "enemy"+_root.getNextHighestDepth(),_root.getNextHighestDepth())
    
    
    tempEnemy._x = random(1140);
    tempEnemy._y = random(1030);
    tempEnemy._rotation = random(360);
    
    

    if(enemyBehavior == "typeA")
    {

      tempEnemy.health = 10;
      tempEnemy.speed = 1;
      tempEnemy.turnRate = .05;
      tempEnemy.agroRange = 200;
      tempEnemy.mode = "follow"
    } 
    else if(enemyBehavior == "typeB")
    {

      tempEnemy.health = 5;
      tempEnemy.speed = 1;
      tempEnemy.turnRate = .5;
      tempEnemy.agroRange = 200;
      tempEnemy.mode = "follow"
    }
    else if(enemyBehavior == "typeC")
    {

      tempEnemy.health = 6;
      tempEnemy.speed = 1;
      tempEnemy.turnRate = .5;
      tempEnemy.agroRange = 200;
      tempEnemy.mode = "follow"
    }
    else if(enemyBehavior == "typeD")
    {

      tempEnemy.health = 3;
      tempEnemy.speed = 1;
      tempEnemy.turnRate = .5;
      tempEnemy.agroRange = 200;
      tempEnemy.mode = "run"
    }
    
    
    
    tempEnemy.distanceX = 0;
    tempEnemy.distanceY = 0;
    tempEnemy.distanceTotal = 0;
    tempEnemy.moveDistanceX = 0;
    tempEnemy.moveDistanceY = 0;
    tempEnemy.moveX = 0;
    tempEnemy.moveY = 0;
    tempEnemy.totalmove = 0;    
    
    
    enemies.push({clip: enemymovieclip, hp: 5});
    enemies.push({clip: enemymovieclip, hp: 10});
    enemies.push({clip: enemymovieclip, hp: 6});
    enemyArray.push(tempEnemy);
  }


if you need more info just ask ^^

Greetings

Reaven


picture
Myth
avatar
Administrator
Level: 99 - Posts: 477
Joined: Dec 9, 2006
Code:
enemies.push({clip: enemymovieclip, hp: 5});

with "enemymovieclip" i meant the variable name in which you store the movieclips you attach to the root.

so:
Code:
var tempEnemy:MovieClip = _root.attachMovie(enemyLibraryClip, // ... etc

// and then
enemies.push({clip: tempEnemy, hp: 5});


but this is really confusing me. i see you use two arrays now: enemies and enemyArray. I think you should make it:

Code:
enemyArray.push({clip: tempEnemy, hp: 5});

and forget the enemies array.

Also, since tempEnemy is a movieclip object in which you already store variables, you can also store HP like this:
Code:
    
if(enemyBehavior == "typeA")
    {
      tempEnemy.hp = 10; // store hp here
      tempEnemy.health = 10;
      tempEnemy.speed = 1;
      tempEnemy.turnRate = .05;
      tempEnemy.agroRange = 200;
      tempEnemy.mode = "follow"
    } 


In this case you don't need to store objects in the array anymore and now you can simply do:
Code:
enemyArray.push(tempEnemy);


To get the hp for an enemy, you can simply loop the array:
Code:
 
for(var i = 0; i < enemyArray.length; i++) {
    trace("hp for enemy #"+i+" is: "+enemyArray[i].hp);
}


is this what you want?
because you're explanation is sometimes so foggy that my eyes hurt lol


picture
reaven
avatarposts
Excelling Guardian
Level: 20 - Posts: 312
Joined: Dec 11, 2008
it works now for 100% bigsmile
thanks for your help and time cool

Greetings

Reaven


picture
Crisis
avatar
Administrator
Level: 99 - Posts: 921
Joined: Dec 8, 2006
That's nice to hear :), good luck finishing your game ^^


"The absence of rules is the enemy of art." ~Orson Wells
picture
< Go to page: 1, 2 >
There are a total of 3152 Clashflash.com members who have posted 7266 articles. Our newest registered user is Hooooda7, welcome!
There are currently 15 users online of whom 0 logged in and 15 guest(s).
auto ban