Jump to content

Help with a Effect and its script


A.J.

Recommended Posts

Hello,

 

Taking a look at the ant nectar and the stimpak, I did a consumable for certain purposes. It had some effects but also a visual effect (imod).

I had to do a script with the start effect and finish effect blocks, just like the ant nectar. Now everything works fine, I eat the consumable, the visual effect starts, the other things in the script happen, after a while it finishes, if I eat again it works again, etc.

 

The problem is when I stack it (eat more in a row). If I enter in my inventory and eat a couple of them, everything breaks and the consumable won't work anymore until I reload a game. I would like to insert some control on this, I tried with a HasMagicEffect, but it doesn't work.

 

I'm wondering if it's really possible to do that, or it's beyond the starteffect block possibilities, or maybe I should use other block types in some other place.

Anyway, here's the script:

scn aaPPuksEffectScript

begin ScriptEffectStart

	player.additem aaPPuksTicket 1
	player.additem aaPPuksBoxEmpty 1
	set aaPinkyAptSet.aaPPuksCounter to aaPinkyAptSet.aaPPuksCounter + 1

	if HasMagicEffect aaPPuksEFFECT == 0

		showmessage aaPPuksEffectMessage
		playsound aaPPuksStomachEffect
		iMod aaPPuksEffectISFX2

	endif

end

begin ScriptEffectFinish

	riMod aaPPuksEffectISFX2
	set aaPinkyAptSet.aaPPuksCounter to 0

end

The rest of the "effects" it has to do, with the imod, is that it adds a empty box of that item, increases a counter (too many means bad things, but I added this line when the scripts wasn't already working, so I don't think it's the cause), plays some sound and shows a message on top left. The part in red is what I added later, when I saw it wasn't working while stacking, to see if the imod, the playsound or the showmessage were the ones giving troubles when stacking. The consequence of it is that part isn't working even the first time I eat the consumable, I don't know why since that expression should return 0 the first time, but maybe the fact that is inside a ScriptEffectStart implies HasMagicEffect is already at 1. I don't care to extent or reset the time of the imod if I eat some when I already have the effect, I only care to have the variables setted and the items added.

 

This is the only working way I found when I was experimenting with consumables and visual effects, at first I tried some scripts tied to the item itself with some OnEquip block but it wasn't working at all, maybe it sounds stupid using OnEquip but on console player.equipitem on a consumable was working. Any advice on what I could try to make this script safer?

 

I thank you very much.

 

EDIT: It doesn't write in red, after that I submit. THE RED PART was the line "if hasmagiceffect ... ... == 0"

Link to comment

Sure, script effect blocks are better for ingredients; you can actually 'cast' them with CIOS like any other spell. Equipping & OnEquip can cause trouble, even though to the player, it looks like equipping something.

Two things:

- like any other block that only runs once, in one frame, there is a chance the script doesn't have time to retrieve the information in the HasMagicEffect if-line. Try sticking it in a ScriptEffectUpdate block

- instead of HasMagicEffect, which should be run against the base effect and I don't think that it functions reliably against a specific script base effect, you can run IsSpellTarget against the ingredient itself. You can also run IsImageSpaceActive against the imagespace modifier in this case.

Link to comment

Thank you very much for the advices, DoctaSax, I'm going to check these functions on the guide to understand how they work.

 

What I can't focus exactly is how I should manage the whole thing.

 

Using only a Script Start / End / etc. block causes me the issue that the script itself stops working the second time I run it (If I eat more ingestibles while the effect is still active).

 

So you tell me to place a control on the effect itself and simply not running the script if the effect is still active. But the problem is that I don't care that much about the visual effect itself and I surely could place it under a control like that; but I care about the other effects (a variable changes value, a couple of items are added) and these things still break my script.

 

I wrote bad, I try to explain better.

 

I eat the ingestible: visual blurs but also an empty box is added on my inventory, and more important, a global variable is increased by one(quest.how_many_ingestibles_I_ate = itself + 1) . This because there's a running gamemode script linked to a quest that checks that variable, how many ingestibles I've eaten: it kills me if I eat 5 in a row, while it resets when the effect finishes.

 

Now I can avoid the redundancy of imod, checking with a hasmagiceffect or isspell or what I'll find will be better following your useful advice. But I can't avoid the increase of the variable itself, it should happen anytime I eat a ingestible. I already tried that: if I write it inside the scriptstart/end block, the second time I eat a ingestible the script breaks. Maybe I remember bad, but ... I remember some consumables were stacking, like radaway. Maybe they were working because the effect itself is hardcoded, while I can't stack two effects if they come from a script?

Link to comment

There aren't many vanilla scripted ingredients - cateye, psycho, maybe something else - but I've never heard of problems with stacking them.

Are any of the items that you add scripted too?

Have you tried with just the additem code, nothing else, & see if that stacks?

Link to comment

No the items I add in the script are not scripted themselves, are static items (empty boxes), I remember there was a similar thing on FWE with empty bottles when drinking.

What do you mean for "additem code"? Do you mean equipitem by console, without going through inventory? now this is a wonderful idea and I tried it. I also checked the scripted buffs you suggested me, I forgot they were scripted.

 

But actually I found how to solve it, thanks also to the nuka cola. I write it here so maybe it can be useful to someone else in the future.

 

Actually the script wasn't breaking, and the effect was stacking... but only the base one, the duration of the main effect (before the "ingestible expires" message on top left). Let me make things more clear.

 

- If I eat 1 ingestible:

base effect 30 seconds

script effect: imod 30 seconds, additem empty box, playsound, increases counter

effect finishes: reset counter, and now and only now I can use another ingestible to make script running (so the thing of the counter was useless, also if I was eating more, no more empty boxes were added).

 

Nuka cola gave me the idea: it has a script that adds a cap when you drink one. And if I was drinking 5 in a row, it was adding 1+1+1+1+1 caps. This because it has a AddCaps script effect separated by the other base effects, with duration 0. If it was linked to the regen health for example, that leasts 25 seconds, it wouldn't have worked.

 

So:

I made a script for the imod,the base effect,the playsound and the reset counter and linked to an effect with duration 30.

I made another script for the add empty box and increase counter and linked to a separate effect with duration 0.

 

Now:

Everytime I eat a box, it istantly adds one in the inventory and increases the counter by 1.

The other effect, the visual and base one, also starts. The imod unfortunately will only run once (30 seconds), the duration visual effect doesn't stack, while the base effect stacks (30 seconds x number of boxes eaten). So the blurry sight will be ok a long time before the effect will expires. But I can survive with it, imod effect is separated, I don't think I can do anything for it.

 

And:

Since the counter actually increases everytime I eat one, and only will be resetted when the base effect will expires (30 seconds x number of boxes eaten), if I eat 5 in a row I actually die! Wohoooo!!! :D

 

Thank you for showing me the way, DoctaSax. This script wouldn't have had a future without you.

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use