Raised This Month: $122 Target: $400
 30% 

[EXTENSION] NPCs in CS:S (extended)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
donrevan
AlliedModders Donor
Join Date: Jul 2010
Old 03-19-2018 , 11:33   [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #1

This is a updated (and extended) version of raydan's NPCs in CS:S extension. This release was requested in the donor section.
It fixes compatibility problems with latest CS:S, adds functionality to existing CEntity base classes as well as completely new entities.



I always wanted to polish this more and add JUST THIS ONE little feature but it's a never ending story (especially due to the complexity of this extension). Hopefully this release will get some interested people attracted to do some improvements on it

There are also a couple of new entities in this version that are not in the original one (from the top of my head):
  • npc_barnacle
  • npc_monk (bare bones)
  • npc_barney (bare bones)
  • npc_clawscanner
  • npc_contactgrenade
  • npc_cscanner
  • npc_combine_s
  • npc_grenade_frag
  • npc_turret_ceiling
  • npc_houndeye
  • weapon_ar2
  • ..probably more..

This extension improves support for more humanoid enemies (npc_combine_s is supported). Make sure to npc_create_equipment weapon_ar2 before spawning them trough the console.

The idea was to do a coop gamemode that awards every player points for completing a level (via game_end entity). There's even a little sourcepawn API to interact with the point system. But feel free to do w/e you want.
By using Stripper:Source you can easily make a lot of maps work with this extension. I've attached some S:S scripts to this post (see maps.zip, based on one of raydan's posts) and a simple map to showcase some of the features.

monster_dump output (all entities, factories... ignore the numbers):
Spoiler


recommended cvars:
Code:
// co-op settings
mp_flashlight 1
mp_limitteams 0
mp_autoteambalance 0
mp_ignore_round_win_conditions 1

// difficulty settings
exec skill
Installation:
extract package.zip and raydan's patch.zip into your game server root directory.
Download latest extension from github (npcs_in_css.zip) page and extract in your game server root as well.
(Optional: download maps.zip for two maps with config files for stripper, don't forget to install Stripper:Source.)
This extension is build against a rather old SM version so if there are any problems please let me know.
It is highly recommended to install CEF alongside this extension.
Currently CS:S and Windows only!

Please tell me if you notice there are any files missing I'll upload them ASAP.

Source:
https://github.com/mipek/npcs-in-css

Todo:
There's still alot of work to do like fixing custom inputs and keyvalues, reworking CPickupItem logic (and make it possible to properly pickup shield, healthvials etc. by pressing +USE, adding new NPCs/entities and of course add linux support and maybe even CS:GO support (huge task with LTCG turned on). Look at CE_TODO in the source code.

In order to add linux support you would AT LEAST need to update the calling conventions in sign_func.cpp from thiscall to cdecl on linux/gcc (and of course add the required gamedata).
The amount of gamedata this extension requires is insane. It also detours quite a lot of functions with CDetour so I imagine compatibility with other extension's isn't the best.

Credits:
raydan
Obsidian Conflict
pred and all CEntity developers
Peace-Maker
Attached Files
File Type: zip maps.zip (4.46 MB, 19 views)
File Type: zip package.zip (19.4 KB, 20 views)

Last edited by donrevan; 03-19-2018 at 18:07.
donrevan is offline
raydan
Senior Member
Join Date: Aug 2006
Old 03-20-2018 , 02:14   Re: [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #2

i am surprise someone still interest in this, it almost 7 years old.
the public version stop update at 2012, but i still adding all HL2 npc in my own version until 2014. i remeber a buggy race in cs:s old day. then i don't play anymore and stop update it.
after 3 years checked someone updated it and make it work, nobody try adding new npc?
i think it time to release my latest version in 2014, let someone keep update it. and i am sure those sign need to update, but not for me.

if server crash or freeze, there are a "bug" https://bugs.alliedmods.net/show_bug.cgi?id=4946
old day, my server compile with updated "tier1.lib", i don't know valve changed or not right now

checked all source code in google are gone

these new entity not in public
Code:
npc_helicopter
npc_enemyfinder
npc_enemyfinder_combinecannon
npc_cscanner
npc_clawscanner
npc_barnacle
npc_combinegunship
npc_strider
npc_combine_camera
bounce_bomb
npc_zombine
npc_combinedropship
npc_turret_ceiling
npc_turret_ground
npc_barney
npc_alyx
npc_sniper
npc_metropolice
npc_citizen
npc_hunter
prop_combine_ball
prop_vehicle_jeep
raydan is offline
donrevan
AlliedModders Donor
Join Date: Jul 2010
Old 03-20-2018 , 08:52   Re: [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #3

Quote:
Originally Posted by raydan View Post
i am surprise someone still interest in this, it almost 7 years old.
the public version stop update at 2012, but i still adding all HL2 npc in my own version until 2014. i remeber a buggy race in cs:s old day. then i don't play anymore and stop update it.
after 3 years checked someone updated it and make it work, nobody try adding new npc?
i think it time to release my latest version in 2014, let someone keep update it. and i am sure those sign need to update, but not for me.

if server crash or freeze, there are a "bug" https://bugs.alliedmods.net/show_bug.cgi?id=4946
old day, my server compile with updated "tier1.lib", i don't know valve changed or not right now

checked all source code in google are gone

these new entity not in public
Code:
...
That'd be great - I already added some more NPCs but it looks like you have even more! It should be possible to merge both versions because the gamedata in this version is updated and working fine.

Did you add HL2 weapons or mapped CS:S weapons to HL2 animations for enemies? (npc_create_equipment for metropolice, combine etc.)

This extension has just too much code haha
donrevan is offline
raydan
Senior Member
Join Date: Aug 2006
Old 03-21-2018 , 02:29   Re: [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #4

https://github.com/raydan/npc-in-css
source code stop update at 2014, compile/reference with hl2sdk2013

i will try answer questions about the code, let see who can make it work

files in "_game_server_files"
Code:
*"monster.cstrike.games.txt" outdated
*unzip "monster.zip" to "custom" folder
*put "monster_download.txt" to "addons\sourcemod\configs" folder, use for "monster_core.sp"
*put "skill.cfg" to "cfg" folder
*upzip "stripper.zip" to "addons\stripper", use for  Stripper:Source extension
*"monster.sp" use for coop server, outdated need update
player regen health, show aiming npc name & health
show player death message by using a bot
start map vote at end game, "monster_map_end" command call from "CE_CGameEnd::AcceptInput"
"mp_playercollide" console var for player noclip each other
the following are unsolve/bug/missing/notes
Code:
*npc_combine_cannon
missing npc_combine_cannon

*CGrenadeHelicopter create bug
grenade_helicopter or grenade can't spawn, not sure

*momentary_rot_button, see CE_CMomentaryRotButton
rotate over 360 degree, it look like reset 0.
i created a map to test momentary_rot_button open a door, it work in hl2dm, but no in cs:s
i found the problem from "oc_manor" map, decompile it and get momentary_rot_button to make a test map

*door can't open
there was a map(can't remember the map name, player are inside a house),
there is door can't open(press E), but i remember it working and i finished that map before.
and i was try decompile it and copy the door to make a test map, it work in hl2dm, but no in cs:s
may be added some new code make trace ray or something broken

*patch.cpp CleanUpMap
it try fix round restart make some entity(info_target) position/angle go wrong
in cs:s it auto call "round draw/TerminateRound" when first player join game, then some entity position/angle go wrong
problem happen in hl2dm too, but hl2dm no round restart. you can call it manually
example:
the last boss in coop_zelda01_b
any func_tank, example map tbr_coop_thousand_antlions_v3b

*patch.cpp CAI_NetworkBuilder_Build
see hl2sdk CAI_NetworkBuilder::Build. "ai_network_build_helper" not exists, that is only way to do it

*patch.cpp LoadNetworkGraph
see hl2sdk CAI_NetworkManager::LoadNetworkGraph. it try to bypass "AINET_VERSION_NUMBER" checking
it try to patch "DevMsg( "Checking version\n" );" 7 bytes
make it load *.ain directly from "maps\graphs", some .bsp packed .ain inside

*weapon_replace.cpp
there are weapon_rpg(weapon_flashbang), weapon_physcannon(weapon_c4)

*prop_vehicle_jeep
not sure it working

*new macros DECLARE_HOOK_SUBCLASS
see hl2sdk CAI_NPC::OnCalcBaseMove, Inherited from IAI_MotorMovementServices
not sure that is the correct way to do that
coop server.cfg setting, tickrate 33, 16 players
Code:
mp_playercollide 0
sv_pure 0
sv_lan 0
sv_airaccelerate 10
sv_gravity 800
mp_humanteam CT
mp_ignore_round_win_conditions 1
sv_hudhint_sound 0
sv_enablebunnyhopping 1
mp_buytime 0.5
mp_startmoney 1
mp_c4timer 45
mp_flashlight 1
mp_footsteps 1
mp_falldamage 1
mp_hostagepenalty 0
mp_timelimit 0
mp_winlimit 0
mp_maxrounds 0
mp_roundtime 1
mp_freezetime 0
mp_autoteambalance 0
mp_limitteams 0
mp_friendlyfire 0
mp_tkpunish 0
mp_autokick 0
mp_spawnprotectiontime 10
sv_timeout 60
mp_forcecamera 0
mp_allowspectators 1
sv_parallel_sendsnapshot 0
sv_parallel_packentities 0
sv_maxrate 1000000
sv_minrate 1000000
sv_maxupdaterate 33
sv_minupdaterate 33
fps_max 0
rate 1000000
sv_mincmdrate 33
sv_maxcmdrate 33
sv_cheats 0
sv_pausable 0
mp_chattime 8
mp_restartgame 0
phys_pushscale 1
sv_disablefreezecam 1
sv_nonemesis 1
sv_nomvp 1
sv_allow_wait_command 0
list of npc:
Code:
npc_headcrab
npc_headcrab_fast
npc_headcrab_black
npc_fastzombie
npc_fastzombie_torso
npc_zombie_torso
npc_zombie
npc_poisonzombie
npc_manhack
npc_antlionguard
npc_stalker
npc_antlion
npc_vortigaunt
npc_rollermine
env_headcrabcanister
npc_turret_floor
npc_combine_s
npc_helicopter
npc_enemyfinder
npc_enemyfinder_combinecannon
npc_cscanner
npc_clawscanner
npc_barnacle
npc_combinegunship
npc_strider
npc_combine_camera
bounce_bomb
npc_zombine
npc_turret_ceiling
npc_turret_ground
npc_crow
npc_seagull
npc_pigeon
npc_breen
npc_barney
npc_alyx
npc_eli
npc_gman
npc_kleiner
npc_dog
npc_monk
npc_mossman
npc_sniper
npc_metropolice
npc_citizen
npc_bullsquid
npc_houndeye
npc_hunter
npc_advisor
list of maps tested long ago
Code:
above_the_fallen_day2b
cl_coop_laserquest_b3
cl_coop_level1_escape
cl_coop_level2_survive_v6
cl_coop_level3_topside_b2
coop_canals_v4_r1
coop_citadel_escape_p6
coop_level01_dooms_entry_v1b
coop_level02_traps_v1c
coop_level07_scary_house_fix2
coop_meows_fun_day_out_z1
coop_meows_island_defence
coop_meows_sewer_mania_v4
coop_meows_symphony_eight_v_4
coop_meows_tower_of_babel_v_4
coop_missile_silo214
coop_mw_revenge_ttc_v1
coop_npcwar3_aldo
coop_resident_evil_sg_zb4
coop_resistance_part1_v1c
coop_wardogs_v5
coop_zelda01_b
jr_coop_undergroundescape_v1
js_coop_2fort_teleport_p1
js_coop_combine2_sg_b4
js_coop_combine2_ttc_p5
js_coop_dasole2_ttc_b1
js_coop_dasole2_v4
js_coop_haunted_house_v20
js_coop_missiontwo_v1f
js_coop_part2_powerworks_v1a
js_coop_part2_waterworks_v3
js_coop_part3_waterworks_v2
js_coop_powerworks_v2
js_coop_save_dog_tbr_v5
js_coop_save_scientist_v2
js_coop_shore_v6
js_coop_siege_v4
js_coop_stargate_p9
js_coop_swampthing_x_v3
js_coop_tbr_[a1]_ttc_v5a
js_coop_teleport_sg_zb3
js_coop_teleport_v9
js_coop_thunder_b4
js_coop_waterworks_ttc_v3
js_c_citadel_blast_hdr_fix11
js_lm_coop_underground_v4b
level04_across_the_darkness3a
level05_diehard_fix2
level06_the_base
level08_a_place_to_die_a4
level10_end_of_evil_a2
mph_fire_pit_final_v5
mph_rebel_incursionv2
nobeloffice
oc_big_gappoi_v6m
oc_danmaku_i
oc_inlight
oc_manor
oc_newgappi_g
oc_sogeki_v2b
Poison_Coop_RE1_Beta1
sg_coop_resistance_b2
sg_coop_runoff_zb
sg_coop_steamlab_b5
sp_sawlife2
synb2_diehard
synb2_school_for_freshman
synb2_underground
syn_across_the_darkness_b3
syn_breenoffice_v1c
syn_broken_escape_part1
syn_d_crimson_v1c
syn_lvcoop_part1
syn_lvcoop_part2
syn_starship_oblivion
tbr_coop_thousand_antlions_v3b
reference:
Code:
view page source code: http://www.facepunch.com/threads/807565-Applying-Patch-files
https://bugs.alliedmods.net/show_bug.cgi?id=4946
Obsidian Conflict
Synergy
found some test map and tested them in hl2dm & gmod today, in attachments
Code:
*test.bsp
*test3.bsp
momentary_rot_button
"key" entity from coop_zelda01_b, inside "stripper.zip" it try to fix
cs:s m_vDuckHullMax higher then hl2dm
*test_bug1.bsp
hl2dm crash
gmod work
should fixed in the extension
*test_bug2.bsp
CTriggerHurt::HurtAllTouchers
should fixed in the extension
*test_crash2.bsp
ShouldRemoveThisRagdoll
hl2dm crash
gmod work
should fixed in the extension
Attached Files
File Type: zip maps.zip (70.8 KB, 8 views)

Last edited by raydan; 03-21-2018 at 10:35.
raydan is offline
blacklagoon
Senior Member
Join Date: Jun 2012
Old 03-30-2018 , 09:16   Re: [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #5

Had some free time and got a successfull binary compiled against csgosdk can't test though, with donrevan's version.

Ain't got no server to test the build and i would be pretty bad at sigscanning and finding required offsets on windows but i'd gladly share the src if you think it's worth gaining your time if it's still on your to do list.

Last edited by blacklagoon; 04-02-2018 at 04:56.
blacklagoon is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Old 04-06-2018 , 15:19   Re: [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #6

If need help finding signatures for linux/windows CS:S, don't hesitate asking me. Just drop them here or... skype.
Linux code and Signatures can be taken from here https://forums.alliedmods.net/showthread.php?t=268065 it doesn't include all of them though.
Btw some of the signature hooks are excessive and can be avoided... those for emitting sounds and testing collision and some others.
I spent months trying to bring this extension to linux platform, unfortunately there are constructions that are extremely difficult to understand.
raydan, could you please share your expirience with us?, how did you get to the decisions you used in this extensions and all these signatures for windows... it's even hard to find them for linux, but windows binaries provide no clues at all.

Last edited by kadet.89; 04-06-2018 at 15:54.
kadet.89 is offline
Send a message via Skype™ to kadet.89
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 04-06-2018 , 15:53   Re: [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #7

Quote:
Originally Posted by kadet.89 View Post
If need help finding signatures for linux/windows CS:S, don't hesitate asking me. Just drop them here or... skype.
Some of the signatures and linux code can be taken from here https://forums.alliedmods.net/showthread.php?t=268065
I spent months trying to bring this extension to linux platform, unfortunately there are constructions that are extremely difficult to understand.
raydan, could you please share your expirience with us?, how did you get to the decisions you used in this extensions and all these signatures for windows... it's even hard to find them for linux, but windows binaries provide no clues at all.
On linux alot of functions are inlined

EDIT: On CS:GO and TF2 that is, don't know about CS:S
__________________

Last edited by Pelipoika; 04-06-2018 at 17:24.
Pelipoika is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Old 04-07-2018 , 05:25   Re: [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #8

Pelipoika, well, I wouldn't say many, yes, I met some but for me it wasn't a problem because such functions are quite short and can be implemented without any problems.
raydan, could you share the maps?

Last edited by kadet.89; 04-07-2018 at 10:59.
kadet.89 is offline
Send a message via Skype™ to kadet.89
donrevan
AlliedModders Donor
Join Date: Jul 2010
Old 04-07-2018 , 21:06   Re: [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #9

Quote:
Originally Posted by kadet.89 View Post
Btw some of the signature hooks are excessive and can be avoided... those for emitting sounds and testing collision and some others.
Yes and only about 90% of the actual gamedata is being used. A patch would be great!

Quote:
Originally Posted by kadet.89 View Post
I spent months trying to bring this extension to linux platform, unfortunately there are constructions that are extremely difficult to understand.
Where do you have problems understanding it? Maybe I can help you.

Quote:
Originally Posted by kadet.89 View Post
... all these signatures for windows... it's even hard to find them for linux,
but windows binaries provide no clues at all.
It isn't a difficult task, it's just time consuming. CS:S has very little inlined functions and once you have the old cs:s binary (the original signatures match to) it's easy to spot when looking at the source at the same time (most of the time).
donrevan is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Old 04-08-2018 , 06:34   Re: [EXTENSION] NPCs in CS:S (extended)
Reply With Quote #10

Here is my first try to build the extension for linux:

HTML Code:
In file included from /home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/AI/CAI_Navigator.h:16:0,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/Class/CAI_NPC.h:10,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/Class/CCycler_Fix.h:5,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.h:6,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.cpp:2:
/home/d/SDK/hl2sdk-css/game/shared/simtimer.h: In member function ‘void CSimpleSimTimer::Set(float, float)’:
/home/d/SDK/hl2sdk-css/game/shared/simtimer.h:57:42: error: request for member ‘RandomFloat’ in ‘random’, which is of non-class type ‘long int() throw ()’
    m_next = gpGlobals->curtime + random->RandomFloat( minInterval, maxInterval );
                                          ^
/home/d/SDK/hl2sdk-css/game/shared/simtimer.h: In member function ‘void CRandSimTimer::Set(float, float, bool)’:
/home/d/SDK/hl2sdk-css/game/shared/simtimer.h:141:43: error: request for member ‘RandomFloat’ in ‘random’, which is of non-class type ‘long int() throw ()’
     m_next = gpGlobals->curtime + random->RandomFloat( m_minInterval, m_maxInterval );
                                           ^
/home/d/SDK/hl2sdk-css/game/shared/simtimer.h: In member function ‘void CRandSimTimer::Reset()’:
/home/d/SDK/hl2sdk-css/game/shared/simtimer.h:150:42: error: request for member ‘RandomFloat’ in ‘random’, which is of non-class type ‘long int() throw ()’
    m_next = gpGlobals->curtime + random->RandomFloat( m_minInterval, m_maxInterval );
                                          ^
/home/d/SDK/hl2sdk-css/game/shared/simtimer.h: In member function ‘void CRandStopwatch::Start(float, float)’:
/home/d/SDK/hl2sdk-css/game/shared/simtimer.h:281:42: error: request for member ‘RandomFloat’ in ‘random’, which is of non-class type ‘long int() throw ()’
    m_next = gpGlobals->curtime + random->RandomFloat( minOverride, maxOverride );
                                          ^
In file included from /home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/Class/CAI_NPC.h:27:0,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/Class/CCycler_Fix.h:5,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.h:6,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.cpp:2:
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/AI/CAI_Squad.h: In static member function ‘static void* CAI_Squad::operator new(size_t)’:
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/AI/CAI_Squad.h:204:19: error: ‘g_pMemAlloc’ was not declared in this scope
   void *pResult = g_pMemAlloc->Alloc( nBytes );
                   ^
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/AI/CAI_Squad.h: In static member function ‘static void* CAI_Squad::operator new(size_t, int, const char*, int)’:
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/AI/CAI_Squad.h:211:19: error: ‘g_pMemAlloc’ was not declared in this scope
   void *pResult = g_pMemAlloc->Alloc( nBytes, pFileName, nLine );
                   ^
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/AI/CAI_Squad.h: In static member function ‘static void CAI_Squad::operator delete(void*)’:
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/AI/CAI_Squad.h:218:3: error: ‘g_pMemAlloc’ was not declared in this scope
   g_pMemAlloc->Free(pMem);
   ^
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/AI/CAI_Squad.h: In static member function ‘static void CAI_Squad::operator delete(void*, int, const char*, int)’:
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/AI/CAI_Squad.h:222:3: error: ‘g_pMemAlloc’ was not declared in this scope
   g_pMemAlloc->Free(pMem);
   ^
In file included from /home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/CEntity.h:100:0,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.h:5,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.cpp:2:
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/Class/CAI_NPC.h: In member function ‘virtual void CNPCBaseInteractive<NPC_CLASS>::InitDataMap()’:
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/macros.h:42:56: error: there are no arguments to ‘BaseEntity’ that depend on a template parameter, so a declaration of ‘BaseEntity’ must be available [-fpermissive]
   datamap_t *pMap = gamehelpers->GetDataMap(BaseEntity()); \
                                                        ^
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/Class/CAI_NPC.h:2019:2: note: in expansion of macro ‘CE_DECLARE_CLASS’
  CE_DECLARE_CLASS( CNPCBaseInteractive, NPC_CLASS );
  ^
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/macros.h:42:56: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
   datamap_t *pMap = gamehelpers->GetDataMap(BaseEntity()); \
                                                        ^
/home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/Class/CAI_NPC.h:2019:2: note: in expansion of macro ‘CE_DECLARE_CLASS’
  CE_DECLARE_CLASS( CNPCBaseInteractive, NPC_CLASS );
  ^
In file included from /home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.cpp:2:0:
/home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.h: At global scope:
/home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.h:11:6: error: use of enum ‘Entity_Function’ without previous declaration
 enum Entity_Function;
      ^
/home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.cpp: In member function ‘void CE_NPC_Custom::CE_PostInit()’:
/home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.cpp:84:2: error: ‘CE_PostInit’ is not a member of ‘CE_NPC_Custom::BaseClass {aka CE_Cycler_Fix}’
  BaseClass::CE_PostInit();
  ^
/home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.cpp:96:34: error: invalid conversion from ‘unsigned char*’ to ‘size_t {aka unsigned int}’ [-fpermissive]
   memset(member_data, 0, sm_npc->original_member_data);
                                  ^
In file included from /home/d/SDK/hl2sdk-css/public/tier0/platform.h:56:0,
                 from /home/d/SDK/hl2sdk-css/public/tier0/basetypes.h:11,
                 from /home/d/SDK/hl2sdk-css/public/mathlib/vector.h:20,
                 from /home/d/SDK/hl2sdk-css/public/datamap.h:15,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/extension.h:4,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/CEntity/CEntity.h:82,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.h:5,
                 from /home/d/SDK/sourcemod/extensions/npc/Extension/SM/npc_custom.cpp:2:
/usr/include/string.h:62:14: note:   initializing argument 3 of ‘void* memset(void*, int, size_t)’
 extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
The SDK is about 1 year old... you can see all kinds of errors here, there are SDK problems and platform-specific problems and not sure about g_pmAlloc. A fast glance showed no roots for this variable. There are problems with the names of files as linux is case-sensitive. Well, and more errors is yet to come, ambuild doesn't show all of them.
Based on 4284d24

For playing sounds in CSS I use IEngineSound:
Code:
#include "engine/IEngineSound.h"
IEngineSound *engsound = NULL;
bool Extension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	GET_V_IFACE_ANY(GetEngineFactory, engsound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
}
That's the way it works here: https://forums.alliedmods.net/showthread.php?t=268065
It provides all kinds of interfaces and can be used instead of EmitSound hooks.

For DispatchEffect TE_DispatchEffect can be used (or not... not sure):
Code:
	IServerTools *servertools = NULL;
	bool Tracer::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
	{
		GET_V_IFACE_ANY(GetServerFactory, servertools, IServerTools, VSERVERTOOLS_INTERFACE_VERSION);
	}
	ITempEntsSystem * tesystem = servertools->GetTempEntsSystem();
SetVariantString("ParticleEffectStop");
AcceptEntityInput(entity, "DispatchEffect");
Code:
	char conf_error[255];
	if (!gameconfs->LoadGameConfigFile("sdktools.games", &g_pGameConf, conf_error, sizeof(conf_error)))
	{
		if (error)
		{
			#if defined SHOW_MSG
			g_pSM->LogError(myself, "Could not read sdktools.games: %s", conf_error);
			#endif
		}
		return false;
	}
	int offset = 0;
	
	if(!g_pGameConf->GetOffset("AcceptInput", &offset) || !offset) {
		#if defined SHOW_MSG
		g_pSM->LogError(myself, "AcceptInput offset is broken");
		#endif
		gameconfs->CloseGameConfigFile(g_pGameConf);
		return false;
	}

	SH_MANUALHOOK_RECONFIGURE(AcceptInput,offset,0,0);

SH_DECL_MANUALHOOK5(AcceptInput, 0, 0, 0, bool, const char *, CBaseEntity *, CBaseEntity *, variant_t, int);
SH_MCALL(pEntity, AcceptInput)("DispatchEffect", pEntity, pEntity, value, 0);
SDKHooks can be used to control entities:

Code:
#include <ISDKHooks.h>
ISDKHooks *g_pSDKHooks = NULL;

bool Extension::SDK_OnLoad(char *error, size_t maxlength, bool late)
{	
	if(!g_pGameConf->GetOffset("PostThink", &offset) || !offset) {
		#if defined SHOW_MSG
		g_pSM->LogError(myself, "PostThink offset is broken");
		#endif
		gameconfs->CloseGameConfigFile(g_pGameConf);
		return false;

	}
	//Spawn
	//SetTransmit
	//PreThink...
	//All kinds of vhooks
	sharesys->AddDependency(myself, "sdkhooks.ext", true, true);   
	SM_GET_IFACE(SDKHOOKS, g_pSDKHooks);
	if (g_pSDKHooks != NULL)
	{
		g_pSDKHooks->AddEntityListener(&g_entlistener);
	}  
}
void Extension::SDK_OnUnload()
{
	if (g_pSDKHooks != NULL)
	{
		g_pSDKHooks->RemoveEntityListener(&g_entlistener);
	}
}
GameRules can be taken from sdktools:
https://sm.alliedmods.net/new-api/sd...eRules_GetProp

Collision tests:
Code:
#include <IEngineTrace.h>
class CTraceFilterPhysicsEntity : public CTraceFilterEntitiesOnly
{
public:
	CTraceFilterPhysicsEntity()
	{
	}
	virtual bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask)
	{
		CBaseEntity *pEntity = (CBaseEntity *) pServerEntity;
		char *classname = CHelper::getClassname(pEntity);
		if(!classname || !strstr (classname, "prop_physics")) {
			return false; 
		}
		return true;
	}
};
IEngineTrace *enginetrace = NULL;
bool Extension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	GET_V_IFACE_ANY(GetEngineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER);
}
	Ray_t ray;
	ray.Init(eye_position, vec_end);
	
	trace_t tr;
	CTraceFilterEntity simple(pEdict->GetIServerEntity());	
	enginetrace->TraceRay(ray, MASK_SOLID|CONTENTS_DEBRIS|CONTENTS_HITBOX, &simple, &tr);	
	if (tr.fraction == 1.0f)
	{
		return NULL;
	}
Attached Files
File Type: 7z npc.7z (753.6 KB, 7 views)

Last edited by kadet.89; 04-08-2018 at 08:11.
kadet.89 is offline
Send a message via Skype™ to kadet.89
Reply


Thread Tools
Display Modes

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 03:50.


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