Jump to content

[HELP} Need help with simple scripting


AlexScorpion

Recommended Posts

yes that was a package destination marker ...

 

so what would the script look like if i would like to move the marker to the activator ???

 

scn AlexSquadAssaultStealthToScript 



Float Timer 
short doOnce 

Begin OnLoad 
     
       if doOnce == 0 
         Set timer to 30 
          AlexSquadMarker.moveto activator ??
        
         set AlexSquadAssaultStealthToMarker to 1 
         ShowMessage AlexMoveInStealthIsWorking 
               set doOnce to 1 
       endif 
        
End 

Begin GameMode 

       if timer > 0 
               set timer to timer - getsecondspassed 
        

       else 
          set AlexSquadAssaultStealthToMarker to 0 
           
               disable 
               MarkForDelete 
       endif 

Link to comment
Share on other sites

cause none of the methods below have worked for me

scn AlexSquadAssaultStealthToScript 

ref me 
Float Timer 
short doOnce 




Begin OnLoad 
     
            if doOnce == 0 
         set me to getself 
          AlexSquadMarker.moveto me                    ;where AlexSquadMarker is the reference id of the xmarker 
         Set timer to 30 
         set AlexSquadAssaultStealthToMarker to 1 
         ShowMessage AlexMoveInStealthIsWorking 
               set doOnce to 1 

endif 
        
End 

Begin GameMode 

       if timer > 0 
               set timer to timer - getsecondspassed 
        

       else 
          set AlexSquadAssaultStealthToMarker to 0 
           
               disable 
               MarkForDelete 
       endif 

End

 

ref rSelf 
ref rSomeOtherRef 

begin gamemode 

   set rSelf to getself 
   rSomeOtherRef.moveto rSelf 

end

 

ref rSomeOtherRef 

begin gamemode 

   rSomeOtherRef.moveto this 

end

Link to comment
Share on other sites

Basics: AlexSquadMarker should be the name given to a dynamic xmarker (not the base object) which is marked as persistent and placed somewhere in the gameworld (ie a dummy cell).

 

Are you re-adding the package every time the marker is moved? or calling evp?

 

As I said AI isn't my strong point, but as far as I'm aware if you move the marker it won't make a difference until the actual package pointing to the marker is updated. Try having a global which is set in the onload block and cleared when the timer in the gamemode block runs out, and then insert this into the NPC's script:

 

short oncecheck 
if packageupdate > 0 && oncecheck < 1 
evp 
set oncecheck to 1 
endif 
if oncecheck > 0 && packageupdate < 1 
set oncecheck to 0 
endif

 

Replace packageupdate with the quest.variable for the global variable.

 

This will only work if the package remains on them permanently. If you're adding it when the marker is moved the only thing I can think of which may be causing a problem is that you need to wait a frame or two before AlexSquadStealthToMarker is set.

 

The other bit I'm not sure about is the timer, I'm guessing setting AlexSquadStealthToMarker to 0 removes the package? So basically they're going to stealth to a point for 30s, then once the 30s is up, no matter if they reached it or not they're going to turn around and recommence what they were doing before? I doubt its causing problems, but could you post the block which deals with the AI package and AlexSquadStealthToMarker.

Edited by Skevitj
Link to comment
Share on other sites

  • 3 weeks later...

hello there again .. i seem to be stuck again :(

 

so i've been working on my armors level up/outfit menu

and recently i've switched to form list (eliminates using individual ref for each weapon/armor)

 

i have a global that goes from 0 to 3 (button press)

i have a form list with 4 armors

and i have a script that checks the global and then equips an armor from that list

if FormListIndex != AlexAssaultArmor || FormListIndex == AlexAssaultArmor
 Set FormListIndex to AlexAssaultArmor   
  Set rArmorRef to ListGetNthForm AlexAssaultAllArmorList FormListIndex 
endif  

If  rArmorRef != 0 getequiped rArmorRef == 0 && getdead == 0 
  if GetItemCount rArmorRef == 0
        additem rArmorRef 1 1  
     equipitem rArmorRef 0 1  
endif


;also tried something like this 

If  rArmorRef != AlexAssaultArmor && getdead == 0
     removeitem rArmorRef 1 1
else 
   additem rArmorRef 1 1
   equipitem rArmorRef 0 1
endif


and this where i hit the bump ... i mean ... how do i remove and add armors with the same ref ID without writing down all possible combinations ..

 

thanks in advance

Alex

Link to comment
Share on other sites

and this where i hit the bump ... i mean ... how do i remove and add armors with the same ref ID without writing down all possible combinations ..

 

I'm not sure if I understand what you're asking... but I think this does what you want.

 

if (FormListIndex != AlexAssaultArmor || rArmorRef == 0) && GetDead == 0
if rArmorRef
	RemoveItem rArmorRef 1
endif

set FormListIndex to AlexAssaultArmor
set rArmorRef to ListGetNthForm AlexAssaultAllArmorList FormListIndex
AddItem rArmorRef 1
EquipItem rArmorRef 0
endif

Link to comment
Share on other sites

I don't fully understand your description of what you are trying to do. Here is the part I understand. You have a formlist, which you know contains four armors; and you have a messagebox, which contains four buttons. When say button N is pushed, you want to get the N'th armor from the formlist, give this armor to the actor and then equip it. I don't use nvse but I assume your line "Set rArmorRef to ListGetNthForm AlexAssaultAllArmorList FormListIndex" gets the proper armor reference. So it seems your code should simply be (untested):

 

Set rArmorRef to ListGetNthForm AlexAssaultAllArmorList FormListIndex
additem rArmorRef 1
equipitem rArmorRef

 

I don't understand the need for your conditionals, in particular "if (a == b) || (a != b)" in line 1 which is always true, and line 6 is missing part of one comparison.

 

Edit: Ninja'd, yeah, basically what he said.

Edited by davidlallen
Link to comment
Share on other sites

thanks guys ... i should have been more clear lol ..

 

button press .. well it's actually a menu .. say if button 1 is pressed the global variable AlexAssaultArmor is set to 0 .. and when button 2 is pressed the global is set to 1 and so on ..

 

now that script with always true line ( it needs to be true so that the formlist will be always set to my formlist)

if FormListIndex != AlexAssaultArmor || FormListIndex == AlexAssaultArmor  Set FormListIndex to AlexAssaultArmor      Set rArmorRef to ListGetNthForm AlexAssaultAllArmorList FormListIndex endif 

 

sets the Formlistindex to my global .. if global == 1 then the index will be set to 1 (and under index 1 in my formlist i have armor number 2)

and then then my armorRef is set to that index and finally i'm adding and equiping that armor ... my problem is that i cannot remove the previously equiped armor from the npc's inventory

Link to comment
Share on other sites

I saw this thread, and wanted to ask if any of you was willing to post some advice to people wanting to learn to script or to beginners over at my How To Become A Modder Thread.

 

It'd be really helpful since I believe the community desperately needs more people who are able to create scripted content.

Edited by simplywayne90
Link to comment
Share on other sites

  • Recently Browsing   0 members

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