Raised This Month: $ Target: $400
 0% 

Spawn weapon entity without physics..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xioSlayer
Senior Member
Join Date: Apr 2011
Old 11-07-2011 , 15:20   Spawn weapon entity without physics..
Reply With Quote #1

In L4D2 I am using zuko's code to spawn weapons. When the weapon_melee entity is created physics are applied instantly and the weapon falls to the floor. Is there a way to make weapons spawn in a resting state and still be able to be knocked down when bumped?

I know that weapon_melee_spawn entities have physics disabled permanently. That would be ok as well, this is how I have been accomplishing this same task with guns (like weapon_autoshotgun_spawn). however, when i try to create a weapon_melee_spawn entity, I must not be giving it the right information because the entity doesn't spawn.

In Zuko's code he has a check for if you want to create weapon_explosive_barrel, and it applies the appropriate keyvalues to make that entity. How do you find this information? If I could find this information then I would know what values to give weapon_melee_spawn.

I tried using this dev plugin, and it showed some of the properties, but none of the ones i was looking for.
https://forums.alliedmods.net/showthread.php?t=143081


Here is Zuko's code for the barrel to show you what information i'd like to be able to find.

Code:
        if(StrEqual(weapon, "weapon_explosive_barrel", false))
        {
            new ent = CreateEntityByName("prop_fuel_barrel");
            DispatchKeyValue(ent, "model", "models/props_industrial/barrel_fuel.mdl");
            DispatchKeyValue(ent, "BasePiece", "models/props_industrial/barrel_fuel_partb.mdl");
            DispatchKeyValue(ent, "FlyingPiece01", "models/props_industrial/barrel_fuel_parta.mdl");
            DispatchKeyValue(ent, "DetonateParticles", "weapon_pipebomb");
            DispatchKeyValue(ent, "FlyingParticles", "barrel_fly");
            DispatchKeyValue(ent, "DetonateSound", "BaseGrenade.Explode");
            DispatchSpawn(ent); 
            g_pos[2] -= 10.0-(i*2);
            TeleportEntity(ent, g_pos, NULL_VECTOR, NULL_VECTOR); //Teleport spawned weapon
        }

Last edited by xioSlayer; 11-07-2011 at 15:26.
xioSlayer is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 11-07-2011 , 16:32   Re: Spawn weapon entity without physics..
Reply With Quote #2

I maintain Zuko's plugin at this point, you can easily find info on map entities such as weapon_explosive_barrel or other map entities easily with the left4dead2.fgd which can be found in common\left 4 dead 2\bin\
Also if an entity that you're looking for isn't found there you can easily do a stripper dump to find the key values an entity uses. To answer your question on why the melee weapons use physics, it's because weapon_melee is the single count version of a weapon. That's similar to how weapon_pistol will spawn a pistol with physics enabled, while weapon_pistol_spawn spawns a stationary weapon with a "count"
Here's some info from left4dead2.fgd
PHP Code:
@PointClass base(WeaponSpawnstudioprop("models/weapons/melee/w_fireaxe.mdl") = weapon_melee_spawn "Melee Weapon"
[
    
melee_weapon(string) : "Melee Weapon" "any" "Options: 'Any' or a comma-delimited string of melee weapon script names. Leave blank for none."

You must not have been passing melee_weapon key value to the entity. I'm not sure if you can set a count for how many melee weapons for this entity.
__________________

Last edited by McFlurry; 11-07-2011 at 16:34.
McFlurry is offline
Send a message via Skype™ to McFlurry
xioSlayer
Senior Member
Join Date: Apr 2011
Old 11-07-2011 , 17:55   Re: Spawn weapon entity without physics..
Reply With Quote #3

Quote:
Originally Posted by McFlurry View Post
I maintain Zuko's plugin at this point, you can easily find info on map entities such as weapon_explosive_barrel or other map entities easily with the left4dead2.fgd which can be found in common\left 4 dead 2\bin\
Also if an entity that you're looking for isn't found there you can easily do a stripper dump to find the key values an entity uses. To answer your question on why the melee weapons use physics, it's because weapon_melee is the single count version of a weapon. That's similar to how weapon_pistol will spawn a pistol with physics enabled, while weapon_pistol_spawn spawns a stationary weapon with a "count"
Here's some info from left4dead2.fgd
PHP Code:
@PointClass base(WeaponSpawnstudioprop("models/weapons/melee/w_fireaxe.mdl") = weapon_melee_spawn "Melee Weapon"
[
    
melee_weapon(string) : "Melee Weapon" "any" "Options: 'Any' or a comma-delimited string of melee weapon script names. Leave blank for none."

You must not have been passing melee_weapon key value to the entity. I'm not sure if you can set a count for how many melee weapons for this entity.
Aha! thanks for all that great info McFlurry :]

Yes, I was not passing the melee_weapon value. I assumed it was melee_script_name, since that is the value you pass with weapon_melee entity.

Now it is working, and also, weapon_melee_spawn does support count, for whoever else might eventually need this information.
xioSlayer is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 11-07-2011 , 18:05   Re: Spawn weapon entity without physics..
Reply With Quote #4

Thanks for that useful piece of info.
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
xioSlayer
Senior Member
Join Date: Apr 2011
Old 11-08-2011 , 18:10   Re: Spawn weapon entity without physics..
Reply With Quote #5

Now how would I go about reading melee_weapon from the weapon_melee_spawn entity?

Why is it that DispatchKeyValues uses one name, and GetEntProp uses another? and more importantly, how can I find this 'alternate' name needed for GetEntProp?



This is the code that reads melee_script_name from weapon_melee entities, but it does not work for weapon_melee_spawn.

Code:
GetEntPropString(i, Prop_Data, "m_strMapSetScriptName", meleeName, sizeof(meleeName));

Last edited by xioSlayer; 11-08-2011 at 18:28.
xioSlayer is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 11-08-2011 , 19:37   Re: Spawn weapon entity without physics..
Reply With Quote #6

Seems the melee_weapon key value is tied to this
PHP Code:
m_iszMeleeWeapon (Save|Key)(4 Bytes) - melee_weapon 
Got that from datamaps.
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
xioSlayer
Senior Member
Join Date: Apr 2011
Old 11-08-2011 , 19:46   Re: Spawn weapon entity without physics..
Reply With Quote #7

Quote:
Originally Posted by McFlurry View Post
Seems the melee_weapon key value is tied to this
PHP Code:
m_iszMeleeWeapon (Save|Key)(4 Bytes) - melee_weapon 
Got that from datamaps.
thank you, i was looking at the original left 4 dead datamaps by mistake


This code below uses GetEntDataString and the String:meleeName is set to: "Ào>¥K"

what am I missing about getting the proper value?

Code:
GetEntDataString(i, FindDataMapOffs(i, "m_iszMeleeWeapon"), meleeName, sizeof(meleeName));

Last edited by xioSlayer; 11-08-2011 at 22:34.
xioSlayer is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 11-09-2011 , 12:13   Re: Spawn weapon entity without physics..
Reply With Quote #8

Try
PHP Code:
GetEntPropString(entityProp_Data"m_iszMeleeWeapon"stringsizeof(string)); 
It might not even be a string.
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
xioSlayer
Senior Member
Join Date: Apr 2011
Old 11-09-2011 , 15:07   Re: Spawn weapon entity without physics..
Reply With Quote #9

Quote:
Originally Posted by McFlurry View Post
Try
PHP Code:
GetEntPropString(entityProp_Data"m_iszMeleeWeapon"stringsizeof(string)); 
It might not even be a string.

That worked


muchos gracias.

Last edited by xioSlayer; 11-09-2011 at 18:09.
xioSlayer is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode