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, 03:25:28 PM *
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: Problem setting War3_DealDamageModPercent  (Read 238 times)
Vulpone
Full Member
***
Posts: 140



View Profile Email
« on: July 23, 2011, 08:17:08 AM »

Greetings fellow coders!

So, here's the deal. Inspired by DonRevan and TeacherCreature's work, I decided to learn to code. I've read a book on C some time ago, so adjusting to the basic functions in War3Source was not EXTREMELY hard -- thanks to DonRevan's continuous help and support.

But he's not here right now and my first race is on the verge of completion Wink.

So, tl;dr: here's the scoop.


Code:
public OnW3TakeDmgBulletPre( victim, attacker, Float:damage)
{
for(new client = 1; client <= MaxClients; client++)
{
new race = War3_GetRace(client);
if (bInUlti[client] = true && race == thisRaceID && IsPlayerAlive( client ) )
{
War3_DamageModPercent(2.0);
}
else if(bInUlti[client] = false && race == thisRaceID && IsPlayerAlive( client ) )
{
War3_DamageModPercent(1.0);
}
}
}

I declared the bool bInUlti[MAXPLAYERS] and I set it to true in the Ultimate.
I believe my intent is obvious:
The ultimate sets bInUlti to true, which then triggers double damage.
I've also created a Timer that sets bInUlti[client] to false after a certain time(dependent on the Ultimate level), which SHOULD then stop the double damage.

However, for some reason this doesn't work - I do not get receive the damage.

Can you see the fault in the code?

For additional reference, here's the other pieces of code..

Ultimate:
Code:
public OnUltimateCommand(client, race, bool:pressed)
{
if( race == thisRaceID && pressed && IsPlayerAlive( client ) )
{
new ulti=War3_GetSkillLevel( client, race, SKILL_ULT );
if( ulti > 0)
{
if( War3_SkillNotInCooldown( client, thisRaceID, SKILL_ULT, true ) )
{
bInUlti[client] = true;
War3_SetBuff( client,fMaxSpeed,thisRaceID, 1.65 );
CreateTimer(durationUlti[ulti], Timer_RemoveDamage, client);
CreateTimer(durationUlti[ulti], normal_speed, client);
PrintHintText( client, "You've been enhanced!");
War3_CooldownMGR(client,GetConVarFloat(ultCooldownCvar),thisRaceID,SKILL_ULT,true,true);
EmitSoundToAll( ultOn, client );
EmitSoundToAll( ultOn, client );

}
else
{
new cooldownUlti = War3_CooldownRemaining(client,thisRaceID,SKILL_ULT);
PrintHintText( client, "Enhancement failed You can enhance in %d seconds!", cooldownUlti );
}
}
else
{
PrintHintText( client, "You have not yet unlocked your Ultimate!");
}
}
}

Declaring the bool:
Code:
new bool:bInUlti[MAXPLAYERS];


The Timer:
Code:
public Action:Timer_RemoveDamage(Handle:timer,any:client)
{
if(client>0)
{
bInUlti[client]=false;
}
else
PrintToServer("Error when setting bInUlti[client] to false!.");
}


Thanks a lot in advance,
Vulpone

PS: Remember, this is my first race and I'm not a professional - yet. I'll continue working hard on races and I'll try to contribute if I can Wink.
Logged

Sapere aude!
Ownz
Developer
Administrator
Hero Member
*****
Posts: 2045



View Profile WWW Email
« Reply #1 on: July 23, 2011, 09:06:52 AM »

War3_DamageModPercent( deals with one single bullet, there should be no reason to loop through all players. you set the bullet to have double damage then back to 1.0 which has no effect

you dont need to set to 1.0, just dont set it

see  hammerstorm
Logged

DarkEnergy
Vulpone
Full Member
***
Posts: 140



View Profile Email
« Reply #2 on: July 23, 2011, 12:29:35 PM »

I see! Then DamageModPercent is perhaps the wrong function to call, as my Race is supposed to get the additional damage THROUGHOUT the entire Ultimate.

So, I decided to go with "War3_DealDamage" hooked on to a Timer that sets bInUlti to false after the time is over, which THEN turns of War3_DealDamage, as it requires bInUlti to be true.

Cannot be sure of it working, as I have yet to test it.
I will do so now and I'll tell you back.
Logged

Sapere aude!
Ownz
Developer
Administrator
Hero Member
*****
Posts: 2045



View Profile WWW Email
« Reply #3 on: July 23, 2011, 12:30:49 PM »

Quote
see race hammerstorm for example
Logged

DarkEnergy
Vulpone
Full Member
***
Posts: 140



View Profile Email
« Reply #4 on: July 23, 2011, 12:41:56 PM »

Yeah, thanks for the advice. I took a look at it, and while I was reading the code, I figured that by simply raising the number by which the damage is incremented, I had more control. I didn't want it to do 2x Damage, as stabbing the back would be too strong.

But I believe I get the concept now. I'll use the code another time.

Thanks again for your quick response and help.

PS: The current code works like a blast. My first race is now done. :d Thanks.
Logged

Sapere aude!
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!