Archived copy of war3source.com, the War3Source forum (2009–2020), rebuilt from the Internet Archive by wc3mods.net. This page was captured on 2012-10-24 (original capture). Forum · All archived topics · Wiki · Bug tracker · Blog
Chat

War3:Source
October 24, 2012, 11:23:37 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Download: http://war3source.com/index.php?board=9.0
What is War3Source?: http://war3source.com/index.php?topic=200.0
Sample Stats: http://war3source.com/war3stats
Steam Community Group: http://steamcommunity.com/groups/war3source
War3Source SVN Checkout: http://ownageclan.com/svn/war3source/
War3Source servers: http://www.game-monitor.com/search.php?vars=war3_version=
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Tryed Making a Heal ultimate  (Read 2080 times)
Martin Texno
Newbie
*
Posts: 22


I'm Constructive ?

martinkongerule@hotmail.com martinmikalsen@yahoo.com
View Profile WWW Email
« on: December 01, 2009, 04:08:31 PM »

Hello, i tryed making a health Ultimate, Still can't test it  Cheesy

So here's the code
I feel there is something wrong ?


Code:
new Float:fLastUsed[65];
new iHealthAdded[65];

#define HEALTH_COOLDOWN 20
public OnUltimateCommand(client,race,bool:pressed)
{
if(pressed && race==raceID)
{
new health_level=War3_GetSkillLevel(client,race,3);
  new old_health=GetClientHealth(client);
new current_time=GetEngineTime();
if(health_level>0 && (current_time>=(fLastUsed[client]+HEALTH_COOLDOWN) || fLastUsed[client]==0.0))
{
switch(health_level)
{
case 1:
iHealthAdded[client]=20;
case 2:
iHealthAdded[client]=30;
case 3:
iHealthAdded[client]=40;
case 4:
iHealthAdded[client]=50;
}
SetEntityHealth(client,old_health+iHealthAdded[client]);
fLastUsed[client]=current_time;
CreateTimer(5.0,FinishHealth,GetClientUserId(client));
}
}
}

public Action:FinishHealth(Handle:timer,any:userid)
{
new client=GetClientOfUserId(userid);
if(client>0)
{
new new_hp=GetClientHealth(client)-iHealthAdded[client];
if(new_hp<1)
{
FakeClientCommand(client,"kill\n");
}
else
{
SetEntityHealth(client,new_hp);
}
}
}
« Last Edit: December 02, 2009, 11:04:51 AM by Martin Texno » Logged

Support ?
Anthony Iacono
Lead Developer
Full Member
***
Posts: 132

Lets make it better.

anthonyiacono@gmail.com
View Profile WWW Email
« Reply #1 on: December 01, 2009, 05:31:40 PM »

Hey,

First off:
Code:
new health_level=War3_GetSkillLevel(client,race,1);
Should be:
Code:
new health_level=War3_GetSkillLevel(client,race,3);
Since 0==skill 1, 1==skill 2, 2==skill 3, 3==ultimate

There actually isn't a built in system for health. This is how I would do it:
Code:
new Float:fLastUsed[65];
new iHealthAdded[65];

#define HEALTH_COOLDOWN 20
public OnUltimateCommand(client,race,bool:pressed)
{
if(pressed && race==raceID)
{
new health_level=War3_GetSkillLevel(client,race,3);
  new old_health=GetClientHealth(client);
new current_time=GetEngineTime();
if(health_level>0 && (current_time>=(fLastUsed[client]+HEALTH_COOLDOWN) || fLastUsed[client]==0.0))
{
switch(health_level)
{
case 1:
iHealthAdded[client]=20;
case 2:
iHealthAdded[client]=30;
case 3:
iHealthAdded[client]=40;
case 4:
iHealthAdded[client]=50;
}
SetEntityHealth(client,old_health+iHealthAdded[client]);
fLastUsed[client]=current_time;
CreateTimer(5.0,FinishHealth,GetClientUserId(client));
}
}
}

public Action:FinishHealth(Handle:timer,any:userid)
{
new client=GetClientOfUserId(userid);
if(client>0)
{
new new_hp=GetClientHealth(client)-iHealthAdded[client];
if(new_hp<1)
{
FakeClientCommand(client,"kill\n");
}
else
{
SetEntityHealth(client,new_hp);
}
}
}

You would also put this in player spawn:
Code:
iHealthAdded[client]=0;
fLastUsed[client]=0.0;

Let me know if you don't understand.
Logged
stinkyfax
Full Member
***
Posts: 116


View Profile Email
« Reply #2 on: December 05, 2009, 07:57:05 AM »

native ForcePlayerSuicide(client);
use it instead. fake client command is cheaty way of escaping difficulties which might fail. Ex: there are server side plugins blocking kill command.
Logged

Anthony Iacono
Lead Developer
Full Member
***
Posts: 132

Lets make it better.

anthonyiacono@gmail.com
View Profile WWW Email
« Reply #3 on: December 05, 2009, 10:16:12 AM »

Yeah you're right, I actually changed to that after I wrote the tutorial, I just wasn't thinking clearly during it. But if you look at the races it should say ForcePlayerSuicide.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!