Aller au contenu

Photo

Creature Special Abilities - How to Implement New Ones ?


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Darin

Darin
  • Members
  • 282 messages
 There are at least 4 different types of special abilities I can think of, 3 of which I can do myself (and will explain here); the other is a complete mystery to me.

(1) Things that happen to PCs when the creature hits them - easiest way to do these is a special attack script using item scripting on the creature's weapon/claws - set the unique on hit power on the claws, do the item-script thing and bam, done.

(2) Things that happen to  PCs when they hit the creature - on hit on the armor does this, no problem.

(3) When the creature dies - put in the OnDeath script.  I actually copied the basic nw_(whatever) on death script and add if(GetTag(OBJECT_SELF)=="c_creaturetag"){insert here}

(4) Special Abilities the creature chooses to use - No clue.  That's the question.  Assume I have a script in mind, where/how do I get my creature to use it?  They tend not to use items (but most items have a special ability you can give instead, like alchemist fire).  But I want to write a script that the creature can use in combat...but not as a reaction to being hit or an effect of hitting.  And it's a "new" ability (not an existant spell).  How do I do this?

#2
Dann-J

Dann-J
  • Members
  • 3 161 messages
I believe creatures will only use special abilities of their own volition that are in the hench_spells.2da. The abilities themselves are just new entries in spells.2DA.

If you don't want to rely on the existing creature behaviour, then you'd have to force the ability use via one of its event scripts (heartbeat, perception, etc). Exactly which script you chose to modify would depend on when you want the creature to use its ability. An initial one-off charge attack would probably go in the OnPerceived script slot, for instance.

In that case, you wouldn't necessarily need a new spells.2DA entry - although you'd then have to 'fake' things like the usual spellcast messages (Creature is using xxxx ability, Creature is casting xxxx, etc). It's generally easier to hook into spells.2DA though, since that allows the ability to use projectile effects, automatically calculates the delay between spell cast and spell hit (based on distance), and automatically plays the creature's casting animation.

#3
kevL

kevL
  • Members
  • 4 078 messages
(4) what Dann says, or if yer feeling brave .....


sounds like you need to tie into the Combat AI

DetermineCombatRound() or HenchDetermineCombatRound() <-- combatAI


These will make a call to a custom script, the name of which is set as a string_var on the NPC. The details quickly get complicated and specific, so will just point to

x2_ai_demo
x2_inc_switches


There are a few other x2_ai_* scripts, for beholders, mindflayers, & shadows that if you can find them are good examples of the X2_SPECIAL_COMBAT_AI_SCRIPT implementation,


note: this works only *in combat* -- otherwise use the heartbeat or perception etc.

#4
Darin

Darin
  • Members
  • 282 messages
Okay, so....how do I set it to react to being taunted? (I assume EVENT_MASTER_TOGGLEMODE_TAUNT is the way to get a companion to react to the PC taunting, not the taunt victim)

#5
kevL

kevL
  • Members
  • 4 078 messages
well, if you look in nwn2_scriptsets.2da you should see rows for Player_Default (the PC) and Companion_Possessed (a player-controlled companion). In the column ScriptUserDefine it says the first is 'gb_comp_usrdef' and the second is 'gb_player_ud'

I don't think those scripts already exist, so you could perhaps create those scripts and set up a condition (in either or both) that checks for event 2012 ( _TAUNT ) and go about the business of having a companion react in that,

#6
Shaughn78

Shaughn78
  • Members
  • 637 messages

EpicFetus wrote...
(3) When the creature dies - put in the OnDeath script.  I actually copied the basic nw_(whatever) on death script and add if(GetTag(OBJECT_SELF)=="c_creaturetag"){insert here}

(4) Special Abilities the creature chooses to use - No clue.  That's the question.  Assume I have a script in mind, where/how do I get my creature to use it?  They tend not to use items (but most items have a special ability you can give instead, like alchemist fire).  But I want to write a script that the creature can use in combat...but not as a reaction to being hit or an effect of hitting.  And it's a "new" ability (not an existant spell).  How do I do this?


For number 3, you don't need to modify the default script. In the first several lines of the on death event it looks for a local string on the dead creature "DeathScript" Whatever string is assigned to the variable the script will execute that script. DeathScript = "do_something_fancy_ondeath". As long as a script (module or campaign) exist called do_something_fancy_ondeath you will get the custom behavior.

For number 4 you can also look at the user defined events. You will need to create a new spawn script, the toolset has templates and unmark the events you want to happen then create your user defined script.

You can also look at my boulder toss script it using these types of scripts.

Modifié par Shaughn78, 15 novembre 2012 - 10:15 .


#7
kevL

kevL
  • Members
  • 4 078 messages
... for items it's also possible to use Tag-based scripts