Jump to content

Scripting Problem ; Robbing the Player


Dynastia

Recommended Posts

My goal is to have a generic dialogue which leads up to a beating/robbery against the player, perpetrated by a generic NPC. The goodbye dialogue adds a unique unplayable brass knuckles with a setunconscious script to the NPC. The NPC then attacks the player through startcombat player, and when if player.getunconscious they stopcombat player and player.removeallitems. And get rid of the unique-knockout-weapon too, to tidy things up.

 

The weapon works fine, but I'm having a major problem getting the NPC to stop beating up the unconscious player. I've tried using spell effects and attaching an object scripts on the weapon itself, to no avail. Here's my script, which I'm now trying to apply to the weapon (after numerous attempts to make an almost identical code in an effectscript attached to a spell, and questscript attached to a quest)... the code is just so damn simple but refuses to work when I test it.

 

scn aaBeatingScript

ref me

begin scripteffectstart
set me to getself
startcombat player
addscriptpackage aaMeleeOnly
end

begin scripteffectupdate

if player.getunconscious
stopcombat player
player.removeallitems me
removescriptpackage aaMeleeOnly
removeitem aaKnockoutKnuckles ,1
endif

if getdead
removescriptpackage aaMeleeOnly
removeitem aaKnockoutKnuckles ,1
endif

End

Begin ScriptEffectFinish
removescriptpackage aaMeleeOnly
evp
removeitem aaKnockoutKnuckles ,1
end

 

aaMeleeOnly is a scriptpackage that just states Sandbox and Combat Style DEFAULTMELEE. It's the only way I could make the NPC in question use the knockout weapon instead of any gun they might have on them (the dialogue isn't supposed to be tied to a specific NPC so I have no way of knowing what weapons they might be carrying)

 

aaKnockoutKnuckles are the unique weapon in question, which knocks its victim out (and works just fine).

 

Please help, experts. What am I doing wrong?

Link to comment
Share on other sites

First off, if I get this, the script you posted runs on a weapon, yes? You cant use any of the 'ScriptEffect" blocks on an object script (which your script would need to be if running on a weapon). You would have to move that stuff to a gamemode block. Then, if your NPC is in combat with the player and you use a stopcombat command, its possible that the NPC would just start combat again. You may have to use a faction for this and clear the player's enemy flag for that faction when you stop the combat.
Link to comment
Share on other sites

First off, if I get this, the script you posted runs on a weapon, yes? You cant use any of the 'ScriptEffect" blocks on an object script (which your script would need to be if running on a weapon). You would have to move that stuff to a gamemode block. Then, if your NPC is in combat with the player and you use a stopcombat command, its possible that the NPC would just start combat again. You may have to use a faction for this and clear the player's enemy flag for that faction when you stop the combat.

 

Yes, it's on a weapon. I couldn't get it working on an effect. I've changed it all to begin gamemode, and now instead of the NPC refusing to stop combat, the reticule over the NPC briefly turns red, but he immediately becomes non-hostile again.

 

I think the problem is either with the scriptpackage which forces melee weapons overriding the script (if that's at all possible) or I'm just not getting the syntax right for the "if player.getunconscious" part (i've tried every combination of player, playerREF, 1, and to 1 that I can think of).

Link to comment
Share on other sites

I never tried to make the player become unconscious, only NPCs. So I can't say from experience if that will work or not. When I want the player to fall down, I just damage his fatigue - which works well. It even has the side effect of letting the player get back up when his fatigue recovers. Basically, for every point you damage the player's fatigue above his current amount, the player will remain on the floor for 1 second. As for your script, when you changed the block, did you use explicit commands for your NPC? For example,

 

startcombat player

addscriptpackage aaMeleeOnly

 

won't do anything because these commands are using implicit references - meaning they will affect the object that the script is running on. So, it seems to me your are trying to get the weapon to start combat with the player and adding the script package to the weapon. I would have thought that the latter would have resulted in an error when compiling, but I guess not. You would have to make your commands use explicit references like:

 

NPCRef.startcombat player

NPCRef.addscriptpackage aaMeleeOnly

This holds true for many of the commands in your script. Every time you want them to affect the NPC, you'll need to prepend the explicit reference NPCRef. to the commands.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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