Page 1 of 1

help required calling functions from state fpsstate

Posted: November 19th, 2013, 6:01 am
by mad.scientist
Hi
I am trying to find a relatively quick way of calling a function defined within fpsstate in game.h and setting up an ICOMMAND for it (to allow access from mapname.cfg). This is to make a fix for a schools workshop. the settings I wish to change are within fpsstate.

However I cannot seen to get COMMAND/ICOMMAND to work within fpsstate. I figure the best way to do this is to call the function (for example respawn()) from outside. any pointers would be gratefully recieved as to the styntax.

Regards
John

Re: help required calling functions from state fpsstate

Posted: November 19th, 2013, 8:31 am
by Hirato
they should go into fps.cpp, and you'd access the fpsstate object via a fpsent object, such as player1.

Re: help required calling functions from state fpsstate

Posted: November 19th, 2013, 8:23 pm
by mad.scientist
Thanks for that Hirato,
I got there in the end with help from both yourself and Wind Astella.

For anyone also searching on the topic and wants the single player fps as a magic based rpg without the pickups (you can buy the ammo and health from a menu, and have been renamed with such magic like names as scathe dust and dragons breath ).

an example of this would be
level_trigger_2 = [buymagic;]

The following code in the fps.cpp file will allow you to make the changes by command.

Potion is fairly self explainatory (just replace player1->maxhealth with your value)

Buymagic allows for adding ammo to the renamed weapons. The value 3 in this case represents what used to be rockets, however it can be changed to suit your needs

Code: Select all

void potion(physent *d){    // allows level trigger to control health conditions
    if(d==player1 || (d->type==ENT_PLAYER )){
 player1->health=player1->maxhealth;
        }


}

  ICOMMAND(potion, "", (), potion(player1););

  void buymagic(physent *d, int gun){   //allows level trigger to change ammo (renamed as spells)
    if(d==player1 || (d->type==ENT_PLAYER )){
 player1->ammo[gun]=player1->ammo[gun]=100;

  }
  }

  ICOMMAND(buymagic, "", (), buymagic(player1,3);); //change number to change weapon top up in thi case rockets in original script