Ikarus (Pakiet skryptów) 413784 1020

O temacie

Autor orcwarrior

Zaczęty 11.06.2010 roku

Wyświetleń 413784

Odpowiedzi 1020

Splash

Splash

Moderator
posty4210
Propsy3412
ProfesjaNierób
  • Moderator
Trzeba zapewne wywoływać co klatkę, bo silnik automatycznie zmienia wartość zmiennej, zgadłem? Jeśli tak, to wiem, gdzie popełniłem błąd kiedyś xD
 
Nie zajmuję się multiplayerami do Gothica. Przestańcie zawracać mi tym głowę...
Ps. Siemekk ma downa i śpi w pufie

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Tak sobie myślałem nad naprawieniem kursora z LeGo (zrobienie by się nie ciął). Mud-Freak znalazł adresy:
const int mouseUpdate                             = 5062907; //0x4D40FB // Hook length 5
const int mouseDeltaX                             = 9246300; //0x8D165C
const int mouseSensX                              = 9019720; //0x89A148

Gdyby Hooki działały na funkcje get_mousePosition to by było świetnie! Ale tak nie jest :( Więc jak najlepiej było by pobrać prędkość działania myszki (MouseSensX i Y) a potem dodać do do kursora ? Tutaj niestety mało wiem w jaki najlepszy i najkrótszy sposób to obliczyć :/
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.
Z tego co pamiętam, Mud-Freak (albo Lehona) mówił coś o dodaniu / odjęciu liczby FPS. Dzieje się tak, ponieważ FPS spadają czasami (ładowanie czegokolwiek).

Pobieranie FPS'ów:
var int fps; fps = invf(divf(MEM_Timer.frameTimeFloat, 1000));
Aczkolwiek raczej będziesz musiał użyć samego MEM_Timer.frameTimeFloat.
 
:ok: zachęca do dalszej pomocy. Nie zapominaj o tym!

Prywatne wiadomości typu "Ej, pomocy" kasuję od razu. Od tego jest forum, a nie PW.

To me, defeat in anything is merely temporary, and its punishment is but an urge for me to greater effort to achieve my goal. Defeat simply tells me that something is wrong in my doing; it is a path leading to success and truth.

In order to realize our true self we must be willing to live without being dependent upon the opinion of others.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Znalazłem post:
Cytuj
EDIT: Here a more thorough explanation:

MEM_Timer.frameTimeFloat is usually between 3 and let's say 30. It is the interframe-interval in milliseconds (the time since the last frame). You need to scale the cursor movement by this value in order to have mouse movement independent of the frames-per-second ("frame locked") so that it always moves at the same speed.
So you want to scale the mouse input by a number which is smaller for small IFI (interframe-intervals) and higher for longer IFI: The cursor should move faster when the last frame (= last cursor update) was long ago (low frame-rate) and slower if the last frame has just passed (high frame-rate).

You have to image this: y = b + a * x where x is the mouse input, a is the scaling factor, b is a bias and y is the final cursor movement. The bias b should always be set to zero, because otherwise the cursor will move even when there is no mouse input. That's why there is no bias in the code I provided. So let's change the equation to: y = a * x
The scalar (or slope) a (in the code it's called frameAdj) is made up of the IFI and a multiplier. (In the code I provided that multiplier is 0.016. This is, however, way to small for cursor movement.) The equation should look like this now: y = multipilier * IFI * x.
We need to find an appropriate multiplier.
The engine should do this exactly like this. Maybe you can find the engine function where it scales the mouse input when turning the player model for example (I am not talking about the mouse sensitivity! This is something completely different).

You cannot set the multiplier to any value. It needs to be tuned, so that for all IFI (or frames per second) the cursor movement ends up at the same speed.
Maybe there is an easier way to find out an appropriate multiplier, but you could do the following:
1. Remove the line: var int frameAdj; frameAdj = mulf(MEM_Timer.frameTimeFloat, fracf(16, 1000)); // Frame lock
2. Make frameAdj (this is our a from the equation above) a global variable (float) and write a script which lets you change (increase/decrease) that variable by button presses.
3. Write a script that displays frameAdj and the IFI (MEM_Timer.frameTimeFloat) (this is a float!) at every frame to the screen (not to the zSpy, this slows down the game and falsifies the testing).
Then start the game and do the following:
Write down the IFI (e.g. 5.0), then change frameAdj by button presses until the cursor movement is of correct speed, once you found the correct value, write down that number next to the IFI (e.g. 5.0 -> 0.7). Then repeat these steps at various locations in the world where the IFI is different. In the end you have a list of different IFI and frameAdj pairs to which you can fit a line. The slope of the line is your multiplier which you can put into the script instead of fracf(16, 1000).
Tylko trochę nie kapuje jak to odejmować xD Ze zmiennych teoretycznie potrzebnych mam to:
FPS, czułość myszy. I zmienną kursora >.< (wszystko floats)
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.
Więc masz dwie opcje:
1. Dostosować szybkość myszki samodzielnie, czyli ustawić zmienną, która będzie skalowała szybkość myszki odpowiednio, oraz dostosować tą zmienną do każdego świata, żeby zawsze chodziła tak samo.
2. Poszukać w engine, żeby gra sama to ustawiała poprawnie, przez co będzie mniej roboty, a działać będzie rewelacyjnie.

Czyli wychodzi na to, że jeśli weźmiesz się za skalowanie tego, to będziesz musiał się bawić i z MEM_Timer.frameTimeFloat i z odpowiednim skalerem (zmienna dostosowująca szybkość). Raczej nie powinno być z tym problemu, starczy, że wejdziesz w miejsce, gdzie nic się nie znajduje oraz miejsce, gdzie jest nawalone vobów (każdy objekt w gdzie to vob).

EDIT: To uczucie, jak za dużo czasu przebywasz w angielskim społeczeństwie i piszesz "objekt" zamiast "obiekt". :F
 
:ok: zachęca do dalszej pomocy. Nie zapominaj o tym!

Prywatne wiadomości typu "Ej, pomocy" kasuję od razu. Od tego jest forum, a nie PW.

To me, defeat in anything is merely temporary, and its punishment is but an urge for me to greater effort to achieve my goal. Defeat simply tells me that something is wrong in my doing; it is a path leading to success and truth.

In order to realize our true self we must be willing to live without being dependent upon the opinion of others.

Xardas47

Xardas47

Użytkownicy
Mhroczny charakterek
posty249
Propsy150
ProfesjaProgramista
  • Użytkownicy
  • Mhroczny charakterek
Trzeba przemnożyć szybkość kursora (czy tam wektor jego przesunięcia) przez MEM_Timer.frameTimeFloat (jeśli to jest w mili sekundach to wypadało by zamienić na sekundy) i dodatkowo przez jakąś zmienną dodatkową jeśli będzie za szybko/za wolno. To jest chyba najpopularniejszy sposób na zrobienie ruchu niezależnego od klatek w GameDevie.
 

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Tylko jak podpiąć to pod to :F
    Cursor_RelX = c.relX;
    Cursor_RelY = c.relY;
    Cursor_fX = addf(mulf(mkf(Cursor_RelX), mulf(MEM_ReadInt(Cursor_sX), mkf(2))), Cursor_fX);
    Cursor_fY = addf(mulf(mkf(Cursor_RelY), mulf(MEM_ReadInt(Cursor_sY), mkf(2))), Cursor_fY);

    Cursor_X = roundf(Cursor_fX);
    Cursor_Y = roundf(Cursor_fY);
    Cursor_Wheel = c.wheel;
Z tego co widzę jest tu dodawanie, ale w sposób tak chaotyczny że aż płaczę ;-; jedyne co tutaj widzę to floaty, a te MEM_ReadInt to nawet nie wiem w jakim celu służą xD
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Xardas47

Xardas47

Użytkownicy
Mhroczny charakterek
posty249
Propsy150
ProfesjaProgramista
  • Użytkownicy
  • Mhroczny charakterek
Po matematycznemu to działanie na floatach wygląda tak: (Cursor_RelX * Cursor_sX * 2) + Cursor_fX
Obstawiam że mnożone floaty to właśnie przesunięcie (z uwzględnieniem czułości, chyba) i potem to przesunięcie jest dodawane do poprzedniej pozycji.  Ta dwójka to pewnie mnożnik prędkości o którym pisałem. Czyli prawdopodobnie musisz te floaty pomnożyć jeszcze przez MEM_Timer.frameTimeFloat (ew. wcześniej podzielić go przez 10^n jak przyjmuje za duże wartości) i dostosować tego stałego floata żeby prędkość była odpowiednia.
 

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Cytuj
3. Write a script that displays frameAdj and the IFI (MEM_Timer.frameTimeFloat) (this is a float!) at every frame to the screen (not to the zSpy, this slows down the game and falsifies the testing).
Trochę tego nie rozumiem... Jak funkcję? Mam zrobić 500 ifów na kliknięcie klawisza? Nawet jeśli, to co napisać w funkcji aby nie było błędów.
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Tak sobie dłubię i chcę sprawdzać czy npc jest przyjazny.
Cały skrypt ma polegać na tym:
Jest przyjacielem i nie został namierzony(focus_vob) to funkcja zawraca 0. Jest przyjacielem i został znaleziony jako focus_vob funkcja zawraca 1.
Napisałem to tak:
if(Hlp_GetInstanceID(trgt)>=0)//został znaleziony
{
if(Hlp_Is_oCNpc(trgt)) //jest npc
{
if(Hlp_GetInstanceID(trgt)==Hlp_GetInstanceID(npc))
{
Print("Target focus - friend, but ATTACK!");
return 1;              //Namierzony i uderzony!!!
};
};
}
else //Nie został namierzony
{
Print("Target nofocus - friend, no ATTACK!");
return 0; //więc nie atakuj
};
Jak nie jest namierzony to działa, lecz gdy już jest to crash co może być tego przyczyną?
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.
(Hlp_GetInstanceID(trgt)>=0)
 
:ok: zachęca do dalszej pomocy. Nie zapominaj o tym!

Prywatne wiadomości typu "Ej, pomocy" kasuję od razu. Od tego jest forum, a nie PW.

To me, defeat in anything is merely temporary, and its punishment is but an urge for me to greater effort to achieve my goal. Defeat simply tells me that something is wrong in my doing; it is a path leading to success and truth.

In order to realize our true self we must be willing to live without being dependent upon the opinion of others.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Zmiana nie pomogła, a nawet wywołała to, że crashuje nawet gdy nie jest namierzony :/ Log nie wskazuje nic ciekawego :/
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.
To zapewne wina trgt.
 
:ok: zachęca do dalszej pomocy. Nie zapominaj o tym!

Prywatne wiadomości typu "Ej, pomocy" kasuję od razu. Od tego jest forum, a nie PW.

To me, defeat in anything is merely temporary, and its punishment is but an urge for me to greater effort to achieve my goal. Defeat simply tells me that something is wrong in my doing; it is a path leading to success and truth.

In order to realize our true self we must be willing to live without being dependent upon the opinion of others.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
her = hlp_getnpc(hero);
trgt = _^(her.focus_vob);
Wywoływane zawsze gdy hero uderzy bronią.
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.
Posłałeś swój skrypt na WoG:
func int HeroDamage_CanDoHit_CNPCPass(var c_npc npc)
{
var c_npc trgt;
var ocnpc her; her = hlp_getnpc(hero);
trgt = _^(her.focus_vob);
if(npc.aivar[AIV_DAMAGEID]==HeroDamage_DamageID+1)
{
return 0;
};
if(Npc_IsInState(npc,ZS_Dead))||(Npc_IsInState(npc,ZS_Unconscious))
||(Npc_IsInState(npc,ZS_MagicSleep))
{
return 0;
}     
else if((Npc_GetAttitude(npc,hero)==ATT_FRIENDLY)||(npc.flags == NPC_FLAG_FRIEND)||(npc.aivar[AIV_PARTYMEMBER]==true))
{
if(Hlp_GetInstanceID(trgt))//został znaleziony
{
if(Hlp_Is_oCNpc(trgt)) //jest npc
{
if(Hlp_GetInstanceID(trgt)==Hlp_GetInstanceID(npc))
{
Print("Target focus - friend, but ATTACK!");
return 1;              //Namierzony i uderzony!!!
};
};
}
else //Nie został namierzony
{
Print("Target nofocus - friend, no ATTACK!");
return 0; //więc nie atakuj
};

}
else if(Npc_GetAttitude(npc,hero)==ATT_NEUTRAL)&&(HeroDamage_HostileEnemies!=0)&&(HeroDamage_TimeHeroAttackedNeutralFocus==0)
{
trgt = _^(her.focus_vob);
if(Hlp_Is_oCNpc(trgt))
{
if (Hlp_GetInstanceID(npc) == Hlp_GetInstanceID(trgt))
{
Print("Target focus - Attack!");
return 1;              //Namierzony to uderzony!!!
}
else
{
Print("Target nofocus - don't attack!");
return 0; //Walczysz z 10? Żaden problem :D
};
};
}
else
{     
return 1;     
};
};

Wszytko jak mówiłem, trgt jest problemem. Hlp_Is_oCNpc = int, dodajesz C_NPC.

func int Hlp_Is_oCNpc (var int ptr) {
    if (!ptr) { return 0; };
    return (MEM_ReadInt (ptr) == oCNpc_vtbl);
};
 
:ok: zachęca do dalszej pomocy. Nie zapominaj o tym!

Prywatne wiadomości typu "Ej, pomocy" kasuję od razu. Od tego jest forum, a nie PW.

To me, defeat in anything is merely temporary, and its punishment is but an urge for me to greater effort to achieve my goal. Defeat simply tells me that something is wrong in my doing; it is a path leading to success and truth.

In order to realize our true self we must be willing to live without being dependent upon the opinion of others.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Teraz widzę :faceplam: Dawałem c_npc miast int... wystarczyło zamienić na  her.focus_vob :D
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Cześć. Mam taki mały problem... Chcę zapisać Instancję przedmiotu do tablicy. Tablica ma rozmiar 10 więc chciałem użyć MEM_WriteStatArr, jednak o dziwo Instancja zawraca 0...
Wiem że mogę zapisać to pojedynczo, ale dzięki MEM_WriteStatArr kod będzie krótszy.
Oto fragment kodu:
class aCQuickSlot
{
var int Item_ID[10];
var int View_ptr[10];
};
//Tutaj inne funkcje + Instancja
func void AddInFilter(var int FlagID, var int it)
{
var aCQuickSlot qs; qs = get(new(aQuickSlot));

if(!MEM_ReadStatArr(qs.View_ptr,FlagID))
{
MEM_WriteStatArr(qs.View_ptr,FlagID,View_Create(Calculate_ViewPos(FlagID),256,Calculate_ViewPos(FlagID)+512,768));
View_SetTexture(MEM_ReadStatArr(qs.View_ptr,FlagID),"AQUICKSLOT_L.tga");
View_Open(MEM_ReadStatArr(qs.View_ptr,FlagID));
};

MEM_WriteStatArr(qs.Item_ID,FlagID,it);
};
func void QS_GetItem()
{
var aCQuickSlot qs; qs = get(new(aQuickSlot));
var C_Item itm; itm = _^(MEM_ReadInt(ESP+324+4));
var int i; i = Hlp_GetInstanceID (itm);
if(MEM_KeyState(KEY_1)==KEY_PRESSED){ if(MEM_ReadStatArr(qs.Item_ID,1)!=i){AddInFilter(1,i);}else{RemoveFromFilter(1);}; };
if(MEM_KeyState(KEY_2)==KEY_PRESSED){ if(MEM_ReadStatArr(qs.Item_ID,2)!=i){AddInFilter(2,i);}else{RemoveFromFilter(2);}; };
[...]
I tak dalej...
P.S dziwne jest to, że View jest zapisany, a Item już nie...
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.
Nie wiem, czy ma to jakiekolwiek znaczenie, ale spróbuj _@() zamiast GetInstanceID.

Albo po prostu var int itm; itm = MEM_ReadInt(ESP+324+4);
 
:ok: zachęca do dalszej pomocy. Nie zapominaj o tym!

Prywatne wiadomości typu "Ej, pomocy" kasuję od razu. Od tego jest forum, a nie PW.

To me, defeat in anything is merely temporary, and its punishment is but an urge for me to greater effort to achieve my goal. Defeat simply tells me that something is wrong in my doing; it is a path leading to success and truth.

In order to realize our true self we must be willing to live without being dependent upon the opinion of others.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Zawróci to samo. Ale problem nie leży w tym że itm zawraca 0. Gdy sprawdzam bezpośrednio w funkcji QS_GetItem to zawraca prawidlowe wartości. Coś jest chyba z Mem_WriteStatArr dot. Instancji.
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Splash

Splash

Moderator
posty4210
Propsy3412
ProfesjaNierób
  • Moderator
Jak wywoływana jest funkcja QS_GetItem?

var aCQuickSlot qs; qs = get(new(aQuickSlot));Musisz się jeszcze sporo nauczyć o PermMem...
 
Nie zajmuję się multiplayerami do Gothica. Przestańcie zawracać mi tym głowę...
Ps. Siemekk ma downa i śpi w pufie


0 użytkowników i 2 gości przegląda ten wątek.
0 użytkowników
Do góry