Reading the docs, the event SMART_EVENT_RANGE says its supposed to trigger when the creature type is in range of the target type. I’m trying to get a creature to perform an action when it gets in range of another creature or game object using a SAI script.

However, when I try to have a creature perform an action when its in range of a game object or creature, it never gets triggered. Performing a search of SMART_EVENT_RANGE in the core code doesn’t yield much results… I see it is added for caster templates, but what about all other creatures/game objects? Is it implemented at all?

Or maybe there’s a better way to achieve what I’m trying to do?

Thank you!

Ok I think I’ve found my issue. I thought SMART_EVENT_RANGE would be called all the time, but it is only called when the creature is in combat, so that it satisfy the code to get a victim.

As seen in the core as of today:

        if (!me || !me->IsInCombat() || !me->GetVictim())

        if (me->IsInRange(me->GetVictim(), (float)e.event.minMaxRepeat.min, (float)e.event.minMaxRepeat.max))
            ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax, me->GetVictim());

Probably it would be nice to have an event that is triggered out-of-combat, so that creatures can check if they get in range of a specific target type. I might just add it in my core and see if it works.

Take a look at [COLOR=rgb(51,51,51)]SMART_EVENT_OOC_LOS. Hacky, but this is how all scripts alike are handled.

That’s kind of what I want to do, but I don’t want it to check LOS. So I will add my own version of the event that won’t check for LOS.

Ok so I implemented my new events to make this a lot less hacky, so I was wondering, when I do my push should I be doing it on the 4.3.4 branch or on the master? (I’m working on 4.3.4)

Thank you.

If something have use on both 3.3.5a and 4.3.4 on master, if it’s intended only for 4.3.4 only on 4.3.4

How do I create a pull request on the master branch through Git Extensions? I did a commit on my local clone, but when I try to push the changes, obviously it refuses because my account doesn’t have the rights. What is the right procedure? Do I have to do it from the github website, or can I do it from Git Extensions? Thanks.

You’ll have to fork the TC repository to your own Github account, then push your changes to your own fork and proceed to make a pull request from the fork to the TC repo.

Thanks for the info, I was able to create the pull request that way. Check it out and let me know what you think. I tested it with both guid or entry and it works like a charm.

Pushed in

Yeah sorry about the misplaced break. As for the indentation, not sure what happened, looks right in Visual Studio. Thanks for pushing this in.

No problem. You might want to change it so that gameobjects can use it too. For now I disabled that as it wouldn’t work anyway.