cfh85 Posted September 19, 2012 Share Posted September 19, 2012 the first one is to 'forge' keys for doors. It's an ability added to an NPC through dialogue. The PC then gets a door in it's cross hairs and if it has a key the NPC should produce a message either saying they can or can't forge it. In the even they can the key is added to the NPC's inventory. This isn't the final version of the script as that has extra checks, but I have tried this version. As far as the problem I just don't know why it doesn't work. It just seems to do nothing Scriptname CFHCompanionsAbilitySkillAgilitySecurityScript;Forge Key;<------------ need to detect if it's lockable -------->Ref SelfRef LockRef KeyFloat TimerFloat LevelFloat LockLevelFloat SpecializationBegin Gamemode If Timer < 20 Set Timer to (Timer + GetSecondsPassed) Set Lock to GetCrosshairRef If Lock.IsDoor == 0 Return Else Set Key to Lock.GetOpenKey If Key.IsKey == 0 Set Lock to Lock.GetLinkedDoor Set Key to Lock.GetOpenKey If Key.IsKey == 0 Return EndIf EndIf Set Self to GetSelf Self.AddItemNS Key 1 MessageBox "%n has forged the Key" Self Set Timer to 0 Self.RemoveSpell CFHCompanionsAbilitySkillAgilitySecurity EndIf Else Set Timer to 0 Self.RemoveSpell CFHCompanionsAbilitySkillAgilitySecurity EndifEnd[/Code] The second script is to 'bribe the guards'. Again it's in an ability that is added to an NPC. The ability when added to the NPC searches for the closest guard and then tells the NPC to cast a spell at them. This spell then changes the guards class to non guard and lowers aggression, responsibility and confidence. The part I'm having a problem with is the part that tells the NPC to cast the spell. I've tried it using a cast package and changing the location data, and I've tried just using cast. Either way the NPC doesn't cast at a guard and the spell seems to go off behind him/her [Code]Scriptname CFHCompanionsClass27AbilityScript;Thief - Bribe GuardsArray_var Targetsarray_var MyStringmapRef SelfRef TargetRef TempTargetFloat DistanceFloat KeyFloat NoGuardsFloat LevelFloat CostBegin Gamemode Set Self to GetSelf Let Targets := GetHighActors Let Key := Ar_size Targets Set NoGuards to 0 While Key > 0 Let Key -= 1 Let TempTarget := Targets[Key] If (TempTarget.IsGuard == 0) Continue Else If (Self.GetDistance TempTarget) < (Distance) Set Target to TempTarget Set Distance to (Self.GetDistance TempTarget) Continue EndIf If NoGuards == 0 Set Target to TempTarget Set Distance to (Self.GetDistance TempTarget) Set NoGuards to 1 EndIf EndIf Loop If NoGuards == 1 Let Level := Call UDCFHCompanionLevelNeutral Self Set Cost to (20 * (100 - Level)) Player.RemoveItem Gold001 Cost Self.Cast CFHCompanionClass27BribeSp Target EndIf Self.RemoveSpell CFHCompanionsClass27AbilityEnd[/Code] Link to comment Share on other sites More sharing options...
WarRatsG Posted September 19, 2012 Share Posted September 19, 2012 I think the first script may be failing because Ref Key is a base object, and your syntax is using it as a reference. Easily fixed:IsKey Key As for the second script, I think that the cast function is letting you down. It's practically useless when an NPC uses a target spell, and unpredictable with a touch spell. Self spells work well enough though. To solve this, I reckon "PlayGroup Cast 1" combined with an activator placed in front of or above the caster to fire the spell would be the closest match. Link to comment Share on other sites More sharing options...
cfh85 Posted September 19, 2012 Author Share Posted September 19, 2012 Now I've got it to add the key when it should however, after it's successfully added the a key once, the next time I ask the NPC to forge a key it just immediately adds the previous one, whilst my crosshair is still pointing at the NPC Scriptname CFHCompanionsAbilitySkillAgilitySecurityScript;Forge KeyRef SelfRef LockRef KeyFloat TimerFloat LevelFloat LockLevelFloat SpecializationFloat DoOnceBegin Gamemode If DoOnce == 1 If Timer < 20 Set Timer to (Timer + GetSecondsPassed) Set Lock to GetCrosshairRef If Lock.IsDoor == 0 Return Else Set Key to Lock.GetOpenKey If (IsKey Key) == 0 Set Lock to Lock.GetLinkedDoor Set Key to Lock.GetOpenKey If (IsKey Key) == 0 Return EndIf EndIf Set Specialization to Self.GetClassSpecialization Set Level to (Self.GetFactionRank CFHCompanionLevelFaction) If Specialization == 2 Set Level to (Level * 2) EndIf If (Level > (Self.GetAV Agility)) Set Level to (Self.GetAV Agility) EndIf If (Level > (Self.GetAV Security)) Set Level to (Self.GetAV Security) EndIf Set LockLevel to Lock.GetLockLevel If Level > LockLevel Self.AddItemNS Key 1 MessageBox "has forged the Key" Else MessageBox "could not forged the Key" EndIf Set DoOnce to 0 Self.RemoveSpell CFHCompanionsAbilitySkillAgilitySecurity EndIf Else Set DoOnce to 0 Self.RemoveSpell CFHCompanionsAbilitySkillAgilitySecurity Endif Else Set Timer to 0 Set Self to GetSelf Set Lock to 0 Set key to 0 Set DoOnce to 1 EndIfEnd [/Code] Link to comment Share on other sites More sharing options...
WarRatsG Posted September 20, 2012 Share Posted September 20, 2012 That is definitely strange. I cant think of why it would return a door you're not even facing, especially since you already cleared the variable. Some output functions will help to shine a light on the problem. Any time a function returns something, print it. It should show specifically where the dodgy value is. Link to comment Share on other sites More sharing options...
cfh85 Posted September 21, 2012 Author Share Posted September 21, 2012 output functions? I had a look on the wiki about debug, but I don't think I can find anything that would help Link to comment Share on other sites More sharing options...
WarRatsG Posted September 21, 2012 Share Posted September 21, 2012 One of the functions in your script is pointing to the door, or the door key. Some PrintToConsole calls will show where the weakness is. An example would be:PrintToConsole $Key Link to comment Share on other sites More sharing options...
Recommended Posts