Is there a quicker function that checks if a certain variable is inside a numeral range, for example to check if a player's combat skill is between 30 and 60?
Is there a quicker function that checks if a certain variable is inside a numeral range, for example to check if a player's combat skill is between 30 and 60?
I don't think there is a much "quicker" way than this (separate if-conditions).
Code:
if (x > 30) {
if (x < 60) {
return TRUE;
};
};
return FALSE;
I'd assume that quick refers to "quick to type", because the difference in speed will most likely be negligible.
Anyway, I don't think there's a shortcut, but that sounds like a great addition to the scriptbin.
// Call this
List_ForFS(MEM_World.voblist, addConditionFuncToChests);
func void addConditionFuncToChests(var int node) {
var zCListSort list; list = _^(node);
var int ptr; ptr = list.data; // Ikarus says this is of type zCVob but that's just a typo
if (Hlp_Is_oCMobContainer(ptr)) {
var oCMobContainer chest; chest = _^(ptr);
chest._oCMobInter_conditionFunc = "MYCONDITIONFUNC"; // You probably need to use all caps
};
};
Edit: If you can't use lego you'll have to loop through the list by yourself, but that isn't hard.
You can check chest._oCMobInter_useWithItem for the useWithItem-attribute and chest._oCMobLockable_keyInstance for a required key that will still allow lockpicking (both are strings).
You can check chest._oCMobInter_useWithItem for the useWithItem-attribute and chest._oCMobLockable_keyInstance for a required key that will still allow lockpicking (both are strings).
I have a little problem with EventManager script. Code:
Code:
func void QS_DrawSpell()
{
const int oCMsgWeapon__sizeof = 80;
const int oCMsgWeapon__oCMsgWeapon = 7759824;
const int zCEventManager__OnMessage = 6283728;
var int oCMsgWeaponPtr; oCMsgWeaponPtr = MEM_Alloc(oCMsgWeapon__sizeof);
CALL_PtrParam(0);
CALL_PtrParam(7);
CALL_PtrParam(0);
CALL__thiscall(oCMsgWeaponPtr, oCMsgWeapon__oCMsgWeapon);
var int EM; EM = MEMINT_VobGetEM(_@(hero));
if(EM)
{
CALL_PtrParam(_@(hero));
CALL_PtrParam(oCMsgWeaponPtr);
CALL__thiscall(EM, zCEventManager__OnMessage);
Print("DZIAŁAJ!");
};
MEM_Free(oCMsgWeaponPtr);
Script don't have crash, but don't work. I don't know where i made a mistake (I first time use MEM_Alloc) sizeof is good, i have print, but hero don't draw rune (AI_ReadySpell is for QuickBar). And my question - where i made a mistake? In C++ code work!
I want to add the name of quest when first time activated,
I'm not sure what you are asking for.
If you want to display the name of a quest when B_LogEntry is called you could change it like this.
Code:
func void B_LogEntry_Detailed (var string topic, var string entry)
{
Log_AddEntry(topic, entry);
var string text;
text = ConcatStrings (PRINT_NewLogEntry, ": ");
text = ConcatStrings (text, topic);
PrintScreen(text, -1, YPOS_LOGENTRY, FONT_ScreenSmall, 2);
Snd_Play("LogEntry");
};
If you want to have different Log Entries depending on how the Quest was started you could try something like this:
Spoiler:(zum lesen bitte Text markieren)
Code:
var int MIS_FindQuestItem;
var int useAlternateTitleForFindQuestItemQuest;
const string TOPIC_FindQuestItem = "Retrieve quest item for Friendly Guy";
const string TOPIC_FindQuestItem_Alternate = "Quest item found on Bandits";
func void findQuestItem(){
if(MIS_FindQuestItem == LOG_RUNNING){ // Player already talked to Friendly Guy
B_LogEntry_Detailed (TOPIC_FindQuestItem, "I found his quest item.");
}else{
useAlternateTitleForFindQuestItemQuest = true;
Log_CreateTopic (TOPIC_FindQuestItem_Alternate, LOG_MISSION);
Log_SetTopicStatus(TOPIC_FindQuestItem_Alternate, LOG_RUNNING);
B_LogEntry_Detailed (TOPIC_FindQuestItem_Alternate, "I found a strange quest item on some bandits. I wonder who was the original owner?");
};
CreateInvItems (hero, ItMi_QuestItem, 1);
};
INSTANCE DIA_None_123_FriendlyGuy_StartQuestDia (C_Info)
{
npc = None_123_FriendlyGuy;
nr = 2;
condition = DIA_None_123_FriendlyGuy_StartQuestDia_condition;
information = DIA_None_123_FriendlyGuy_StartQuestDia_info;
permanent = FALSE;
important = FALSE;
description = "Can I help you?";
};
FUNC INT DIA_None_123_FriendlyGuy_StartQuestDia_condition (){
return TRUE;
};
FUNC VOID DIA_None_123_FriendlyGuy_StartQuestDia_info ()
{
AI_Output(other, self, "DIA_None_123_FriendlyGuy_StartQuestDia_15_0"); //Can i help you?
AI_Output(self, other, "DIA_None_123_FriendlyGuy_StartQuestDia_15_1"); //Yes! Recover my lost quest item for me.
AI_Output(self, other, "DIA_None_123_FriendlyGuy_StartQuestDia_15_2"); //Bandits took it and they are hiding in a cave north of here.
MIS_FindQuestItem = LOG_RUNNING;
if(!useAlternateTitleForFindQuestItemQuest){ // Player did not find quest item first
Log_CreateTopic (TOPIC_FindQuestItem, LOG_MISSION);
Log_SetTopicStatus(TOPIC_FindQuestItem, LOG_RUNNING);
B_LogEntry_Detailed (TOPIC_FindQuestItem, "Friendly Guys quest item was stolen by some bandits. He sent me to recover it.");
}else{
B_LogEntry_Detailed (TOPIC_FindQuestItem_Alternate,"Turns out that quest item belongs to Friendly Guy. Some bandits stole it from him. He wants to have it back.");
};
};
INSTANCE DIA_None_123_FriendlyGuy_FinishQuestDia (C_Info)
{
npc = None_123_FriendlyGuy;
nr = 2;
condition = DIA_None_123_FriendlyGuy_FinishQuestDia_condition;
information = DIA_None_123_FriendlyGuy_FinishQuestDia_info;
permanent = FALSE;
important = FALSE;
description = "Here is your quest item.";
};
FUNC INT DIA_None_123_FriendlyGuy_FinishQuestDia_condition (){
if(MIS_FindQuestItem == LOG_RUNNING){
if(Npc_HasItems(hero, ItMi_QuestItem) > 0){
return TRUE;
};
};
};
FUNC VOID DIA_None_123_FriendlyGuy_FinishQuestDia_info ()
{
AI_Output(other, self, "DIA_None_123_FriendlyGuy_FinishQuestDia_15_0"); //Here is your quest item.
B_GiveInvItems(other, self, ItMi_QuestItem, 1);
AI_Output(self, other, "DIA_None_123_FriendlyGuy_FinishQuestDia_15_1"); //Thank you!
if(!useAlternateTitleForFindQuestItemQuest){ // Player did not find FindQuestItem first
B_LogEntry_Detailed (TOPIC_FindQuestItem, "Friendly Guy thanked me for returning his quest item.");
Log_SetTopicStatus(TOPIC_FindQuestItem, LOG_SUCCESS);
}else{
B_LogEntry_Detailed (TOPIC_FindQuestItem_Alternate, "Friendly Guy thanked me for returning his quest item.");
Log_SetTopicStatus(TOPIC_FindQuestItem_Alternate, LOG_SUCCESS);
};
MIS_FindQuestItem = LOG_SUCCESS;
};