lfnetwork.com mark read register faq members calendar

Thread: Frequently used script functions
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 01-25-2005, 01:18 PM   #1
tk102
Well past expiration date
 
tk102's Avatar
 
Join Date: Jan 2004
Posts: 5,766
Current Game: Dragon Age: Origins
Forum Veteran Helpful! Notable contributor 
Frequently used script functions

How can I make a creature do something?
Code:
// the some_action is a function that  usually starts with "Action"
AssignCommand(oCreature,some_action)
How can I make something happen after awhile?
Code:
fDelayInSeconds=2.0;
DelayCommand(fDelayInSeconds,some_action);
How can I script an object into a container?
Code:
object oItem=CreateItemOnObject( "item_template", GetObjectByTag("container_tag"));
How can I script an object into my Inventory?
Code:
object oItem=CreateItemOnObject( "item_template", GetFirstPC());
How can I equip an item by scripting once I have it in my inventory?
Code:
AssignCommand(GetFirstPC(), ActionEquipItem(oItem, nInventorySlot);
How can I spawn an object at a a specific location?
Code:
/* Possible Object types:
OBJECT_TYPE_CREATURE 
OBJECT_TYPE_ITEM          
OBJECT_TYPE_TRIGGER    
OBJECT_TYPE_DOOR        
OBJECT_TYPE_WAYPOINT 
OBJECT_TYPE_PLACEABLE
OBJECT_TYPE_STORE  */

// for the 3 floats in the function below
// you can use the X, Y, Z coordintates from
// the whereami cheat code
vector vPosition=Vector(0.0, 0.0, 0.0);

 location lWhereToSpawn=Location(vPosition,0.0);

CreateObject( OBJECT_TYPE_CREATURE,
"object_template",lWhereToSpawn);
How can I create an object right next to me?
Code:
// same OBJECT_TYPEs as above

CreateObject( OBJECT_TYPE_CREATURE,
"object_template", GetLocation(GetFirstPC()));
How can I give myself credits?
Code:
GiveGoldToCreature( GetFirstPC(),nAmount);
How can I take credits away from myself?
Code:
TakeGoldFromCreature(nAmount, GetFirstPC());
How can I give myself Light Side or Dark Side points?
Code:
/* Alignments:
ALIGNMENT_DARK_SIDE
ALIGNMENT_LIGHT_SIDE
ALIGNMENT_NEUTRAL */
AdjustAlignment( GetFirstPC(),ALIGNMENT_DARK_SIDE,nAmount);
How can I give myself experience points?
Code:
 // you guessed it...
 GiveXPToCreature(GetFirstPC(),nAmount);
How can I multiclass a character into a Jedi?
Code:
/*possible classes:
    CLASS_TYPE_SOLDIER
    CLASS_TYPE_SCOUT
    CLASS_TYPE_SCOUNDREL     
    CLASS_TYPE_JEDIGUARDIAN 
    CLASS_TYPE_JEDICONSULAR
    CLASS_TYPE_JEDISENTINEL 
    CLASS_TYPE_COMBATDROID
    CLASS_TYPE_EXPERTDROID
    CLASS_TYPE_MINION */

AddMultiClass( CLASS_TYPE_JEDIGUARDIAN, GetObjectByTag("Mission"));
How can I start a basic conversation?
Code:
void main() {
ActionStartConversation(GetFirstPC(),"dlg_filenamehere");
}
Canderis Edit:
If the above code does not work try defining the npc who will be talking:
Code:
void main()
{
  object oNPC=GetObjectByTag("npc_tag");
  AssignCommand ((oNPC), ActionStartConversation(GetFirstPC(),"npc_tag"));

}
How can I make an NPC walk up to me and start a conversation?
Code:
void main() {
  object oNPC=GetObjectByTag("npc_tag");
  location lMe=GetLocation(GetFirstPC());
    ActionDoCommand(SetCommandable(TRUE,oNPC));
  AssignCommand (oNPC,ActionForceMoveToLocation(lMe,FALSE));
  AssignCommand (oNPC, ActionStartConversation(GetFirstPC()));
}
===============================
Kotor 2: TSL only - new practical functions:

* those functions can help you avoid .utc file conflicts that will crash the game or prevent plot advancement as explained in this thread

Give a new feat to a creature:
Code:
// DJS-OEI 1/13/2004
// 786: Grants the target a feat without regard for prerequisites.
void GrantFeat( int nFeat, object oCreature );
Give a new Force power to a Creature:

Code:
// DJS-OEI 1/13/2004
// 787: Grants the target a spell without regard for prerequisites.
void GrantSpell( int nSpell, object oCreature );
Change the appearance of a creature:
Code:
// 850
// ChangeObjectAppearance
// oObjectToChange = Object to change appearance of
// nAppearance = appearance to change to (from appearance.2da)
void ChangeObjectAppearance( object oObjectToChange, int nAppearance );
Adjust attributes:
Code:
 
// 833
// AWD-OEI 7/06/2004
// This function adjusts a creatures stats.
// oObject is the creature that will have it's attribute adjusted
// The following constants are acceptable for the nAttribute parameter:
// ABILITY_STRENGTH
// ABILITY_DEXTERITY
// ABILITY_CONSTITUTION
// ABILITY_INTELLIGENCE
// ABILITY_WISDOM
// ABILITY_CHARISMA
// nAmount is the integer vlaue to adjust the stat by (negative values will work).
void AdjustCreatureAttributes(object oObject, int nAttribute, int nAmount);
Adjust skills:
Code:
// 869
// DJS-OEI 10/9/2004
// This function adjusts a creature's skills.
// oObject is the creature that will have its skill adjusted
// The following constants are acceptable for the nSkill parameter:
// SKILL_COMPUTER_USE
// SKILL_DEMOLITIONS
// SKILL_STEALTH
// SKILL_AWARENESS
// SKILL_PERSUADE
// SKILL_REPAIR
// SKILL_SECURITY
// SKILL_TREAT_INJURY
// nAmount is the integer value to adjust the stat by (negative values will work).
void AdjustCreatureSkills(object oObject, int nSkill, int nAmount);

Last edited by Canderis; 06-28-2013 at 03:25 PM. Reason: Added an alternate code
tk102 is offline   you may: quote & reply,
Old 01-26-2005, 09:02 AM   #2
Darth333
Administraterror
 
Darth333's Avatar
 
Status: Administrator
Join Date: Feb 2004
Location: In my secret dungeon...
Posts: 8,292
Re: Frequently used scripts

Quote:
Originally posted by tk102
How can I give myself Light Side or Dark Side points?
Code:
/* Alignments:
ALIGNMENT_DARK_SIDE
ALIGNMENT_LIGHT_SIDE
ALIGNMENT_NEUTRAL */
AdjustAlignment( GetFirstPC(),ALIGNMENT_DARK_SIDE,nAmount);
Here is a shortcut to give DS or LS points - jst refer to these scripts in the .dlg file

KotOR
*- for ds points:

k_act_darksml
k_act_darkmed
k_act_darkhigh

*- for ls points:
k_act_lightghigh
k_act_lightmed
k_act_lightsml

TSL
*- for ds points:
a_darkhigh
a_darkmed
a_darksml

*- for ls points:
a_lighthigh
a_lightmed
a_lightsml

the TSL scripts got nuked when the server "burped" - ChAiNz.2da

Last edited by Darth InSidious; 08-02-2009 at 02:30 PM. Reason: Removed size tags around the code box.
Darth333 is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Tutorials: Scripting > Frequently used script functions

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:37 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.