|
-
Zitat von Rayzer
Try this instead MEM_InstToPtr:
Code:
var oCNpc npc; npc = Hlp_GetNpc(slf);
CALL__thiscall(_@(npc.state_vtbl), 7788672);
That works perfect, many thanks!
-
Focusnames
Hello. Tell me how best to change the color of the attacker on the NPS hero. Using Npc_IsInState is fine, but the situation is different (this is my fault). The other NPC is attacked by another NPS and they both have a red color. I do not know how to do it correctly, so that only the NPS, who attack only the hero, have red color.
Code:
func void _Focusnames()
{
var int col;
col = -1; // Stupid pseudo-locals
var oCNpc her;
her = Hlp_GetNpc(hero);
if(Hlp_Is_oCNpc(her.focus_vob))
{
var c_npc oth;
oth = MEM_PtrToInst(her.focus_vob);
var int att;
att = Npc_GetPermAttitude(hero, oth);
/*if(att == ATT_FRIENDLY)
{
col = Focusnames_Color_Friendly();
}
else if(att == ATT_NEUTRAL)
{
col = Focusnames_Color_Neutral();
}
else if(att == ATT_ANGRY)
{
col = Focusnames_Color_Angry();
}
else if(att == ATT_HOSTILE)
{
col = Focusnames_Color_Hostile();
};*/
//new
if(att == ATT_HOSTILE)
{
col = Focusnames_Color_Hostile();
};
//if(Npc_IsInState(oth,ZS_Attack))
//if(B_Attack(oth, hero, AR_NONE, 0))
if(Npc_GetTarget(hero) && Npc_IsInState(oth,ZS_Attack))
{
col = Focusnames_Color_Hostile();
};
//end
}
****
-
most of the code is in comments? You most likely need to reset the variable "col" when the attitude is not hostile, e.g. using else after the other conditions.
You might also want to consider Npc_GetTempAttitude
-
Zitat von Milky-Way
most of the code is in comments? You most likely need to reset the variable "col" when the attitude is not hostile, e.g. using else after the other conditions.
You might also want to consider Npc_GetTempAttitude
The colour already gets reset to white (-1) at the beginning of the function - that was a bug with the original script and was fixed in LeGo a while ago. I agree, though - the amount of commented code makes it hard to read the code (syntax highlighting in an editor helps, of course).
I don't think it's a problem with the attitude detection, let's look at the corresponding codeblock:
Code:
if(Npc_GetTarget(hero) && Npc_IsInState(oth,ZS_Attack))
{
col = Focusnames_Color_Hostile();
};
The second part - the state check - is fine, of course. The block will only consider NPCs (i.e. focusnames) that are currently attacking/in ZS_Attack. The first part, though, is probably where the bug comes from. It simply checks if the hero has a target, which is a rather redundant check, because a change to the focusname color is only meaningful if there is in fact a target (which gets checked at the beginning anyway). What you probably want is something akin to this:
Code:
if (oth.focus_vob == _@(hero)) && ...
// Note that 'oth' would need to be of type oCNpc in this case, not C_Npc
I.e. you check if 'oth' is currently focusing on the hero. Of course, this isn't perfect either - the NPC might not be looking directly at the hero at the moment (e.g. his focus might be empty), which would cause the color to remain white. A look into ZS_Attack() shows us how to properly detect the current target of an NPC (at least the way Gothic is doing it):
Code:
Npc_GetTarget (self); // other = target
So maybe what you ultimately want is like this:
Code:
Npc_GetTarget(oth);
if (_@(other) == _@(hero)) && Npc_IsInState(...)
-
Zitat von Lehona
Code:
Npc_GetTarget(oth);
if (_@(other) == _@(hero)) && Npc_IsInState(...)
It did not occur to me to use the class pointer, thank you very much, now there will be more variety. And the code that is commented out is simply not needed, since made other colors for other situations.
-
Zitat von N1kX
And the code that is commented out is simply not needed, since made other colors for other situations.
Commented out code hurts readability (even more so when you're posting your code for others to review, e.g. here on this forum) and you should have saved prior versions (i.e. the versions that contain the now-commented code) in source control (git, svn) anyway, so you can always take a "look back in time".
That's just general advice though, only the Sith deal in absolutes
-
Was ist die empfohlene Funktion, um mit nicht mehr benötigten handles umzugehen? clear, release, delete?
Ich merke mir (manchmal) den Namen einer TA-Routine für Npc. Die wird dann mit PermMem als string gespeichert und in einer aivar des jeweiligen Npc verlinkt. Nach einer gewissen Zeit benutze ich diese TA-Routine dann noch mal und brauche sie danach nicht mehr (bzw. würde sie wieder neu speichern, falls ich sie noch mal bräuchte).
Jetzt könnte ich den gespeicherten string auf "" setzen und mein Code würde weiter funktionieren, weil ich den String dann als nicht vorhanden interpretiere (nutze ich als Default-Wert, wenn es noch kein handle gibt, siehe unten). Aber dann bleiben die handles dauerhaft erhalten, auch wenn ich sie nie wieder brauche für diesen Npc.
Eine Alternative wäre es daher, die handles nach Benutzung zu löschen und wieder neu zu erstellen, falls ich zukünftig noch mal ein handle für diesen Npc brauche. Doch zum Löschen von handles habe ich mehrere Funktionen gefunden. Welche wäre für meine Zwecke die richtige? Ich sehe zwar im LeGo-Code die Unterschiede, verstehe sie aber nicht wirklich.
Code:
func int STR_SaveStrOnHandle(var int sh, var string str) {
if (!Hlp_IsValidHandle(sh)){
sh = new(string@);
};
var _string s; s = get(sh);
s.s = str;
return sh;
};
func string STR_GetSavedStr(var int sh) {
if(!Hlp_IsValidHandle(sh)){
return "";
};
var _string s; s = get(sh);
return s.s;
};
//returns the current daily routine identifier e.g. "start" in rtn_start_1001
func string Npc_GetRoutineName(var c_npc npc){
var oCNpc _oCNpc; _oCNpc = Hlp_GetNpc(npc);
var int npcID; npcID = MEM_ReadInt(_@(_oCNpc)+608);
var zCPar_symbol symb; symb = _^(MEM_GetSymbolByIndex(npcID));
//find first underscore and remove it
var string rtnIdentifierName; rtnIdentifierName = symb.name;
var int underscore; underscore = STR_IndexOf(rtnIdentifierName, "_");
var int len; len = STR_Len (rtnIdentifierName);
if (underscore != -1){
rtnIdentifierName = STR_SubStr(rtnIdentifierName, underscore+1, len-underscore-1);
};
//find second underscore and remove it
underscore = STR_IndexOf(rtnIdentifierName, "_");
if (underscore != -1){
rtnIdentifierName = STR_SubStr(rtnIdentifierName, 0, underscore);
};
return rtnIdentifierName;
};
Meine Benutzung:
Code:
slf.aivar[AIV_RoutineHandle] = STR_SaveStrOnHandle(slf.aivar[AIV_RoutineHandle], Npc_GetRoutineName(slf));
...
if (!Hlp_StrCmp(STR_GetSavedStr(slf.aivar[AIV_RoutineHandle]), "")) {
Npc_ExchangeRoutine(slf, STR_GetSavedStr(slf.aivar[AIV_RoutineHandle]));
AI_ContinueRoutine (slf);
// reset: hierfür hätte ich gerne eine Alternative zum Löschen von handles
slf.aivar[AIV_RoutineHandle] = STR_SaveStrOnHandle(slf.aivar[AIV_RoutineHandle], "");
};
-
Das Gegenstück zu 'new' ist 'delete'.
Grundsätzlich:
'free' funktioniert mit Pointern anstatt Handles (damit kann man also kein Handle löschen).
'clear' löscht das Handle und den verwalteten Speicher.
'delete' ist genau wie 'clear', ruft aber noch den Destruktor auf. Da _string (was du vermutlich verwendest) keinen Destruktor hat, ist das äquivalent zu 'clear'.
Da könnte die Dokumentation aber definitiv noch verbessert werden, das ist sehr undurchsichtig.
-
-
Apprentice
hello!
I found a easier way to get function id.
It is very simple:
Code:
func void Function ()
{
Print ( "function");
};
func void main ()
{
const func id = Function;
MEM_CallByID (id); // const func is treated as const int, but takes a function
};
This can be useful when you call a lot of functions and need better code optimization.
You can also rewrite the MEM_CALLByID function for better optimization and do not create as many objects and act on pointers.
-
Zitat von bogu9821
hello!
I found a easier way to get function id.
It is very simple:
Code:
func void Function ()
{
Print ( "function");
};
func void main ()
{
const func id = Function;
MEM_CallByID (id); // const func is treated as const int, but takes a function
};
This can be useful when you call a lot of functions and need better code optimization.
You can also rewrite the MEM_CALLByID function for better optimization and do not create as many objects and act on pointers.
Nice idea. Unfortunately, I don't think this will work when the function is not known beforehand - which mostly is the idea of MEM_CallByID. In the case you describe the best "code optimization" would be just calling the function.
-
To elaborate on mud-freak's reply:
The case you posted works perfectly fine. But consider this rather nonsensical example:
Code:
func void Function ()
{
Print ( "function");
};
func void main ()
{
const func id = Function;
const func id2 = id;
MEM_CallByID (id2); // const func is treated as const int, but takes a function
};
Looks like it should work? I don't think so. CallbyID will see the id of 'main.id', which is not a function and thus cannot be executed. MEM_GetFuncID is able to resolve those symbolic links recursively until it finds a proper function ID.
-
Zitat von Lehona
[Bild: HonoredImpoliteBobcat-size_restricted.gif]
Ich denke ich muss das noch ein bisschen rescalen, so dass der Alphawert eher von 255 auf ~40 sinkt anstatt bis ganz 0, denn auf den letzten paar Metern ist das für den Spieler sowieso nicht mehr erkennbar.
Zitat von Bloodfly91
Mir ist noch etwas bei den Buffs aufgefallen. Sämtliche Buff-Texturen aktiver Buffs des Helden werden auch weiterhin angezeigt, wenn das Spiel pausiert ist oder wenn der Spieler sich in einem Dialog befindet. Da beim pausieren des Spiels und in Dialogen das HUD ausgeblendet wird, sollten mMn. auch die Buffs dann nicht mehr sichtbar sein.
Hallo,
gibt es hierzu eigentlich schon irgendwelche Neuigkeiten? Bis zum Release des großen Velen Content-Patches wird es höchstwahrscheinlich nicht mehr lange dauern und eigentlich sind keine weiteren Updates mehr für die Modifikation geplant, sollten dann keine Fehler mehr auftreten, was aber natürlich eher unwahrscheinlich ist.
Trotzdem würde ich sehr gerne noch dieses Feature mit einbauen, insofern das möglich ist.
Geändert von Bloodfly91 (20.06.2019 um 10:22 Uhr)
-
Gut, dass du mich nochmal darauf ansprichst, habe das Verstecken der Buffs jetzt implementiert. Ich glaube, dass du einfach die Buffs.d bei dir einfügen kannst (und die alte überschreiben), dann kannst du ja mal gucken, ob das deinen Vorstellungen entspricht. Falls da Änderungen drin sind, die in deiner LeGo-Version noch nicht verfügbar sind, musst du noch warten, dass ich die Tage 'n Release fertig mache
-
Hey, super! Danke!
Habe es sofort mal ausprobiert, allerdings sind scheinbar leider tatsächlich solche Änderungen vorhanden. Zumindest erhalte ich die Fehlermeldung, dass die Funktion "TAN" in der Zeile 199 undefiniert ist.
Zitat von Lehona
Gut, dass du mich nochmal darauf ansprichst, habe das Verstecken der Buffs jetzt implementiert. Ich glaube, dass du einfach die Buffs.d bei dir einfügen kannst (und die alte überschreiben), dann kannst du ja mal gucken, ob das deinen Vorstellungen entspricht. Falls da Änderungen drin sind, die in deiner LeGo-Version noch nicht verfügbar sind, musst du noch warten, dass ich die Tage 'n Release fertig mache
-
LeGo 2.6.0
- Buffs on the Hero now fade out visually over time. This behaviour can be deactivated in Userconst.d. It may impact performance.
- Buffs are now hidden when the player interface is hidden, e.g. in dialogs.
- Anim8 now uses the ingame timer, i.e. it's paused when a menu is open.
- Added functions to change the individual texture of bars (Thanks to KarolWojtasiuk)
- Added Q_Peek(queue), to peek at the next element of a queue
- Added some miscellaneous functions, trigonometry related
- Fixed an issue with FFs if they had their delay set to 0 and were using the ingame timer.
- Fixed 'oCNpc_RemoveFromSlot' for Gothic 1
- Fixed a crash in Render.d (Thanks to bogu9821)
-
Hello.
What is the best way to make the summon summoned of the same color, if attacked, then of a different color.
I did like this:
focusnames.d
Code:
if(oth.guild == GIL_SUMMONED_GOBBO_SKELETON)
{
col = Focusnames_Color_Friendly();
}
The guild check works well, but if you attack your summon, the color will hang, but I think that this is not critical. I thought so, but the garbage comes out:
Code:
Npc_GetTarget(oth);
if(oth.guild == GIL_SUMMONED_GOBBO_SKELETON)
{
col = Focusnames_Color_Friendly();
if((_@(other) == _@(hero)) && Npc_IsInState(oth,ZS_Attack))
{
col = Focusnames_Color_Hostile();
};
}
Geändert von N1kX (24.06.2019 um 19:43 Uhr)
-
Zitat von N1kX
What is the best way to make the summon summoned of the same color, if attacked, then of a different color.
I did like this:
focusnames.d
Code:
if(oth.guild == GIL_SUMMONED_GOBBO_SKELETON)
{
col = Focusnames_Color_Friendly();
}
The guild check works well, but if you attack your summon, the color will hang, but I think that this is not critical. I thought so, but the garbage comes out:
Code:
Npc_GetTarget(oth);
if(oth.guild == GIL_SUMMONED_GOBBO_SKELETON)
{
col = Focusnames_Color_Friendly();
if((_@(other) == _@(hero)) && Npc_IsInState(oth,ZS_Attack))
{
col = Focusnames_Color_Hostile();
};
}
You're using other instead of oth, for one.
“Da ist auch noch ein anderer Geruch in der Luft, der Geruch von Feuern, die in der Ferne brennen, mit einem Hauch Zimt darin - so riecht das Abenteuer!”
― aus Walter Moers' "Die 13 1/2 Leben des Käpt'n Blaubär"
-
Geändert von Bloodfly91 (24.06.2019 um 19:30 Uhr)
-
Zitat von N1kX
Hello.
What is the best way to make the summon summoned of the same color, if attacked, then of a different color.
I did like this:
focusnames.d
Code:
if(oth.guild == GIL_SUMMONED_GOBBO_SKELETON)
{
col = Focusnames_Color_Friendly();
}
The guild check works well, but if you attack your summon, the color will hang, but I think that this is not critical. I thought so, but the garbage comes out:
Code:
Npc_GetTarget(oth);
if(oth.guild == GIL_SUMMONED_GOBBO_SKELETON)
{
col = Focusnames_Color_Friendly();
if((_@(other) == _@(hero)) && Npc_IsInState(oth,ZS_Attack))
{
col = Focusnames_Color_Hostile();
};
}
@GiftGrün 'other' is filled with target of 'oth' - after calling Npc_GetTarget (oth) at the beginning of N1kX's code - so this should be okay
@N1kX I think that summoned NPCs (monsters) are never using ZS_Attack but ZS_MM_Attack instead so try something like this instead:
Code:
if(NPC_IsPlayer (other)) && (Npc_IsInState(oth,ZS_MM_Attack))
@Lehona and LeGo contributors - thank you for your great work folks
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- Anhänge hochladen: Nein
- Beiträge bearbeiten: Nein
|
|