Raised This Month: $51 Target: $400
 12% 

How do I do things with Entities?


Post New Thread Reply   
 
Thread Tools Display Modes
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 09-01-2005 , 00:25  
Reply With Quote #41

Well, I'm using HLDS, not HLTV, but you might got something going there, maybe HLTV activates when I activate my HLDS. Don't know I'll see what I can do about that.

EDIT: Okay, I just kinda browsed through the hltv.cfg, and I don't see anything that enables the hltv or disables it. Maybe I'm not looking at it right, could someone make sure?

SECOND EDIT: Okay, I just found out that the animation code in my decay_effects() function was the thing that was causing the error message and the thing that caused people to be kicked from the server, don't know why though.

THIRD EDIT: Fixed the animation code.

FOURTH EDIT: Okay I found a very similar function of touch in the Vexd_Utilities, it's called vexd_pfntouch(pToucher, pTouched), and I was wondering if that would also works with inanimate objects, because pfn_touch(ptr, ptd) does not work.
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 09-01-2005 , 15:55  
Reply With Quote #42

Okay, I debugged pretty much everything, but there is still one thing that doesn't work, and that is the fact that nothing happens when my entity touches the wall!!!! I'm frusterated about this, and really really don't know how to fix this, someone please give me advice on what to do!!! Thank you. Here's a little piece of my code:

Code:
//------------------------------------------------------------------------------------ public plugin_init() {     register_plugin("SUPERHERO Cell", "1.0", "Gorlag/Batman")     //THE CVARS     register_cvar("cell_level", "1")     register_cvar("cell_damage", "1000")     register_cvar("cell_radius", "50")     register_cvar("cell_cooldown", "50")     register_cvar("cell_diskspeed", "750")     register_cvar("cell_disklife", "50")     register_cvar("cell_blastdecal", "1")     //THIS LINE MAKES THE HERO SELECTABLE     shCreateHero(gHeroName, "Energy Disk", "Unleash an energy disk and take control of where it flies!", true, "cell_level")     //INITIAL ACTIONS     register_srvcmd("cell_init", "cell_init")     shRegHeroInit(gHeroName, "cell_init")     //KEY DOWN COMMAND     register_srvcmd("cell_kd", "cell_kd")     shRegKeyDown(gHeroName, "cell_kd")     //SPAWNING EVENT     register_event("ResetHUD", "newSpawn", "b")     //THIS EVENT IS TRIGGERED WHEN SOMEONE DIES     register_event("DeathMsg", "cell_kill", "a")     //SET THE LIFE OF THE DISK     set_task(0.1, "cell_disklife", 0, "", 0, "b")     //IF "*" is in there then it's a wildcard for any classname in pTouched[]     register_touch("disk", "*", "touch_event")     for(new id = 1; id <= SH_MAXSLOTS; id++)         diskTimer[id] = -1 } //-------------------------------------------------------------------------------------- public fire_disk(id) {     //Makes an array of origin in the (x,y,z) coordinate system.     new origin[3]     //Makes an array of velocity, specifically in the (x,y,z) coordinate system     new velocity[3]     get_user_origin(id, origin, 0)     new Float:fOrigin[3], Float:fVelocity[3]     new Float: minBound[3] = {-50.0, -50.0, 0.0}     new Float: maxBound[3] = {50.0, 50.0, 0.0}     origin[2] += 50  //This line is same as origin[2] = origin[2] + 50     IVecFVec(origin, fOrigin)     NewEnt = CreateEntity("info_target")  //Makes an object     entity_set_string(NewEnt, EV_SZ_classname, "disk")     //This tells what the object will look like     ENT_SetModel(NewEnt, "models/shmod/friezadisc.mdl")     //This will set the origin of the entity     entity_set_vector(NewEnt, EV_VEC_origin, fOrigin)     //This will set the movetype of the entity     entity_set_int(NewEnt,EV_INT_movetype, MOVETYPE_NOCLIP)     entity_set_int(NewEnt, EV_INT_solid, SOLID_TRIGGER)     //This will set the velocity of the entity     velocity_by_aim(id, get_cvar_num("cell_diskspeed"), fVelocity)     FVecIVec(fVelocity, velocity)     entity_set_size(NewEnt, minBound, maxBound)     entity_set_edict(NewEnt, EV_ENT_owner, id)     //This will set the entity in motion     entity_set_vector(NewEnt, EV_VEC_velocity, fVelocity) } //-------------------------------------------------------------------------------------- public touch_event(pToucher, pTouched)  //ptr is the toucher, and ptd is the touched! {     //Checks to make sure that the entity is valid!     if(!is_valid_ent(pToucher) || !is_valid_ent(pTouched))     return PLUGIN_CONTINUE      //Now to deal the damage to the victim (touched) and remove the toucher (the disk)     new resulting_string[32]  //Makes a new empty string that will store 31 characters.     //Allows you to retrieve the entity of the toucher, in this case the disk.     entity_get_string(pToucher, EV_SZ_classname, resulting_string, 31)     //Now because the data above is a string, the "==" would not work, when comparing.     //Instead use the equal method.     //Makes sure that the toucher entity is the disk.     if(equal(resulting_string, "disk")){     fake_touch(pToucher, pTouched)         new aimvec[3], Float:fAimvec[3]  //This is the position where the disk collides         entity_get_vector(pTouched, EV_VEC_origin, fAimvec)         FVecIVec(fAimvec, aimvec)      special_effects(pToucher, pTouched, aimvec)     }     return PLUGIN_CONTINUE } //----------------------------------------------------------------------------------------- public special_effects(pToucher, pTouched, aimvec[3]) {     new Float:fVelocity[3]     new velocity[3]     new damage     entity_get_vector(pToucher, EV_VEC_velocity, fVelocity)     FVecIVec(fVelocity, velocity)     //Got to know who's the one using the disk     //So that when the victim dies, he knows who's the killer     //That used the disk     new killer = entity_get_edict(pToucher, EV_ENT_owner)     if(is_user_connected(pTouched) && is_user_alive(pTouched)){         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)         write_byte(103)  //BLOOD         write_coord(aimvec[0])         write_coord(aimvec[1])         write_coord(aimvec[2])         write_coord(velocity[0])         write_coord(velocity[1])         write_coord(velocity[2])         write_byte(248)         write_byte(100)         message_end()         damage = get_cvar_num("cell_damage")         new victim = pTouched         shExtraDamage(victim, killer, damage, "Frieza's Energy Disk")     }     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)     write_byte(9)  //SPARKS     write_coord(aimvec[0])     write_coord(aimvec[1])     write_coord(aimvec[2])     message_end() } //-----------------------------------------------------------------------------------------
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 09-01-2005 , 23:11  
Reply With Quote #43

Code:
public touch_event(pToucher, pTouched)  //ptr is the toucher, and ptd is the touched! {     client_print(0, print_chat, "* [DEBUG] Disk %i hit Entity %i", pToucher, pTouched);     new Float:origin[3], Float:flOrigin[3]     entity_get_vector(pToucher, EV_VEC_origin, flOrigin)     FVecIVec(flOrigin,origin)     // can't hit owner     if(pTouched == entity_get_edict(pToucher, EV_ENT_owner)) {         return PLUGIN_HANDLED     }     // hit world or entity besides player     if(!is_valid_ent(pTouched) || !is_user_connected(pTouched)) {         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)         write_byte(9)  //SPARKS         write_coord(floatround(flOrigin[0]))         write_coord(floatround(flOrigin[1]))         write_coord(floatround(flOrigin[2]))         message_end()         remove_entity(pToucher);         return PLUGIN_CONTINUE     }     fakedamage(pTouched, "freeza_disk", 50.0, 0)     special_effects(pToucher, pTouched, origin)     remove_entity(pToucher)     return PLUGIN_CONTINUE }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 09-02-2005 , 01:07  
Reply With Quote #44

Well, thanks for the code, hopefully that'll fix it =D. But I want my disk to hurt the user as well lol. Cause if you watch the show DBZ, frieza gets sliced by his own attack.

EDIT: Hmm, fakedamage, don't know what it does, but I'll check it out =D. And thanks again avalanche.
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 09-02-2005 , 05:22  
Reply With Quote #45

Okay, thanks to your debugging stuff, my disk in no-clip mode doesn't touch "entity 0" i.e. the inanimate objects. But when I set it to fly mode, it does touch the walls and stuff, BUT it still doesn't do the animation, but the disk in fly mode, is really really laggy. So I'm going to leave the movetype to noclip mode, and I have a better idea of how to make animation appear through the walls. I'll use the entity_get_distance(pToucher, 0) in my loop.

Thanks avalanche really appreciate the help.

P.S. Someone should make something in the engine include to make 0 an entity constant, like this

Code:
#define ENTITY_NONPLAYER  0
I think that would be helpful =D.
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 09-02-2005 , 08:08  
Reply With Quote #46

Well, after looking at the entity_get_distance(), I realize I needed the coordinates of the disk, and the inanimate objects, but since inanimate objects are all over the place, this task of trying to make sparks on the wall seems impossible. I'm just gonna find some other animation to add.
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 09-05-2005 , 08:31  
Reply With Quote #47

Don't know but I was curious, is there any function that could make a model rotate, just by where you are facing? If so would it be dealing with angle vectors?
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag 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 01:25.


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