AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Aim vectors, detect impact, explosions (https://forums.alliedmods.net/showthread.php?t=93533)

moosewanted 05-30-2009 08:12

Aim vectors, detect impact, explosions
 
Hey,
I havn't really searched much on these matters as I normally would but I thought I may aswell.

Im basically creating a new weapon and asking for ideas on firing a rocket.

First I would create the rocket entity.

* What sort of movetype, TOSS?
* Should it be solid?
* The ent size
* Set the model

Then I would set the origin/rotation(so that it lines up with the direction the user is aiming in) - How would I do this?
PHP Code:

set_pev(g_ent_player_model[id], pev_aimentid

Then I would set the velocity- How would I do this?
PHP Code:

velocity_by_aim (idROCKET_SPEEDrocket_velocity

Then I would need to detect the impact origin of the rocket and make it explode - Any ideas on this?

On impact it would explode and cause damage in a radius - Using a sphere
PHP Code:

EngFunc_FindEntityInSphere 

And search for players?

Then the rocket would be deleted.




I understand that I can find most of this out by looking through plugins, but I have limited time and I intend to do it while waiting on this topic.

I appreciate any help.
Thanks

EDIT:Confused, this code works on a local server made by "create game" on the cs menu. But doesn't work when I put it on my server?

PHP Code:

#include <amxmodx>
#include <fakemeta>

#define MODEL_CLASSNAME "apache_rocket"
#define APACHE_ROCKET_MODEL_PATH "models/rpgrocket.mdl"
#define ROCKET_SPEED "800"

new g_rocket[33]

public 
plugin_precache()
{
    
engfunc(EngFunc_PrecacheModelAPACHE_ROCKET_MODEL_PATH)
}

public 
plugin_init()
{
    
register_concmd("fire_rocket","fm_fire_rocket")
}

public 
fm_fire_rocket(id)
{
    
g_rocket[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    
client_print(0print_chat"Create Named Enitiy")
    if(!
pev_valid(g_rocket[id])) return;

    
set_pev(g_rocket[id], pev_classnameMODEL_CLASSNAME)
    
client_print(0print_chat"Model Classname")
    
set_pev(g_rocket[id], pev_movetypeMOVETYPE_TOSS)
    
client_print(0print_chat"Movetype")
    
set_pev(g_rocket[id], pev_solidSOLID_BBOX)
    
client_print(0print_chat"SOLID BBOX")

    
engfunc(EngFunc_SetSize,g_rocket[id],Float:{-5.0,-5.0,-5.0},Float:{5.0,5.0,5.0})

    
set_pev(g_rocket[id], pev_ownerid)
    
client_print(0print_chat"owner")
    
engfunc(EngFunc_SetModelg_rocket[id], APACHE_ROCKET_MODEL_PATH)
    
client_print(0print_chat"MODEL")

    new 
Float:Origin[3]
    
pev(idpev_originOrigin)
    
Origin[2] = Origin[2] + 32
    engfunc
(EngFunc_SetOrigin,g_rocket[id],Origin)

    new 
Float:rocket_velocity[3]
    
velocity_by_aim (id800rocket_velocity)
    
client_print(0print_chat"VELOCITY")

    
set_pev(g_rocket[id], pev_velocityrocket_velocity)
    
client_print(0print_chat"set velocity")
    
set_task(5.0"remove_rocket"id)
    
client_print(0print_chat"Task")
}

public 
remove_rocket(id)
{
    
remove_task(id)
    
engfunc(EngFunc_RemoveEntityg_rocket[id])
    
client_print(0print_chat"Remove rocket")


Code is experimental.

Arkshine 05-30-2009 09:11

Re: Aim vectors, detect impact, explosions
 
Quote:

Then I would need to detect the impact origin of the rocket and make it explode - Any ideas on this?

On impact it would explode and cause damage in a radius - Using a sphere
Use register_touch() : register_touch( MODEL_CLASSNAME, "*", "Event_RocketTouch" ); Event_RocketTouch will be called when the rocket touches something or someone. For the radius damage, you could try radius_damage().


Quote:

But doesn't work when I put it on my server?
Can you give more informations ?

moosewanted 05-30-2009 09:16

Re: Aim vectors, detect impact, explosions
 
Quote:

Originally Posted by arkshine (Post 837980)
Can you give more informations ?

hmm

amxx plugins shows it loaded perfectly fine
same as amxmodmenu pause plugins menu

The debug messages I added don't appear
No entity is created

It just doesn't work, nothing happens

This is the console when it does work on a local server:
Code:

BUILD 4554 SERVER (0 CRC)
Server # 2
  VAC secure mode disabled.
L 05/30/2009 - 14:16:12: [admin.amxx] Login: "mystyle. >> moosewanted<11><STEAM_ID_LAN><>" became an admin (account "loopback") (access "abcdefghijklmnopqrstu") (address "loopback")
mystyle. >> moosewanted connected
mystyle. >> moosewanted is joining the Counter-Terrorist force
Scoring will not start until both teams have players
Type 'amx_langmenu' in the console to display a menu where you can choose your language
] fire_rocket
Type 'amx_help' in the console to see available commands
Time Left: 19:42 min. Next Map: cs_assault
Create Named Enitiy
Model Classname
Movetype
SOLID BBOX
owner
MODEL
VELOCITY
set velocity

Screenshot:
http://foolplay.co.uk/uploaded/allie...oilrig0000.bmp


This is on my hosted server:
Code:

[ 23] unknown                unknown    unknown          rocket_test2.am  running
Code:

] fire_rocket
] fire_rocket
] fire_rocket 
] fire_rock

basically doesn't do anything

Arkshine 05-30-2009 09:20

Re: Aim vectors, detect impact, explosions
 
When you write the command in the console ( in-game ) nothing happens ? If so try to use register_clcmd() instead.

moosewanted 05-30-2009 09:22

Re: Aim vectors, detect impact, explosions
 
Quote:

Originally Posted by arkshine (Post 837991)
When you write the command in the console ( in-game ) nothing happens ? If so try to use register_clcmd() instead.

I have tried this aswell :)

Arkshine 05-30-2009 09:50

Re: Aim vectors, detect impact, explosions
 
Plugin File open error = the compiled plugin *.amxx is not provided in plugins/ or the name provided in plugins.ini is not the same as the name in plugins/

moosewanted 05-30-2009 09:51

Re: Aim vectors, detect impact, explosions
 
Quote:

Originally Posted by arkshine (Post 838010)
Plugin File open error = the compiled plugin *.amxx is not provided in plugins/ or the name provided in plugins.ini is not the same as the name in plugins/

I just worked that out, but yeh, the same problem exists.
Now the plugin doesn't work with a listen server or a hosted server with: register_clcmd()

Arkshine 05-30-2009 09:57

Re: Aim vectors, detect impact, explosions
 
Saying it doesn't work, it doesn't help at all.

Make sure the plugin is loaded. The right plugin.
If loaded, where do you type the command ?
Are there errors in logs ?

You should see your debug, if not, it's not the right plugin.

moosewanted 05-30-2009 10:15

Re: Aim vectors, detect impact, explosions
 
Quote:

Originally Posted by arkshine (Post 838016)
Saying it doesn't work, it doesn't help at all.

Make sure the plugin is loaded. The right plugin.
If loaded, where do you type the command ?
Are there errors in logs ?

You should see your debug, if not, it's not the right plugin.

The plugin is loaded, the right one is loaded.
I type the command in the console.
Error logs? no? I'll go read the debugging plugins wiki, when it loads...
There are no debug messages.

See the 3rd post for the definition of: it doesn't work

Arkshine 05-30-2009 11:30

Re: Aim vectors, detect impact, explosions
 
You must use the console in-game since you use register_clcmd().


All times are GMT -4. The time now is 13:51.

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