View Single Post
  #4  
Old 05-16-2010, 11:57 AM
R@S R@S is offline
Approved Member
 
Join Date: Apr 2009
Posts: 560
Default

How to script a mission:

The most important thing to remember is to never alter the original source files. If you need to change something in those files you have to use a Replace Function. There is one exception, the e6q.a file where you activate your mod. At the end of that file, just above the initial part you need to add your mod. Like this:

Quote:
Originally Posted by Code
#include "MOD\Temp_mod.a"
Then in your newly created folder called MOD you create the file(Temp_mod.a) that controls which other files that are to be included in your mod.

Another thing to keep in mind is to have an empty line at the end of every file. If you don't you'll get a bunch of weird error messages when compiling it.

// ************************************************** ***********************
// Temp_mod (Temp_mod.a)
// ************************************************** ***********************
Quote:
Originally Posted by Temp_mod.a
MOD "Temp_mod" Version "01"

#include "MOD\TemplateQuest.a" // a quest
#include "MOD\QuestGiver.a" // a character

INITIAL
//Test by adding a hummer at the start of the game
call AddCar("Hummer")
END INITIAL

ERROR
ModUpdateList Add Next "0"
END ERROR

END MOD

// ************************************************** ***********************
// Creating a quest in the source code (TemplateQuest.a)
// ************************************************** ***********************
Quote:
Originally Posted by TemplateQuest.a
ROOM TemplateQuestRoom // *** Marks the beginning of the TemplateQuest Room *** \\
def object TemplateQuest
begin // *** Marks the beginning of the TemplateQuest object *** \\

Attribute State = qAvailable

phrase TakeQuest()
this.State = qGiven
call PrintToJournal(this, "TemplateQuest Taken. ")
end phrase

phrase GoalReached()
if (this.State==qGiven)
this.State = qGoalReached
call PrintToJournal(this, "TemplateQuest Goal Reached. ")
end if
end phrase

phrase CompleteQuest()
this.State = qCompleted
if (this.State==qCompleted)
call PrintToJournal(this, "Missions complete. ")
end if
Player.AddMoney(5000)
Player.ChangeReputation(5-10)
Player.ChangeProfessionalship(10)
throw "Finish Template"
end phrase

phrase GoalFailed()
if (this.State==qGiven)
this.State = qGoalFailed
call PrintToJournal(this, "TemplateQuest Goal Failed. ")
end if
end phrase

phrase FailQuest()
this.State = qFailed
if (this.State==qFailed)
this.State = qFailed
call PrintToJournal(this, "Mission failed.")
end if
throw "Finish Template"
end phrase
// ************************************************** **************
// For QuestGiver // This is where the character dialog jumps in
// when called from the character object
// ************************************************** **************
Quote:
Originally Posted by TemplateQuest.a
phrase CompletedFor_QuestGiver()
if (this.State in [qGoalReached, qGoalFailed])
return Yes
else
return No
end if
end phrase

phrase PrintCompletedUserChoices_QuestGiver(StartPos)
if (this.State==qGoalReached)
print("Tells about quest when it's finished and waiting for reward ")
userch("Sweet. ", 5)
end if
if (this.State==qGoalFailed)
print("Tells about quest when it's failed ")
userch("Drat.", 7)
end if

switch (askch)
when 5:
TemplateQuestRoom.QuestGiver_D1_3()
when 7:
TemplateQuest.QuestGiver_D1_4()
end switch
end phrase

phrase RelatedTo_QuestGiver()
if (this.State in [qAvailable, qGiven])
return Yes
else
return No
end if
end phrase

phrase PrintRelatedUserChoices_QuestGiver(StartFrom)
if (this.State==qAvailable)
print("Tells about quest before it's taken ")
userch("Sounds fun.", 3)
end if
if (this.State==qGiven)
print("Tells about quest when it's taken ")
userch("Forgot.", 4)
end if

switch (askch)
when 3:
TemplateQuestRoom.QuestGiver_D1_1()
when 4:
TemplateQuestRoom.QuestGiver_D1_2()
end switch
end phrase
// ************************************************** ***********************
// The initial part where you set up the characters involved and quest name
// ************************************************** ***********************
Quote:
Originally Posted by TemplateQuest.a
initial
TemplateQuest.inherit StdQuest
TemplateQuest.RegisterMe("TemplateQuest Name")
QuestGiver.AddQuest(TemplateQuest, NULL)
end initial

end // *** Marks the end of the TemplateQuest object *** \\
// ************************************************** ***********************
// Dialogs for QuestGiver NOTE: they are outside the TemplateQuest
// object but inside the TemplateQuest room
// ************************************************** ***********************
Quote:
Originally Posted by TemplateQuest.a
phrase QuestGiver_D1_1()
print("Tells about quest.")
userch("Player accepts quest. (end conversation).", ucOK)

if (askch==ucOK)
TemplateQuest.TakeQuest()
stop chat imm
end if
end phrase

phrase QuestGiver_D1_2()
print("Reminds what needs doing.")
userch("D'oh. (end conversation).", ucOK)

if (askch==ucOK)
stop chat imm
end if
end phrase

phrase QuestGiver_D1_3()
print("Says attaboy and gives reward.")
userch("Thx. (end conversation).", ucOK)

if (askch==ucOK)
TemplateQuest.CompleteQuest()
stop chat imm
end if
end phrase

phrase QuestGiver_D1_4()
print("Falure dialog.")
userch("Sorry. (end conversation).", ucOK)

if (askch==ucOK)
TemplateQuest.FailQuest()
stop chat imm
end if
end phrase

end ROOM // *** Marks the end of the TemplateQuest Room *** \\

// ************************************************** ***********************
// Creating a character in the source code (QuestGiver.a)
// ************************************************** ***********************
Quote:
Originally Posted by QuestGiver.a
def object QuestGiver
begin

List Attribute Quests
List Attribute QuestRelations
List Attribute MyFriends
List Attribute MyEnemies

phrase PrintGreetings()
call PrintToJournal(QuestGiver, "Here you can have a short description and bio of the character that will show up in the population tab. ")
print("Yes? ")
end phrase

phrase PrintJustTalkUC()
if(TemplateQuestRoom.TemplateQuest.State in [qAvailable, qGiven]) then userch("Let's talk about new quest.", 1)
if(TemplateQuestRoom.TemplateQuest.State in [qGoalReached, qGoalFailed]) then userch("Let's talk about active quest.", 1)
userch("Never mind. (end conversation)", ucStopChat)

switch (askch)
when 1:
callm TemplateQuestRoom.TemplateQuest.PrintRelatedUserCh oices_QuestGiver()
when 2:
callm TemplateQuestRoom.TemplateQuest.PrintRelatedUserCh oices_QuestGiver()
when ucStopChat:
stop chat imm
end switch
end phrase

initial
QuestGiver.inherit StdSubject
QuestGiver.RegisterMe("QuestGiver.ini") // Remember to create the INI file for the character
end initial
end

ROOM QuestGiverRoom
conv Main check (call CombatMode() == No)
QuestGiver.MainConv()
end conv
END ROOM
// ************************************************** ***********************
// A small example of Patrol phrases
// ************************************************** ***********************
Quote:
Originally Posted by Code
phrase Patrols()
QuestGiver.RegisterMe("QuestGiver.ini")
QuestGiver.BecomeNeutral(Player)
QuestGiver.MySector = LasVacasiones
QuestGiver.LocationInSector = "Patrol P2"

on event "Sector loading finished "+str(LasVacasiones.Name) callm this.PPoint_1()
delete when "Finish Example01"
end phrase

phrase PPoint_1()
QuestGiver.ForceSetLocation("Patrol P1")

on event str(QuestGiver.ININame)+" reached " + "Patrol P1" callm this.PPoint_2()
delete when "Finish Example01"
end phrase

phrase PPoint_2()
QuestGiver.ForceSetLocation("Patrol P2")

on event str(QuestGiver.ININame)+" reached " + "Patrol P2" callm this.PPoint_1()
delete when "Finish Example01"
end phrase
// ************************************************** ***********************
// A Selection of Uselful User Functions
// ************************************************** ***********************
Quote:
Originally Posted by Code
Player.AddMoney(5000)
Player.DecMoney(5000)

Player.DelItem(Stuff)
Player.AddItem(Stuff)

Player.AddToTeam(Guy)
Player.DelFromTeam(Guy)

Player.Say("Hello!")
Guy.Say("Hello!")

Guy.RegisterMe("Guy.ini")
Guy.BecomeNeutral(Player)
Guy.MySector = Artrigo01
Guy.LocationInSector = "Some Place"

Guy.ForceSetLocation("Some Other Place")

if (callm Player.HasItem(Stuff)==Yes)
userch("Ok. ", ucOK)
end if

if (callm Player.HasInTeam(Guy)==Yes)
userch("Ok. ", ucOK)
end if

if (callm Player.CanAddTeamMember()==Yes)
userch("Come with me. (joins team)", ucOK)
end if

if (callm Player.GetMoney()>=1000)
Player.DecMoney(1000)
end if

if (callm Player.HasWeaponInHands()==Yes)

if (callm Guy.CanSee(OtherGuy)==Yes)

if (EventParmStr==SpecialItem)

call SetTalkingWithInCode(Guy.ININame)

call MakeExplosion("MinePlace", TNT)

call SetDisplayImage("bmp\\Quest\\Pic.jpg")
call ClearDisplayImage()

on event TIMER1+5 callm this.StartAttack()
delete when "Finish TemplateQuest"

on event "Guy reached " + "SomePlace" callm TemplateQuest.GotThere()
delete when "Finish TemplateQuest"

on event "Killed finally "+str(Guy.ININame) callm this.HimDead()
delete when "Finish TemplateQuest"

on event "Sector loading finished "+str(Artrigo.Name) TemplateQuest.SetUpMap()
delete when "Finish TemplateQuest"

Last edited by R@S; 05-16-2010 at 12:02 PM.
Reply With Quote