Post: MW3 GSC Functions Thread (Called from sprx)
04-24-2016, 07:52 PM #1
bendev10
Save Point
(adsbygoogle = window.adsbygoogle || []).push({}); Hello NextGenUpdate.

Introduction:
Since this forum is completly dead, i decided to create a new Thread based on GSC functions. Then bring more life to this section Sal
The purpose of this thread is to recreate functions seen on MW2 1.11 days or current BO2 GSC Mods together.

Why i say recreate? Since there is no way to inject GSC into MW3 (Nobody figured it out, maybe Enstone idk), we need to call the GSC functions from a sprx Plugin and it's much more difficult to handle everything. I will explain more details below.

In order to do this we need to hook into a game function that handles notifies. So we can call any GSC function if a notify is set.

What you need for this?:

- Minimum experience on GSC scripting
- Some c++ knowdlendge
- Visual Studio 2010 with the PS3SDK installed.(Google it if you don´t have it)
- CShark, you can download it here: You must login or register to view this content.

Problems we will find:

-There is only 1 "thread" for running scripts.
-We can only call functions if a notify is set(for now)
-We cannot use "waits", so we need to make use of GetLevelTime or something to get a time reference.



Functions Zone:



Basic client Structure(Add to Structures.h):
    
struct Client_t {

int currentTime;
char* currentWeapon;
VariableStruct* LocationSelector;
float* LocationSelectorPos;
};

Shoot Projectiles

    
void shootProjectile(int clientIndex, const char* Projectile) {

if (OnNotify("weapon_fired", clientIndex, CT_ENTITY)) {

float* Origin = VectorScale(Main::Call<float*>(anglestoforward, Object::Call<float*>(getplayerangles, clientIndex, CT_ENTITY)), 1000000);
float* Trace = Main::String::Call<float*>(bullettrace, "position", Object::Call<float*>(gettagorigin, clientIndex, CT_ENTITY, "tag_eye"), Origin, 0, &entityArray[0]);
Main::Call<int>(magicbullet, Projectile, Object::Call<float*>(gettagorigin, 0, CT_ENTITY, "tag_eye"), Trace, &entityArray[0]);
}
}

//Example : shootProjectile(0, "javelin_mp");


Setup Buttons for notifies

    
Object::Call<int>(notifyonplayercommand, clientIndex, CT_ENTITY, "dpad_up", "+actionslot 1");
Object::Call<int>(notifyonplayercommand, clientIndex, CT_ENTITY, "button_r2", "+frag");
Object::Call<int>(notifyonplayercommand, clientIndex, CT_ENTITY, "button_l2", "+smoke");
//Do with all buttons ...


Teleport Gun:

    
void TeleportGun(int clientIndex) {

if (OnNotify("+actionslot 1", clientIndex, CT_ENTITY)) {

Client[clientIndex].HasTlpGun = !Client[clientIndex].HasTlpGun;

}
if (OnNotify("weapon_fired", clientIndex, CT_ENTITY) && Client[clientIndex].HasTlpGun) {

float* Origin = VectorScale(Main::Call<float*>(anglestoforward, Object::Call<float*>(getplayerangles, 0, CT_ENTITY)), 1000000);
float* Trace = Main::String::Call<float*>(bullettrace, "position", Object::Call<float*>(gettagorigin, 0, CT_ENTITY, "tag_eye"), Origin, 0, &entityArray[0]);
Object::Call<null>(setorigin, clientIndex, CT_ENTITY, Trace);

}
}


Spawn and move helicopter to your position:

Add the following to Client_t structure:
    
struct {
Helicopter_t Helicopter;
helicopterStatus Hstatus;
}Mod_helicopter;

Add the following to "Structures.h":
    

enum Team_t {
allies,
axis
};

struct Helicopter_t {
int entityNum;
int owner;
Team_t team;
};

enum helicopterStatus {

beginLocation,
wait,
};


Add these functions to GSCFunctions.h:
    

void locationSelector(int clientIndex, float Alture, char* notify) {

Client[clientIndex].LocationSelector = OnNotify("confirm_location", clientIndex, CT_ENTITY);
if (OnNotify(notify, clientIndex, CT_ENTITY)) {
Object::Call<int>(beginlocationselection, clientIndex, CT_ENTITY, "map_artillery_selector");
Client[clientIndex].currentWeapon = Object::Call<char*>(getcurrentweapon, clientIndex, CT_ENTITY);
Object::Call<int>(disableoffhandweapons, clientIndex, CT_ENTITY);
Object::Call<int>(giveweapon, clientIndex, CT_ENTITY, "killstreak_precision_airstrike_mp");
Object::Call<int>(switchtoweapon, clientIndex, CT_ENTITY, "killstreak_precision_airstrike_mp");
}

if (Client[clientIndex].LocationSelector) {

float* Location = Client[clientIndex].LocationSelector->vectorValue;
float AddTo[] = { 0, 0, Alture };
Client[clientIndex].LocationSelectorPos = Main::String::Call<float*>(bullettrace, "position", VectorAdd(Client[clientIndex].LocationSelector->vectorValue, AddTo), Client[clientIndex].LocationSelector->vectorValue, 0, undefined);
Object::Call<int>(endlocationselection, clientIndex, CT_ENTITY);
Object::Call<int>(enableoffhandweapons, clientIndex, CT_ENTITY);
Object::Call<int>(takeweapon, clientIndex, CT_ENTITY, "killstreak_precision_airstrike_mp");
Object::Call<int>(switchtoweapon, clientIndex, CT_ENTITY, Client[clientIndex].currentWeapon);
}
}


void spawnHelicopter(Helicopter_t* heli, int owner, float *startPos, const char* helicopterType, const char* helicopterModel) {

heli->entityNum = (int)Main::Call<entNum*>(spawnhelicopter, owner, startPos, Object::Call<float*>(getplayerangles, owner, CT_ENTITY), helicopterType, helicopterModel);
heli->owner = owner;
char* team = Fields::String::getField<char*>(pers, "team", owner, CT_ENTITY);
(team == "allies") ? heli->team = allies : heli->team = axis;
}



void ComeHeliPosition(int clientIndex) {

Object::Call<null>(vehicle_setspeed, Client[clientIndex].Mod_helicopter.Helicopter.entityNum, CT_ENTITY, 100, 50);
Object::Call<null>(setvehgoalpos, Client[clientIndex].Mod_helicopter.Helicopter.entityNum, CT_ENTITY, Client[clientIndex].LocationSelectorPos, true);
}

void doPilotHelicopter(int clientIndex) {



if (Client[clientIndex].Mod_helicopter.Hstatus == beginLocation)
{
locationSelector(clientIndex, 500, "weapon_fired");
if (OnNotify("dpad_up", clientIndex, CT_ENTITY))
{
float startPos[3] = { 1000, -12000, 3000 };
spawnHelicopter(&Client[clientIndex].Mod_helicopter.Helicopter, clientIndex, startPos, "cobra_mp", "vehicle_cobra_helicopter_fly_low");
ComeHeliPosition(clientIndex);
Client[clientIndex].Mod_helicopter.Hstatus = wait;
}
}


}

//Example: doPilotHelicopter(0);




All these functions are working, the thread design is quite bad for now cause i want to know if people are willing to participate on this.
So yea, comment if you would like to participate on recreating functions and keep going with this stuff.

Credits:
Shark: CShark Developer
John: CShark Co-Developer
Last edited by bendev10 ; 04-25-2016 at 03:13 PM.

The following 4 users say thank you to bendev10 for this useful post:

MemoryPointers, mrdarkblue, saucedo, Shark
04-25-2016, 03:01 AM #2
saucedo
Can’t trickshot me!
Originally posted by bendev10 View Post
on MW2 1.14 days


I think you meant 1.11
04-25-2016, 03:01 PM #3
bendev10
Save Point
Originally posted by saucedo View Post
I think you meant 1.11


Yea my bad, makes no sense to rewrite cfg m0dz.
04-26-2016, 06:38 AM #4
Nice post man!!!

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo