Author Topic: [How To] Triggers: Trigger dialogue, attack, doors, radiation...  (Read 3394 times)

[How To] Triggers: Trigger dialogue, attack, doors, radiation...
« on: November 20, 2012, 10:28:29 pm »
With this script you can trigger dialogue by stepping on a teleport!
Useful for quests and general atmosphere, as the player will not be able to just run around without talking to npcs/starting combat with npc etc.
Trigger dialogue with npc by teleport:
Code: [Select]

#include "replication_bank.fos"
import bool DialogNpc( Critter& player, int role ) from "stdlib";
#define ROLE_MAN ( 4 ) 

//add script in mapper on npc
void _ManInit( Critter& man, bool firstTime )
{
    man.StatBase[ ST_NPC_ROLE ] = ROLE_MAN;
}


//add script in mapper on teleport
void t_Teleport( Critter& player, Scenery& trigger, bool entered, uint8 dir )
{
    if( not entered )
        return;
   
    if( !player.IsPlayer() )
        return;

   Map@ map = player.GetMap();
   if( !valid( map ) )
        return;

Critter @ man = map.GetNpc( ROLE_MAN, FIND_LIFE | FIND_ONLY_NPC, 0 );
        if( valid( man ) )
        {
            DialogNpc( player, ROLE_MAN); //trigger dialog from stdlib
        }
}
}

« Last Edit: December 30, 2012, 04:11:53 am by muhoooool »

Re: Triggers? How to script triggered dialogue ?
« Reply #1 on: November 29, 2012, 05:13:00 pm »
use this code to make npc shout:
Code: [Select]
#define STR_M ( 6000 )  // number in text file
man.SayMsg( SAY_SHOUT_ON_HEAD, TEXTMSG_TEXT, STR_M );
instead of previous:
Quote
Code: [Select]
DialogNpc( player, ROLE_MAN); //trigger dialog from stdlib
« Last Edit: December 23, 2012, 01:48:20 am by muhoooool »

Re: [How To] Triggers: Trigger dialogue and more.
« Reply #2 on: December 23, 2012, 01:51:11 am »
to trigger attack:
Code: [Select]
AddAttackPlane( man, 0, player );instead of previous/ combined with shout
« Last Edit: December 23, 2012, 01:52:47 am by muhoooool »

Re: [How To] Triggers: Trigger dialogue and more.
« Reply #3 on: December 23, 2012, 02:03:44 am »
Change a game variable:
Code: [Select]
GameVar@ var = GetLocalVar( LVAR_your_var, player.Id );
    if( entered && player.IsPlayer() )
        {
           
            if( valid( var ) && var == 0 )
{                                   // previous code goes here
        var = 1;}
This is useful when you need something to repeat only once (where you add code), or to change variables for quest purposes - such as exploration/making sure a player visited a location.

Re: [How To] Triggers: Trigger dialogue and more.
« Reply #4 on: December 23, 2012, 08:04:45 pm »
Radiation:
Code: [Select]
import void AffectRadiation( Critter& cr, int value ) from "radiation";
AffectRadiation( player, value); // change strenght by adding AffectRadiation( player, value / 2);

Re: [How To] Triggers: Trigger dialogue and more.
« Reply #5 on: December 23, 2012, 08:12:21 pm »
Door open:
Code: [Select]
import void door_open( Critter& player, Scenery& trigger, bool entered, uint8 dir, int entireNum ) from "trigger";
door_open( player, trigger, entered, dir, param );
Add entire Fast ( entry point) under the door you want to open with trigger.
change in mapper:
on entire:
entirenumber:100*
on trigger:
ParamsCount: 1
Parameter0: 100*
Script: your_script
func: t_Teleport

*Numbers need to match
« Last Edit: December 23, 2012, 08:16:44 pm by muhoooool »