Jump to content

script is confusing the !@#$ out of me. HELP!?!


angelwraith

Recommended Posts

ok so its like 11th hour with this mod ive been working on.. all together if i can nail a few problems, the design time i have left is less than a day.. ive been working on it for what feels like an eternity and i would really like to release the first version of the mod...

 

 

this is my first mod..

this is my first post..

i have scripting experience with a variety of programs similar to geck but not fallout specifically

 

i really dont like when people give up trying to fix their code after the first try and post for help.. so believe me when i say this particular bit has been vexing me for DAYS and i am at my end with it and really just want to move on.

 

ok 1 more thing.. i dont really want to release the mod until the whole thing is done.

and i dont want to give away too many details about what im doing here.

 

LOOK at the code.. you'll get an idea for whats to come in this mod.

many unique behaviors have been scripted in this mod like what you see here.. (and dual operational fusion reactors)

 

so here it is..

SCN SUBweapmineSCRIPT


Float TIMER
Float isactivated
Float runonce
REF rContainer

Begin onAdd
set TIMER to 0
set isactivated to 0
set runonce to 1
END

Begin OnDrop
if (GetContainer == 0)
set TIMER to 0
set isactivated to 1
set runonce to 0
playsound SUBbeepboom
ENDIF
END

Begin GAMEMODE
if (isactivated == 1)
	set timer to TIMER + getSecondsPassed
	if (TIMER > 10)
		if (GetContainer == 0)
			PlaceAtMe DLC03TeslaCannonExplosion 1 1 0
			set isactivated to 0
			set TIMER to 0
			Disable
			MarkForDelete
		ENDIF

		if (GetContainer != player) && (GetContainer != 0)
			set rContainer to getContainer
				rContainer.PlaceAtMe DLC03TeslaCannonExplosion 5 1 0
				set isactivated to 0
				set TIMER to 0
			ENDIF
		ENDIF
	ENDIF
ENDIF

if (runonce == 1)
	if (getContainer == player)
		playsound SUBaccessgranted
	else
		set TIMER to 0
		set isactivated to 1
		playsound SUBbeepboom
	ENDIF
	set runonce to 0
ENDIF
END

 

 

ok so to explain whats going on here and what i need from you.

 

the onAdd and onDrop begin blocks are basically the activators for the script inside the GAMEMODE block.

the reason i did it this way is so i could use the timer

 

the first part of the GAMEMODE block says if you drop me (not Xfer into container)

in 10 seconds i am going to explode, DISABLE AND DELETE.

the second part says if you move me into a container or onto a NPC

in 10 seconds i am going to explode but with 5 times the intensity

the last part of the GAMEMODE block says whenever i am moved into a inventory one of 2 things happens

if the inventory is the player, a access granted sound is played

if the inventory is NOT the player the same action as a xfer into a container

 

so what it does is this

any item can use the script

if that item is picked up by the player.. a sound says access granted

if its picked up by someone other than the player, droped onto the ground or reverse pickpocketed onto someone a explosion happens wherever it is.

 

I.E. you and only you can use the item.. all else who try will die.

and if you drop it it goes bye-bye.

 

ok so this is what i cant figure out...

for some reason i cant remove the item from a container when the explosion happens.. CTD every time.. i dont get it

 

this is what i tried:

 

ref rSelf ;;at the top obviously

 

if (GetContainer != player) && (GetContainer != 0) ;;;;;; this is already there and working, just providing it so you

set rContainer to getContainer ;;;;;; know where i put the new code below

 

set rSelf to GetSelf

rContainer.removeItem rSelf 1

i think this didnt work because removeitem needs a object ID and getself returns a ref ID ??? correct me if im wrong about this!! how do i get the object id from a ref if thats it??

 

 

this script is working as is but without the behavior desired above as described so you should be able to set ANY item to use this script (preferably a weapon) just remove the playsound functions from the code and it should work just fine.

 

if you like what you see, know this there is a lot more like this in the mod.. and if you help me figure this out ill be that one step closer to release.

 

oh one more thing.. and this is a shot in the dark because i really dont have much more info right now as to whats causing this, but upon entering one of my interior cells, and only 1 of them, sometimes the meshes/textures or whatever for the first person arms disappear and the texture for the gun disappears...

im not really wanting to rebuild the cell but at this point i cant seem to pinpoint whats causing the glitch in only that one place.. so unfortunately im considering it.

Link to comment
Share on other sites

I quickly ran your script through my script validator, and it looks like you've got an extra "endif" statement in there. It's unlikely that this would cause issues, but it's something that you'll want to fix nonetheless. I'm not sure whether in fact it's an extra "endif" statement or a missing "if" statement, given your indentation.

 

Whereas using floating point variables should still work for your "isactivated" and "runonce" variables, you really should be using "int" variables for them, given that they're only assigned integer values.

 

I've cleaned up your script a bit, try this and see if it works:

ScriptName SUBWeapMineScript

float fTimer

int bIsActivated
int bRunOnce

ref rContainer

Begin OnAdd

set rContainer to GetContainer
set fTimer to 0
set bIsActivated to (rContainer.GetIsReference player) == 0

if rContainer.GetIsReference player
	PlaySound SUBAccessGranted
else
	PlaySound SUBBeepBoom
endif

End

Begin OnDrop

if GetContainer == 0
	set fTimer to 0
	set bIsActivated to 1
	set bRunOnce to 0
	PlaySound SUBBeepBoom
endif

End

Begin GameMode

if bIsActivated
	set fTimer to fTimer + GetSecondsPassed
	if fTimer > 10
		if rContainer == 0
			PlaceAtMe DLC03TeslaCannonExplosion 1 1 0
			Disable
			MarkForDelete
		elseif rContainer != player
			rContainer.PlaceAtMe DLC03TeslaCannonExplosion 5 1 0
			RemoveMe
		endif
	endif
endif

End

set rSelf to GetSelf

rContainer.removeItem rSelf 1

i think this didnt work because removeitem needs a object ID and getself returns a ref ID ??? correct me if im wrong about this!! how do i get the object id from a ref if thats it??

That's correct. Each form is referred to in a script via its formID (editorIDs are used when forms are being "hard-coded", which are converted to formIDs when the script is compiled) and for the purposes of scripting it is helpful to separate forms into base forms and references. RemoveItem requires the formID of a base form, whereas GetSelf returns a reference's formID (often referred to as a refID).

 

If you don't know already, a reference is basically an instance of a base form that exists within the game world. For example, if you see a gun on the ground, that instance of the gun is a reference, which contains data like position, and points to the gun's base form which controls things that apply to all references to the gun, such as its value and name.

 

@arkentera666:

I don't understand the mentality behind posting to say that you can't help. The quality of your posts is much more important than their quantity.

 

Cipscis

Link to comment
Share on other sites

beautiful!!!! worked perfectly.. thank you soo much.. and about the endif.. i think that got in there as a copy error when i was removing the broken script but its working perfectly now thanks to you.. and your script validator is pretty nice.. i use it often. just couldnt read my mind to tell me that the code i needed was "removeme" which btw is such a simple, elegant and functional command, i love it... thank you very, very much.

 

now if only i could figure out whats causing the textures to glitch when entering that cell...

 

you cipscis are one person i would gladly provide the files to if you thought you might be able to figure this problem out, as i believe you would be able to help me w/o jeopardizing the secrecy i am going for pre-release with this project.

 

if you think you're up to this let me know and ill figure out a way to get the files to you.

 

ive put a lot together since my last post so i am yet that much closer to a release version.

 

i have a few small dents and dings that i cant seem to figure out...

 

i would say the mod is 85% complete.. that being said.. if you decide to help, i promise your work is going into a project that will reach fruition, i am not going to waste your time, the things i would ask for help on are things that i have put a lot of time into figuring out and just cant seem to pull together.

Link to comment
Share on other sites

oh one more thing i just thought of.. is there any way to make that onadd block only call if the container is a NPC and not a actual container like chests & lockers & cabinets.

 

i really only want the onadd to fire if SOMEONE other than the player has it added to their inventory.

 

although i must admit i like that it cant be transfered into any container

 

i added an additional conditional statment to the code you provided to allow the items to be tranfered into one specific safe.. but im sure someone is going to compain if the weapons can only be safely stored in one location

 

(btw your code is still going to be used so the weapon deletes off of a corpse if it was used to create an explosion at the NPC)

Link to comment
Share on other sites

oh one more thing i just thought of.. is there any way to make that onadd block only call if the container is a NPC and not a actual container like chests & lockers & cabinets.
You're looking for IsActor. Try replacing the current OnAdd block with:

 

Begin OnAdd

set rContainer to GetContainer
set fTimer to 0
set bIsActivated to (rContainer.IsActor && rContainer.GetIsReference player == 0) 

if rContainer.GetIsReference player
	PlaySound SUBAccessGranted
elseif rContainer.IsActor
	PlaySound SUBBeepBoom
endif

End

Link to comment
Share on other sites

oh one more thing i just thought of.. is there any way to make that onadd block only call if the container is a NPC and not a actual container like chests & lockers & cabinets.
You're looking for IsActor. Try replacing the current OnAdd block with:

 

Begin OnAdd

set rContainer to GetContainer
set fTimer to 0
set bIsActivated to (rContainer.IsActor && rContainer.GetIsReference player == 0) 

if rContainer.GetIsReference player
	PlaySound SUBAccessGranted
elseif rContainer.IsActor
	PlaySound SUBBeepBoom
endif

End

 

 

pluged it in and as far as i can tell it works.. not sure though because i did get a crash.. but i was tinkering with some other stuffs so it might be that too.. let you know soon.

 

thank you.. you guys rock.

 

all the helpfullness is great.

Link to comment
Share on other sites

ok so there were 3 things that i needed to happen here

1. if the item is dropped on the ground it blows up

2. if the item is added to someone other than the player it blows them up

3. it can be transfered into safes and containers

 

if i changed one part as per instructed in both cases it lead to another part to not work

 

this is what i came up with in the end that works exactly the way i need

ScriptName SUBWeapMineScript

float fTimer
int bIsActivated
ref rContainer


Begin OnAdd
set rContainer to GetContainer
if rContainer.GetIsReference player
	PlaySound SUBAccessGranted
elseif (rContainer != player) && (rContainer.IsActor)
	set fTimer to 0
	rContainer.PlaySound3d SUBBeepBoom
	set bIsActivated to 1
endif

End


Begin OnDrop
if (GetContainer == 0)
	set rContainer to 0
	set fTimer to 0
	PlaySound3d SUBBeepBoom
	set bIsActivated to 1
endif
End


Begin GameMode
if bIsActivated == 1
	set fTimer to fTimer + GetSecondsPassed
	if fTimer > 9
		if rContainer == 0
			PlaceAtMe DLC03TeslaCannonExplosion 1 1 0
			Disable
			MarkForDelete
		elseif (rContainer != player) && (rContainer.IsActor)
			rContainer.PlaceAtMe DLC03TeslaCannonExplosion 2
			rContainer.PlaceAtMe DLC03TeslaCannonExplosion 1 64 1
			rContainer.PlaceAtMe DLC03TeslaCannonExplosion 1 64 2
			rContainer.PlaceAtMe DLC03TeslaCannonExplosion 1 64 3
			rContainer.PlaceAtMe DLC03TeslaCannonExplosion 1 64 0
			RemoveMe
		endif
	endif
endif
End

 

 

i couldnt of done it w/o your guidence guys.. thanks so very much for the help!!

Link to comment
Share on other sites

ok new question..

 

i have a script that activates a container..

works perfectly inside the cell the container is located..

but outside the cell it is unreliable.. only working sometimes

 

when its messing up if i wait it sometimes starts to work .. completly random

inside the refrence's cell everything is flawless 100% of the time

 

here is the code.. tell me what you think

SCN SUBdsREFSCRIPT

Begin OnEQUIP player
SUBdsREF.Activate Player
Player.UnequipItem SUBdsACTREF 0 1
END

 

btw SUBdsACTREF refers to the object that carries the script

Link to comment
Share on other sites

  • Recently Browsing   0 members

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