Small modding tasks

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Small modding tasks

Post by Drofder2004 » June 26th, 2011, 1:43 am

F |Madness| U wrote: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
to my knowledge, doesnt exist in CoD4.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Small modding tasks

Post by F |Madness| U » June 26th, 2011, 11:11 am

On Black Ops, I found a function setScoreBoardColumns ( kills, deaths, assists, kdr ), but as you can see there isn't an option to change the score column :S
-

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Small modding tasks

Post by F |Madness| U » June 30th, 2011, 11:59 am

I've got a problem which is probably pretty simple to do, just I have no clue how after trying to find out. Basically I want a certain weapon to do damage on someone, if they go inside a certain trigger at a certain time. I know how to script the trigger prat, I just don't know how to actually hurt the player with this certain weapon when they are inside the trigger. I want to use something like an airstrike, not an actual gun, but I don't need the FX or something, I just want the weaponfile to be applied to that player when they're inside the trigger, if you understand what I mean. -Thanks.
-

User avatar
iCYsoldier
CJ Worshipper
CJ Worshipper
Posts: 289
Joined: December 5th, 2009, 7:12 am
Location: Australia

Re: Small modding tasks

Post by iCYsoldier » June 30th, 2011, 2:35 pm

You could edit the "Callback_PlayerDamage" function in the "_globallogic_player.gsc" file in maps\mp\gametypes. This is the function that calculates the damage done. One of its parameters is the 'sWeapon' string which, I assume, is the weapon that was used to hurt the player. You can check if this equals some weapon of your choice. You could also get the trigger entity from the map and check if the player is touching it. I think this will work, good luck :)

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Small modding tasks

Post by F |Madness| U » June 30th, 2011, 3:56 pm

I don't think you understand :P That function is used to check things once they have been damaged isn't it? I want to somehow make somebody be damaged by a certain weapon, not check if they have been damaged by it.
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Small modding tasks

Post by Drofder2004 » June 30th, 2011, 7:45 pm

iCY I believe is correct.
The callback function for player_damage is the function that deals with any damage.

you should be able to call it yourself and insert custom parameters, where sWeapon is the weapon you want to use and iDamage is the amount of damage.

If you don't understand, will actually go look at the syntax (cba atm :P) later (or someone else will respond by then).
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Small modding tasks

Post by F |Madness| U » June 30th, 2011, 8:36 pm

I think I understand it now! I was messing around trying to ge ta knife to do a certain amount of damage, because for some reason the knife damage varies (I think depending on where you hit the person) between about 130-140 damage. Anyway I managed to use the Callback funtion to make the knife damage always do 50, so I think I may be able to know what to do now. If I fail then be ready to see this topic bumped again in a few hours :D
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Small modding tasks

Post by Drofder2004 » June 30th, 2011, 10:01 pm

Glad for a change not to have to write the code first before an attempt is made :)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Small modding tasks

Post by F |Madness| U » July 19th, 2011, 11:29 am

20 days later and I failed! I tried something like

Code: Select all

for(i=0;i<level.players.size;i++)
        {
                player = level.players[i];
                if(isDefined(minetrigger) && player IsTouching(minetrigger) && player.team == "axis")
                {
                        player thread damage(eInflictor, eAttacker, 1000, iDFlags, "MOD_EXPLOSION", "artillery_mp", vPoint, vDir, sHitLoc, timeOffset);
                        
However I got a load of errors, I'm guessing because of all the unitialised variables. Was this the right way of making the player be damaged by artillery_mp, do I just need to make up a value for each variable?

Also, I have an array of distances (see code below), and was wondering how I can get the largest distance from the array, and relate it back to the corresponding spawnpoint.origin? I tihnk I know how I would get the cooresponding spawnpoint.origin, but I'm just unsure as to how to pick out the largest value from that array.

Code: Select all

        dist_from_zombies = [];
        for(i = 0; i < level.spawnpoints.size; i++)
        {
                spawnpoint = level.spawnpoints[i];
                dist_from_zombies[i] = getclosest(spawnpoint.origin, axis);
        }
-

User avatar
iCYsoldier
CJ Worshipper
CJ Worshipper
Posts: 289
Joined: December 5th, 2009, 7:12 am
Location: Australia

Re: Small modding tasks

Post by iCYsoldier » July 19th, 2011, 1:20 pm

For the first problem, you do need to make up values for each variable

Second problem, you can just use a standard find maximum value algorithm. I want write the code because I'm lazy and you should do it :P What you want to do is create a temp variable to store the maximum value. Loop through each value in the array and do a simple if check to check if the current array item is larger than the temp one. If it is, set temp to the current value. Finally, return temp.

I pretty much just gave you the pseudo code for it :S :oops:

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Small modding tasks

Post by F |Madness| U » July 19th, 2011, 3:30 pm

Edit: Ignore for now.
-

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Small modding tasks

Post by F |Madness| U » July 19th, 2011, 7:07 pm

Thankyou for explaining iCYSoldier, I would rather people explain than just write code out for me :) I managed to solve the damage problem quickly, and after a few hours managed to get a working code for what I wanted. It basically teleports you to a spawnpoint that is furthest away from a zombie, code is below if anyone is interested or wants to say what I could have improved in the code :P

Code: Select all

teleport()
{
        self endon("teleported");
        // -- Creates an array of players that are on zombie team
        zombies = [];
        for(i = 0; i < level.players.size; i++)
        {
                if(level.players[i].pers["team"] == "axis")
                {
                        zombies = add_to_array(zombies, level.players[i]);
                }
        }
        
        // -- For reach spawnpoint, it finds the closest player from zombies array, and adds them into an array, then gets the distance between the spawnpoint and player, and adds the distnace into an array.
        closestzombie = [];
        dist_from_zombies = [];
        for(i = 0; i < level.spawnpoints.size; i++)
        {
                closestzombie[i] = getclosest(level.spawnpoints[i].origin, zombies);
                dist_from_zombies[i] = distance(level.spawnpoints[i].origin, closestzombie[i].origin);
        }
        
        // -- For each distance in the array, checks to see if its bigger than the previous, ending variable `furthest` should have the largest distance.
        furthest = dist_from_zombies[0];
        for(i = 1; i < dist_from_zombies.size; i++)
        {
                if(dist_from_zombies[i] > furthest)
                        furthest = dist_from_zombies[i];
        }
        // -- Then checks the distance between each spawnpoint, and each closest zombie to that spawn.
        // -- If the distance is the same as the variable above, it puts you at that spawnpoint. 
        for(i=0; i<level.spawnpoints.size; i++)
        {
                if(distance(level.spawnpoints[i].origin,closestzombie[i].origin)==furthest)
                {
                        self setOrigin(level.spawnpoints[i].origin);
                        self notify("teleported");
                }
        }       
}
-

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests