Page 1 of 2

Small modding tasks

Posted: June 16th, 2011, 7:58 pm
by F |Madness| U
I made this thread so that if I have some small modding tasks, I can post here (and other people if they wish to) and hopefully people can help each other.

I'd like to start off by wondering how I could make somebody melee when they try to shoot. (I think I have the idea of how the code should look something like, I just don't know a function/way to make a player melee).

Code: Select all

noShoot()
{
        for(;;)
        {
                while(!self AttackButtonPressed())
                        wait 0.05;
                self "make person shoot"  <---- stuck on this bit
        }
}
Note this is for Black Ops not CoD4, so not all things will apply, but I will still try. I am being told that you can't do AI on a player, meaning you can't make them melee/jump etc, but there must be a way to code what I want.

Re: Small modding tasks

Posted: June 16th, 2011, 9:44 pm
by Drofder2004
I believe you can do it using a menu and passing a variable to "cmd", I don't have the code at hand, but I have seen similar things done. I am sure someone will have the answer.

Re: Small modding tasks

Posted: June 16th, 2011, 10:04 pm
by F |Madness| U
Not really sure what you mean by using a menu and passing a variable to cmd, I'll wait for someone else I guess :P

Re: Small modding tasks

Posted: June 16th, 2011, 10:19 pm
by Drofder2004
From OpenWarfareMod

Menu: http://openwarfare.no-ip.org:88/websvn/ ... ntcmd.menu

Precache:

Code: Select all

game["menu_clientcmd"] = "clientcmd";
precacheMenu( game["menu_clientcmd"] );
Code:

Code: Select all

ExecClientCommand( cmd )
{
   self setClientDvar( game["menu_clientcmd"], cmd );
   self openMenu( game["menu_clientcmd"] );
   self closeMenu( game["menu_clientcmd"] );
}
Usage:

Code: Select all

self thread ExecClientCommand( "+melee; wait 2; -melee" );

Re: Small modding tasks

Posted: June 16th, 2011, 11:59 pm
by F |Madness| U
Unfortunately I don't think that will work, as Black Ops doesn't support vstrs or the wait command :?

Re: Small modding tasks

Posted: June 17th, 2011, 12:48 pm
by iCYsoldier
Drofder2004 wrote:From OpenWarfareMod

Menu: http://openwarfare.no-ip.org:88/websvn/ ... ntcmd.menu
[...]
Does this work on test clients aswell? I tried the jump command on my player, and it worked, but I then tried it on a bot, and nothing happened. Does it just not work on bots, or is there anything else required for it to work?

Re: Small modding tasks

Posted: June 17th, 2011, 8:40 pm
by Drofder2004
I do not know how to do it with bots, if it is possible at all.

Are there specific intentions, maybe there is a work around?

Re: Small modding tasks

Posted: June 17th, 2011, 10:47 pm
by F |Madness| U
Little question I have. Basically I have a timer and once the timer reaches 0, some code (timercode lets call it) is performed (the timer is irrelevant now). Now, if somebody dies, and the timercode has been performed, and they are on allies team, I want something to happen, but if the timercode hasn't been performed, I would like them to respawn as normal.

Now my code is:

Code: Select all

timercode()
{
        // my code here //
        onDeath(true);
}
 
onDeath(aftertimer)
{
        self waittill("death");
        
        if(aftertimer && self.team == "allies")   //--- error is with this line
        {
                //my code here//
        }
}
 
However I get the error cannot cast bool to undefined (or other way around- can't remember) about the line specified above. It's probably that my concept of how bools work is wrong, so if somebody could help me thanks :)

Re: Small modding tasks

Posted: June 17th, 2011, 11:24 pm
by iCYsoldier
Drofder2004 wrote:I do not know how to do it with bots, if it is possible at all.

Are there specific intentions, maybe there is a work around?
My goal is to just simply make the bot mantle/climb :P If you know a workaround, that'd be great!

@Madness I think it's because you aren't calling the 'onDeath' function on a player, and then you are using the variable 'self.team'. I'm not entirely sure though

Re: Small modding tasks

Posted: June 17th, 2011, 11:29 pm
by IzNoGoD
Its not self.team, its self.pers["team"].
Unless Treyarch/IW decided to fck the scripting community in its arse that is...

Re: Small modding tasks

Posted: June 18th, 2011, 12:39 am
by F |Madness| U
the onDeath function is infinitely called once a player spawns, and is executed once self dies, so it is called on a player. And self.team is valid in Black Ops atleast.

Maybe because I have level thread timercode(), yet player/self thread onDeath()?

Re: Small modding tasks

Posted: June 18th, 2011, 6:04 pm
by F |Madness| U
Arrgghh i cannot get this to work.

Edit: Ah I found a really easy way :P On init() I just put level.timerInAction = 1;

And after my timer finished I put level.timerInAction = 0; Then just if(level.timerInAction) then blah blah.. Sure to come across some more scrpiting errors soon though :D

Re: Small modding tasks

Posted: June 25th, 2011, 3:26 pm
by F |Madness| U
I've ran across a problem where once a player gets 30000 score on the scoreboard, it does not go any higher. (The score limit per person is capped at 30000 it seems). I tried searching through all rawfiles for the figure 30000, however found nothing related to any kind of scorelimits. Any idea how I could remove this? As in the mod I am trying to create a 30,000 score isn't much.

Re: Small modding tasks

Posted: June 25th, 2011, 3:42 pm
by Drofder2004
The limit is probably hard-coded, but there is no reason why you cannot create your own variable to store scores, but displaying them on the stock scoreboard obviously will not work, but in time, you could create a custom scoreboard.

Re: Small modding tasks

Posted: June 25th, 2011, 4:16 pm
by F |Madness| U
Well I know there is a function somewhere that allows you to change what you see on the scoreboard. For TDM it is something like
onScoareBoard( score, kills, deaths, assists, kdr ). So if changed `score` to `newscore`and then set up a way to save the players score to newscore, it might work? Although at the moment I have no idea how I would add it to their newscore :P