hedgewars/uChat.pas
changeset 4467 adedeec8f18f
parent 4465 743673c67d0c
child 4814 e19791f08443
equal deleted inserted replaced
4466:8ee58126f7bf 4467:adedeec8f18f
   179     end;
   179     end;
   180 
   180 
   181 visibleCount:= cnt;
   181 visibleCount:= cnt;
   182 end;
   182 end;
   183 
   183 
       
   184 procedure SendHogSpeech(s: shortstring);
       
   185 begin
       
   186 SendIPC('h' + s);
       
   187 ParseCommand('/hogsay '+s, true)
       
   188 end;
       
   189 
   184 procedure AcceptChatString(s: shortstring);
   190 procedure AcceptChatString(s: shortstring);
   185 var i: TWave;
   191 var i: TWave;
   186     c, t: LongInt;
   192     c, t: LongInt;
       
   193     x: byte;
   187 begin
   194 begin
   188 t:= LocalTeam;
   195 t:= LocalTeam;
   189 if not CurrentTeam^.ExtDriven and
   196 x:= 0;
   190    ((s[1] = '"') and (s[Length(s)] = '"') or
   197 if (s[1] = '"') and (s[Length(s)] = '"') then x:= 1
   191     (s[1] = '''') and (s[Length(s)] = '''') or
   198 else if (s[1] = '''') and (s[Length(s)] = '''') then x:= 2
   192     (s[1] = '-') and (s[Length(s)] = '-')) then
   199 else if (s[1] = '-') and (s[Length(s)] = '-') then x:= 3;
       
   200 if not CurrentTeam^.ExtDriven and (x <> 0) then
   193     for c:= 0 to Pred(TeamsCount) do
   201     for c:= 0 to Pred(TeamsCount) do
   194         if (TeamsArray[c] = CurrentTeam) then t:= c;
   202         if (TeamsArray[c] = CurrentTeam) then t:= c;
   195 // "Make hedgehog say something"
   203 
   196 if (s[1] = '"') and (s[Length(s)] = '"') then
   204 if x <> 0 then
   197     begin
   205     begin
   198     if t = -1 then
   206     if t = -1 then
   199         ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
   207         ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
   200     else
   208     else
   201         ParseCommand('/hogsay '#1 + char(t) + copy(s, 2, Length(s)-2), true);
   209         SendHogSpeech(char(x) + char(t) + copy(s, 2, Length(s)-2));
   202     exit
   210     exit
   203     end;
   211     end;
   204 // 'Make hedgehog think something'
   212 
   205 if (s[1] = '''') and (s[Length(s)] = '''') then
       
   206     begin
       
   207     if t = -1 then
       
   208         ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
       
   209     else
       
   210         ParseCommand('/hogsay '#2 + char(t) + copy(s, 2, Length(s)-2), true);
       
   211     exit
       
   212     end;
       
   213 // -Make hedgehog yell something-
       
   214 if (s[1] = '-') and (s[Length(s)] = '-') then
       
   215     begin
       
   216     if t = -1 then
       
   217         ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
       
   218     else
       
   219         ParseCommand('/hogsay '#3 + char(t) + copy(s, 2, Length(s)-2), true);
       
   220     exit
       
   221     end;
       
   222 // These 3 are same as above, only are to make the hedgehog say it on next attack
   213 // These 3 are same as above, only are to make the hedgehog say it on next attack
   223 if (s[1] = '/') and (copy(s, 1, 5) = '/hsa ') then
   214 if (s[1] = '/') and (copy(s, 1, 5) = '/hsa ') then
   224     begin
   215     begin
   225     if CurrentTeam^.ExtDriven then
   216     if CurrentTeam^.ExtDriven then
   226         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   217         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   227     else
   218     else
   228         ParseCommand('/hogsay '#4 + copy(s, 6, Length(s)-5), true);
   219         SendHogSpeech(#4 + copy(s, 6, Length(s)-5));
   229     exit
   220     exit
   230     end;
   221     end;
   231 if (s[1] = '/') and (copy(s, 1, 5) = '/hta ') then
   222 if (s[1] = '/') and (copy(s, 1, 5) = '/hta ') then
   232     begin
   223     begin
   233     if CurrentTeam^.ExtDriven then
   224     if CurrentTeam^.ExtDriven then
   234         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   225         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   235     else
   226     else
   236         ParseCommand('/hogsay '#5 + copy(s, 6, Length(s)-5), true);
   227         SendHogSpeech(#5 + copy(s, 6, Length(s)-5));
   237     exit
   228     exit
   238     end;
   229     end;
   239 if (s[1] = '/') and (copy(s, 1, 5) = '/hya ') then
   230 if (s[1] = '/') and (copy(s, 1, 5) = '/hya ') then
   240     begin
   231     begin
   241     if CurrentTeam^.ExtDriven then
   232     if CurrentTeam^.ExtDriven then
   242         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   233         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   243     else
   234     else
   244         ParseCommand('/hogsay '#6 + copy(s, 6, Length(s)-5), true);
   235         SendHogSpeech(#6 + copy(s, 6, Length(s)-5));
   245     exit
   236     exit
   246     end;
   237     end;
   247 
   238 
   248 if (copy(s, 1, 6) = '/team ') and (length(s) > 6) then
   239 if (copy(s, 1, 6) = '/team ') and (length(s) > 6) then
   249     begin
   240     begin