Jump to content

Im doing it wrong (scripting)


Scripts18

Recommended Posts

Try to use the onDying() event, that fires as soon as the actor begins to die. Then inside you put the getCombatTarget(), since the actor should still be in combat with the player. Try that. The problem with onObjectEquipped is that it will check if the player is in combat only once afaik, and will completely miss if you switch targets, for example. I would avoid putting in loops in the onObjectEquip, that just hogs system resources and should not be neccesary.

 

If the above doesn't work, you can try updating the player's combat target every time the player hits something with the weapon, using the onHit() event. That should work.

Link to comment
Share on other sites

Try to use the onDying() event, that fires as soon as the actor begins to die. Then inside you put the getCombatTarget(), since the actor should still be in combat with the player. Try that. The problem with onObjectEquipped is that it will check if the player is in combat only once afaik, and will completely miss if you switch targets, for example. I would avoid putting in loops in the onObjectEquip, that just hogs system resources and should not be neccesary.

 

If the above doesn't work, you can try updating the player's combat target every time the player hits something with the weapon, using the onHit() event. That should work.

 

I found better than that

 


ScriptName LevelingUpWeapon extends ObjectReference

int property xp auto

Event OnObjectEquipped( Form Weapon, ObjectReference akReference )
	
           Debug.notification("Leveling Up Weapon Was Equiped")		
		
EndEvent
  
Event OnDeath(Actor akKiller)

           If Game.GetPlayer().getEquippedWeapon() ==  LevelinUpWeapon
  
		    If (akKiller == game.getplayer()) 
				
				    Debug.Notification("You Killed An Enemy")                            
				    Debug.notification("Your Weapon Gained 1 xp")                             
				    xp += 1  
					
			Endif
			
		Endif
       
EndEvent  

Event OnObjectUnEquipped( Form Weapon, ObjectReference akReference )
	
           Debug.notification("Leveling Up Weapon Was UnEquiped")		
		
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

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