iq has a mode called ``horde mode'' where monsters are continuously spawned and in nightmare difficulty level monsters respawn after death.
Seldom it happens that a monster is not correctly initialized and it starts acting weirdly, for example it cannot turn around, it cannot be hurt...
For example in this little movie, skip to time 6:25 and you will see I fight against a Grunt I cannot hurt and I even move through it.
My new monsters are created as the regular ones, as you can see in the ogre.qc file, I moved the monster initialization in another function and saved it in a field. (seek ``make_ogre'')
Instead in world.qc I spawn an entity and call the very same function (seek ``UnleashHorde''), so I cannot understand why it happens. I think in the original game it cannot happen as all monster are already spawned during gameplay... still I cannot understand why it happen here.
It is very similar in the subs.qc file to allow respawn of monster on nightmare difficulty level. (seek ``monster_respawn_think'')...
Any idea?
Thanks
Wrongly spawned monsters problem.
Re: Wrongly spawned monsters problem.
Code: Select all
monsterType.init(newmis);
Code: Select all
//select a random monster (in the air)
monster = nextent(world);
while (monster) {
if(monster.flags & FL_MONSTER) {
if (pointcontents(monster.origin) == CONTENT_EMPTY) {
c = c + 1;
if (random() < 1/c)
monsterType = monster;
}
}
monster = nextent(monster);
}
//spawn the new monster
newmis = spawn();
monsterType.init(newmis);
newmis.flags = newmis.flags | FL_ROAMINGMONSTER;
Re: Wrongly spawned monsters problem.
You cannot, read again. That is a very common trick to select a random object from a list you do not know the length.
In the first loop c is one so random() < 1 is always true. After all if you have to select a random object from a list of only one object you have no choice, in the second loop the new object has 50%, in the third it has 33%....
Beside you cannot reach this loop if there are no monsters in the level.
In the first loop c is one so random() < 1 is always true. After all if you have to select a random object from a list of only one object you have no choice, in the second loop the new object has 50%, in the third it has 33%....
Beside you cannot reach this loop if there are no monsters in the level.