KingGsterUK Posted July 14, 2011 Share Posted July 14, 2011 NPC's don't repair their gear so to for a workaround what I'm trying to do is write a script that will check to see if the item is in the inventory, if its equipped then add or remove. Take a look. SCN AdoringFanScript Short FanGreet Short DoOnceA Begin GameMode SetEssential ArenaFan1 0 ArenaFan1Ref.SetIgnoreFriendlyHits 1 if DoOnceA == 0 if GetEquipped 010047e2 == 0 if GetItemCount 010047e2 == 0 AddItem 010047e2 1 EquipItem 010047e2 Set DoOnceA to 1 endif elseif GetEquipped 010047e2 == 0 if GetItemCount 010047e2 >= 1 RemoveItem 010047e2 1 AddItem 010047e2 1 EquipItem 010047e2 Set DoOnceA to 1 endif endif endif if DoOnceA == 1 if GetEquipped 010047e2 == 1 Set DoOnceA to 0 endif endif end The script works, it doesn't keep spawning weapons in his inventory or removing them, I've checked his body. My problem is the RemoveItem command makes him drop the weapon instead of actually de-spawning it. To test it I made the item have 2 health, he hits a guy, the weapon breaks, he drops it, he spawns another weapon. Checked his body on death and there's only one weapon there so everything's good except from him littering the place. I thought of having like 50k health on the weapon but he would be using it for ages on low health/damage before It broke if you get me. Is there anyway I can get it to completely de-spawn? Cheers. Link to comment Share on other sites More sharing options...
KingGsterUK Posted July 14, 2011 Author Share Posted July 14, 2011 Hmm... I've tried disable as well instead of remove but the same happens. Maybe it's because the item is broke he drops it and then doesn't get chance to remove or disable it because it's not in his inventory. So that leads to to a different question. Is there a way to check item health using a script. If there is it should enable me to remove it before he drops it. Link to comment Share on other sites More sharing options...
Maskar Posted July 14, 2011 Share Posted July 14, 2011 Yes, you're right. He drops it automatically when his weapon is broken. You can check item health with GetEquippedCurrentHealth. There's however 1 big issue with your script. You should be using the editor id name, rather than 010047e2. Link to comment Share on other sites More sharing options...
fore Posted July 14, 2011 Share Posted July 14, 2011 Maybe the reason for dropping is somewhere else (just guessing). The player cannot change weapon while swinging, i.e. during one fight animation. This way the system protects itself from undefined situations during these animations. So most likely you can't change/delete an NPC's weapon during a swing, and dropping may be some left over information after the swing is complete. I don't know off hand if it's possible to check reliably for attack animation (isAtacking?), and postpone the removeitem after that, but I think it's worth trying. Link to comment Share on other sites More sharing options...
KingGsterUK Posted July 15, 2011 Author Share Posted July 15, 2011 (edited) Excellent thanks guys for the input. The way I have it now, when you first meet the adoring fan he's naked haha but the first time he's in a fight he will get his gear and keep it. Renewing his gear every time he starts combat as well, eliminating the worry of broken equipment! Here's my working script: SCN AdoringFanScript Short FanGreet Short DoOnceA Short DoOnceB Short DoOnceC Short DoOnceD Short DoOnceE Short DoOnceF Short DoOnceG Begin GameMode SetEssential ArenaFan1 0 ArenaFan1Ref.SetIgnoreFriendlyHits 1 if DoOnceA == 0 if IsInCombat == 1 RemoveItem 000adoringblade 1 if GetEquipped 000adoringblade == 0 if GetItemCount 000adoringblade == 0 AddItem 000adoringblade 1 EquipItem 000adoringblade set DoOnceA to 1 endif endif endif endif if DoOnceA == 1 if IsInCombat == 0 Set DoOnceA to 0 endif endif if DoOnceB == 0 if IsInCombat == 1 RemoveItem 000adoringboots 1 if GetEquipped 000adoringboots == 0 if GetItemCount 000adoringboots == 0 AddItem 000adoringboots 1 EquipItem 000adoringboots Set DoOnceB to 1 endif endif endif endif if DoOnceB == 1 if IsInCombat == 0 Set DoOnceB to 0 endif endif if DoOnceC == 0 if IsInCombat == 1 RemoveItem 000AdoringCuirass 1 if GetEquipped 000AdoringCuirass == 0 if GetItemCount 000AdoringCuirass == 0 AddItem 000AdoringCuirass 1 EquipItem 000AdoringCuirass Set DoOnceC to 1 endif endif endif endif if DoOnceC == 1 if IsInCombat == 0 Set DoOnceC to 0 endif endif if DoOnceD == 0 if IsInCombat == 1 RemoveItem 000AdoringGauntlets 1 if GetEquipped 000AdoringGauntlets == 0 if GetItemCount 000AdoringGauntlets == 0 AddItem 000AdoringGauntlets 1 EquipItem 000AdoringGauntlets Set DoOnceD to 1 endif endif endif endif if DoOnceD == 1 if IsInCombat == 0 Set DoOnceD to 0 endif endif if DoOnceE == 0 if IsInCombat == 1 RemoveItem 000AdoringGreaves 1 if GetEquipped 000AdoringGreaves == 0 if GetItemCount 000AdoringGreaves == 0 AddItem 000AdoringGreaves 1 EquipItem 000AdoringGreaves Set DoOnceE to 1 endif endif endif endif if DoOnceE == 1 if IsInCombat == 0 Set DoOnceE to 0 endif endif if DoOnceF == 0 If IsInCombat == 1 RemoveItem 000AdoringMask 1 if GetEquipped 000AdoringMask == 0 if GetItemCount 000AdoringMask == 0 AddItem 000AdoringMask 1 EquipItem 000AdoringMask Set DoOnceF to 1 endif endif endif endif if DoOnceF == 1 if IsInCombat == 0 Set DoOnceF to 0 endif endif if DoOnceG == 0 If IsInCombat == 1 RemoveItem 000AdoringCloak 1 if GetEquipped 000AdoringCloak == 0 if GetItemCount 000AdoringCloak == 0 AddItem 000AdoringCloak 1 EquipItem 000AdoringCloak Set DoOnceG to 1 endif endif endif endif if DoOnceG == 1 if IsInCombat == 0 Set DoOnceG to 0 endif endif end I am however curious how to tell him to cast a heal spell on himself. What I have in mind is when he drops below 25% health, he will cast his first heal and another every 5 seconds. When he's not in combat, he heals up to full. How would i go about doing that? Because he's not actually using his heal spell I gave him at the moment and he has enough spell points and restoration skill points. Edited July 15, 2011 by KingGsterUK Link to comment Share on other sites More sharing options...
fg109 Posted July 15, 2011 Share Posted July 15, 2011 (edited) You should not name things starting with numbers because the game thinks that you're actually giving a form id instead of editor id. And for casting spells, I believe you can control that through their combat style. Instead of having all those if conditions, why not just do this? Begin OnStartCombat set count to GetItemCount *item* RemoveItem *item* count AddItem *item* 1 EquipItem *item* ; ... End Edited July 15, 2011 by fg109 Link to comment Share on other sites More sharing options...
Recommended Posts