Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

GetFirstObjectInShape does not work

AlibertoAliberto 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


  • FreshLemonBunFreshLemonBun Member Posts: 901
    The GetFirstObjectInShape and GetNextObjectInShape functions do work correctly. The issue has to be with something else unless the GetFirstObjectInShape function was used incorrectly. If you're using the constant SHAPE_CONE then the shape may operate in a way you don't really want, in which case you need to compute the angle yourself and use spheres.

    From your description it's unclear exactly what you're doing.

  • AlibertoAliberto Member Posts: 80
    I'm not doing anything, I use original scripts of version 1.69 of area spells such as meteor swarm or similar.
    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));
    // 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.

  • FreshLemonBunFreshLemonBun Member Posts: 901
    You would have to post your code to figure out why your script doesn't work. The only thing I can see in the snippet you posted besides typos is that OBJECT_SELF changes depending on the caller, if the caller isn't who you think it is then the function wont work as expected.

    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."

  • AlibertoAliberto Member Posts: 80
    :-) sorry if I'm laughing, this script is exactly the copy of the original script file of the Meteor Swarm spell (evidently including typos), they are the guys in the Beamdog who must say why it does not work.
    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

  • squattingmonksquattingmonk Member Posts: 59
    Again, you'd have to post your script. If it is working in the meteor swarm script, then there's a good possibility it's not GetFirstObjectInShape() that's broken.

  • raz651raz651 Member Posts: 175

    It is interesting that this person wants us to share our fix with them.

    Aliberto said:

    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

    But does not what to share his fix with us.

    Aliberto said:

    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

  • FreshLemonBunFreshLemonBun Member Posts: 901
    The thing you posted contains typos because you define "object oTarget" twice, which means it would never compile, the spell script for meteor swarm doesn't contain this mistake. If you open up nw_s0_metswarm you'll find that it is different to what you posted, as it is a complete spell script and what you posted is a snippet that doesn't really show anything. For what it's worth the spell meteor swarm functions correctly and has not changed from 1.69 to 1.74 so the issue you're having is not with the spell not working.

    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.

  • meaglynmeaglyn Member Posts: 89
    It will actually compile as is since the second "object oTarget" is in a narrower scope. It is legal to do that although some compilers can warn you if you are shadowing a variable in a larger scope. What this will do though is never change the oTarget variable that is controlling the loop. So if there is a first object in shape this script will just run until TMI and then exit.

  • FreshLemonBunFreshLemonBun Member Posts: 901
    That's pretty interesting and probably has something to do with what was going on, although the meteor swarm spell does it correctly.

  • AlibertoAliberto Member Posts: 80
    ok, i'm wrong a copy-paste ....
    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

    soon I will also insert a video with the bug of the gethasspell function that is even more resounding

    tnx, Ali

  • BalkothBalkoth Member Posts: 147
    I watched the whole video and I'm not seeing the bug you're referring to.

  • FlipFlopJKFlipFlopJK Member Posts: 3
    edited May 2018
    yes, there is a bug, at min 4:43 - 4:45 when he cast the spell against the balor at the right of the rock. It seems that the speel don't see monster, infact at the end of the video he cast the spell against the last balor, but the effect of the spell doesn't appear in the log and if you read the YELL, the target is the character instead the balor

    Post edited by FlipFlopJK on
  • BalkothBalkoth Member Posts: 147
    I see what you mean. However, repeating his experiment (using Scintillating Sphere against one Balor which is located east of the caster) results in the Balor being hit (along with the character, who IS targeted because of the AoE spell...looks like he's playing on Normal mode, though so it doesn't hurt him. I did test this on normal and hardcore mode, though, both hit the Balor).

    Not sure what to say.

  • AlibertoAliberto Member Posts: 80
    edited May 2018
    Balkoth said:

    Not sure what to say.

    Thanks for reply.
    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

  • FreshLemonBunFreshLemonBun Member Posts: 901
    It isn't clear what is going on but I don't see the reason to conclude that it is a bug with the GetFirstObjectInShape function. I also tried to reproduce the issue but as with Balkoth I was unable to reproduce the same result as you showed.

    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.

  • AlibertoAliberto Member Posts: 80
    Thanks for reply.
    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

Sign In or Register to comment.