Author Topic: Strings updating  (Read 1481 times)

abgar

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Strings updating
« on: April 02, 2015, 10:42:56 PM »
Hi guys,
Long time reader, but first time poster.

It could be a hangover speaking, but i can't my head right about this part.....

Im creating a race that will summon dead allies, and change them to a specific race for the duration of the round (or until they die).

The summon and change race is working fine, and i've declared a global string that captures their current race prior to summon, so that on death or round end, they get changed back to their original race again.

The problem i'm facing is that each time a new ally is summoned, ALL players i've summoned have their original race 'reset'.
So i summon an Orcish Horde -> i change his race automatically to X -> he dies and gets auto changed back to Orcish Horde.  [ALL GOOD HERE]
BUT
If i summon an Orcish and change his race automatically to X --> then i summon a Human Alliance and change his race to X, then when either / both die, they BOTH get changed back to Human Alliance.

How can i define a variable string so that every 'summoned' player reverts back  to their individual race on death or round end?

The coding i'm using is:
SUMMON --> works good
Code: [Select]
origrace = War3_GetRace(target);
new x=War3_GetRaceIDByShortname("xrace");
War3_CooldownMGR(client,SummonCD[skill_summon],thisRaceID,SKILL_SUMMON,_,_);
War3_SpawnPlayer(target);
War3_SetRace(target,x);

ON DEATH TO REVERT RACE:
Code: [Select]
public OnWar3EventDeath(victim, attacker)
{
new x=War3_GetRaceIDByShortname("xrace");
if(War3_GetRace(victim)==x)
{
War3_SetRace(victim,origrace);
}
}

And obviously i've declared origrace as a global string.

Can anyone help here please?

Cheers guys :)

Revan

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Strings updating
« Reply #1 on: April 03, 2015, 05:13:02 AM »
Hey,

I think the problem is that you don't do any checks in OnWar3EventDeath. Another thing is that you need a global variable to store the race the players was on before. See this:
Code: [Select]
new g_iRaceChange[MAXPLAYERSCUSTOM];

public OnWar3EventDeath(victim, attacker)
{
new x=War3_GetRaceIDByShortname("xrace");
if(g_iRaceChange[victim] != 0 && War3_GetRace(victim) == x)
{
War3_SetRace(victim, g_iRaceChange[victim]);
g_iRaceChange[victim] = 0;
}
}

summon:
Code: [Select]
g_iRaceChange[target] = War3_GetRace(target); // store his race
new x=War3_GetRaceIDByShortname("xrace");
War3_CooldownMGR(client,SummonCD[skill_summon],thisRaceID,SKILL_SUMMON,_,_);
War3_SpawnPlayer(target);
War3_SetRace(target,x);

So the problem is that since it's a global variable(aka it's the same for each player) all players will have the same race reset. I hope I understood your problem correctly :D
#war3source on gamesurge

abgar

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: Strings updating
« Reply #2 on: April 03, 2015, 05:56:29 AM »
That's worked perfectly Revan - thanks heaps for that :)

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Strings updating
« Reply #3 on: April 03, 2015, 06:36:33 PM »
Good work Revan

abgar

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: Strings updating
« Reply #4 on: April 11, 2015, 06:11:18 AM »
Hmmm bugger...

On further testing, i've found that if the summoned player survives the round completely, they start the next round again as xrace - until they die, at which point they revert back to origrace.

Is there an 'OnWar3RoundEnd' function or similar i can call to revert the race the same way i have on War3EventDeath?

Cheers guys :)

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Strings updating
« Reply #5 on: April 11, 2015, 02:24:54 PM »
u have to hook the round end specific to your game, war3 doesn't provide one, i don't think