Aller au contenu

Photo

How to check if area has specify monster?


  • Veuillez vous connecter pour répondre
8 réponses à ce sujet

#1
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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);
    }


#2
Proleric

Proleric
  • Members
  • 2 360 messages
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.
  • WhiteTiger aime ceci

#3
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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



#4
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages

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



#5
Proleric

Proleric
  • Members
  • 2 360 messages
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.
  • WhiteTiger aime ceci

#6
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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  :D  B)



#7
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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? 



#8
Proleric

Proleric
  • Members
  • 2 360 messages

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.
  • WhiteTiger aime ceci

#9
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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.