Author Topic: 1/3 Damage to Specific Bot  (Read 1178 times)

0 Members and 1 Guest are viewing this topic.

Offline BondJamesBond

  • Flagrunner
  • ****
  • Posts: 986
    • http://tobylands.com
1/3 Damage to Specific Bot
« on: August 14, 2008, 12:16:13 am »
Hi what I'm trying to do:

For the bot named "Yamatsu Hikori" - he receives only 1/3 damage from bullets - and only NO damage from an M79 or grenade.

Code: [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  if (IDToName(Victim) = 'Yamatsu Hikori') then begin
     if (Damage > 1000) then begin
     Result := Damage - (Damage + 1);
     end else
     result := Damage Div 3;
     end else
     begin
     Result := Damage;
     end;
end;

It doesn't work at all. He is completely invincible to bullets - but dies when hit with an m79 or nade. i am nub.
The computer is a moron.
?  - Peter Drucker

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: 1/3 Damage to Specific Bot
« Reply #1 on: August 14, 2008, 12:31:26 am »
This is how I'd do it (havent tested it out):
Code: [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Result := Damage;
  if IDToName(Victim) = 'Yamatsu Hikori' then begin
     if Damage > 1000 then begin
Result := 0;
     end else begin
Result := Damage / 3;
     end;
  end;
end;
« Last Edit: August 14, 2008, 02:25:13 am by iDante »

Offline zop

  • Major
  • *
  • Posts: 81
Re: 1/3 Damage to Specific Bot
« Reply #2 on: August 14, 2008, 01:21:28 am »
Thanks.
I learn something from these.

http://122.116.167.31:23238:23238/galavela/?inc=player&name=%5BTomato+Bird%5D+Cibo[/size=1]

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: 1/3 Damage to Specific Bot
« Reply #3 on: August 14, 2008, 01:55:55 am »
iDante, your code makes everyone else take 0 damage too. You didnt specify Result when the first IF returns false. And you have an unclosed begin.

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: 1/3 Damage to Specific Bot
« Reply #4 on: August 14, 2008, 03:26:10 am »
iDante, your code makes everyone else take 0 damage too. You didnt specify Result when the first IF returns false. And you have an unclosed begin.
Might wanna get your eyes checked. It works. He uses four begins and four ends. And he made the Result equal Damage before the first IF.
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!

Offline BondJamesBond

  • Flagrunner
  • ****
  • Posts: 986
    • http://tobylands.com
Re: 1/3 Damage to Specific Bot
« Reply #5 on: August 14, 2008, 03:42:06 am »
heh SpiltCoffee - check the edit message

but it still doesn't work for me - same problem as in original post  :|
« Last Edit: August 14, 2008, 03:54:20 am by BondJamesBond »
The computer is a moron.
?  - Peter Drucker

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: 1/3 Damage to Specific Bot
« Reply #6 on: August 14, 2008, 04:02:13 am »
iDante, your code makes everyone else take 0 damage too. You didnt specify Result when the first IF returns false. And you have an unclosed begin.
Might wanna get your eyes checked. It works. He uses four begins and four ends. And he made the Result equal Damage before the first IF.
I fixed it. I did have the correct number of begins and ends, but I forgot the Result:=Damage before it.

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: 1/3 Damage to Specific Bot
« Reply #7 on: August 14, 2008, 04:25:53 am »
Oh, didn't see that. I need to get my eyes checked too, then. :P
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!

Offline BondJamesBond

  • Flagrunner
  • ****
  • Posts: 986
    • http://tobylands.com
Re: 1/3 Damage to Specific Bot
« Reply #8 on: August 14, 2008, 03:49:48 pm »
yah - nvm - it works fine. I just had to change the 0 to a negative number.

I also discovered I had put something that made him recover 100 health each second

 :-X :-X :-X

thanks much
« Last Edit: August 14, 2008, 04:25:24 pm by BondJamesBond »
The computer is a moron.
?  - Peter Drucker