| 12-04-2009, 09:31 AM | #1 |
Is it possible to use triggers to replace AI? It will require to run code as thread so that each AI can act and use globals without affecting one another. Is ExecuteFunc a StartThread() as well with similar effect? but It seems ExecuteFunc have to takes nothing while i will require the function to pass the player that the trigger(AI) will need to control. |
| 12-04-2009, 02:40 PM | #2 |
you shoud not use normal natives inside AI control, there is no triggers and no events, AI ran in single thread. |
| 12-04-2009, 03:16 PM | #3 |
I mean to run my AI using triggers rather than .ai file. Well because I need to use some of the natives to perform decision making. There seems to be some working normal natives Just like I2S() is not working while S2R is working. There are some other important natives which I wish to use such as IssueBuildOrderById() to make the AI build in some kind of patterns and I can even build up custom formatio using normal natives to get my calculation done. |
| 12-04-2009, 06:58 PM | #4 |
It can be done. And there are some scripts here which emulates some AI natives. |
| 12-04-2009, 08:22 PM | #5 | |
Quote:
Do you mean emulates normal natives? or emulate AI natives in trigger script? |
| 12-05-2009, 04:26 AM | #6 |
You cant StartThread() inside normal code, Thread can be started only inside AI block. |
| 12-05-2009, 04:37 AM | #7 |
I mean whether the ExecuteFunc is equivalent to starting a thread or not. I was thinking to use trigger to start a universal thread and then use that thread to call StartMeleeAI() and then within each AI they start their own thread for building sequence and so on. Is there a way to declare global variables for AI script? I've only seen declaration using Variable Editor but will ai script be able to access the global there? I'm testing on this though but warcraft do not let me start the game so the map should have some error. |
| 12-05-2009, 06:07 AM | #8 |
execute will run inside other thread, soo you can use waits. inside AI no w8 is allowed. |
| 12-05-2009, 05:46 PM | #9 |
how about globals for AI? how can it be declared? Variable editor in trigger editor will not share it with AI file. ---Edited--- Is there a way to place globals into blizzard.j or common.j file without corrupting it? Whenever I add some global to common.j or blizzard.j, the warcraft will not start. |
| 12-06-2009, 09:09 AM | #10 |
import new version of blizzard.j inside map. there is no problems with globals declarations, no reasons to change main files. |
| 12-06-2009, 10:49 AM | #11 | |
Quote:
How do i import it correctly to make the map use the blizzard.j that i modified? I'm still using original WE and all i can do is import then into the imported files but not make a folder call scripts myself. Or actually i can do it? I've imported a blizzard.j but it did not use it so i guess it must be in this path scripts/blizzard.j. Did I miss something? Mind telling me how to declare globals properly so that I can achieve the global sharing variables. This is example of what i want to achieve: integer VarA is the global. and if required to be predefined then it will be set as 0. Computer 1 set VarA = 3. Computer 2 use VarA for calculations which when access it, will give the value = 3. It means that 2 different threads are sharing the very same global. if computer 1 overwrites it then computer 2 will get the new value. Declaring inside .ai file makes them not sharing the same global although it has the same name. Is there something similar to this? set T1.udg_ThreadNum = 5 accessing and changing the variables of other threads. Just like the example above where T1 is a thread name and udg_ThreadNum is a global inside that thread. |
| 12-06-2009, 11:22 AM | #12 |
To make it short. I wish to make threads communicate with each other. |
| 12-06-2009, 06:05 PM | #13 |
try to use gamecache values for this. init gamecache inside AI and use it to share data, but with 124 patch this will be very hard since you cannot share handles. |
| 12-07-2009, 08:44 AM | #14 |
+rep DioD. Alright after done some reading on gamecache -Passing data is not instant? but how slow it is? a sec? -Do they store array as well? Is it possible to pass trigger to gamecache and then access the trigger in AI? Like this? call StoreInteger( AIcache, "Test", "Trigger", H2I(testTrig) ) Then calling it from AI scripts. You're on that post i read but i didn't get it clear whether the author on that post said it is possible or not. i've read from somewhere that I2H will cause random bugs. How? Is there solution? Regarding the user defined casting functions, is it workable? such as: Code:
function Int2Str takes integer i returns string
return i
return null
endfunctionwell since I2S is not working in ai scripts, so if this is possible then it will be useful for me. |
| 12-07-2009, 01:21 PM | #15 |
return bug not allowed in 124 you cant shere hanles over cache. |
