Jump to content

Compiler Override Not Working and I Could Also Be an Idiot.


EPDGaffney

Recommended Posts

So, I'm trying to teach myself how to modify stuff in an array based on whether it has a specific effect attached. I could be doing it very highly wrong, but at some point it seemed necessary to use a feature that overrides the default compiler, but this isn't working.

 

 

scn GSBViperAntiVenomAddScript

array_var AntiVenomBase
array_var AntiVenomDLC
array_var Ingestibles
ref Entry

begin _gamemode
    if GetGameRestarted
        let Ingestibles := GetLoadedTypeArray 47
        foreach Entry <- Ingestibles
            if Entry.GetBaseEffectScript NVAntivenomEffect
                AddNewEffect
            endif
        loop
    endif
end

 

 

Yes, I realise GetBaseEffectScript is probably not what I wanted; that only occurred to me recently. But my major problem is that it doesn't like the operands for the operator <-. That and I don't actually know what I'm doing anyway. I've gleaned that <- seems to be what I want and then forgot why, but it only seems to get past that line if I make Entry an array_var, which at least I don't think I want...do I? I read somewhere that the compiler override is often used in stuff like this but it doesn't work here (at least, if it just requires putting an underscore by the name of the blocktype). Maybe I've stretched it beyond its limits.

 

Thank you in advance.

 

Edit: I'm aware that that code has unfinished stuff in it. I just tried a bunch of stuff and copied it as is.

 

Edit 2: I think my major problem here is really that I can't find the function I need to check the effects on ingestibles. So, does anyone know what that is?

 

Edit 3: I think it will work now. The function is GetNthEffectBase. Now what I want is to check the entire list of effects regardless of how many there are. Any advice on that?

Edited by EPDGaffney
Link to comment
Share on other sites

"entry" or any other name you wish to give an interator in a foreach loop is still a little stringmap in itself, containing 2 elements: under "key" you'll find the key of the element that is currently under iteration, under "value" its value. So you can't treat it as a reference (which wouldn't work anyway) or a form.

The simplest way of doing something with an element under iteration is to pass whichever bit of intel you need to a new variable:

foreach entry <- ingestibles
  let rIngestible := entry["value"]
  if < your condition >
    ; do something
  endif
loop

For a regular array you can also use while loops, here's a backwards one (which is my preference in case I need to erase an element):

let iKey := ar_size ingestibles
while -1 < (iKey -= 1)
  let rIngestible := ingestibles[iKey]
  ;if...
;
 ; endif
loop
Edited by DoctaSax
Link to comment
Share on other sites

Thanks very much. I still don't completely understand but I do a bit more than before. I had already been looking for something like that

let rIngestible := entry["value"]

line and implemented one, but hadn't had the time to test it until just now, and it's not working. I have a game save where I've yet to enter the room where the NPC with the custom poison is, and the test is to wait a bit to give the code time to run (should it run instantly? I don't know) and then enter the room to let him poison me and then test the vanilla game's Antivenom, which should now have been modified to cure my poison as well, but it doesn't actually do that.

 

I'll look into what you said about edit 3 once I get this working, I think, unless you advise otherwise. The vanilla Antivenom has only one effect, so this should work on it. Do you see anything wrong with my new code?

scn GSBViperAntiVenomAddScript

array_var GSBIngestibles
array_var GSBEntry
ref GSBAntivenomBase

begin gamemode
    if GetGameRestarted
        let GSBIngestibles := GetLoadedTypeArray 47
        foreach GSBEntry <- GSBIngestibles
            let GSBAntivenomBase := GSBEntry["value"]
            if GetNthEffectBase NVAntivenomEffect 0
                AddNewEffect GSBAntivenomBase GSBAntivenomFXAdd 0 0 0 0
            endif
        loop
    endif
end

Thanks again.

Link to comment
Share on other sites

Hope you see this before you get too far into your explanation but Ladez helped me and pointed out that I was using that function wrong. I needed:

if GetNthEffectBase GSBAntivenomBase 0 == NVAntivenomEffect

And it finally works 100% perfectly. Well, besides the fact that I'm not checking all the effects on an ingestible yet, but I'll work on that and post back. Thanks for all your help.

Link to comment
Share on other sites

I was about to type something to that effect, no pun intended.

It might help not to call "GSBAntivenomBase" that. It suggests it's a base effect, while it's not.

 

For checking all base effects of the ingestibles, I suggest this (if switching out the names):

let rIngestible := entry["value"]
let iKey := GetNumEffects rIngestible
while -1 < (iKey -= 1)
  if NVAntiVenomEffect == GetNthEffectBase rIngestible, iKey
    ; do the add
  endif
loop
Link to comment
Share on other sites

Haha, I didn't even catch the unintentional pun at first and now I'm dying.

 

'Base' is actually to contrast with DLC. As far as I know, the only two types of poison removal effect are this one and one that gets added by Honest Hearts. Later on, I need to make a script that checks for HH and does basically this exact script on it. Is there a better naming convention for that, and should it be a separate script? I'm a little confused on how GetGameRestarted works.

 

Also, should I be checking to make sure stuff doesn't already have my custom poison removal effect added?

 

I don't have time right now but I'll work this maybe to-morrow and let you know how it goes.

 

Appreciate all the help. I was really frustrated before and now I'm excited, haha.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...