Let's say I'm making a spell with Duration = 1 Round/lv that can be casted starting at level X.
So the Duration for X = 6, for X+1 = 12, etc...
Is there a way to automatically fill this? Because what I do is manually change every effect in every field and it can be a pain sometimes.
Thanks!
Oh, and I missed this the first time. Let me introduce you to the Extend-o-matic. Let's say I wanted to alter the duration of the third level hold spell from a flat one turn to, say, the same duration as haste (three rounds + one round per level)
So, first question, is what I want to do doable staying into one dialog (i.e. using ActionOverride) or do I have to make a secondary dialog so that my created creature will actually be able to pick the items? If the first option's a yes, what am I doing wrong?
Yes. Just create an invisible creature, add a script to prompt them to speak with LastSummonerOf(Myself), and then assign your dialogue. Limited Wish is probably a good example to draw upon for the spell and creature.
Second question, IESDP says that TakePartyItem takes entire stacks at once, and it can't remove a single instance of an item if these items are stacked. Is there a workaround to that? A way to take a single item from a stack?
TakePartyItemNum("arow01",1) will take one arrow from a stack.
Let's say I'm making a spell with Duration = 1 Round/lv that can be casted starting at level X.
So the Duration for X = 6, for X+1 = 12, etc...
Is there a way to automatically fill this? Because what I do is manually change every effect in every field and it can be a pain sometimes.
Thanks!
Oh, and I missed this the first time. Let me introduce you to the Extend-o-matic. Let's say I wanted to alter the duration of the third level hold spell from a flat one turn to, say, the same duration as haste (three rounds + one round per level)
@Raduziel There are two main reasons: First one is, you can't check inventory through a spell. So if you don't have POTN44 and select that option for example, you would still be able to cast the spell, and obtain the brewed potion, without consuming anything. Second one is, if you want to brew multiple potions at one, the dialog allows you to do that much faster, while the spell only allows you one potion every 6 seconds.
And last reason, OPcode 123 has the same issue as action TakePartyItem, which is that it removes entire stacks.
So, first question, is what I want to do doable staying into one dialog (i.e. using ActionOverride) or do I have to make a secondary dialog so that my created creature will actually be able to pick the items? If the first option's a yes, what am I doing wrong?
Yes. Just create an invisible creature, add a script to prompt them to speak with LastSummonerOf(Myself), and then assign your dialogue. Limited Wish is probably a good example to draw upon for the spell and creature.
Yeah I know that's already what I am doing for the overall system. In my example the creature I am summoning has ZKWTBREW as a resource name, and I am trying to make it take the potion that is supposed to be consumed by the dialog using ActionOverride, but there must be something I am doing wrong with it, or maybe.
I took the TakePartyItemNum advice and edited the dialog file accordingly. Here's the complete dialog file I use (kind of a spoil of my next mod I guess ):
BEGIN ZKWTBREW
IF ~TRUE()~ brew SAY ~Choose a Potion~ +~Global("ZKWTTHUN","LOCALS",0) OR(6) PartyHasItem("POTN03") PartyHasItem("POTN04") PartyHasItem("POTN05") PartyHasItem("POTN06") PartyHasItem("POTN07") PartyHasItem("POTN12") PartyHasItem("POTN44")~+~Thunderbolt Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ thunderbolt
IF ~~ thunderbolt SAY ~Thunderbolt increases physical damage both dealt and received by 30%. You can brew 2 of them using any potion of strength you have available.~ +~PartyHasItem("POTN44")~+ ~Brew using Potion of Strength~ DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN44",1))~ +brew +~PartyHasItem("POTN03")~+ ~Brew using Potion of Hill Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN03",1))~ +brew +~PartyHasItem("POTN04")~+ ~Brew using Potion of Frost Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN04",1))~ +brew +~PartyHasItem("POTN05")~+ ~Brew using Potion of Fire Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN05",1))~ +brew +~PartyHasItem("POTN06")~+ ~Brew using Potion of Cloud Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN06",1))~ +brew +~PartyHasItem("POTN07")~+ ~Brew using Potion of Storm Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN07",1))~ +brew +~PartyHasItem("POTN12")~+ ~Brew using Potion of Stone Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN12",1))~ +brew +~TRUE()~+~Brew something else~+brew
END
IF ~~ blizzard SAY ~While under the effects of the Blizzard Potion, everytime you make a kill, time is stopped for 2 seconds. You can brew 2 of them using an Oil of Speed~ +~PartyHasItem("POTN14")~+ ~Brew using Oil of Speed~DO ~CreateItem("ZKWTBLIZ",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN14",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ fullmoon SAY ~A Full Moon potion increases your maximum hit points by 20%. You can brew 5 of them using an Elixir of Health~ +~PartyHasItem("POTN17")~+ ~Brew using Elixir of Health~DO ~CreateItem("ZKWTFUMO",5,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN17",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ swallow SAY ~Swallow gives you a 1 HP/second regeneration for one turn, but decreases the physical damage you inflict by 20% for the same duration. You can brew 1 of them using any potion of healing you have available.~ +~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTSWAL",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew +~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTSWAL",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew +~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTSWAL",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew +~TRUE()~+~Brew something else~+brew
END
IF ~~ raffard SAY ~White Raffard's Decoction instantly restores you to 50% of your hit points. You can brew 1 of them using any potion of healing you have available.~ +~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTRAFF",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew +~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTRAFF",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew +~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTRAFF",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew +~TRUE()~+~Brew something else~+brew
END
IF ~~ honey SAY ~White Honey instantly dispels effects on you, both negative and positive, and restores your toxicity to 0. You can brew 1 of them using any potion of healing you have available.~ +~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTWHHO",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew +~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTWHHO",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew +~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTWHHO",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew +~PartyHasItem("POTN20")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTWHHO",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN20",1))~ +brew +~TRUE()~+~Brew something else~+brew
END
IF ~~ golden SAY ~A Golden Oriole potion cures and grants immunity to disease and poison. You can brew 1 using an antidote.~ +~PartyHasItem("POTN20")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTGOOR",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN20",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ petri SAY ~Petri's Philter increases your elemental damage by 30%. You can brew 3 using a potion of genius.~ +~PartyHasItem("POTN29")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTPEPH",3,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN29",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ wolf SAY ~Wolf's Elixir increases your critical hit range by 3. You can brew 3 using a potion of agility.~ +~PartyHasItem("POTN19")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTWOLF",3,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN19",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ thunderbolt2 SAY ~Enhanced Thunderbolt increases the physical damage you deal by 60% and the physical damage you receive by 30%. You can brew 2 of them using any potion of strength you have available.~ +~PartyHasItem("POTN44")~+ ~Brew using Potion of Strength~ DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN44",1))~ +brew +~PartyHasItem("POTN03")~+ ~Brew using Potion of Hill Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN03",1))~ +brew +~PartyHasItem("POTN04")~+ ~Brew using Potion of Frost Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN04",1))~ +brew +~PartyHasItem("POTN05")~+ ~Brew using Potion of Fire Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN05",1))~ +brew +~PartyHasItem("POTN06")~+ ~Brew using Potion of Cloud Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN06",1))~ +brew +~PartyHasItem("POTN07")~+ ~Brew using Potion of Storm Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN07",1))~ +brew +~PartyHasItem("POTN12")~+ ~Brew using Potion of Storm Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN12",1))~ +brew +~TRUE()~+~Brew something else~+brew
END
IF ~~ blizzard2 SAY ~While under the effects of the Enhanced Blizzard Potion, everytime you make a kill, time is stopped for 6 seconds. You can brew 2 of them using an Oil of Speed~ +~PartyHasItem("POTN14")~+ ~Brew using Oil of Speed~DO ~CreateItem("ZKWTBLI2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN14",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ fullmoon2 SAY ~An Enhanced Full Moon potion increases your maximum hit points by 50%. You can brew 5 of them using an Elixir of Health~ +~PartyHasItem("POTN17")~+ ~Brew using Elixir of Health~DO ~CreateItem("ZKWTFUM2",5,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN17",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ swallow2 SAY ~Enhanced Swallow gives you a 3 HP/second regeneration for one turn, but decreases the physical damage you inflict by 20% for the same duration. You can brew 1 of them using any potion of healing you have available.~ +~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTSWA2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew +~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTSWA2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew +~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTSWA2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew +~TRUE()~+~Brew something else~+brew
END
IF ~~ raffard2 SAY ~Enhanced White Raffard's Decoction instantly restores you to 80% of your hit points. You can brew 1 of them using any potion of healing you have available.~ +~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTRAF2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew +~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTRAF2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew +~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTRAF2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew +~TRUE()~+~Brew something else~+brew
END
IF ~~ golden2 SAY ~An Enhanced Golden Oriole potion cures and grants immunity to disease and poison, as well as protection from Mind affecting effects. You can brew 1 using an antidote.~ +~PartyHasItem("POTN20")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTGOO2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN20",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ petri2 SAY ~Enhanced Petri's Philter increases your elemental damage by 60%. You can brew 3 using a potion of genius.~ +~PartyHasItem("POTN29")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTPEP2",3,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN29",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ wolf2 SAY ~Enhanced Wolf's Elixir increases your critical hit range by 6. You can brew 3 using a potion of agility.~ +~PartyHasItem("POTN19")~+ ~Brew using Antidote~ DO ~CreateItem("ZKWTWOL2",3,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN19",1))~ +brew +~TRUE()~+~Brew something else~+brew END
IF ~~ quit SAY ~You are done brewing potions for now.~ IF ~~ DO ~SetGlobal("ZKWtDialog","GLOBAL",2)~ EXIT END
And for some reason my creature, with resource name ZKWTBREW, can't take the item from my inventory, probably because I'm doing something wrong with the object identifier, I just don't know what.
Also, totally unrelated, but mode 3 of opcode 12 is dealing percentage damage. Is it percentage of maximum health or percentage of current health?
Dumb question, for the next version of EEUITweaks, I want to rename one component (lefreut's BG2 Store Screen Tweaks) and also probably rename the resources and directories used by this component (remove the BG2 because I will make it compatible with BGEE and SoD).
Is it safe to do it or is it considered a bad practice?
The actions in a dialogue are executed by the creature running the dialogue; you don't need an AO here at all. So, for example, your actions here are being run as if the player was executing the dialogue:
DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN44",1))~ +brew
You want to instead use something like:
DO ~TakePartyItemNum("POTN44",1) GiveItemCreate("ZKWTTHUN",LastTalkedToBy,2,0,0) DestroyItem("potn44")~ +brew
@CamDawg thank you very much. Actually my mistake was much more stupid than that, but for some reason the script I used was making it so it would set my character's dialog file to something, and then the player would talk to himself. Totally far-fetched and stupid, dunno why I did that.
I used the line of action you gave me and now it works just as intended, thank you a lot.
One last question for now, I promise. Is there a way to heal a creature by a %. Healing mode 1 is increment, mode 2 is set, mode 3 is set % (which from what I understand sets your HP to a % of your maximum HP).
Something like, I don't know, negative damage using damage mode 4?
Dumb question, for the next version of EEUITweaks, I want to rename one component (lefreut's BG2 Store Screen Tweaks) and also probably rename the resources and directories used by this component (remove the BG2 because I will make it compatible with BGEE and SoD).
Is it safe to do it or is it considered a bad practice?
From someone who started with Cam's Tweaks, then merged it with Idobek's Tweaks to become G3 Tweaks, which then spawned Tutu Tweaks, then renamed G3 Tweaks to BG2 Tweaks, which then spawned BG Tweaks, IWD Tweaks, IWD2 Tweaks, and PsT Tweaks, added Ease of Use and IWD-in-BG2 Tweaks and then merged all of these back into Tweaks Anthology... yes, you'll be fine.
It applies a 100% spell failure using Opcode60 or it is a whole different thing?
Thanks!
When you look at a BG2 dead magic area like ar3004, you'll notice that its area script spams spin646 every couple of rounds. spin646 is a no-visual, always-work dispel magic plus the aforementioned op 60s on top.
It applies a 100% spell failure using Opcode60 or it is a whole different thing?
Thanks!
When you look at a BG2 dead magic area like ar3004, you'll notice that its area script spams spin646 every couple of rounds. spin646 is a no-visual, always-work dispel magic plus the aforementioned op 60s on top.
Every dead-magic area uses this same spell?
A character immune to Opcode60 would also be immune to this effect, right?
Some more noob WeiDU questions - I have a function, and I want to "return" an array of values. I've thought of passing in an array name into the function, and then having the function fill that array, but since all SETs are local in a function this doesn't work. I think this would work in a macro, but I would really prefer using a function. Is there something I am missing, or is a macro the only way to go? And as an aside, is there any naming conventions I should be using for variables I "pass" into macros and define in macros to make sure I don't have any collisions in the global scope? Thanks!
@CamDawg apparently there is no way of granting immunity against dead-magic areas.
I tried setting immunity against Opcode 60 without success.
And then I tried immunity against the specific spell (SPIN646 IIRC), also without success.
The spell that grants immunity is coded as Non-Magical and Permanent After Death, so I don't know if it can be affected by the dispel you talked about.
Am I missing something here?
PS: I was able to get cast spells normally in the dead-magic area of SoD (the one the party is ambushed by an assassin), but Watcher's Keep keeps misleading me.
And then I tried immunity against the specific spell (SPIN646 IIRC), also without success.
The spell that grants immunity is coded as Non-Magical and Permanent After Death, so I don't know if it can be affected by the dispel you talked about.
I'm actually surprised that didn't work--it's what I was going to suggest.
Some more noob WeiDU questions - I have a function, and I want to "return" an array of values. I've thought of passing in an array name into the function, and then having the function fill that array, but since all SETs are local in a function this doesn't work. I think this would work in a macro, but I would really prefer using a function. Is there something I am missing, or is a macro the only way to go? And as an aside, is there any naming conventions I should be using for variables I "pass" into macros and define in macros to make sure I don't have any collisions in the global scope? Thanks!
You can return values from a macro or function, including arrays. You need to define returned variables with RET; here's a macro I wrote that adds a new portrait icon to statdesc.2da and then returns the value of the new entry as the variable icon:
DEFINE_ACTION_FUNCTION cd_new_portrait_icon INT_VAR string = 0 STR_VAR bam_file = "****" RET icon BEGIN
You can return values from a macro or function, including arrays.
Maybe, I'm just not doing it correctly, but I still can't get it to work. I know how to return both an int and a string from a function, but I really want to return an array, like, accessed with the array construct $. Take this for example:
DEFINE_ACTION_FUNCTION RETURN_ARRAY
RET
array
BEGIN
ACTION_DEFINE_ARRAY array BEGIN ~Hello~ ~World~ END
END
LAF RETURN_ARRAY RET array END
OUTER_SPRINT temp $array(0)
PRINT ~Temp: %temp%~
Obviously this doesn't work, but I would expect to be able to access the array "array" from outside the function. In fact, WeiDU throws an error stating that the return value "array" is not defined. I believe that this is because all the array construct does is expand the variable name out to something like array_0, so I don't believe they are "real" values that can be passed around. Am I missing something?
Ah, I may be ahead of myself. @argent77made the request (and Wisp completed it) to be able to return arrays on Feb 10 and I don't think it was included in the WeiDU v244 release.
OK, I've got a big and confusing one here. I'm trying to do some Regexp stuff in WeiDU, and I've created a macro that lets me run a regexp on a string, and then get both the matched indexes and the matched strings out. Here it is:
DEFINE_ACTION_MACRO getRegexpInString BEGIN
/**
* Arguments:
* VAR_STR getRegexpInString.string
* VAR_STR getRegexpInString.to_find
*
* VAR_STR getRegexpInString.indexes_array
* VAR_STR getRegexpInString.values_array
*/
LOCAL_SET index = 0
LOCAL_SET insertion_index = 0
ACTION_IF VARIABLE_IS_SET getRegexpInString.indexes_array AND NOT IS_AN_INT getRegexpInString.indexes_array BEGIN
OUTER_PATCH ~%getRegexpInString.string%~ BEGIN
SET index = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~%getRegexpInString.to_find%~)
WHILE index != 0 - 1 BEGIN
PATCH_PRINT ~getRegexpInString INDEX_BUFFER found match at index %index%~
SET $~%getRegexpInString.indexes_array%~(~%insertion_index%~) = index
SET index = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~%getRegexpInString.to_find%~ index + 1)
SET insertion_index += 1
END
END
END
OUTER_SET insertion_index = 0
ACTION_IF VARIABLE_IS_SET getRegexpInString.values_array AND NOT IS_AN_INT getRegexpInString.values_array BEGIN
OUTER_PATCH ~%getRegexpInString.string%~ BEGIN
REPLACE_EVALUATE CASE_INSENSITIVE ~%getRegexpInString.to_find%~ BEGIN
PATCH_PRINT ~getRegexpInString REPLACE_EVALUATE found match "%MATCH0%"~
SPRINT $~%getRegexpInString.values_array%~(~%insertion_index%~) ~%MATCH0%~
SET insertion_index += 1
END
~%MATCH0%~
END
END
OUTER_SET getRegexpInString.indexes_array = 0 - 1
OUTER_SET getRegexpInString.values_array = 0 - 1
END
I apologize for the forum's formatting of the code. Anyway, am I baffled, because it seems like INDEX_BUFFER and REPLACE_EVALUATE are interpreting the same regexp differently. If I run that macro with this code:
INDEX_BUFFER is giving me the output I want, but REPLACE_EVALUATE isn't. Why in the world are they behaving differently? I've gone over my code again and again, and I can't find anything conceptually wrong with it. I know this is a big question to ask, but does *anyone* have any idea what is going on? Thank you immensely if you are still reading this after that big info dump.
EDIT: I've made a version that returns the values I expect it to, it is just really inefficient because I had to use a workaround, and this workaround has to take many unnecessary substrings. Here it is if anyone is wondering:
DEFINE_ACTION_MACRO getRegexpInString BEGIN
/**
* Arguments:
* VAR_STR getRegexpInString.string
* VAR_STR getRegexpInString.to_find
*
* VAR_STR getRegexpInString.indexes_array
* VAR_STR getRegexpInString.values_array
*/
LOCAL_SET index = 0
LOCAL_SET insertion_index = 0
LOCAL_SET inner_loop_count = 0
LOCAL_SPRINT after_index ~~
OUTER_PATCH ~%getRegexpInString.string%~ BEGIN
SET index = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~%getRegexpInString.to_find%~)
WHILE index != 0 - 1 BEGIN
PATCH_IF VARIABLE_IS_SET getRegexpInString.indexes_array AND NOT IS_AN_INT getRegexpInString.indexes_array BEGIN
SET $~%getRegexpInString.indexes_array%~(~%insertion_index%~) = index
END
PATCH_IF VARIABLE_IS_SET getRegexpInString.values_array AND NOT IS_AN_INT getRegexpInString.values_array BEGIN
READ_ASCII index after_index (BUFFER_LENGTH - index)
SET inner_loop_count = 0
INNER_PATCH ~%after_index%~ BEGIN
REPLACE_EVALUATE CASE_INSENSITIVE ~%getRegexpInString.to_find%~ BEGIN
PATCH_IF inner_loop_count == 0 BEGIN
SPRINT $~%getRegexpInString.values_array%~(~%insertion_index%~) ~%MATCH0%~
SET inner_loop_count += 1
END
END
~%MATCH0%~
END
END
SET index = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~%getRegexpInString.to_find%~ index + 1)
SET insertion_index += 1
END
END
OUTER_SET getRegexpInString.indexes_array = 0 - 1
OUTER_SET getRegexpInString.values_array = 0 - 1
END
@Bubb INDEX_BUFFER finds the next instance of regexp starting from the specified index. REPLACE_EVALUATE finds the each instance of regexp starting from the first character after the last instance of regexp.
@kjeron Thank you for clarifying. That is the conclusion I came to after some more testing.. which is a shame, really. Here is the scenario I want to accomplish: I want to be able to find all the starting indexes of a certain regexp, AND I want to grab the matched strings. Basically, I want to have an INDEX_BUFFER that also returns to me the string it matched (or, alternatively, the length of the string it just matched). Is there any way to do this better than the edit I made on my previous post? My version is *really* laggy because of how much unnecessary work it has to do, but it's the only way I could figure out.
Hello, I had two questions: Is the level of a simulacrum hardcoded to 60% of the caster's level? And how does OPcode 165 (Pause Target) works exactly: is there any way to be immune to that OPcode and does it set any flags (state_helpless flag in mind mostly) while active?
EDIT: I would like to make an AoE spell that checks if the target is helpless, and if it is the case, it has 25% chance of being slain instantly. How do I proceed? Can I do that directly somehow using OPcode 232 ? Or do I need to cast a spell that will add an effect to the targets, with the said effect triggering OPcode 232 on the target, checking if they are helpless and slaying them if this is the case? Or maybe another solution?
Comments
First one is, you can't check inventory through a spell. So if you don't have POTN44 and select that option for example, you would still be able to cast the spell, and obtain the brewed potion, without consuming anything.
Second one is, if you want to brew multiple potions at one, the dialog allows you to do that much faster, while the spell only allows you one potion every 6 seconds.
And last reason, OPcode 123 has the same issue as action TakePartyItem, which is that it removes entire stacks.
Yeah I know that's already what I am doing for the overall system. In my example the creature I am summoning has ZKWTBREW as a resource name, and I am trying to make it take the potion that is supposed to be consumed by the dialog using ActionOverride, but there must be something I am doing wrong with it, or maybe.
I took the TakePartyItemNum advice and edited the dialog file accordingly. Here's the complete dialog file I use (kind of a spoil of my next mod I guess ):
BEGIN ZKWTBREW
IF ~TRUE()~ brew
SAY ~Choose a Potion~
+~Global("ZKWTTHUN","LOCALS",0)
OR(6)
PartyHasItem("POTN03")
PartyHasItem("POTN04")
PartyHasItem("POTN05")
PartyHasItem("POTN06")
PartyHasItem("POTN07")
PartyHasItem("POTN12")
PartyHasItem("POTN44")~+~Thunderbolt Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ thunderbolt
+~Global("ZKWTTHUN","LOCALS",1)
OR(6)
PartyHasItem("POTN03")
PartyHasItem("POTN04")
PartyHasItem("POTN05")
PartyHasItem("POTN06")
PartyHasItem("POTN07")
PartyHasItem("POTN12")
PartyHasItem("POTN44")~+~Enhanced Thunderbolt Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ thunderbolt2
+~Global("ZKWTBLIZ","LOCALS",0)
PartyHasItem("POTN14")~+~Blizzard Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ blizzard
+~Global("ZKWTBLIZ","LOCALS",1)
PartyHasItem("POTN14")~+~Enhanced Blizzard Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ blizzard2
+~Global("ZKWTFUMO","LOCALS",0)
PartyHasItem("POTN17")~+~Full Moon Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ fullmoon
+~Global("ZKWTFUMO","LOCALS",1)
PartyHasItem("POTN17")~+~Enhanced Full Moon Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ fullmoon2
+~Global("ZKWTGOOR","LOCALS",0)
PartyHasItem("POTN20")~ +~Golden Oriole Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ golden
+~Global("ZKWTGOOR","LOCALS",1)
PartyHasItem("POTN20")~ +~Enhanced Golden Oriole Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ golden2
+~Global("ZKWTPEPH","LOCALS",0)
PartyHasItem("POTN29")~+~Petri's Philter~ DO ~SetGlobal("Start","LOCALS",1)~+ petri
+~Global("ZKWTPEPH","LOCALS",1)
PartyHasItem("POTN29")~+~Enhanced Petri's Philter~ DO ~SetGlobal("Start","LOCALS",1)~+ petri2
+~Global("ZKWTSWAL","LOCALS",0)
OR(3)
PartyHasItem("POTN08")
PartyHasItem("POTN52")
PartyHasItem("POTN55")~+~Swallow Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ swallow
+~Global("ZKWTSWAL","LOCALS",1)
OR(3)
PartyHasItem("POTN08")
PartyHasItem("POTN52")
PartyHasItem("POTN55")~+~Enhanced Swallow Potion~ DO ~SetGlobal("Start","LOCALS",1)~+ swallow2
+~Global("ZKWTRAFF","LOCALS",0)
OR(3)
PartyHasItem("POTN08")
PartyHasItem("POTN52")
PartyHasItem("POTN55")~+~White Raffard's Decoction~ DO ~SetGlobal("Start","LOCALS",1)~+ raffard
+~Global("ZKWTRAFF","LOCALS",1)
OR(3)
PartyHasItem("POTN08")
PartyHasItem("POTN52")
PartyHasItem("POTN55")~+~Enhanced White Raffard's Decoction~ DO ~SetGlobal("Start","LOCALS",1)~+ raffard2
+~Global("ZKWTWOLF","LOCALS",0)
PartyHasItem("POTN19")~+~Wolf's Elixir~ DO ~SetGlobal("Start","LOCALS",1)~+ wolf
+~Global("ZKWTWOLF","LOCALS",0)
PartyHasItem("POTN19")~+~Enhanced Wolf's Elixir~ DO ~SetGlobal("Start","LOCALS",1)~+ wolf2
+~OR(4)
PartyHasItem("POTN08")
PartyHasItem("POTN52")
PartyHasItem("POTN55")
PartyHasItem("POTN20")~+~White Honey~ DO ~SetGlobal("Start","LOCALS",1)~+ honey
+~TRUE()~+~Quit brewing~+ quit
END
IF ~~ thunderbolt
SAY ~Thunderbolt increases physical damage both dealt and received by 30%. You can brew 2 of them using any potion of strength you have available.~
+~PartyHasItem("POTN44")~+ ~Brew using Potion of Strength~ DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN44",1))~ +brew
+~PartyHasItem("POTN03")~+ ~Brew using Potion of Hill Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN03",1))~ +brew
+~PartyHasItem("POTN04")~+ ~Brew using Potion of Frost Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN04",1))~ +brew
+~PartyHasItem("POTN05")~+ ~Brew using Potion of Fire Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN05",1))~ +brew
+~PartyHasItem("POTN06")~+ ~Brew using Potion of Cloud Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN06",1))~ +brew
+~PartyHasItem("POTN07")~+ ~Brew using Potion of Storm Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN07",1))~ +brew
+~PartyHasItem("POTN12")~+ ~Brew using Potion of Stone Giant Strength~DO ~CreateItem("ZKWTTHUN",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN12",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ blizzard
SAY ~While under the effects of the Blizzard Potion, everytime you make a kill, time is stopped for 2 seconds. You can brew 2 of them using an Oil of Speed~
+~PartyHasItem("POTN14")~+ ~Brew using Oil of Speed~DO ~CreateItem("ZKWTBLIZ",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN14",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ fullmoon
SAY ~A Full Moon potion increases your maximum hit points by 20%. You can brew 5 of them using an Elixir of Health~
+~PartyHasItem("POTN17")~+ ~Brew using Elixir of Health~DO ~CreateItem("ZKWTFUMO",5,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN17",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ swallow
SAY ~Swallow gives you a 1 HP/second regeneration for one turn, but decreases the physical damage you inflict by 20% for the same duration. You can brew 1 of them using any potion of healing you have available.~
+~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTSWAL",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew
+~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTSWAL",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew
+~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTSWAL",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ raffard
SAY ~White Raffard's Decoction instantly restores you to 50% of your hit points. You can brew 1 of them using any potion of healing you have available.~
+~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTRAFF",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew
+~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTRAFF",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew
+~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTRAFF",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ honey
SAY ~White Honey instantly dispels effects on you, both negative and positive, and restores your toxicity to 0. You can brew 1 of them using any potion of healing you have available.~
+~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTWHHO",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew
+~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTWHHO",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew
+~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTWHHO",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew
+~PartyHasItem("POTN20")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTWHHO",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN20",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ golden
SAY ~A Golden Oriole potion cures and grants immunity to disease and poison. You can brew 1 using an antidote.~
+~PartyHasItem("POTN20")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTGOOR",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN20",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ petri
SAY ~Petri's Philter increases your elemental damage by 30%. You can brew 3 using a potion of genius.~
+~PartyHasItem("POTN29")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTPEPH",3,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN29",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ wolf
SAY ~Wolf's Elixir increases your critical hit range by 3. You can brew 3 using a potion of agility.~
+~PartyHasItem("POTN19")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTWOLF",3,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN19",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ thunderbolt2
SAY ~Enhanced Thunderbolt increases the physical damage you deal by 60% and the physical damage you receive by 30%. You can brew 2 of them using any potion of strength you have available.~
+~PartyHasItem("POTN44")~+ ~Brew using Potion of Strength~ DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN44",1))~ +brew
+~PartyHasItem("POTN03")~+ ~Brew using Potion of Hill Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN03",1))~ +brew
+~PartyHasItem("POTN04")~+ ~Brew using Potion of Frost Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN04",1))~ +brew
+~PartyHasItem("POTN05")~+ ~Brew using Potion of Fire Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN05",1))~ +brew
+~PartyHasItem("POTN06")~+ ~Brew using Potion of Cloud Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN06",1))~ +brew
+~PartyHasItem("POTN07")~+ ~Brew using Potion of Storm Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN07",1))~ +brew
+~PartyHasItem("POTN12")~+ ~Brew using Potion of Storm Giant Strength~DO ~CreateItem("ZKWTTHU2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN12",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ blizzard2
SAY ~While under the effects of the Enhanced Blizzard Potion, everytime you make a kill, time is stopped for 6 seconds. You can brew 2 of them using an Oil of Speed~
+~PartyHasItem("POTN14")~+ ~Brew using Oil of Speed~DO ~CreateItem("ZKWTBLI2",2,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN14",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ fullmoon2
SAY ~An Enhanced Full Moon potion increases your maximum hit points by 50%. You can brew 5 of them using an Elixir of Health~
+~PartyHasItem("POTN17")~+ ~Brew using Elixir of Health~DO ~CreateItem("ZKWTFUM2",5,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN17",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ swallow2
SAY ~Enhanced Swallow gives you a 3 HP/second regeneration for one turn, but decreases the physical damage you inflict by 20% for the same duration. You can brew 1 of them using any potion of healing you have available.~
+~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTSWA2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew
+~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTSWA2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew
+~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTSWA2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ raffard2
SAY ~Enhanced White Raffard's Decoction instantly restores you to 80% of your hit points. You can brew 1 of them using any potion of healing you have available.~
+~PartyHasItem("POTN08")~+ ~Brew using Potion of Healing~DO ~CreateItem("ZKWTRAF2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN08",1))~ +brew
+~PartyHasItem("POTN52")~+ ~Brew using Potion of Extra Healing~DO ~CreateItem("ZKWTRAF2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN52",1))~ +brew
+~PartyHasItem("POTN55")~+ ~Brew using Potion of Superior Healing~DO ~CreateItem("ZKWTRAF2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN55",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ golden2
SAY ~An Enhanced Golden Oriole potion cures and grants immunity to disease and poison, as well as protection from Mind affecting effects. You can brew 1 using an antidote.~
+~PartyHasItem("POTN20")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTGOO2",1,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN20",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ petri2
SAY ~Enhanced Petri's Philter increases your elemental damage by 60%. You can brew 3 using a potion of genius.~
+~PartyHasItem("POTN29")~+ ~Brew using Antidote~DO ~CreateItem("ZKWTPEP2",3,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN29",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ wolf2
SAY ~Enhanced Wolf's Elixir increases your critical hit range by 6. You can brew 3 using a potion of agility.~
+~PartyHasItem("POTN19")~+ ~Brew using Antidote~ DO ~CreateItem("ZKWTWOL2",3,0,0) ActionOverride("ZKWTBREW",TakePartyItemNum("POTN19",1))~ +brew
+~TRUE()~+~Brew something else~+brew
END
IF ~~ quit
SAY ~You are done brewing potions for now.~
IF ~~ DO ~SetGlobal("ZKWtDialog","GLOBAL",2)~ EXIT
END
And for some reason my creature, with resource name ZKWTBREW, can't take the item from my inventory, probably because I'm doing something wrong with the object identifier, I just don't know what.
Also, totally unrelated, but mode 3 of opcode 12 is dealing percentage damage. Is it percentage of maximum health or percentage of current health?
Is it safe to do it or is it considered a bad practice?
I used the line of action you gave me and now it works just as intended, thank you a lot.
One last question for now, I promise. Is there a way to heal a creature by a %. Healing mode 1 is increment, mode 2 is set, mode 3 is set % (which from what I understand sets your HP to a % of your maximum HP).
Something like, I don't know, negative damage using damage mode 4?
1) How can I remove the Breakable flag of a weapon using Weidu?
2) How can I remove the use of spell scrolls to a cleric/wizard kit? The only solution I can think would ban cleric and green scrolls as well.
It applies a 100% spell failure using Opcode60 or it is a whole different thing?
Thanks!
A character immune to Opcode60 would also be immune to this effect, right?
There are two in WK, one in SoD and a modder can make another - that's what concerns me.
I tried setting immunity against Opcode 60 without success.
And then I tried immunity against the specific spell (SPIN646 IIRC), also without success.
The spell that grants immunity is coded as Non-Magical and Permanent After Death, so I don't know if it can be affected by the dispel you talked about.
Am I missing something here?
PS: I was able to get cast spells normally in the dead-magic area of SoD (the one the party is ambushed by an assassin), but Watcher's Keep keeps misleading me.
I can't say that I'm happy about surprising you.
Mix feelings, man.
DEFINE_ACTION_FUNCTION RETURN_ARRAY RET array BEGIN ACTION_DEFINE_ARRAY array BEGIN ~Hello~ ~World~ END END LAF RETURN_ARRAY RET array END OUTER_SPRINT temp $array(0) PRINT ~Temp: %temp%~
Obviously this doesn't work, but I would expect to be able to access the array "array" from outside the function. In fact, WeiDU throws an error stating that the return value "array" is not defined. I believe that this is because all the array construct does is expand the variable name out to something like array_0, so I don't believe they are "real" values that can be passed around. Am I missing something?
DEFINE_ACTION_MACRO getRegexpInString BEGIN /** * Arguments: * VAR_STR getRegexpInString.string * VAR_STR getRegexpInString.to_find * * VAR_STR getRegexpInString.indexes_array * VAR_STR getRegexpInString.values_array */ LOCAL_SET index = 0 LOCAL_SET insertion_index = 0 ACTION_IF VARIABLE_IS_SET getRegexpInString.indexes_array AND NOT IS_AN_INT getRegexpInString.indexes_array BEGIN OUTER_PATCH ~%getRegexpInString.string%~ BEGIN SET index = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~%getRegexpInString.to_find%~) WHILE index != 0 - 1 BEGIN PATCH_PRINT ~getRegexpInString INDEX_BUFFER found match at index %index%~ SET $~%getRegexpInString.indexes_array%~(~%insertion_index%~) = index SET index = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~%getRegexpInString.to_find%~ index + 1) SET insertion_index += 1 END END END OUTER_SET insertion_index = 0 ACTION_IF VARIABLE_IS_SET getRegexpInString.values_array AND NOT IS_AN_INT getRegexpInString.values_array BEGIN OUTER_PATCH ~%getRegexpInString.string%~ BEGIN REPLACE_EVALUATE CASE_INSENSITIVE ~%getRegexpInString.to_find%~ BEGIN PATCH_PRINT ~getRegexpInString REPLACE_EVALUATE found match "%MATCH0%"~ SPRINT $~%getRegexpInString.values_array%~(~%insertion_index%~) ~%MATCH0%~ SET insertion_index += 1 END ~%MATCH0%~ END END OUTER_SET getRegexpInString.indexes_array = 0 - 1 OUTER_SET getRegexpInString.values_array = 0 - 1 END
I apologize for the forum's formatting of the code. Anyway, am I baffled, because it seems like INDEX_BUFFER and REPLACE_EVALUATE are interpreting the same regexp differently. If I run that macro with this code:
OUTER_SPRINT getRegexpInString.string ~Hello Hello Hello~ OUTER_SPRINT getRegexpInString.to_find ~ *Hello~ OUTER_SPRINT getRegexpInString.indexes_array ~index_results~ OUTER_SPRINT getRegexpInString.values_array ~value_results~ LAM getRegexpInString
I get this output:
INDEX_BUFFER is giving me the output I want, but REPLACE_EVALUATE isn't. Why in the world are they behaving differently? I've gone over my code again and again, and I can't find anything conceptually wrong with it. I know this is a big question to ask, but does *anyone* have any idea what is going on? Thank you immensely if you are still reading this after that big info dump.
EDIT: I've made a version that returns the values I expect it to, it is just really inefficient because I had to use a workaround, and this workaround has to take many unnecessary substrings. Here it is if anyone is wondering:
DEFINE_ACTION_MACRO getRegexpInString BEGIN /** * Arguments: * VAR_STR getRegexpInString.string * VAR_STR getRegexpInString.to_find * * VAR_STR getRegexpInString.indexes_array * VAR_STR getRegexpInString.values_array */ LOCAL_SET index = 0 LOCAL_SET insertion_index = 0 LOCAL_SET inner_loop_count = 0 LOCAL_SPRINT after_index ~~ OUTER_PATCH ~%getRegexpInString.string%~ BEGIN SET index = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~%getRegexpInString.to_find%~) WHILE index != 0 - 1 BEGIN PATCH_IF VARIABLE_IS_SET getRegexpInString.indexes_array AND NOT IS_AN_INT getRegexpInString.indexes_array BEGIN SET $~%getRegexpInString.indexes_array%~(~%insertion_index%~) = index END PATCH_IF VARIABLE_IS_SET getRegexpInString.values_array AND NOT IS_AN_INT getRegexpInString.values_array BEGIN READ_ASCII index after_index (BUFFER_LENGTH - index) SET inner_loop_count = 0 INNER_PATCH ~%after_index%~ BEGIN REPLACE_EVALUATE CASE_INSENSITIVE ~%getRegexpInString.to_find%~ BEGIN PATCH_IF inner_loop_count == 0 BEGIN SPRINT $~%getRegexpInString.values_array%~(~%insertion_index%~) ~%MATCH0%~ SET inner_loop_count += 1 END END ~%MATCH0%~ END END SET index = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~%getRegexpInString.to_find%~ index + 1) SET insertion_index += 1 END END OUTER_SET getRegexpInString.indexes_array = 0 - 1 OUTER_SET getRegexpInString.values_array = 0 - 1 END
INDEX_BUFFER finds the next instance of regexp starting from the specified index.
REPLACE_EVALUATE finds the each instance of regexp starting from the first character after the last instance of regexp.
Thank you for clarifying. That is the conclusion I came to after some more testing.. which is a shame, really. Here is the scenario I want to accomplish: I want to be able to find all the starting indexes of a certain regexp, AND I want to grab the matched strings. Basically, I want to have an INDEX_BUFFER that also returns to me the string it matched (or, alternatively, the length of the string it just matched). Is there any way to do this better than the edit I made on my previous post? My version is *really* laggy because of how much unnecessary work it has to do, but it's the only way I could figure out.
Is the level of a simulacrum hardcoded to 60% of the caster's level? And how does OPcode 165 (Pause Target) works exactly: is there any way to be immune to that OPcode and does it set any flags (state_helpless flag in mind mostly) while active?
EDIT: I would like to make an AoE spell that checks if the target is helpless, and if it is the case, it has 25% chance of being slain instantly. How do I proceed? Can I do that directly somehow using OPcode 232 ? Or do I need to cast a spell that will add an effect to the targets, with the said effect triggering OPcode 232 on the target, checking if they are helpless and slaying them if this is the case? Or maybe another solution?