Jump to content

Script issues


AnotherGuy98

Recommended Posts

Hi, I made a mod "QuestSide" and along the way during the development one of the quests stopped working correctly, the issue is that during part of the quest if you put a specific item in the proper container it is supposed to update the quest, in game it doesn't do this. I can't find the problem with the script... looking at it, it should work but idk.

 

Any Idea why it doesn't work? The quest starts with iDoOne set to 1, the problem comes when it's time for the pick up to be set, Which is when the item is placed in the container by the PC

 

SCN PackageDeliveryQuestScript
Short iDoOnce
Short Pickup
Short Decision
Short Rock
Short DoneBefore
Short Spawn
Short Ambush
Begin Gamemode
If iDoOnce ==1 && Decision ==0 && getstage aaPD ==1
Set Decision to (Decision + GetRandomPercent)
Set iDoOnce to 2
Endif
;__________________________________________________________________________
; Which box
If Decision ==0 && iDoOnce ==2
Set Decision to (Decision + GetRandomPercent)
Endif
If Decision >0 && Decision <=10 && iDoOnce ==2
Setstage aaPD 10
Set iDoOnce to 3
Endif
If Decision >10 && Decision <=20 && iDoOnce ==2
Setstage aaPD 20
Set iDoOnce to 3
Endif
If Decision >20 && Decision <=30 && iDoOnce ==2
Setstage aaPD 30
Set iDoOnce to 3
Endif
If Decision >30 && Decision <=40 && iDoOnce ==2
Setstage aaPD 40
Set iDoOnce to 3
Endif
If Decision >40 && Decision <=50 && iDoOnce ==2
Setstage aaPD 50
Set iDoOnce to 3
Endif
If Decision >50 && Decision <=60 && iDoOnce ==2
Setstage aaPD 51
Set iDoOnce to 3
Endif
If Decision >60 && Decision <=70 && iDoOnce ==2
Setstage aaPD 52
Set iDoOnce to 3
Endif
If Decision >70 && Decision <=80 && iDoOnce ==2
Setstage aaPD 53
Set iDoOnce to 3
Endif
If Decision >80 && Decision <=90 && iDoOnce ==2
Setstage aaPD 54
Set iDoOnce to 3
Endif
If Decision >90 && Decision <=100 && iDoOnce ==2
Setstage aaPD 55
Set iDoOnce to 3
Endif
;__________________________________________________________________________
If iDoOnce ==3 && Pickup ==0
Set Pickup to (Pickup + GetRandomPercent)
Set iDoOnce to 4
Endif
;__________________________________________________________________________
; Rock one stages
If Pickup ==0 && iDoOnce ==4
Set Pickup to (Pickup + GetRandomPercent)
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox1.Getitemcount aaChems >=1 && getstage aaPD 10
Setstage aaPD 60
Set iDoOnce to 5
Player.additem aaRockNote1 1
aaDBox1.removeitem aaChems 1
aaRock1.additem aaPay 1
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox2.Getitemcount aaChems >=1 && getstage aaPD 20
Setstage aaPD 61
Set iDoOnce to 5
Player.additem aaRockNote1 1
aaDBox2.removeitem aaChems 1
aaRock1.additem aaPay 1
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox3.Getitemcount aaChems >=1 && getstage aaPD 30
Player.additem aaRockNote1 1
aaRock1.additem aaPay 1
aaDBox3.removeitem aaChems 1
Setstage aaPD 62
Set iDoOnce to 5
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox4.Getitemcount aaChems >=1 && getstage aaPD 40
Setstage aaPD 63
Set iDoOnce to 5
Player.additem aaRockNote1 1
aaDBox4.removeitem aaChems 1
aaRock1.additem aaPay 1
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox5.Getitemcount aaChems >=1 && getstage aaPD 50
Setstage aaPD 64
Set iDoOnce to 5
Player.additem aaRockNote1 1
aaDBox5.removeitem aaChems 1
aaRock1.additem aaPay 1
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox6.Getitemcount aaChems >=1 && getstage aaPD 51
Setstage aaPD 65
Set iDoOnce to 5
Player.additem aaRockNote1 1
aaDBox6.removeitem aaChems 1
aaRock1.additem aaPay 1
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox7.Getitemcount aaChems >=1 && getstage aaPD 52
Setstage aaPD 66
Set iDoOnce to 5
Player.additem aaRockNote1 1
aaDBox7.removeitem aaChems 1
aaRock1.additem aaPay 1
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox8.Getitemcount aaChems >=1 && getstage aaPD 53
Setstage aaPD 67
Set iDoOnce to 5
Player.additem aaRockNote1 1
aaDBox8.removeitem aaChems 1
aaRock1.additem aaPay 1
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox9.Getitemcount aaChems >=1 && getstage aaPD 54
Setstage aaPD 68
Set iDoOnce to 5
Player.additem aaRockNote1 1
aaDBox9.removeitem aaChems 1
aaRock1.additem aaPay 1
Endif
If Pickup >0 && Pickup <=50 && iDoOnce ==4 && aaDBox10.Getitemcount aaChems >=1 && getstage aaPD 55
Setstage aaPD 69
Set iDoOnce to 5
Player.additem aaRockNote1 1
aaDBox10.removeitem aaChems 1
aaRock1.additem aaPay 1
Endif
;_________________________________________________________________________
; Rock two stages
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox1.Getitemcount aaChems >=1
Setstage aaPD 70
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox1.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox2.Getitemcount aaChems >=1
Setstage aaPD 71
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox2.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox3.Getitemcount aaChems >=1
Setstage aaPD 72
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox3.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox4.Getitemcount aaChems >=1
Setstage aaPD 73
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox4.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox5.Getitemcount aaChems >=1
Setstage aaPD 74
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox5.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox6.Getitemcount aaChems >=1
Setstage aaPD 75
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox6.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox7.Getitemcount aaChems >=1
Setstage aaPD 76
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox7.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox8.Getitemcount aaChems >=1
Setstage aaPD 77
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox8.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox9.Getitemcount aaChems >=1
Setstage aaPD 78
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox9.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
If Pickup >50 && Pickup <=100 && iDoOnce ==4 && aaDBox10.Getitemcount aaChems >=1
Setstage aaPD 79
Set iDoOnce to 5
Player.additem aaRockNote2 1
aaDBox10.removeitem aaChems 1
aaRock2.additem aaPay 1
Endif
;__________________________________________________________________________
; Spawn some raiders
If Pickup >75 && Pickup <=100 && iDoOnce ==4 && Spawn ==0
Set Spawn to 1
aaRock2.placeatme EncFiendRandom 4
Endif
If Pickup >25 && Pickup <=50 && iDoOnce ==4 && Spawn ==0
Set Spawn to 1
aaRock1.placeatme EncFiendRandom 4
Endif
; Box spawn
If Decision >6 && Decision <=10 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox1.Placeatme EncFiendRandom 3
Endif
If Decision >16 && Decision <=20 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox2.Placeatme EncFiendRandom 3
Endif
If Decision >26 && Decision <=30 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox3.Placeatme EncFiendRandom 3
Endif
If Decision >36 && Decision <=40 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox4.Placeatme EncFiendRandom 3
Endif
If Decision >46 && Decision <=50 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox5.Placeatme EncFiendRandom 3
Endif
If Decision >56 && Decision <=60 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox6.Placeatme EncFiendRandom 3
Endif
If Decision >66 && Decision <=70 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox7.Placeatme EncFiendRandom 3
Endif
If Decision >76 && Decision <=80 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox5.Placeatme EncFiendRandom 3
Endif
If Decision >86 && Decision <=90 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox5.Placeatme EncFiendRandom 3
Endif
If Decision >96 && Decision <=100 && iDoOnce ==4 && Ambush ==0
Set Ambush to 1
aaDBox5.Placeatme EncFiendRandom 3
Endif
;__________________________________________________________________________
; complete the correct stages
If iDoOnce ==5 && Getstage aaPD <70 && GetStage aaPD >=60 && player.Getitemcount aaPay >=1
Setstage aaPD 80
Set iDoOnce to 6
Endif
If iDoOnce ==5 && Getstage aaPD <80 && GetStage aaPD >=70 && Player.Getitemcount aaPay >=1
Setstage aaPD 85
Set iDoOnce to 6
Endif
;__________________________________________________________________________
; ask about delivery
If DoneBefore ==1 && Player.gethasnote aaPDLoc ==0
player.additem aaPDLoc 1
Endif
End
Edited by zombieslaya1990
Link to comment
Share on other sites

Without digging into details, overall you have too many compound conditionals (&&) which make it both difficult and unlikely to work out which are succeeding. ALL of the conditions in the compound chain must be true to proceed to the "then" statements. So it could be any one of them which is causing the failure.

 

Try splitting them up along the lines of any condition which is repeated should have subsequent instances as nested conditions under it instead.

 

For example, In "Rock one stage":

If Pickup >0 && Pickup <=50
  if iDoOnce ==4
     IF aaDBox1.Getitemcount aaChems >=1 
       if getstage aaPD 10
         Setstage aaPD 60
         Set iDoOnce to 5
         Player.additem aaRockNote1 1
         aaDBox1.removeitem aaChems 1
         aaRock1.additem aaPay 1
       elseif getstage aaPD 20
         Setstage aaPD 61
         Set iDoOnce to 5
         Player.additem aaRockNote1 1
         aaDBox2.removeitem aaChems 1
         aaRock1.additem aaPay 1
       elseif getstage aaPd (##) etc.
     ; else "fall through"
       endif ;getstage aaPD
   ; Else "fall through"
     Endif ;aaDBox1.Getitemcount
     IF aaDBox2.Getitemcount aaChems >=1
        if getstage aaPD 20
          ... (etc.)...
      ; else "fall through" 
        endif ;getstage aaPD
   ; Else "fall through"
     Endif ;aaDBox2.Getitemcount
; else "fall through"
  endif ;iDoOnce ==4
;ELSE "do nothing"
Endif ;Pickup >0 && Pickup <=50

Then you can insert messages to tell which conditions are actually returning "true". This will also be more efficient as you will only need to test unique conditions once instead of repeatedly. Though I do believe there is a limit (12?) to how deep you may nest conditions in GECK.

 

You should also always bear in mind what will happen when a condition "fails" (returns false). In effect every "If" (or "elseif") should have an "else". If you intent that nothing should happen in that circumstance, then leave a comment to that effect so you know later that was considered and the intended result. All of that takes more lines of code but makes it easier to follow and narrow down where your logic is failing. In the long run, that is much more important.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

the problem is with the getitemcount for each container... every other part worked, I tried as you had sugested

I don't understand how it wouldn't work, the refid is correct, and the item to place is the correct one given to the player when the quest starts. this is quite frustraiting

it doesn't work regardless of the item that it is set to, but it does work if it is supposed to find 0 of the item in it

Edited by zombieslaya1990
Link to comment
Share on other sites

Here is where someone much more familiar with GECK than I should be able to help, but in the meantime try putting a space after the comparison operator (i.e. ">= 1"). Sometimes parsers get finicky about spaces when doing comparisons as opposed to assignments.

 

You can also try assigning the result of the "Getitemcount" to a variable and then comparing the variable. That way you can display the variable value in a message to confirm you are actually getting something to compare with. Testing against a variable instead of repeatedly calling a function is also more efficient.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

If Pickup ==0 && iDoOnce ==4

Set Pickup to (Pickup + GetRandomPercent) ; has potential to = 0

Endif


If Pickup >0


~~~~~~~~~~~~~


Are you wanting that 1% chance to not be true ?


And do you have some scripting in the Quest stages ? what do they look like? Plus the containers ???

Link to comment
Share on other sites

in that part if pickup ==0 again then If i am right it would still meet the requirements for the if statement and be tried again.

 

i've since changed the script a lot to no avail, it works up until the GetItemCount and then wont work .

i've used messages to show each part working, the only time the message doesn't show is at the getitemcount stage, I even tried changing the object which didn't work either.

Edited by zombieslaya1990
Link to comment
Share on other sites

Well after running a quick test my self ...

 

Dropped a container in at good springs ... placed a 10mm pistol next to it. Gave the container a ref-ID and flagged persistent.

 

Then made a Quest script that looks like this ...

 

SCN MyTestAddScript
Begin GameMode
If zzmytestFootRef.GetItemCount Weap10mmPistol >= 1
Player.additem WeapAlienBlaster 1 100
endif
end
~~~~~~~~~~~~~~~~~
Then made a quest ... set it as start game enabled , set it's delay to 1.0 and attached the script.
Went in game and it's adding AlienBlasters to my inventory every second (that I'm in game mode)
After placing the 10mm in the footlocker. Stops when taking it out.
So should be working for you ... unless there is a problem with the item it's checking for ?
What is "aaChems" exactly ?
Link to comment
Share on other sites

  • Recently Browsing   0 members

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