Posted: Sun Dec 06, 2015 9:08 am Post subject: [ACS] SetWeapon strangeness with Fist, Chainsaw and Pistol.
As usually SetWeapon_test. ACS will save in array all info about Player's ammo and weapons when player dies.
The strangeness manifested at Player spawn/respawn moment.
In Zdoom SetWeapon works fine with any weapon.
In ZDaemon single mode:
1) When player joins the game he has fist and pistol. Let's change active weapon to fist. Then kill the player (by trying opening the door or going to nukage). After respawn the active weapon of player is fist. It is ok. Now select pistol, and die again. We expect after respawn the same active weapon: pistol. BUT after respawn the active weapon of player will be fist... Hmmmmmmmmm... It is not ok.
2) Now let player picks up a chainsaw. When player will die with fist (or chainsaw) he gets the same weapon after respawn (fist or chainsaw). But if active weapon was the pistol - after respawn player gets chainsaw... Hmmmmm again.
3) Restore all other weapons are ok (like in zdoom).
In ZDaemon client/server mode:
1) Join the game, select fist, die and respawn. The result will be very strange: CheckWeapon will show us that we have active weapon - fist, but in real we will have active weapon - pistol. Furthermore: if we'll make shot from pistol CheckWeapon right away will show us the right active weapon - pistol. It is not ok. Now select pistol, die and respawn. The result will be the same: in real - pistol, via CheckWeapon - fist. But after a little delay (~1 sec) CheckWeapon will show us the proper active weapon - pistol.
2) Pick up chainsaw. Change active weapon to fist, die and respawn. We will get very interesting result: CheckWeapon will show us - chainsaw, in real we will have pistol, after ~1 sec pistol will be changed to fist and CheckWeapon will show fist too. If we will die with chainsaw, after respawn the result will be: CheckWeapon will show us - chainsaw, in real we will have pistol, after shot CheckWeapon will show us pistol too. Furthermore: if we'll not shoot but change weapon to fist (by number 1) then CheckWeapon will show us - fist, in real will be chainsaw. If we continue change weapon to fist or chainsaw CheckWeapon will show us wrong active weapon: fist - when we have chainsaw and vise versa. When we change fist/chainsaw by mousewheel - no such bug. And finally let's die with pistol. The result will: in real - pistol, via CheckWeapon - fist, but after a little delay (~1 sec) CheckWeapon will show us the proper active weapon - pistol.
3) Let's pick up next weapon - Shotgun/RocketLauncher/BFG900/etc. The restore of such weapons will be like fist restore in previous paragraph (2): after respawn, CheckWeapon will show us - chainsaw, in real we have pistol, after ~1 sec pistol will be changed to saved weapon and CheckWeapon will show it too. The same behavior is when player dies with fist. Now let's die with chainsaw. The result is: CheckWeapon - chainsaw, in real - pistol, after delay (~1 sec) pistol will be changed to weapon from last use GiveInventory(weapon), but CheckWeapon still return - chainsaw until shot or weapon change. And finally let's die with pistol. We get such result after respawn: CheckWeapon - chainsaw, in real - pistol, after delay (~1 sec) pistol will be changed to weapon from last use GiveInventory(weapon), but CheckWeapon will return now - pistol until shot or weapon change. When we have not a chainsaw, CheckWeapon will show us fist instead of chainsaw.
Btw, By-zero found, if in Respawn script we will use ClearInventory() before any SetWeapon/GiveInventory/etc then weapon change via SetWeapon works properly.
Yeah, ClearInventory() helps and fixes all problems.
I think the problem with the pistol was that the engine spawned the player with pistol and there is no reason to change to pistol again.
Online it seemed the engine restored all weapon and ammo and ended with the last added weapon.
SetWeapon while all this happened seems to be ignored.
Also changed checking if the player is alive. GetPlayerInfo with PLAYERINFO_HEALTH is ZD only and needs "#include "zdaemon.acs" (and correct settings) to get compiled.
Code:
from: While GetPlayerInfo(PlayerNumber(), PLAYERINFO_HEALTH) > 0)
to: While (GetActorProperty(0, APROP_Health) > 0)
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum