Hi again guys, I'm having trouble again >.<
This time I wanted to get started with scripting, and I decided to try to code
this weapon after taking a look at other scripts and how they worked (namely CTF's Health code and ResurrectWormEx) and I ended up with a rather small buggy script:
Code:
require utils;
//Spawn New Worm on top of current worm
override void CWorm::FireFinal(CWeapon* Weap,CShootDesc* Desc)
{
if (Weap->CheckName("Mitosis"))
{
local currentworm = GetCurrentWorm();
if (currentworm != NullObj)
{
local HP = GS->Info.GetWormHealth(WormTeam, WormNumber);
if (HP > 1)
{
GS->Info.SetWormHealth(WormTeam, WormNumber, HP/2 );
local mitX = currentworm->PosX ;
local mitY = currentworm->PosY-16 ;
local mitTeam = currentworm->WormTeam ;
local mitIndex = currentworm->WormNumber ;
local mitName = "Test" ;
local mitHealth = HP/2 ;
//New Worm
CWormParams wParam;
zero(&wParam);
wParam.SetName(mitName);
wParam.SetPosition(mitHealth, mitX, mitY, true);
//Expand Team
GS->Info.Teams[mitTeam-1].Worms[mitIndex-1].Health = mitHealth;
mitWorm = new CWorm(NullObj, mitTeam, mitIndex, &wParam);
GS->Info.Teams[mitTeam-1].Worms[mitIndex-1].Health = mitHealth;
if (mitIndex > GS->Info.Teams[mitTeam-1].NWorms)
{
ExpandNWorms(mitTeam, mitIndex);
}
return;
}
ShowMessage("Not enough HP!");
return;
}
return;
}
super;
}
My intention was to split the worm's HP in half and spawn a new worm on top of it, with as much HP as the user lost.
The result was this:
Right after selecting the weapon, those animated crates appeared around the worm (which for some reason displayed the red headband like the Kamikaze/Fire Punch/Dragonball one when no custom sprites were assigned). The game froze for a second and crashed after attempting to use it.
I'm a total newbie when it comes to EAX, if someone would kindly point me in the right direction it would be greatly appreciated!
If it's of any help, px_errors.txt is attached below.