Author Topic: How to check if area has specify monster?  (Read 648 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to check if area has specify monster?
« on: March 24, 2014, 11:07:54 pm »


               

Boss has OnDamaged event a implemented code that create a helper (mook or henchman monster) to help in the battle. I would like to limit to create a maximum of 5 monsters. How to check If there are 5 henchmans and do not create more? Or other idea that I don't look for can enter here with thanks.


 


This create a mook if the damager hit in 4 m distance


 


    //--------------------------------------------------------------------------

    //Create Creature

    //--------------------------------------------------------------------------

    object oPCDamager = GetLastDamager();

 

    if  (GetDistanceBetween(oPCDamager, OBJECT_SELF) <= 4.0)

    {

    int nCreatureDes = OBJECT_TYPE_CREATURE;

    string sMonstrDes = "resref_monster07";

    location lMonster = GetLocation(OBJECT_SELF);

    int bAnima = TRUE;

    CreateObject(nCreatureDes, sMonstrDes, lMonster, bAnima);

    }


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
How to check if area has specify monster?
« Reply #1 on: March 25, 2014, 12:07:31 am »


               Local int on area.


Initially zero. If less than 5, create helper and increment. Decrement on helper death, if you want another to appear in that situation.
               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to check if area has specify monster?
« Reply #2 on: March 25, 2014, 12:28:42 am »


               

I'm sorry, but I don't understand. How do we do to add a integer for each monster?



               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
How to check if area has specify monster?
« Reply #3 on: March 25, 2014, 01:16:34 am »


               

It would be much simpler to just check for the creatures tag - make it something unique. Check to see if the 5th nearest is valid. If not, spawn. GetNearestObjectByTag.


 


Funky



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
How to check if area has specify monster?
« Reply #4 on: March 25, 2014, 08:15:53 am »


               Well, this is what I had in mind:


   Spoiler
   



I imagine FunkySwerve is suggesting something like this:


   Spoiler
   



where "UniqueMonsterTag" is the unique tag in your monster template.

One difference between these examples as they stand is that the first one doesn't spawn more monsters if one is killed, whereas the second one does (unless your monsters leave lootable corpses, in which case the outcome is less certain). A second difference is that if there were two bosses, the first example allows them to summon 5 helpers each, whereas the second restricts it to 5 per area.

Incidentally, the second parameter to CreateObject has to be the template, not the tag, so I wonder whether "tag_monster07" is correct. If the tag in the template is not unique, you can specify a unique one as the fifth argument to CreateObject.

Also, it's perfectly acceptable to use a constant like OBJECT_TYPE_CREATURE in line; the variable nCreatureDes is unnecessary.

Likewise, the variable bAnima doesn't make the code more legible; some scripters put the literal TRUE in line, others define a constant with a meaningful name, such as USE_APPEAR_ANIMATION.
               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to check if area has specify monster?
« Reply #5 on: March 25, 2014, 04:17:49 pm »


               

I'll save those codes, but in this case I will use the second, because the players need to find the weak point of the boss and use ranged/magic attacks to destroy the leader without creating these mooks/henchmans that can not stop to be created.


 


It's a consecutive arena boss - each area has a different boss - after kill the boss, the player can enter in the "area teleport transition" to the next area (so the player group can "rest" before go next boss).


If player die, he loses your progress (go to respawn in city area) and need back to start first boss. If group kill all consecutive bosses, they won a rewards. Each boss has a specify strategy to kill then I can use two codes you give me.


 



 


 


Likewise, the variable bAnima doesn't make the code more legible; some scripters put the literal TRUE in line, others define a constant with a meaningful name, such as USE_APPEAR_ANIMATION. 

 


I just found this on Lexicon, so I think that could be more understandable. Anima = Animation. In fact it is true that we can replace this with "TRUE".


 


 



 


 


One difference between these examples as they stand is that the first one doesn't spawn more monsters if one is killed, whereas the second one does (unless your monsters leave lootable corpses, in which case the outcome is less certain). A second difference is that if there were two bosses, the first example allows them to summon 5 helpers each, whereas the second restricts it to 5 per area.

 


Yeah, it's only one boss per area. Then when we do that using more than one monster per area will use the first code.


 


 


Anything you need to me to can talk. Thanks  '<img'>  'B)'



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to check if area has specify monster?
« Reply #6 on: March 25, 2014, 04:45:16 pm »


               

tag_monster07 isn't a tag where string sMonstrDes = "tag_monster07"; it's a resref of the monster. I have changed it to a fake name. Some people can read this and think that it's a tag so I changed and edited it on my thread.


Where "UniqueMonsterTag" is the unique tag in your monster template


 


 


The second code contains:



SetLocalInt(OBJECT_SELF, "MonsterCount", nMonsterCount);

Is it only for first code? 



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
How to check if area has specify monster?
« Reply #7 on: March 25, 2014, 11:24:49 pm »


               


The second code contains:

SetLocalInt(OBJECT_SELF, "MonsterCount", nMonsterCount);
Is it only for first code?

Correct - I should have removed it from the second example. My bad.
               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to check if area has specify monster?
« Reply #8 on: March 26, 2014, 01:50:03 am »


               

It's not an example, it's an original code. I am using it and it works well. Good job and thanks for the script.