Saturday, September 17, 2011

A Goblin in the Works

From here on out, the blog will largely deal with what I’m currently working on in the mod.  I am pretty much working through the areas sequentially and adding items and scripts as they become necessary.  As I’ve gone along I have been tweaking scripts here and there as I come across better ways of doing things – of course when one starts tampering with scripts one has to be careful and ensure that nothing got “broken” elsewhere in the mod.

I have created two types of goblins to replace the axe and knife throwing dwarves of the original text game.  I elected goblins because in NWN dwarves are an option for Players to use – and besides the goblins look meaner.

Goblin1 is the one the Player will encounter first.  Like the dwarf it replaces, it attacks the Player and then runs away, leaving a useable weapon behind for the Player.  In the text version of the game, the weapon is a throwing axe; I changed it to a dagger for a couple of reasons:
1)      Throwing axes cannot be used by every character class in NWN; daggers can.  This just makes it easier if a Player wants to play something other than a fighter.
2)      Ranged weapons are “use and lose” in NWN.  Yes, a script could be written to create a new weapon every time the Player used the one they had; but it would seem rather awkward as the character would have to actually run over to retrieve the weapon – after each attack (would be easier to just beat on them with your hands).  [In the text game, this was a simple command “get axe”; but in NWN, the Player would actually have to move over to the weapon, then collect it, and then attack again – and by this time they are likely right next to the goblin anyway.]
Now then, there are no “throwing daggers” in generic NWN … so, my first goblin actually throws a dart, which looks pretty close to a dagger.

I suppose that now would be as good as time as any to discuss combat.  In the text version combat was easy: you threw your axe and picked it up again; if you missed, you did it again, until either you killed the dwarf or the dwarf killed you.  NWN allows for much broader forms of combat and of course it is animated.  Creatures can take damage, one hit does not mean an instant kill – I want to preserve this part of NWN in the Adventure mod.  The goblins will be easy, with little risk to a Player who has a weapon (I’ve made them tough to kill with bare hands).  Some of the other creatures will be nearly impossible to kill, even with a weapon – all in keeping with the original concept of the text game.

Now, back to that first goblin…  It was a bit of a challenge figuring out “where” to drop the dagger.  I really wanted the impression that the dagger “was” the object thrown by the goblin (i.e., it should appear near the area the PC was when the goblin attacked).  I am using the OnEndCombatRound event to trigger the goblin’s hasty retreat – to make sure it attacks before running away; but usually by then, the Player has closed the distance, and is no longer near the area where the dagger should have landed.  To get around this, I used the OnPerceived event to save the Player’s location when the goblin first detects them.  After the combat round, the dagger is created and placed at the saved location.  The real advantage of this is that by using a location the Player actually occupied, the chance of creating the dagger in a place where the Player cannot retrieve it is greatly diminished. 

My only real concern about the script as it stands, is that the game uses rounds of six (6) seconds each – so basically, the goblin doesn’t flee for 6 seconds after attacking – which is a long time ….  I may rethink the use of the EndCombatRound event and move everything into the OnSpawn Event with DelayCommands to synchronize everything.

No comments:

Post a Comment