help required calling functions from state fpsstate

Having issues not related to a specific Sandbox game mode? Get help here!
Please also read the rules for support when posting support requests.
Failure to comply with the forum rules may result in your topic being locked without resolution.
mad.scientist
Member
Member
Posts: 7
Joined: November 13th, 2013, 7:58 am

help required calling functions from state fpsstate

Postby mad.scientist » November 19th, 2013, 6:01 am

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

Hirato
Developer
Developer
Posts: 689
Joined: May 30th, 2009, 1:23 pm
IRC Username: hirato

Re: help required calling functions from state fpsstate

Postby Hirato » November 19th, 2013, 8:31 am

they should go into fps.cpp, and you'd access the fpsstate object via a fpsent object, such as player1.
This is not a url, clicking it is pointless

mad.scientist
Member
Member
Posts: 7
Joined: November 13th, 2013, 7:58 am

Re: help required calling functions from state fpsstate

Postby mad.scientist » November 19th, 2013, 8:23 pm

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



Return to “Sandbox General Support”

Who is online

Users browsing this forum: No registered users and 1 guest