Before I begin:
Yes, I know this would be easier with engine, but I don't want to use engine, I want to use fakemeta, please respond with code that uses fakemeta, not engine
Ok, like the title says, I'm trying to make an entity think, I've done dllfunc(DLLFunc_Think, ent) and all that, but I still won't work. The forward is being called (I've set up some logging as you see), which means it works, its just that my entity won't think :/
Code that creates the entity:
Code:
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
dllfunc(DLLFunc_Spawn, ent);
set_pev(ent, pev_classname, "rpg_rocket");
set_pev(ent, pev_movetype, 5);
set_pev(ent, pev_solid, 2);
set_pev(ent, pev_owner, id);
set_pev(ent, pev_origin, origin);
set_pev(ent, pev_nextthink, engfunc(EngFunc_Time) + 0.1);
engfunc(EngFunc_SetSize, ent, Float:{0.1,0.1,0.1}, Float:{0.1,0.1,0.1});
engfunc(EngFunc_SetModel, ent, "models/rpgrocket.mdl");
engfunc(EngFunc_SetOrigin, ent, origin);
Think code (Yes, forward is registered or else logging wouldn't work):
Code:
public Forward_Think(ent)
{
new classname[32];
pev(ent, pev_classname, classname, 31);
log_amx("Think: %s", classname);
if (!equal(classname, "rpg_rocket"))
return;
new owner = pev(ent, pev_owner);
new RocketMode:mode = gRocketMode[owner];
new Float:velocity[3];
switch (mode)
{
case MODE_RC:
{
velocity_by_aim(owner, RPG_ROCKET_SPEED, velocity);
pev(ent, pev_velocity, velocity);
}
case MODE_HEAT:
{
new target = pev(ent, pev_target);
if (is_user_alive(target))
{
new Float:origin[3];
new Float:entOrigin[3];
new Float:velocity[3];
new Float:speed;
pev(target, pev_origin, origin);
pev(ent, pev_origin, entOrigin);
speed = (float(RPG_ROCKET_SPEED)/ 100.0);
velocity[0] = (origin[0] - entOrigin[0]) * speed;
velocity[1] = (origin[1] - entOrigin[1]) * speed;
velocity[2] = (origin[2] - entOrigin[2]) * speed;
set_pev(ent, pev_velocity, velocity);
}
else // Lets see if we can find another target...
{
new origin[3];
pev(owner, pev_origin, origin);
new players[32];
new player;
new numFound;
get_players(players, numFound, "a");
new closestPlayer;
new lastClosestDist = 99999;
new i;
for (i = 0; i < numFound; i++)
{
player = players[i];
new checkOrigin[3];
pev(player, pev_origin, checkOrigin);
if (get_distance(origin, checkOrigin) < lastClosestDist)
closestPlayer = player;
}
if (is_user_alive(closestPlayer))
set_pev(ent, pev_target, closestPlayer);
else // Oh well, lets explode
{
Explode(ent);
return;
}
}
}
}
new Float:angles[3];
vector_to_angle(velocity, angles);
pev(ent, pev_angles, angles);
new smokeOrigin[3];
pev(ent, pev_origin, smokeOrigin);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_SPRITE) // additive sprite, plays 1 cycle
write_coord(smokeOrigin[0])
write_coord(smokeOrigin[1])
write_coord(smokeOrigin[2]) // coord, coord, coord (position)
write_short(gSprRocketTrail) // short (sprite index)
write_short(20) // byte (scale in 0.1's)
write_short(255) // byte (brightness)
message_end()
set_pev(ent, pev_nextthink, engfunc(EngFunc_Time) + 0.1);
dllfunc(DLLFunc_Think, ent);
}
After, posting this, I realized that I wasn't returning any of the FMRES_* return constants, would that have anything to do with it?
Thank you for any and all help.
__________________