GetFirstObjectInShape does not work
Aliberto
Member Posts: 80
Soon we will open a ticket about this problem but i want to start reporting.
When creating an NPC with the special static ability "aura of fear" (or any other kind of aura) with the editor, the GetFirstObjectInShape and GetNextObjectInShape functions most of the time do not work.
They do not "see" the creature, it is as if it did not exist, it does not return any results, it is not a question of an invalid object.
This seems to happen at the time of spawning when there are so many creatures and if the creatures are far from the character. If the creatures are created by the DM directly in game this does not happen.
We tried to remove the aura and insert it in the onspawn event, and create it a few seconds after the creature is already in game, but the problem persists.
If instead the character starts to attack a monster without aura (and then perceives it) and only then apply the aura, this is the only case in which the function works as it should.
We lost a test to try to figure out what did not work ....
We are preparing a mini module that we will attach to the ticket where to test the problem.
In the meantime, if someone has already had the same problem (and especially if he managed to solve it) he could write here please.
Thank you
When creating an NPC with the special static ability "aura of fear" (or any other kind of aura) with the editor, the GetFirstObjectInShape and GetNextObjectInShape functions most of the time do not work.
They do not "see" the creature, it is as if it did not exist, it does not return any results, it is not a question of an invalid object.
This seems to happen at the time of spawning when there are so many creatures and if the creatures are far from the character. If the creatures are created by the DM directly in game this does not happen.
We tried to remove the aura and insert it in the onspawn event, and create it a few seconds after the creature is already in game, but the problem persists.
If instead the character starts to attack a monster without aura (and then perceives it) and only then apply the aura, this is the only case in which the function works as it should.
We lost a test to try to figure out what did not work ....
We are preparing a mini module that we will attach to the ticket where to test the problem.
In the meantime, if someone has already had the same problem (and especially if he managed to solve it) he could write here please.
Thank you
0
Comments
From your description it's unclear exactly what you're doing.
The same area of the same module in version 1.69 works perfectly (it did it for 8 years).
Simply when a group of monsters with aura of fear is created and is not in the field of perception of the caster (or is partially). The function does not see the creature. I'll give you an example:
//Apply the meteor swarm VFX area impact
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eMeteor, GetLocation(OBJECT_SELF));
//Get first object in the spell area
float fDelay;
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetLocation(OBJECT_SELF));
while(GetIsObjectValid(oTarget))
{
// some instructions
object oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetLocation(OBJECT_SELF));
}
in this example if in the ray of action of the spell there were only the caster and 3 monsters, the only recognized object would be the caster. The 3 monsters would not even be invalid objects, the function ignores them completely.
The first fuction GetFirstObjectInShape would return the caster while GetNextObjectInShape would not return anything, not even an invalid object.
I am now an admirer of 1.74 for several reasons, but after many years to write script i would say that there are many things that worked with the 1.69 and now do not go, or at least work differently, the gethasspell function is a concrete example.
As soon as i find 5 minutes free i create a new module with only one area to show you what I mean. I just hope that some guy from the Beamdog try to explain to me what's going on.
For what it's worth if the get object in shape functions didn't work then most spells would simply malfunction for everybody. You can ask Beamdog but if nothing is broken you might not get an adequate response. You don't need to post a module, just paste your scripts and say exactly where you put it for example "on a creature's onspawn event."
The caller is obviously the character (PC).
then most spells would simply malfunction for everybody.
I simply want to point out that there are many functions that behave differently than 1.69
the "everybody" that you say worked in my module up to version 1.69. then he stopped without changing the scripts.
I repeat this does not want to be a post of accusation or comparison with old versions, I just want to say that there is a problem, a real problem.
If it is perceived by the Beamdog well, otherwise I will do as I did for another 100 problems, we will solve it without sharing (which in fact I have already done this morning).
Thanks for the reply, Ali
It is interesting that this person wants us to share our fix with them.
But does not what to share his fix with us.
You'll need to copy and paste your script and say where you put it in order for anyone to be able to adequately debug it for you.
There's no reason to believe that the get object in shape functions have changed without more precise information, especially not when it seems to work the same as it has for 15 years.
but ... today i wanted to spend an hour of my time to prove and publish the error.
I also changed the spell.
I apologize for the quality of the video, I do not do many and I realized after the quality. In case you understand very well (if you want to understand).
- new empty module
- only one area
- only one monster
- all the scripts are the original ones, no modified script
- I only modify a script to add a sentence in the log
good vision
https://youtu.be/xKoY3Kfe_Ys
soon I will also insert a video with the bug of the gethasspell function that is even more resounding
tnx, Ali
Not sure what to say.
It is not a problem of game mode, it is not a problem of the spell, and actually not even of the function object of this thread.
Remember that without the aura the problem never occurs.
my honest opinion is that it is a graphic (rendering?) problem, ie when the object is created with an aura it seems that for some reason it is not recognized by another object, as if the relationship between them was missing, I think a problem of the engine of the game.
It is not even an invalid object, it simply does not exist for the script called by the character.
I have made an example inserting in the log a single check, but I can assure you that we have spent 2 weeks of time to understand what was happening and the conclusion is that object for any function that can detect it, simply does not exist.
The only thing that the tag is the mouse pointer, in fact, if you try to cast a spell with a single target, the spell takes effect.
One last consideration before leaving the comment to the expert programmers who answered me in previous posts. When the character relog, all is done, the monster is correctly perceived and everything works beautifully.
tnx, Ali
If you had logs from those tests in the last two weeks then you probably should have posted them before. Without more detailed information it wont be possible to see what the cause is, things like the GetSpellTargetObject, the location of the spell target object, the SpellTargetLocation, result for LineOfSightObject and LineOfSightVector, changing difficulty, test if it also happens offline, without encounter system, and so on.
Any number of things could potentially be causing your issue and only Beamdog might know what it is. For example if it only happens online it could be a server issue.
I agree with your way of thinking and dealing with these kinds of problems. But, honestly, i do not have the time (and at this time also the desire) to understand why it happens. I also think that it is not me who has to explain it :-)
After reporting the players, we lost 2 weeks to understand what was happening. I tell you that initially we were skeptical just like you and we told players that it was not possible.
Then we found that the problem really only occurred with monsters that had some kind of aura and in different areas of the module, and we started analyzing the problem.
Now I'll give you a short list of the things we've done including the solution (i hope temporary) that we have found. More than this i will not do, because i have a lot of work to do on the module, discord, wiki, website and many players to follow :-)
- we tried to delete the "while loop" and insert in sequence a number of GetNextObjectInShape instructions equal to the number of objects present in a test area. After each of these instructions, we have inserted checks visible in the log to understand the status of the object. The result was that the instruction corresponding to the "incriminated" object did not return any results.
- we tried to test on a public server, in a LAN and also on the same machine (server + client). We have only tried on linux systems
- we tried to create the monster and insert the aura after, using the onSpawn event and the problem remained!
- we noticed that inserting monsters manually as DM the problem never occurs
- we have noticed that (after the problem occurs) if the player logs out and then reloads everything works perfectly
- we tried to make the character blind, put it in the sanctuary and do all sorts of things to then be able to make it recognize the object without success
- we have noticed that the problem often occurs when visually the monster spawna at a certain distance from the character
we have temporarily solved the problem in this way:
- eliminated the aura from all the monsters (I do not tell you how many)
- in the onSpawn event we only create the visual effect of the aura
- we have inserted an internal variable in each monster that indicates the type of aura
- in the onPerception event we inserted a script that performs the same operations as the original scirpts of the various types of aura
tnx, Ali