How to make an NPC disappear ?[]
In order to make an NPC disappear you need to add to NPC’s spawn set an empty phase and name it ‘gone’. All you have to do now (e.g. after a dialogue or just whenever you need it) is to change NPC’s phase to ‘gone’.
Here’s the script:
void main() { SetStoryNPCStoryPhase("spawnset_name", "gone"); }
If you want to destroy an NPC you can do:
a) teleport an object out of the location and then despawn/kill it. To teleport use ActionJumpToObject b) or you can use DestroyObject – but it doesn’t always work on creatures
How to create Power Places and Rings of Elements ?[]
Stones and Power Places’ effects are placeable. To set them up you need triggers with scripts that switch phase effects of Power Places whenever a player comes up or walks away. You also need the ‘OnUsed’ scripts for both objects – in the first case the script adds an ability boosting up given stats, in the second case it opens up a dialogue with a Power Place (the dialogue lines are linked with the scripts giving particular abbilites). To add ability do as follows:
{ AddAbility("ability_name", oPC); }
How to make an NPC attack us after a dialogue line?[]
If you want a character to be hostile towards a player (e.g. after a dialogue line) you just need to add an ‘Action Script’ script to the dialogue line, after which an NPC is supposed to attack a player. Of course, you can add this script in different places, depending on what you want to achieve (e.g. in the template of our opponent’s ‘On Damage’ or ‘On End Conversation’).
#include "inc_ai" void main() { object oPC = GetFirstPC(); object object_name = GetObjectByTag("character_tag"); AI_ClearPersonalAttitude(object_name, oPC); AI_SetPersonalAttitude(CN_ATTITUDE_HOSTILE, object_name, oPC); SetProfile(object_name, PROFILE_TYPE_ENEMY_WITCHER, TRUE); }
In the template ‘Script set’ should be set to default.
How to open up a dialogue after setting off a trigger (teleport and talk) ?[]
Once a trigger has been set up in a location you have to turn it on after e.g. a dialogue line. To do that, add the script below in action scripts in the desired line of the dialogue:
void main()
{
object dialog = GetObjectByTag("trigger_tag"); //dialog – our name used in trigger script
if(GetEnteringObject() == GetFirstPC())
EnableTrigger(dialog,TRUE);
}
Then we add to the trigger the ‘On Enter’ script which is going to set off the dialogue we’ve written.
#include "inc_dialog"
void main()
{
object our_object = GetObjectByTag("characters_tag");
object dialog = GetObjectByTag("trigger_tag");
TeleportAndTalk(our_object, "dialog_file");
EnableTrigger(dialog,FALSE); //here we set trigger off to prevent starting the dialog everytime we stand on this trigger
}
An exemplary NPC phase change script and turn-off trigger for area transition and cut scene.[]
void main() { object cutscene = GetObjectByTag("cutscene_trigger_tag"); //trigger that turning cutscene on object exit = GetObjectByTag("exit_trigger_tag"); //exit location trigger SetStoryNPCStoryPhase("npc_name","phase_name"); //change story phase of the first npc SetStoryNPCStoryPhase("npc2_name","phase_name"); //change story phase of the second npc EnableTrigger(cutscene,TRUE); //enable cutscene trigger EnableTrigger(exit,TRUE); //enable exit location trigger }
A cutscene set-off trigger looks like this:
void main()
{
object cutscene = GetObjectByTag("cutscene_trigger_tag "); //cutscene – our object name
PlayCutscene("cutscene_name","",TRUE);
EnableTrigger(cutscene, FALSE);
}
How to create flammable/quenchable objects using igni/aard ?[]
#include "inc_ai" // we must use script "on spell cast at" at placeble scripts // light up/quench fire with Aard and Igni. // (by M "TnZ" K) // ======================================================================================================== // lights distance around the object which we “kill” float xDist = 10.0f; // tag objects with lights string xTag = "ob_light"; // ======================================================================================================== void PlaceCampfireMappinOnMap(object oCampfire) { // insert campfire mappin on map if (GetLocalInt(oCampfire, "HasMarker")!=1 && GetDistanceBetween(GetFirstPC(), oCampfire)<10.0) { location lCampfire = GetLocation(oCampfire); CreateObject(OBJECT_TYPE_WAYPOINT, "wp_campfire", lCampfire, FALSE, "wp_campfire"); SetLocalInt(oCampfire, "HasMarker", 1); } } //================================================================== void FireOn(object oCampfire) { // all nearest light sources ON object nLight = GetNearestObjectByTag(xTag, oCampfire, 0); int j = 0; while (nLight != OBJECT_INVALID) { j++; nLight = GetNearestObjectByTag(xTag, oCampfire, j); float iDist2 = GetDistanceBetween(nLight, oCampfire); if (iDist2 < xDist && GetArea(OBJECT_SELF)==GetArea(nLight)) { // turn the light on near this source DClearAllActions(FALSE, nLight); ChangePlaceableEffectPhase(nLight, "Cast"); } } // change placeble animation to ACTIVATE DClearAllActions(FALSE, oCampfire); AssignCommand(oCampfire, ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE, 1.0, 10000.0)); ChangePlaceableEffectPhase(oCampfire, "Cast"); DeleteLocalInt(oCampfire, "iRainOff"); } // ======================================================================================================== void FireOff(object oCampfire) { // all nearest light sources OFF object nLight = GetNearestObjectByTag(xTag, oCampfire, 0); int j = 0; while (nLight != OBJECT_INVALID) { j++; nLight = GetNearestObjectByTag(xTag, oCampfire, j); float iDist2 = GetDistanceBetween(nLight, oCampfire); if (iDist2 < xDist) { // turn the ligh off (near this source) DClearAllActions(FALSE, nLight); ChangePlaceableEffectPhase(nLight, "FadeOut"); } } // change placeble animation to DEACTIVATE DClearAllActions(FALSE, oCampfire); AssignCommand(oCampfire, ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE, 1.0, 1000.0)); ChangePlaceableEffectPhase(oCampfire, "FadeOut"); SetLocalInt(oCampfire, "iRainOff", 1); } // ========================================================================================================== // [ ] // [ SpellCastAt campfires/torches/another_light_sources ] // [ ] // ========================================================================================================== void main() { int nSpellId = GetLastSpell(); if(nSpellId >= 0 && nSpellId <= 9 ) // aard extinguish campfire { FireOff(OBJECT_SELF); } if(nSpellId >= 30 && nSpellId <= 39 ) // igni makes a fire { FireOn(OBJECT_SELF); } }
How to make an object give out puffs of smoke after casting Igni on it?[]
#include "inc_ai" // script must be "on spell cast at" in placeable scripts // object starts smoke after casting igni on it (by tnz) void main() { int nSpellId = GetLastSpell(); if(nSpellId >= 30 && nSpellId <= 39 ) // igni { location lLoc = GetLocation(OBJECT_SELF); CreateVisualEffectAtLocation("fx_fume01", lLoc); } }
Show placeable description after clicking on it.[]
// at „OnUsed” placeable scripts
#include "inc_gui"
void main()
{
ShowObjectDescription(OBJECT_SELF);
}