Jump to content

Scripting Questions


bencebence

Recommended Posts

Hey everybody!

I have two questions:

- How can I bind a script to a reference? For example I can only mine if I'm near a vein? Figured it out.

- The second is a bit same, how can I bind a script to a reference, but this time you have to activate the reference to make it work.

 

Thanks in advance,

 

bencebence

Edited by bencebence
Link to comment
Share on other sites

You should first figure out how to let an activator recognise a pickaxe hit.OnHitWith works on activators but only with arrows. I guess you could make the vein an actor, but that would be kinda tricky.

You could try the following, but it is activated then.

Scn ScriptVeinHitpointsOrSomeOtherTitleIDoNotKnow

Short VeinHP

Begin OnActivate
Set VeinHP to VeinHP + 1
End

Begin GameMode
If (VeinHP == 4 )
   VeinRef.Disable
   Set VeinHP to 0
EndIf

 

This way, when activated four times, the vein will be disabled. However, the VeinHP can be reset when reloading the cell, I do not know for sure.

Link to comment
Share on other sites

I don't want it to be reseted :P

Also here is the script I'm using:

Scriptname RaivenMineScript

short bluntskill
short ready
short chance
short chanceIron
short chanceSilver
short chanceGold
short chanceGlass
short chanceEbony
short playhitsound

Begin GameMode
       if (GetCrossHairRef == GetSelf) && (OnControlDown 4)
               if (Player.GetEquipped MiningPick)
               set ready to 1
               else
               Message "You must equip a Mining Pick to mine the rock."
               endif
       endif
       if (ready)
               set ready to 0
               set bluntskill to player.getactorvalue blunt
               set chance to getrandompercent
               set chanceIron to 10
               set chanceSilver to 7
               set chanceGold to 5
               set chanceGlass to 5
               set chanceEbony to 2 
               if (chance == 98)
		player.additem gem6diamondflawless 1
		message "You found a flawless diamond."
	elseif (chance == 97)
		player.additem gem6diamond 1
		message "You found a diamond."
	elseif (chance == 96)
		player.additem gem6diamondflawed 1
		message "You found a flawed diamond."
	elseif (chance == 95)
		player.additem gem5emeraldflawless 1
		message "You found a flawless emerald."
	elseif (chance == 94)
		player.additem gem5emerald 1
		message "You found am emerald."
	elseif (chance == 93)
		player.additem gem5emeraldflawed 1
		message "You found a flawed emerald."
	elseif (chance == 92)
		player.additem gem4sapphireflawless 1
		message "You found a flawless sapphire."
	elseif (chance == 91)
		player.additem gem4sapphire 1
		message "You found a sapphire."
	elseif (chance == 90)
		player.additem gem4sapphireflawed 1
		message "You found a flawed sapphire."
	elseif (chance == 89)
		player.additem gem3rubyflawless 1
		message "You found a flawless ruby."
	elseif (chance == 88)
		player.additem gem3ruby 1
		message "You found a ruby."
	elseif (chance == 87)
		player.additem gem3rubyflawed 1
		message "You found a flawed ruby."
	elseif (chance == 86)
		player.additem gem2topazflawless 1
		message "You found a flawless topaz."
	elseif (chance == 85)
		player.additem gem2topaz 1
		message "You found a topaz."
	elseif (chance == 84)
		player.additem gem2topazflawed 1
		message "You found a flawed topaz."
	elseif (chance > 10)
		player.additem Coal 1
		message "You found some coal."
	else                            ;or it could be an endif
		if (bluntskill > chance*chanceEbony)
			player.additem EbonOre 1
		elseif (bluntskill > chance*chanceIron)
			player.additem IroneOre 1
		elseif (bluntskill > chance*chanceSilver)
			player.additem Gem0SilverNugget 1
		elseif (bluntskill > chance*chanceGold)
                               player.additem Gem0GoldNugget 1
		elseif (bluntskill > chance*chanceGlass)
			player.additem glassore 1
		elseif (chance <= 10)
			message "You found nothing."
			set playhitsound to 1
		endif
	endif                           ;if you chose endif, then delete this line
	if (playhitsound == 1)
		playsound wpnhitblunt
		set playhitsound to 0
	else
		playsound wpnblockblunt
	endif
endif
       
End

Link to comment
Share on other sites

You should first figure out how to let an activator recognise a pickaxe hit.OnHitWith works on activators but only with arrows. I guess you could make the vein an actor, but that would be kinda tricky.

You could try the following, but it is activated then.

Scn ScriptVeinHitpointsOrSomeOtherTitleIDoNotKnow

Short VeinHP

Begin OnActivate
Set VeinHP to VeinHP + 1
End

Begin GameMode
If (VeinHP == 4 )
   VeinRef.Disable
   Set VeinHP to 0
EndIf

 

This way, when activated four times, the vein will be disabled. However, the VeinHP can be reset when reloading the cell, I do not know for sure.

 

How can I make an activator have the same reference?

Link to comment
Share on other sites

Hmm. I used the script and I have a problem. I can't gain any ores anymore. The script does not work now. Also the ore hp script does not work too.

The script looks like this now, and it does not seems to be working:

 

Scriptname RaivenMineScript

short bluntskill
short ready
short chance
short chanceIron
short chanceSilver
short chanceGold
short chanceGlass
short chanceEbony
short playhitsound
short veinhp

Begin OnActivate
Set VeinHP to VeinHP + 1
End

Begin GameMode
       if (GetCrossHairRef == GetSelf) && (OnControlDown 4)
               if (Player.GetEquipped MiningPick)
               set ready to 1
               else
               Message "You must equip a Mining Pick to mine the rock."
               endif
       endif
       if (ready)
               set ready to 0
               set bluntskill to player.getactorvalue blunt
               set chance to getrandompercent
               set chanceIron to 10
               set chanceSilver to 7
               set chanceGold to 5
               set chanceGlass to 5
               set chanceEbony to 2 
               if (chance == 98)
		player.additem gem6diamondflawless 1
		message "You found a flawless diamond."
	elseif (chance == 97)
		player.additem gem6diamond 1
		message "You found a diamond."
	elseif (chance == 96)
		player.additem gem6diamondflawed 1
		message "You found a flawed diamond."
	elseif (chance == 95)
		player.additem gem5emeraldflawless 1
		message "You found a flawless emerald."
	elseif (chance == 94)
		player.additem gem5emerald 1
		message "You found am emerald."
	elseif (chance == 93)
		player.additem gem5emeraldflawed 1
		message "You found a flawed emerald."
	elseif (chance == 92)
		player.additem gem4sapphireflawless 1
		message "You found a flawless sapphire."
	elseif (chance == 91)
		player.additem gem4sapphire 1
		message "You found a sapphire."
	elseif (chance == 90)
		player.additem gem4sapphireflawed 1
		message "You found a flawed sapphire."
	elseif (chance == 89)
		player.additem gem3rubyflawless 1
		message "You found a flawless ruby."
	elseif (chance == 88)
		player.additem gem3ruby 1
		message "You found a ruby."
	elseif (chance == 87)
		player.additem gem3rubyflawed 1
		message "You found a flawed ruby."
	elseif (chance == 86)
		player.additem gem2topazflawless 1
		message "You found a flawless topaz."
	elseif (chance == 85)
		player.additem gem2topaz 1
		message "You found a topaz."
	elseif (chance == 84)
		player.additem gem2topazflawed 1
		message "You found a flawed topaz."
	elseif (chance > 10)
		player.additem Coal 1
		message "You found some coal."
	endif                            ;or it could be an else
	if (bluntskill > chance*chanceEbony)
			player.additem EbonOre 1
		elseif (bluntskill > chance*chanceIron)
			player.additem IroneOre 1
		elseif (bluntskill > chance*chanceSilver)
			player.additem Gem0SilverNugget 1
		elseif (bluntskill > chance*chanceGold)
                               player.additem Gem0GoldNugget 1
		elseif (bluntskill > chance*chanceGlass)
			player.additem glassore 1
		elseif (chance <= 10)
			message "You found nothing."
			set playhitsound to 1
		endif
                          ;if you chose else, then put an endif here
	if (playhitsound == 1)
		playsound wpnhitblunt
		set playhitsound to 0
	else
		playsound wpnblockblunt
	endif
endif
if (VeinHP == 3 )
	OreVeins.Disable
	OreVeins2.Disable
	OreVeins3.Disable
	OreVeins4.Disable
	OreVeins5.Disable
	OreVeins6.Disable
	OreVeins7.Disable
	OreVeins8.Disable
	OreVeins9.Disable
	OreVeins10.Disable
	OreVeins11.Disable
	OreVeins12.Disable
	OreVeins13.Disable
	OreVeins14.Disable
	OreVeins15.Disable
	OreVeins16.Disable
	OreVeins17.Disable
	OreVeins18.Disable
	OreVeins19.Disable
	OreVeins20.Disable
	OreVeins21.Disable
	OreVeins22.Disable
	OreVeins23.Disable
	OreVeins24.Disable
	message "There are no more veins in this rock"
endIf
End

Link to comment
Share on other sites

Oh I have missed something. The script should be applied on the vein:

Scn ScriptVeinHitpointsOrSomeOtherTitleIDoNotKnow

Short VeinHP
Ref ThisVein

Begin OnActivate
Set VeinHP to VeinHP + 1
End

Begin GameMode
Set ThisVein to GetSelf
If (VeinHP == 4 )
   ThisVein.Disable
   Set VeinHP to 0
EndIf

 

When you activate the vein four times, it should dissapear.

Try again and list what the problems in-game are and if it yields any compiler errors. Is it applied on a vein or on a quest or ... ?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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