Dammit, I must have been very tired yesterday... My suggestions above are so complex, that's typical of me when I should try and find the easiest solutions.
Today I thought that an even better way to make your script work. Technically you only needed help for the replacing weapons of the mutant players inventory part, and didn't really need to translate WeaponItem to Wpn-Tiles.
Well first of I think you can try to use the IPlayer.Disarm (WeaponItemType weaponType, Vector2 velocity), to disarm the mutant every time he tries to pick something up via the Events.PlayerWeaponAddedActionCallback. I tried to use the Disarm function in 2021, and didn't like that the weapon goes flying away. Back then I didn't know you could manipulate the velocity of the disarmed weapon (at least the documentation seems to suggest this). I think you already know how to use this method. Thought I don't know how this will look like if the mutant picks up a weapon while rolling...
This would be the absolute best method. Why? Because if you just spawn a brand new weapon into the game, you will run into the problem of infinite ammo. Mutant picks up Magnum with 1 shot left, now there's a new magnum with full magazine.
So another method/fix is to just give the mutant a new weapon of the same category so he is forced to drop the original weapon. Now remove that weapon from his inventory. The only drawback with this is that it can look kind of ugly. This is something I already tried doing in a previous script, so that's why i knew this method, i just didn't remember it yesterday. The trick is to conceal the temporary weapon by giving a weapon with the shortest possible name, like Uzi or C4. However you can't hide these weapons as well, because there aren't any other weapons with short names to conceal them. Baton and Chain are perfect to conceal each other for example.
Here is some script i wrote you can see what i mean.
Code: Select all
//Monitor Mutant inventory here
if(Mutant.CurrentPrimaryWeapon.WeaponItem.ToString()!="NONE"){
switch(Mutant.CurrentPrimaryWeapon.WeaponItem.ToString() ){
/* For Beta 1.0.2c
case "M60":
Mutant.GiveWeaponItem(WeaponItem.CARBINE);
Mutant.RemoveWeaponItemType(WeaponItemType.Rifle);
Mutant.GiveWeaponItem(WeaponItem.M60);
Mutant.RemoveWeaponItemType(WeaponItemType.Rifle);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
*/
case "BAZOOKA":
Mutant.GiveWeaponItem(WeaponItem.CARBINE);
Mutant.RemoveWeaponItemType(WeaponItemType.Rifle);
Mutant.GiveWeaponItem(WeaponItem.BAZOOKA);
Mutant.RemoveWeaponItemType(WeaponItemType.Rifle);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
default:
WeaponItem CurrentWeapon = Mutant.CurrentPrimaryWeapon.WeaponItem;
Mutant.GiveWeaponItem(WeaponItem.BAZOOKA);
Mutant.RemoveWeaponItemType(WeaponItemType.Rifle);
Mutant.GiveWeaponItem(CurrentWeapon);
Mutant.RemoveWeaponItemType(WeaponItemType.Rifle);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
}
}
if(Mutant.CurrentSecondaryWeapon.WeaponItem.ToString()!="NONE"){
switch(Mutant.CurrentSecondaryWeapon.WeaponItem.ToString() ){
case "UZI":
Mutant.GiveWeaponItem(WeaponItem.PISTOL);
Mutant.RemoveWeaponItemType(WeaponItemType.Handgun);
Mutant.GiveWeaponItem(WeaponItem.UZI);
Mutant.RemoveWeaponItemType(WeaponItemType.Handgun);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
default:
WeaponItem CurrentWeapon = Mutant.CurrentSecondaryWeapon.WeaponItem;
Mutant.GiveWeaponItem(WeaponItem.UZI);
Mutant.RemoveWeaponItemType(WeaponItemType.Handgun);
Mutant.GiveWeaponItem(CurrentWeapon);
Mutant.RemoveWeaponItemType(WeaponItemType.Handgun);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
}
}
if(Mutant.CurrentMeleeWeapon.WeaponItem.ToString()!="NONE"){
switch(Mutant.CurrentMeleeWeapon.WeaponItem.ToString() ){
case "CHAIN":
Mutant.GiveWeaponItem(WeaponItem.BATON);
Mutant.RemoveWeaponItemType(WeaponItemType.Melee);
Mutant.GiveWeaponItem(WeaponItem.CHAIN);
Mutant.RemoveWeaponItemType(WeaponItemType.Melee);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
default:
WeaponItem CurrentWeapon = Mutant.CurrentMeleeWeapon.WeaponItem;
Mutant.GiveWeaponItem(WeaponItem.CHAIN);
Mutant.RemoveWeaponItemType(WeaponItemType.Melee);
Mutant.GiveWeaponItem(CurrentWeapon);
Mutant.RemoveWeaponItemType(WeaponItemType.Melee);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
}
}
if(Mutant.CurrentThrownItem.WeaponItem.ToString()!="NONE"){
switch(Mutant.CurrentThrownItem.WeaponItem.ToString() ){
case "C4": //case "C4DETONATOR":
Mutant.GiveWeaponItem(WeaponItem.MINES);
Mutant.RemoveWeaponItemType(WeaponItemType.Thrown);
Mutant.GiveWeaponItem(WeaponItem.C4);
Mutant.RemoveWeaponItemType(WeaponItemType.Thrown);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
default:
WeaponItem CurrentWeapon = Mutant.CurrentThrownItem.WeaponItem;
Mutant.GiveWeaponItem(WeaponItem.C4);
Mutant.RemoveWeaponItemType(WeaponItemType.Thrown);
Mutant.GiveWeaponItem(CurrentWeapon);
Mutant.RemoveWeaponItemType(WeaponItemType.Thrown);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
}
}
if(Mutant.CurrentPowerupItem.WeaponItem.ToString()!="NONE"){
switch(Mutant.CurrentPowerupItem.WeaponItem.ToString() ){
default:
WeaponItem CurrentWeapon = Mutant.CurrentPowerupItem.WeaponItem;
Mutant.GiveWeaponItem(CurrentWeapon);
Mutant.RemoveWeaponItemType(WeaponItemType.Powerup);
Game.PlayEffect("CFTXT", Mutant.GetWorldPosition() + new Vector2(10,5) , "Detected");
break;
}
}
Here's a demonstration
@Odex64 Yes, at first i also thought that maybe it was possible to write it with Dictionary method, but i don't know how to do it (or how it works/logic behind it), and I assumed he also can't because he hadn't done so.
But if you know how to do it and have the time, you could write a Guide because such a translation can turn out to be useful for future Scripters.