• All, I am currently in the process of migrating domain registrations. During this time there may be some intermittent outages or slowdowns. Please contact staff if you have any questions.

Adding NPC through the player

Ales Ros

New member
Hi everyone
I'm trying to add NPC through the player itself.

Yes, I know that the "normal" method is add through the stages files (same thing with enemies, weapons or objects in general), but the main problem about this method is that the NPCs would have to be added at ALL stages, every single file....which is painful. Not to mention that if I wanted to change some NPC, would have to change every file, every line too... yea, just no.

(Of course, if there is a way NPC remain through the game (stages) that would solve the problem, but I don't think there is such option....)

So I came to the conclusion that perhaps the simplest and most practical method would be to generate a NPC through the player itself. In this case, with a key.
Example: If I'm playing with Ryu, I press "F1" on my keyboard and pum... i have Ken as NPC. No mystery.
And if the stage changes... I press the key again. Easy, fast... (and I don't need to edit stages anymore!)

I know how to add NPC/enemies through the stage files, but I have no idea how to do the same on characters files...
I'm reading openbor manual but I still can't understand exacly how I can do that.
 
You mean this video:

I have the code for this but aside of its complexity, I'd have to simplify it to remove stuffs from esn's project. IIRC he hasn't released any demo for that yet.
What’s the difference between that method and the old “striker” method? Any advantages on using one over the other?
 
Alright, here's the second solution: in NPC's IDLE and WALK you declare this script:
Code:
anim    idle
@script
    RePar(0);
@end_script
...
          
anim    walk
@script
    RePar(0);
@end_script
...

RePar is a new function which you should copy to your NPC's animation script. If the NPC isn't using animation script yet, you should declare one which stores this function. Here's the function:
C:
void RePar(int Num)
{// Reset defined player as parent, if the latter exits
    void self = getlocalvar("self");
    void Par = getentityproperty(self,"parent");
    void P = getplayerproperty(Num, "entity");

    if(P && Par==NULL()){
      changeentityproperty(self, "parent", P);
    }
}


BTW about the first solution, I've found simpler way which doesn't need to use global variable at all. Player only need to find NPCs he/she has spawned before then reapply his/her as their parent.
Hi Bloodbane, I tried this and works! However the npc has to have subject_to_screen 1 otherwise respawns at the same position of the parent. Thank you very much :)
 
Back
Top Bottom