Jump to content

Im doing it wrong (scripting)


Scripts18

Recommended Posts

Just cant understand how to do math and compare stuff with papyrus scripting :s

 

 

Take a look at this .... and theres probably errors

 


ScriptName LevelingUpWeapon extends ObjectReference

Event OnObjectEquipped( Form Weapon, ObjectReference akReference )           <----------------- Note: akReference gonna be something else later (This note isnt in the script its just so you can understand a bit more)
	 
       xp = 0
	
	If Game.getplayer().IsInCombat() == true
	
            x = game.getplayer().getcombattarget()
		 
	     Debug.notification("You Are In Combat With" + x) 
	 
	        if  x.getkiller() == game.getplayer() 
			
	             Debug.Notification("You Killed An Ennemy")
	             Debug.notification("Your Weapon Gained 1 xp")
	             xp + 1
	
	         endif
			 
			 
	EndIf
	

	

EndEvent

Link to comment
Share on other sites

The best way to script is in the CK. The auto-debug feature will stop you in your tracks when you are doing things wrong.

 

Debug.Notification("You Killed An Ennemy")

 

Typographical error here. Ennemy --> Enemy

Link to comment
Share on other sites

I disagree - the best way to script is to set up an external editor, like Notepad ++. Then you benefit from color coding, proper indentation etc. CK editor is for quick changes to code only. And if you set up an external editor properly, you will get compilation errors just like in CK.

 

To the OP, what are you trying to do with the script? Hard to say what you're doing wrong if we don't know what it is you're supposed to do in the first place, but looking at the code I assume you're trying to make a weapon that gains experience?

 

In that case you're calling a wrong event. The code you type will fire only once, on item being equipped. You want an event that will fire when an actor dies, or when the weapon hits something. For first use onDeath(), for second use onHit(), see if that helps.

Link to comment
Share on other sites

Try this


ScriptName LevelingUpWeapon extends ObjectReference

int property xp auto
x = game.getplayer() .getcombattarget()


Event OnObjectEquipped( Form Weapon, ObjectReference akReference )           <----------------- Note: akReference gonna be something else later (This note isnt in the script its just so you can understand a bit more)
	 
	If (Game.getplayer().IsInCombat() == true) 
	             			 
	     Debug.notification("You Are In Combat With " + x + "." ) 
	 
	        if  x.getkiller() == game.getplayer() 
			
	             Debug.Notification("You Killed An Ennemy")
	             Debug.notification("Your Weapon Gained 1 xp")
	             xp += 1
	
	         endif
			 
			 
	EndIf
	

	

EndEvent

Edited by FiLTHYESKiMO
Link to comment
Share on other sites

Try this

 

 


x = game.getplayer() .getcombattarget()  <------------------------ the = gives this error : no viable alternative input '='

 

Also @ mansh ... I know will probably put loops , but wanted to test it how it was right now

Edited by Scripts18
Link to comment
Share on other sites

ScriptName LevelingUpWeapon extends ObjectReference

int property xp auto
string proprety x  auto


Event OnObjectEquipped( Form Weapon, ObjectReference akReference )           <----------------- Note: akReference gonna be something else later (This note isnt in the script its just so you can understand a bit more)
              
               If (Game.getplayer().IsInCombat() == true)

                    x = Game.GetPlayer().GetCombatTarget() <----------------- Note: akReference gonna be something else later (This note isnt in the script its just so you can understand a bit more)                                          
                    Debug.notification("You Are In Combat With " + Game.GetPlayer().GetCombatTarget()  + "." ) 
                
                       if  x.getkiller() == game.getplayer() 
                               
                            Debug.Notification("You Killed An Ennemy")
                            Debug.notification("Your Weapon Gained 1 xp")
                            xp += 1
               
                        endif
                                
                                
               EndIf
               

               
       
EndEvent

 

I fired the GetCombatTarget too soon. It was trying to retrieve the target before it existed. Maybe this fixes it?

Edited by FiLTHYESKiMO
Link to comment
Share on other sites

Actually that line didnt give me errors it is something with the x.getkiller and some other stuff , I continued working on my version and I have only 1 problem now

 


ScriptName LevelingUpWeapon extends ObjectReference

int property xp auto

Event OnObjectEquipped( Form Weapon, ObjectReference akReference )   
                
				 
 If game.getplayer().IsInCombat() == True
           
		
		    Actor x = Game.GetPlayer().GetCombatTarget()
               Debug.notification("You Are In Combat With " + x + ".") 
			
 Endif
 
EndEvent
  
Event OnDeath(Actor akKiller)          
  
		    If (akKiller == game.getplayer()) 
				
				    Debug.Notification("You Killed An Enemy")                            
				    Debug.notification("Your Weapon Gained 1 xp")                             
				    xp += 1  
					
			Endif
       
EndEvent 

 

If I use the OnDeaht Event I cant find out who was the npc killed.... and I dont know how to combine those 2 events into 1 (must have the weapon equiped and kill somebody with it to get the xp)

 

Nvm for the event thingy I found out how to

Edited by Scripts18
Link to comment
Share on other sites

  • Recently Browsing   0 members

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