~ubuntu-branches/ubuntu/quantal/hedgewars/quantal

« back to all changes in this revision

Viewing changes to hedgewars/uChat.pas

  • Committer: Bazaar Package Importer
  • Author(s): Dmitry E. Oboukhov
  • Date: 2010-12-28 23:29:54 UTC
  • mfrom: (1.1.9 upstream) (3.2.10 sid)
  • Revision ID: james.westby@ubuntu.com-20101228232954-uvcytyhesmdhhd5e
Tags: 0.9.15-1
* New upstream version.
 + Ability to create, save and load hand drawn maps
 + New maps: Capture the Flag (Blizzard) Map
 + New themes: Christmas
 + Snowflakes on Christmas/Snow themes accumulates on the ground
 + New game modifiers: No wind, More wind
 + New missions: Dangerous ducklings, Diver, Spooky tree, Teamwork
 + New weapons: Mudball, Drill strike
 + Many more Lua hooks
 + Readytimer
 + Ability to edit seed
 + Ability to select gameplay scripts
 + New gameplay scripts: Capture the Flag, No jumping, Random weapon
 + New Lua unified translation framework
 + Code refactoring
 + Max teams upped to 8
 + Cosmetic enhancements to Napalm strike
 + Selecting a game scheme selects the corresponding weapon set
 + Dust when drills dig
 + New hats: beaver, porkey, sheep
 + Add density property to Gears
 + Reworked management of schemes and weapon sets
 + Will ask before deleting teams, schemes and weapon sets
 + Explosions detach rope from land
 + Allow hog speech when not your turn

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    showAll: boolean;
35
35
 
36
36
implementation
37
 
uses uMisc, uStore, uConsts, SDLh, uConsole, uKeys, uTeams;
 
37
uses SDLh, uKeys, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO;
38
38
 
39
39
const MaxStrIndex = 27;
40
40
 
181
181
visibleCount:= cnt;
182
182
end;
183
183
 
 
184
procedure SendHogSpeech(s: shortstring);
 
185
begin
 
186
SendIPC('h' + s);
 
187
ParseCommand('/hogsay '+s, true)
 
188
end;
 
189
 
184
190
procedure AcceptChatString(s: shortstring);
185
191
var i: TWave;
186
 
 
 
192
    c, t: LongInt;
 
193
    x: byte;
187
194
begin
188
 
// "Make hedgehog say something"
189
 
if (s[1] = '"') and (s[Length(s)] = '"') then
190
 
    begin
191
 
    if CurrentTeam^.ExtDriven then
192
 
        ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
193
 
    else
194
 
        ParseCommand('/hogsay '#1 + copy(s, 2, Length(s)-2), true);
195
 
    exit
196
 
    end;
197
 
// 'Make hedgehog think something'
198
 
if (s[1] = '''') and (s[Length(s)] = '''') then
199
 
    begin
200
 
    if CurrentTeam^.ExtDriven then
201
 
        ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
202
 
    else
203
 
        ParseCommand('/hogsay '#2 + copy(s, 2, Length(s)-2), true);
204
 
    exit
205
 
    end;
206
 
// -Make hedgehog yell something-
207
 
if (s[1] = '-') and (s[Length(s)] = '-') then
208
 
    begin
209
 
    if CurrentTeam^.ExtDriven then
210
 
        ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
211
 
    else
212
 
        ParseCommand('/hogsay '#3 + copy(s, 2, Length(s)-2), true);
213
 
    exit
214
 
    end;
 
195
t:= LocalTeam;
 
196
x:= 0;
 
197
if (s[1] = '"') and (s[Length(s)] = '"') then x:= 1
 
198
else if (s[1] = '''') and (s[Length(s)] = '''') then x:= 2
 
199
else if (s[1] = '-') and (s[Length(s)] = '-') then x:= 3;
 
200
if not CurrentTeam^.ExtDriven and (x <> 0) then
 
201
    for c:= 0 to Pred(TeamsCount) do
 
202
        if (TeamsArray[c] = CurrentTeam) then t:= c;
 
203
 
 
204
if x <> 0 then
 
205
    begin
 
206
    if t = -1 then
 
207
        ParseCommand('/say ' + copy(s, 2, Length(s)-2), true)
 
208
    else
 
209
        SendHogSpeech(char(x) + char(t) + copy(s, 2, Length(s)-2));
 
210
    exit
 
211
    end;
 
212
 
215
213
// These 3 are same as above, only are to make the hedgehog say it on next attack
216
214
if (s[1] = '/') and (copy(s, 1, 5) = '/hsa ') then
217
215
    begin
218
216
    if CurrentTeam^.ExtDriven then
219
217
        ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
220
218
    else
221
 
        ParseCommand('/hogsay '#4 + copy(s, 6, Length(s)-5), true);
 
219
        SendHogSpeech(#4 + copy(s, 6, Length(s)-5));
222
220
    exit
223
221
    end;
224
222
if (s[1] = '/') and (copy(s, 1, 5) = '/hta ') then
226
224
    if CurrentTeam^.ExtDriven then
227
225
        ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
228
226
    else
229
 
        ParseCommand('/hogsay '#5 + copy(s, 6, Length(s)-5), true);
 
227
        SendHogSpeech(#5 + copy(s, 6, Length(s)-5));
230
228
    exit
231
229
    end;
232
230
if (s[1] = '/') and (copy(s, 1, 5) = '/hya ') then
234
232
    if CurrentTeam^.ExtDriven then
235
233
        ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
236
234
    else
237
 
        ParseCommand('/hogsay '#6 + copy(s, 6, Length(s)-5), true);
 
235
        SendHogSpeech(#6 + copy(s, 6, Length(s)-5));
238
236
    exit
239
237
    end;
240
238
 
308
306
    end
309
307
end;
310
308
 
 
309
procedure chChatMessage(var s: shortstring);
 
310
begin
 
311
    AddChatString(s)
 
312
end;
 
313
 
 
314
procedure chSay(var s: shortstring);
 
315
begin
 
316
    SendIPC('s' + s);
 
317
 
 
318
    if copy(s, 1, 4) = '/me ' then
 
319
        s:= #2'* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4)
 
320
    else
 
321
        s:= #1 + UserNick + ': ' + s;
 
322
 
 
323
    AddChatString(s)
 
324
end;
 
325
 
 
326
procedure chTeamSay(var s: shortstring);
 
327
begin
 
328
    SendIPC('b' + s);
 
329
 
 
330
    s:= #4 + '[Team] ' + UserNick + ': ' + s;
 
331
 
 
332
    AddChatString(s)
 
333
end;
 
334
 
 
335
procedure chHistory(var s: shortstring);
 
336
begin
 
337
    s:= s; // avoid compiler hint
 
338
    uChat.showAll:= not uChat.showAll
 
339
end;
 
340
 
 
341
procedure chChat(var s: shortstring);
 
342
begin
 
343
    s:= s; // avoid compiler hint
 
344
    GameState:= gsChat;
 
345
    if length(s) = 0 then
 
346
        KeyPressChat(27)
 
347
    else
 
348
        begin
 
349
        KeyPressChat(27);
 
350
        KeyPressChat(47);
 
351
        KeyPressChat(116);
 
352
        KeyPressChat(101);
 
353
        KeyPressChat(97);
 
354
        KeyPressChat(109);
 
355
        KeyPressChat(32)
 
356
        end
 
357
end;
 
358
 
311
359
procedure initModule;
312
360
begin
 
361
    RegisterVariable('chatmsg', vtCommand, @chChatMessage, true);
 
362
    RegisterVariable('say', vtCommand, @chSay, true);
 
363
    RegisterVariable('team', vtCommand, @chTeamSay, true);
 
364
    RegisterVariable('history', vtCommand, @chHistory, true );
 
365
    RegisterVariable('chat', vtCommand, @chChat, true );
 
366
 
313
367
    lastStr:= 0;
314
368
    visibleCount:= 0;
315
369
    showAll:= false;