Expected '{' (line 220) 4205 11

O temacie

Autor Bogdan Zwei

Zaczęty 24.12.2011 roku

Wyświetleń 4205

Odpowiedzi 11

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.

Bogdan Zwei

Expected '{' (line 220)
2011-12-24, 12:54(Ostatnia zmiana: 2011-12-24, 15:10)
Robiłem sobie skrypt, w którym dostaje się +*% do walki bronią, ale wyskakuje mi błąd Expected '{' (line 220).
Oto skrypt:
func void B_TEST (var C_NPC oth, var C_NPC slf)
{

if (Hlp_GetInstanceID(oth) == Hlp_GetInstanceID(hero))
{
var C_ITEM ReadyWeapon;
var int Percent;

ReadyWeapon = Npc_GetReadiedWeapon(hero);

if ( Npc_IsPlayer(hero))
{
if (ReadyWeapon.flags) == ITEM_SWD) || (ReadyWeapon.flags) == ITEM_AXE) && (Percent == 0) // linia 220
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_SWD) || (ReadyWeapon.flags) == ITEM_AXE) && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_1H, 1);
Print (Walka bronią jednoręczną + 1%);
};

if (ReadyWeapon.flags) == ITEM_2HD_SWD) || (ReadyWeapon.flags) == ITEM_2HD_AXE) && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_2HD_SWD) || (ReadyWeapon.flags) == ITEM_2HD_AXE) && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_2H, 1);
Print (Walka bronią dwuręczną + 1%);
};

if (ReadyWeapon.flags) == ITEM_BOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_BOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_BOW, 1);
Print (Walka łukiem + 1%);
};

if (ReadyWeapon.flags) == ITEM_CROSSBOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_CROSSBOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_CROSSBOW, 1);
Print (Walka kuszą + 1%);
};
};
};

Jest zapisany w B_AssessDamage.d i ma B_TEST (other, self); zapisane.
Wyskakuje mi ten błąd, a nie widzę żadnego błędu. Co jest nie tak? Jak dopisuję { przed if, to znowu jest błąd, że ta { jest niepotrzebna...
 
: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.

koksikmajor

koksikmajor

Użytkownicy
posty692
Propsy89
  • Użytkownicy
za każdą zamkniętą klamrą stawia się średnik  :facepalm:
 

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.
Przy "else" nie.
 
: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.

inż. Avallach

inż. Avallach

Administrator
posty7661
Propsy5239
NagrodyV
ProfesjaProgramista
  • Administrator

inż. Avallach
Administrator

Expected '{' (line 220)
#3 2011-12-24, 18:05(Ostatnia zmiana: 2011-12-24, 18:16)
Brakuje ci nie "{" tylko "};". Nie zamknąłeś jednego warunku (lub samej funkcji), nie chce mi się analizować którego. Być może wystarczy dopisać na końcu.

Na przyszłość przy zapisie klamrowym radzę korzystać z tabulatorów, znacznie zwiększają przejrzystość kodu:
Spoiler
func void B_TEST (var C_NPC oth, var C_NPC slf)
{

if (Hlp_GetInstanceID(oth) == Hlp_GetInstanceID(hero))
{
var C_ITEM ReadyWeapon;
var int Percent;

ReadyWeapon = Npc_GetReadiedWeapon(hero);

if ( Npc_IsPlayer(hero))
{
if (ReadyWeapon.flags) == ITEM_SWD) || (ReadyWeapon.flags) == ITEM_AXE) && (Percent == 0) // linia 220
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_SWD) || (ReadyWeapon.flags) == ITEM_AXE) && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_1H, 1);
Print ("Walka bronią jednoręczną + 1%");
};

if (ReadyWeapon.flags) == ITEM_2HD_SWD) || (ReadyWeapon.flags) == ITEM_2HD_AXE) && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_2HD_SWD) || (ReadyWeapon.flags) == ITEM_2HD_AXE) && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_2H, 1);
Print ("Walka bronią dwuręczną + 1%");
};

if (ReadyWeapon.flags) == ITEM_BOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_BOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_BOW, 1);
Print ("Walka łukiem + 1%");
};

if (ReadyWeapon.flags) == ITEM_CROSSBOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_CROSSBOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_CROSSBOW, 1);
Print ("Walka kuszą + 1%");
};
};
};
Z nimi od razu widać że brakuje jednego zakończenia (skrypt kończy się "dalej" niż się zaczął). Ewentualnie możesz też (jak ja) skorzystać z programu ambitniejszego niż notatnik który podświetli ci początek i koniec każdej klamry.

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.

Bogdan Zwei

Expected '{' (line 220)
#4 2011-12-24, 18:23(Ostatnia zmiana: 2011-12-24, 18:24)
Cytuj
func void B_TEST (var C_NPC oth, var C_NPC slf)
{

if (Hlp_GetInstanceID(oth) == Hlp_GetInstanceID(hero))
{
var C_ITEM ReadyWeapon;
var int Percent;

ReadyWeapon = Npc_GetReadiedWeapon(hero);

if ( Npc_IsPlayer(hero))
{
if (ReadyWeapon.flags) == ITEM_SWD) || (ReadyWeapon.flags) == ITEM_AXE) && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_SWD) || (ReadyWeapon.flags) == ITEM_AXE) && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_1H, 1);
Print ("Walka bronią jednoręczną + 1%");
};

if (ReadyWeapon.flags) == ITEM_2HD_SWD) || (ReadyWeapon.flags) == ITEM_2HD_AXE) && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_2HD_SWD) || (ReadyWeapon.flags) == ITEM_2HD_AXE) && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_2H, 1);
Print ("Walka bronią dwuręczną + 1%");
};

if (ReadyWeapon.flags) == ITEM_BOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_BOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_BOW, 1);
Print ("Walka łukiem + 1%");
};

if (ReadyWeapon.flags) == ITEM_CROSSBOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent == 0)
{
Percent += 1;
}
else if (ReadyWeapon.flags) == ITEM_CROSSBOW)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent >= 25)
{
B_AddFightSkill (hero, NPC_TALENT_CROSSBOW, 1);
Print ("Walka kuszą + 1%");
};
};
};
};

Nadal brakuje przed if (ReadyWeapon.flags) == ITEM_SWD) || (ReadyWeapon.flags) == ITEM_AXE) && (Percent == 0) tego [
 
: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.

inż. Avallach

inż. Avallach

Administrator
posty7661
Propsy5239
NagrodyV
ProfesjaProgramista
  • Administrator

inż. Avallach
Administrator

Expected '{' (line 220)
#5 2011-12-24, 18:36(Ostatnia zmiana: 2011-12-24, 18:43)
Aha, bo oprócz tego masz prawdopodobnie złą składnię warunków:
if (ReadyWeapon.flags) == ITEM_SWD) || (ReadyWeapon.flags) == ITEM_AXE) && (Percent == 0)Te nawiasy nie mają sensu, na dodatek jeden jest nie otwarty. Spróbuj tak:
if ((ReadyWeapon.flags == ITEM_SWD || ReadyWeapon.flags == ITEM_AXE) && Percent == 0)Być może w pozostałych też masz źle, porównaj.

//edit: ten skrypt naprawdę nie ma nawet logicznego sensu :|  (tylko go nie usuwaj!). Spróbuj w pamięci podstawić jakieś wartości (na przykład: miecz jednoręczny, ma już 5%) i zobaczyć co algorytm ci z nimi zrobi - nic. To kwestia nie tylko wielu różnych, poważnych błędów składniowych, ale ogólnie całego układu warunków.

RafalBudzis

RafalBudzis

Użytkownicy
posty1967
Propsy808
ProfesjaSkrypter
  • Użytkownicy
za każdą zamkniętą klamrą stawia się średnik  :facepalm:
Nie za każdą przed else NIGDY nie dajemy średnika :P

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.

Bogdan Zwei

Expected '{' (line 220)
#7 2011-12-25, 09:24(Ostatnia zmiana: 2011-12-25, 09:25)
func void B_TEST (var C_NPC oth, var C_NPC slf)
{

if (Hlp_GetInstanceID(oth) == Hlp_GetInstanceID(hero))
{
var C_ITEM ReadyWeapon;
var int Percent;

ReadyWeapon = Npc_GetReadiedWeapon(hero);

if ( Npc_IsPlayer(hero))
{
if ((ReadyWeapon.flags == ITEM_SWD || ReadyWeapon.flags == ITEM_AXE && ReadyWeapon.mainflag == ITEM_KAT_NF) && (Percent == 0))
{
Percent += 1;
}
else if ((ReadyWeapon.flags == ITEM_SWD || ReadyWeapon.flags == ITEM_AXE && ReadyWeapon.mainflag == ITEM_KAT_NF) && (Percent >= 25))
{
B_AddFightSkill (hero, NPC_TALENT_1H, 1);
Print (Walka bronią jednoręczną + 1%);
Percent = 0;
};

if ((ReadyWeapon.flags == ITEM_2HD_SWD || ReadyWeapon.flags == ITEM_2HD_AXE && ReadyWeapon.mainflag == ITEM_KAT_NF) && (Percent == 0))
{
Percent += 1;
}
else if ((ReadyWeapon.flags == ITEM_2HD_SWD || ReadyWeapon.flags == ITEM_2HD_AXE && ReadyWeapon.mainflag == ITEM_KAT_NF) && (Percent >= 25))
{
B_AddFightSkill (hero, NPC_TALENT_2H, 1);
Print (Walka bronią dwuręczną + 1%);
Percent = 0;
};

if ((ReadyWeapon.flags == ITEM_BOW && ReadyWeapon.mainflag == ITEM_KAT_FF)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent == 0))
{
Percent += 1;
}
else if ((ReadyWeapon.flags == ITEM_BOW && ReadyWeapon.mainflag == ITEM_KAT_FF)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent >= 25))
{
B_AddFightSkill (hero, NPC_TALENT_BOW, 1);
Print (Walka łukiem + 1%);
Percent = 0;
};

if ((ReadyWeapon.flags == ITEM_CROSSBOW && ReadyWeapon.mainflag == ITEM_KAT_FF)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent == 0))
{
Percent += 1;
}
else if ((ReadyWeapon.flags == ITEM_CROSSBOW && ReadyWeapon.mainflag == ITEM_KAT_FF)/* || (ReadyWeapon.flags) == ITEM_AXE)*/ && (Percent >= 25))
{
B_AddFightSkill (hero, NPC_TALENT_CROSSBOW, 1);
Print (Walka kuszą + 1%);
Percent = 0;
};
};
};
};


Nie działa. ;/

PS: Próbowałem także bez mainflag'a
 
: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.

inż. Avallach

inż. Avallach

Administrator
posty7661
Propsy5239
NagrodyV
ProfesjaProgramista
  • Administrator

inż. Avallach
Administrator

Expected '{' (line 220)
#8 2011-12-25, 10:20(Ostatnia zmiana: 2011-12-25, 10:58)
Przeczytaj prosze mojego posta. Twoj skrypt nawet jest zle zbudowany logicznie, wyobraz sobie ze gracz skorzystal z tego juz raz, ma 1% i chce znowu. Skrypt nic nie zrobi, bo to ani nie jest == 0 ani >=25. Przeciez nie pisalbym ze jest zle tylko dlatego zeby cie pognebic.

Musisz napisac te warunki od nowa, ewentualnie jesli nie potrafisz to jak wejde na kompa moge zrobic ci prezent gwiazdkowy i zrobic to za ciebie...

Napisz przede wszystkim co ten skrypt ma dokładnie robic.

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.
Jak nic nie robi? Wyraźnie widać, if (Percent ==0) - czyli jeśli nic się nie dzieje Percent += 1;, a potem if (Percent >= 25) to dodaje nam, pokazuje napis, i Percent = 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.

inż. Avallach

inż. Avallach

Administrator
posty7661
Propsy5239
NagrodyV
ProfesjaProgramista
  • Administrator

inż. Avallach
Administrator

Expected '{' (line 220)
#10 2011-12-25, 13:01(Ostatnia zmiana: 2011-12-25, 14:36)
var int learning_1h;
var int learning_2h;
var int learning_bow;
var int learning_cbow;

const int learning_bpp = 100; //ilośc ciosów na 1%

func void learning ()
{
if (!Npc_IsPlayer(other) || self.flags == NPC_FLAG_IMMORTAL ) { return; };

var c_item weapon; weapon = Npc_GetReadiedWeapon(other);

if (weapon.flags == ITEM_SWD + 1082130434 || weapon.flags == ITEM_AXE + 1082130434 )
{
if (learning_1h >= learning_bpp - 1) { B_AddFightSkill (other, NPC_TALENT_1H, 1); learning_1h -= learning_bpp - 1; Print (PRINT_Learn1h1); }
else { learning_1h += 1; };
}
else if (weapon.flags == ITEM_2HD_SWD + 1082130434 || weapon.flags == ITEM_2HD_AXE + 1082130434)
{
if (learning_2h >= learning_bpp - 1) { B_AddFightSkill (other, NPC_TALENT_2H, 1); learning_2h -= learning_bpp - 1; Print (PRINT_Learn2h1); }
else { learning_2h += 1; };
}
else if (weapon.flags == ITEM_BOW + 1082130436)
{
if (learning_bow >= learning_bpp - 1) { B_AddFightSkill (other, NPC_TALENT_BOW, 1); learning_bow -= learning_bpp - 1; Print (PRINT_LearnBow1); }
else { learning_bow += 1; };
}
else if (weapon.flags == ITEM_CROSSBOW + 1082130436)
{
if (learning_cbow >= learning_bpp - 1) { B_AddFightSkill (other, NPC_TALENT_CROSSBOW, 1); learning_cbow -= learning_bpp - 1; Print (PRINT_LearnCrossBow1); }
else { learning_cbow += 1; };
};
};

Printy przy "else" są tylko testowo, żeby sprawdzić czy działa.

//edit:
Oho, flagsy jednak nie są takie jakie chcielibyśmy żeby były.
Już kiedyś się z tym zmagałem, ale po prostu zapomniałem. Otóż Gothic dodaje w trakcie gry do itemów dodatkowe, wewnętrzne flasy które nie są uwzględnione w ich skryptach. W przypadku broni do walki w zwarciu sumują się one do 1082130434, a przy broniach dystansowych jeszcze o 2 więcej. Nie mam ochoty teraz liczyć co to

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.
Temat można zamknąć, wszystko jest cacy i działa. :)
 
: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.


0 użytkowników i 1 Gość przegląda ten wątek.
0 użytkowników
Do góry