FOnline Development > General Discussion
[How To] Triggers: Trigger dialogue, attack, doors, radiation...
muhoooool:
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: ---
#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
}
}
}
--- End code ---
muhoooool:
use this code to make npc shout:
--- Code: ---#define STR_M ( 6000 ) // number in text file
man.SayMsg( SAY_SHOUT_ON_HEAD, TEXTMSG_TEXT, STR_M );
--- End code ---
instead of previous:
--- Quote ---
--- Code: ---DialogNpc( player, ROLE_MAN); //trigger dialog from stdlib
--- End code ---
--- End quote ---
muhoooool:
to trigger attack:
--- Code: ---AddAttackPlane( man, 0, player );
--- End code ---
instead of previous/ combined with shout
muhoooool:
Change a game variable:
--- Code: ---GameVar@ var = GetLocalVar( LVAR_your_var, player.Id );
if( entered && player.IsPlayer() )
{
if( valid( var ) && var == 0 )
{ // previous code goes here
var = 1;}
--- End code ---
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.
muhoooool:
Radiation:
--- Code: ---import void AffectRadiation( Critter& cr, int value ) from "radiation";
AffectRadiation( player, value); // change strenght by adding AffectRadiation( player, value / 2);
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version