Invisible monsters
Moderator: InsideQC Admins
4 posts
• Page 1 of 1
Invisible monsters
So I've set up monsters-only teleporting code, basically the usual teleporting code, with the player bits taken out and everything suitably renamed. All works well and monsters 'port in as they should, and it's all handled code-side.
What I'm now trying to do is make them invisible for a second when they 'port in (it's merely for aesthetic reasons), and then be visible as normal.
What I've done:
At the end of what is usually teleport_touch, but as said, renamed in this monsters only version, and after:
is:
'invisi_mode' is this:
(the centerprint is just so I know that it's going through all the stages I expect it to, its useful too, as originally I put the "other.model = ("");" in invisi_mode(), but then it didn't go to 'invisi_mode_think()' so I moved it)
Anyway, invisi_mode_think() is this:
(There's more for ogres as I'm testing it with them)
Anyway, and as you can guess, the monster stays invisible, but does 'port as expected.
Help please, especially to say if its possible...[/code]
What I'm now trying to do is make them invisible for a second when they 'port in (it's merely for aesthetic reasons), and then be visible as normal.
What I've done:
At the end of what is usually teleport_touch, but as said, renamed in this monsters only version, and after:
- Code: Select all
other.flags = other.flags - other.flags & FL_ONGROUND;
is:
- Code: Select all
other.model = ("");
invisi_mode();
'invisi_mode' is this:
- Code: Select all
void () invisi_mode =
{
local entity player;
player = find(world, classname, "player");
centerprint (player, "invisi_mode....\n"); //just for testing...
self.think = invisi_mode_think;
self.nextthink = time + 1;
};
(the centerprint is just so I know that it's going through all the stages I expect it to, its useful too, as originally I put the "other.model = ("");" in invisi_mode(), but then it didn't go to 'invisi_mode_think()' so I moved it)
Anyway, invisi_mode_think() is this:
- Code: Select all
void () invisi_mode_think =
{
local entity player;
player = find(world, classname, "player");
centerprint (player, "invisi_mode_think....\n"); //just for testing...
if (other.classname == "monster_ogre")
{
setmodel (other, "progs/ogre.mdl");
setsize (other, VEC_HULL2_MIN, VEC_HULL2_MAX);
}
else if (other.classname == "monster_shambler")
setmodel (other, "progs/shambler.mdl");
else if (other.classname == "monster_demon1")
setmodel (other, "progs/demon.mdl");
else if (other.classname == "monster_wizard")
setmodel (other, "progs/wizard.mdl");
else if (other.classname == "monster_zombie")
setmodel (other, "progs/zombie.mdl");
};
(There's more for ogres as I'm testing it with them)
Anyway, and as you can guess, the monster stays invisible, but does 'port as expected.
Help please, especially to say if its possible...[/code]
-

ajay - Posts: 559
- Joined: Fri Oct 29, 2004 6:44 am
- Location: Swindon, UK
if it takes damage before it is made visible, its think function can be changed to animate the pain animation, this is one way it can remain invisible.
Also, your invis_mode uses self, while the place it is called from uses other. In other words, your invis_mode should use other too.
self and other are globals. They don't magically change because you called a different function. They only change for thinks+touches because the engine explicitly changes them before calling.
Small note: if you cleared out the model field, you don't need to do setmodel to restore it, just set the model field back to what it was. the modelindex will not have changed for the duration so it'll all still be valid, assuming it didn't die (so set it back if its still "" and not a gibbed head). This will save you checking each entity type to give it the correct size.
Alternatively, clear out the modelindex instead, as less code checks the modelindex (server doesn't care for modelindex except for networking and SOLID_BSP/MOVETYPE_PUSH, qc only directly uses it for the invis ring). Then you don't have to cache anything for longer than a function. To restore, tmin=self.mins;tmax=self.maxs;setmodel(self, self.model);setsize(self, tmin, tmax); job done.
Also, your invis_mode uses self, while the place it is called from uses other. In other words, your invis_mode should use other too.
self and other are globals. They don't magically change because you called a different function. They only change for thinks+touches because the engine explicitly changes them before calling.
Small note: if you cleared out the model field, you don't need to do setmodel to restore it, just set the model field back to what it was. the modelindex will not have changed for the duration so it'll all still be valid, assuming it didn't die (so set it back if its still "" and not a gibbed head). This will save you checking each entity type to give it the correct size.
Alternatively, clear out the modelindex instead, as less code checks the modelindex (server doesn't care for modelindex except for networking and SOLID_BSP/MOVETYPE_PUSH, qc only directly uses it for the invis ring). Then you don't have to cache anything for longer than a function. To restore, tmin=self.mins;tmax=self.maxs;setmodel(self, self.model);setsize(self, tmin, tmax); job done.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest